summaryrefslogtreecommitdiffstats
path: root/mobile/android/.eslintrc.js
blob: ed444fc772ee336415e9bfa235eabe1995d6a14f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

"use strict";

module.exports = {
  overrides: [
    {
      files: [
        // Bug 1425048 - mainly going away, see bug 1583370.
        "components/extensions/**",
      ],
      rules: {
        "no-unused-vars": "off",
        "no-undef": "off",
      },
    },
    {
      files: ["chrome/geckoview/*Child.js"],
      env: {
        "mozilla/frame-script": true,
      },
    },
    {
      files: [
        "chrome/geckoview/**",
        "components/geckoview/**",
        "modules/geckoview/**",
        "actors/**",
      ],
      rules: {
        "no-unused-vars": [
          "error",
          {
            args: "none",
            vars: "local",
            varsIgnorePattern: "(debug|warn)",
          },
        ],
        "no-restricted-syntax": [
          "error",
          {
            selector: `CallExpression > \
                         Identifier.callee[name = /^debug$|^warn$/]`,
            message:
              "Use debug and warn with template literals, e.g. debug `foo`;",
          },
          {
            selector: `BinaryExpression[operator = '+'] > \
                         TaggedTemplateExpression.left > \
                         Identifier.tag[name = /^debug$|^warn$/]`,
            message:
              "Use only one template literal with debug/warn instead of concatenating multiple expressions,\n" +
              "    e.g. (debug `foo ${42} bar`) instead of (debug `foo` + 42 + `bar`)",
          },
          {
            selector: `TaggedTemplateExpression[tag.type = 'Identifier'][tag.name = /^debug$|^warn$/] > \
                         TemplateLiteral.quasi CallExpression > \
                         MemberExpression.callee[object.type = 'Identifier'][object.name = 'JSON'] > \
                         Identifier.property[name = 'stringify']`,
            message:
              "Don't call JSON.stringify within debug/warn literals,\n" +
              "    e.g. (debug `foo=${foo}`) instead of (debug `foo=${JSON.stringify(foo)}`)",
          },
        ],
      },
    },
  ],
};