|
| 1 | +/* eslint-env node */ |
| 2 | +/* |
| 3 | +This ESLint config aims to work with both |
| 4 | +the JavaScript and the TypeScript parts of the |
| 5 | +codebase. |
| 6 | +*/ |
| 7 | + |
| 8 | +module.exports = { |
| 9 | + root: true, |
| 10 | + env: { |
| 11 | + node: true, |
| 12 | + es6: true, |
| 13 | + webextensions: true, |
| 14 | + browser: true, |
| 15 | + }, |
| 16 | + parser: "@babel/eslint-parser", |
| 17 | + extends: ["prettier", "eslint:recommended"], |
| 18 | + ignorePatterns: [ |
| 19 | + "bundled/feature.js", |
| 20 | + "bundled/content.js", |
| 21 | + "bundled/privileged/sockets/bufferpack.js" /** This is a file we just copied in */, |
| 22 | + "build/", |
| 23 | + "dist/", |
| 24 | + "node_modules/", |
| 25 | + ], |
| 26 | + plugins: [ |
| 27 | + "eslint-plugin-import", |
| 28 | + "eslint-plugin-jsdoc", |
| 29 | + "eslint-plugin-unicorn", |
| 30 | + "eslint-plugin-mozilla", |
| 31 | + ], |
| 32 | + rules: { |
| 33 | + "arrow-parens": ["off", "always"], |
| 34 | + "brace-style": ["off", "off"], |
| 35 | + "comma-dangle": "off", |
| 36 | + complexity: "off", |
| 37 | + "constructor-super": "error", |
| 38 | + "eol-last": "off", |
| 39 | + eqeqeq: ["warn", "smart"], |
| 40 | + "guard-for-in": "warn", |
| 41 | + "id-blacklist": "warn", |
| 42 | + "id-match": "warn", |
| 43 | + "import/no-extraneous-dependencies": ["error"], |
| 44 | + "import/no-internal-modules": "error", |
| 45 | + "jsdoc/check-alignment": "error", |
| 46 | + "jsdoc/check-indentation": "error", |
| 47 | + "jsdoc/newline-after-description": "error", |
| 48 | + "linebreak-style": "off", |
| 49 | + "max-classes-per-file": ["error", 1], |
| 50 | + "max-len": "off", |
| 51 | + "new-parens": "off", |
| 52 | + "newline-per-chained-call": "off", |
| 53 | + "no-bitwise": "warn", |
| 54 | + "no-caller": "error", |
| 55 | + "no-cond-assign": "error", |
| 56 | + "no-debugger": "error", |
| 57 | + "no-duplicate-case": "error", |
| 58 | + "no-duplicate-imports": "error", |
| 59 | + "no-empty": "warn", |
| 60 | + "no-eval": "error", |
| 61 | + "no-extra-bind": "error", |
| 62 | + "no-extra-semi": "off", |
| 63 | + "no-fallthrough": "off", |
| 64 | + "no-invalid-this": "off", |
| 65 | + "no-irregular-whitespace": "off", |
| 66 | + "no-multiple-empty-lines": "off", |
| 67 | + "no-new-func": "error", |
| 68 | + "no-new-wrappers": "error", |
| 69 | + "no-redeclare": "error", |
| 70 | + "no-return-await": "error", |
| 71 | + "no-sequences": "error", |
| 72 | + "no-sparse-arrays": "error", |
| 73 | + "no-template-curly-in-string": "error", |
| 74 | + "no-throw-literal": "error", |
| 75 | + "no-trailing-spaces": "off", |
| 76 | + "no-undef-init": "error", |
| 77 | + "no-underscore-dangle": "warn", |
| 78 | + "no-unsafe-finally": "error", |
| 79 | + "no-unused-labels": "error", |
| 80 | + "no-unused-vars": ["error", { argsIgnorePattern: "^_" }], |
| 81 | + "no-var": "error", |
| 82 | + "object-shorthand": "error", |
| 83 | + "one-var": ["warn", "never"], |
| 84 | + "prefer-const": "error", |
| 85 | + "prefer-object-spread": "error", |
| 86 | + "quote-props": "off", |
| 87 | + radix: "error", |
| 88 | + "space-before-function-paren": "off", |
| 89 | + "space-in-parens": ["off", "never"], |
| 90 | + "spaced-comment": [ |
| 91 | + "error", |
| 92 | + "always", |
| 93 | + { |
| 94 | + markers: ["/"], |
| 95 | + }, |
| 96 | + ], |
| 97 | + "unicorn/prefer-ternary": "error", |
| 98 | + "use-isnan": "error", |
| 99 | + "valid-typeof": "off", |
| 100 | + }, |
| 101 | + overrides: [ |
| 102 | + { |
| 103 | + files: ["bundled/privileged/**"], |
| 104 | + env: { |
| 105 | + es2022: true, |
| 106 | + "mozilla/browser-window": true, |
| 107 | + "mozilla/privileged": true, |
| 108 | + }, |
| 109 | + globals: { |
| 110 | + Cu: "readonly", |
| 111 | + Ci: "readonly", |
| 112 | + Cc: "readonly", |
| 113 | + Cr: "readonly", |
| 114 | + ExtensionAPI: "readonly", |
| 115 | + Services: "readonly", |
| 116 | + OS: "readonly", |
| 117 | + }, |
| 118 | + }, |
| 119 | + { |
| 120 | + files: ["*.ts"], |
| 121 | + parser: "@typescript-eslint/parser", |
| 122 | + parserOptions: { |
| 123 | + project: "tsconfig.json", |
| 124 | + sourceType: "module", |
| 125 | + }, |
| 126 | + plugins: ["@typescript-eslint"], |
| 127 | + rules: { |
| 128 | + "@typescript-eslint/adjacent-overload-signatures": "error", |
| 129 | + "@typescript-eslint/array-type": [ |
| 130 | + "error", |
| 131 | + { |
| 132 | + default: "array", |
| 133 | + }, |
| 134 | + ], |
| 135 | + "@typescript-eslint/ban-types": [ |
| 136 | + "error", |
| 137 | + { |
| 138 | + types: { |
| 139 | + Object: { |
| 140 | + message: |
| 141 | + "Avoid using the `Object` type. Did you mean `object`?", |
| 142 | + }, |
| 143 | + Function: { |
| 144 | + message: |
| 145 | + "Avoid using the `Function` type. Prefer a specific function type, like `() => void`.", |
| 146 | + }, |
| 147 | + Boolean: { |
| 148 | + message: |
| 149 | + "Avoid using the `Boolean` type. Did you mean `boolean`?", |
| 150 | + }, |
| 151 | + Number: { |
| 152 | + message: |
| 153 | + "Avoid using the `Number` type. Did you mean `number`?", |
| 154 | + }, |
| 155 | + String: { |
| 156 | + message: |
| 157 | + "Avoid using the `String` type. Did you mean `string`?", |
| 158 | + }, |
| 159 | + Symbol: { |
| 160 | + message: |
| 161 | + "Avoid using the `Symbol` type. Did you mean `symbol`?", |
| 162 | + }, |
| 163 | + }, |
| 164 | + }, |
| 165 | + ], |
| 166 | + "@typescript-eslint/consistent-type-assertions": "off", |
| 167 | + "@typescript-eslint/dot-notation": "error", |
| 168 | + "@typescript-eslint/indent": "off", |
| 169 | + "@typescript-eslint/member-delimiter-style": [ |
| 170 | + "off", |
| 171 | + { |
| 172 | + multiline: { |
| 173 | + delimiter: "none", |
| 174 | + requireLast: true, |
| 175 | + }, |
| 176 | + singleline: { |
| 177 | + delimiter: "semi", |
| 178 | + requireLast: false, |
| 179 | + }, |
| 180 | + }, |
| 181 | + ], |
| 182 | + "@typescript-eslint/no-empty-function": "warn", |
| 183 | + "@typescript-eslint/no-empty-interface": "error", |
| 184 | + "@typescript-eslint/no-explicit-any": "off", |
| 185 | + "@typescript-eslint/no-misused-new": "error", |
| 186 | + "@typescript-eslint/no-namespace": "error", |
| 187 | + "@typescript-eslint/no-parameter-properties": "off", |
| 188 | + "@typescript-eslint/no-shadow": [ |
| 189 | + "off", |
| 190 | + { |
| 191 | + hoist: "all", |
| 192 | + }, |
| 193 | + ], |
| 194 | + "@typescript-eslint/no-this-alias": "error", |
| 195 | + "@typescript-eslint/no-unused-expressions": "warn", |
| 196 | + "@typescript-eslint/no-use-before-define": "off", |
| 197 | + "@typescript-eslint/no-var-requires": "error", |
| 198 | + "@typescript-eslint/prefer-for-of": "warn", |
| 199 | + "@typescript-eslint/prefer-function-type": "error", |
| 200 | + "@typescript-eslint/prefer-namespace-keyword": "error", |
| 201 | + "@typescript-eslint/quotes": "off", |
| 202 | + "@typescript-eslint/semi": ["off", null], |
| 203 | + "@typescript-eslint/triple-slash-reference": [ |
| 204 | + "error", |
| 205 | + { |
| 206 | + path: "always", |
| 207 | + types: "prefer-import", |
| 208 | + lib: "always", |
| 209 | + }, |
| 210 | + ], |
| 211 | + "@typescript-eslint/type-annotation-spacing": "off", |
| 212 | + "@typescript-eslint/unified-signatures": "error", |
| 213 | + "no-undef": "off", |
| 214 | + "no-unused-vars": "off", |
| 215 | + "@typescript-eslint/no-unused-vars": [ |
| 216 | + "error", |
| 217 | + { argsIgnorePattern: "^_" }, |
| 218 | + ], |
| 219 | + }, |
| 220 | + }, |
| 221 | + ], |
| 222 | +}; |
0 commit comments