├── .babelrc ├── .editorconfig ├── .eslintrc ├── .gitignore ├── IDE-config.xml ├── License.md ├── README.md ├── index.js ├── legacy.js ├── package-lock.json ├── package.json ├── react.js └── rules ├── base ├── best-practices.js ├── errors.js ├── es6.js ├── imports.js ├── node.js ├── strict.js ├── style.js └── variables.js └── react ├── react-a11y.js ├── react-hooks.js └── react.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["exceed"] 3 | } 4 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | # Unix-style newlines with a newline ending every file 4 | [*] 5 | end_of_line = lf 6 | insert_final_newline = true 7 | 8 | 9 | # Matches multiple files with brace expansion notation 10 | # Set default charset 11 | [*.{js,jsx,html,sass}] 12 | charset = utf-8 13 | indent_style = space 14 | indent_size = 2 15 | trim_trailing_whitespace = true 16 | 17 | # don't use {} for single extension. This won't work: [*.{css}] 18 | [*.css] 19 | indent_style = space 20 | indent_size = 2 21 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./index.js", 3 | "rules": { 4 | // disable requiring trailing commas because it might be nice to revert to 5 | // being JSON at some point, and I don't want to make big changes now. 6 | "comma-dangle": 0, 7 | }, 8 | "env": { 9 | "browser": true, 10 | "node": true, 11 | "jasmine": true 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | node_modules -------------------------------------------------------------------------------- /IDE-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 11 | 12 | -------------------------------------------------------------------------------- /License.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2012 Airbnb 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Requirements 2 | 3 | - eslint 5.16 4 | 5 | # Instalation 6 | 7 | `npm i https://github.com/exceedteam/js-linter.git` 8 | 9 | `create file .eslintrc with the following content inside your root project folder` 10 | 11 | For the frontend 12 | 13 | ``` 14 | { 15 | "extends": "linter", 16 | "rules": { 17 | // disable requiring trailing commas because it might be nice to revert to 18 | // being JSON at some point, and I don't want to make big changes now. 19 | "comma-dangle": 0, 20 | }, 21 | "env": { 22 | "browser": true, 23 | "node": true, 24 | "jasmine": true 25 | } 26 | } 27 | ``` 28 | 29 | For backend 30 | 31 | ``` 32 | { 33 | "extends": "linter", 34 | "rules": { 35 | // disable requiring trailing commas because it might be nice to revert to 36 | // being JSON at some point, and I don't want to make big changes now. 37 | "comma-dangle": 0, 38 | "prefer-promise-reject-errors": "off", 39 | "consistent-return": "off", 40 | "no-underscore-dangle": "off", 41 | "no-param-reassign": "off", 42 | "no-unused-expressions": "off", 43 | "no-use-before-define": [ 44 | "error", { "functions": false, "classes": true, "variables": true }] 45 | }, 46 | "env": { 47 | "browser": false, 48 | "node": true, 49 | "jasmine": true 50 | } 51 | } 52 | ``` 53 | For react 54 | 55 | ``` 56 | { 57 | "extends": "eslint-config-linter/react", 58 | "rules": { 59 | // disable requiring trailing commas because it might be nice to revert to 60 | // being JSON at some point, and I don't want to make big changes now. 61 | "comma-dangle": 0 62 | }, 63 | "env": { 64 | "browser": true, 65 | "node": true, 66 | "jasmine": true 67 | } 68 | } 69 | ``` 70 | 71 | # SETUP WEBSTORM 72 | 73 | 1. go to Setting(Preferences) -> JS -> Code quality tools -> ESlint 74 | 2. set checkbox enabled 75 | 3. select used at project node version 76 | 4. select installed eslint module (use eslint version 5 for IDE version lower when 2019.2) 77 | 5. select Use specific config file and select .eslintrc file inside your root project folder 78 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: [ 3 | './rules/base/best-practices', 4 | './rules/base/errors', 5 | './rules/base/node', 6 | './rules/base/style', 7 | './rules/base/variables', 8 | './rules/base/es6', 9 | './rules/base/imports', 10 | './rules/base/strict', 11 | ].map(require.resolve), 12 | parserOptions: { 13 | ecmaVersion: 2018, 14 | sourceType: 'module', 15 | }, 16 | rules: {}, 17 | }; 18 | -------------------------------------------------------------------------------- /legacy.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: [ 3 | './rules/best-practices', 4 | './rules/errors', 5 | './rules/node', 6 | './rules/style', 7 | './rules/variables' 8 | ].map(require.resolve), 9 | env: { 10 | browser: true, 11 | node: true, 12 | amd: false, 13 | mocha: false, 14 | jasmine: false 15 | }, 16 | rules: { 17 | 'comma-dangle': ['error', 'never'], 18 | 'prefer-numeric-literals': 'off', 19 | 'no-restricted-properties': ['error', { 20 | object: 'arguments', 21 | property: 'callee', 22 | message: 'arguments.callee is deprecated', 23 | }, { 24 | property: '__defineGetter__', 25 | message: 'Please use Object.defineProperty instead.', 26 | }, { 27 | property: '__defineSetter__', 28 | message: 'Please use Object.defineProperty instead.', 29 | }], 30 | 'no-var': 'off', 31 | strict: ['error', 'safe'], 32 | } 33 | }; 34 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "eslint-config-linter", 3 | "version": "0.0.1", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "array-includes": { 8 | "version": "3.1.1", 9 | "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.1.tgz", 10 | "integrity": "sha512-c2VXaCHl7zPsvpkFsw4nxvFie4fh1ur9bpcgsVkIjqn0H/Xwdg+7fv3n2r/isyS8EBj5b06M9kHyZuIr4El6WQ==", 11 | "requires": { 12 | "define-properties": "^1.1.3", 13 | "es-abstract": "^1.17.0", 14 | "is-string": "^1.0.5" 15 | } 16 | }, 17 | "array.prototype.flat": { 18 | "version": "1.2.3", 19 | "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.2.3.tgz", 20 | "integrity": "sha512-gBlRZV0VSmfPIeWfuuy56XZMvbVfbEUnOXUvt3F/eUUUSyzlgLxhEX4YAEpxNAogRGehPSnfXyPtYyKAhkzQhQ==", 21 | "requires": { 22 | "define-properties": "^1.1.3", 23 | "es-abstract": "^1.17.0-next.1" 24 | } 25 | }, 26 | "balanced-match": { 27 | "version": "1.0.0", 28 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", 29 | "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" 30 | }, 31 | "brace-expansion": { 32 | "version": "1.1.11", 33 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", 34 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", 35 | "requires": { 36 | "balanced-match": "^1.0.0", 37 | "concat-map": "0.0.1" 38 | } 39 | }, 40 | "concat-map": { 41 | "version": "0.0.1", 42 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 43 | "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" 44 | }, 45 | "confusing-browser-globals": { 46 | "version": "1.0.9", 47 | "resolved": "https://registry.npmjs.org/confusing-browser-globals/-/confusing-browser-globals-1.0.9.tgz", 48 | "integrity": "sha512-KbS1Y0jMtyPgIxjO7ZzMAuUpAKMt1SzCL9fsrKsX6b0zJPTaT0SiSPmewwVZg9UAO83HVIlEhZF84LIjZ0lmAw==" 49 | }, 50 | "contains-path": { 51 | "version": "0.1.0", 52 | "resolved": "https://registry.npmjs.org/contains-path/-/contains-path-0.1.0.tgz", 53 | "integrity": "sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo=" 54 | }, 55 | "debug": { 56 | "version": "2.6.9", 57 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", 58 | "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", 59 | "requires": { 60 | "ms": "2.0.0" 61 | } 62 | }, 63 | "define-properties": { 64 | "version": "1.1.3", 65 | "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", 66 | "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", 67 | "requires": { 68 | "object-keys": "^1.0.12" 69 | } 70 | }, 71 | "doctrine": { 72 | "version": "1.5.0", 73 | "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-1.5.0.tgz", 74 | "integrity": "sha1-N53Ocw9hZvds76TmcHoVmwLFpvo=", 75 | "requires": { 76 | "esutils": "^2.0.2", 77 | "isarray": "^1.0.0" 78 | } 79 | }, 80 | "error-ex": { 81 | "version": "1.3.2", 82 | "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", 83 | "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", 84 | "requires": { 85 | "is-arrayish": "^0.2.1" 86 | } 87 | }, 88 | "es-abstract": { 89 | "version": "1.17.5", 90 | "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.5.tgz", 91 | "integrity": "sha512-BR9auzDbySxOcfog0tLECW8l28eRGpDpU3Dm3Hp4q/N+VtLTmyj4EUN088XZWQDW/hzj6sYRDXeOFsaAODKvpg==", 92 | "requires": { 93 | "es-to-primitive": "^1.2.1", 94 | "function-bind": "^1.1.1", 95 | "has": "^1.0.3", 96 | "has-symbols": "^1.0.1", 97 | "is-callable": "^1.1.5", 98 | "is-regex": "^1.0.5", 99 | "object-inspect": "^1.7.0", 100 | "object-keys": "^1.1.1", 101 | "object.assign": "^4.1.0", 102 | "string.prototype.trimleft": "^2.1.1", 103 | "string.prototype.trimright": "^2.1.1" 104 | } 105 | }, 106 | "es-to-primitive": { 107 | "version": "1.2.1", 108 | "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", 109 | "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", 110 | "requires": { 111 | "is-callable": "^1.1.4", 112 | "is-date-object": "^1.0.1", 113 | "is-symbol": "^1.0.2" 114 | } 115 | }, 116 | "eslint-import-resolver-node": { 117 | "version": "0.3.3", 118 | "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.3.tgz", 119 | "integrity": "sha512-b8crLDo0M5RSe5YG8Pu2DYBj71tSB6OvXkfzwbJU2w7y8P4/yo0MyF8jU26IEuEuHF2K5/gcAJE3LhQGqBBbVg==", 120 | "requires": { 121 | "debug": "^2.6.9", 122 | "resolve": "^1.13.1" 123 | } 124 | }, 125 | "eslint-module-utils": { 126 | "version": "2.6.0", 127 | "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.6.0.tgz", 128 | "integrity": "sha512-6j9xxegbqe8/kZY8cYpcp0xhbK0EgJlg3g9mib3/miLaExuuwc3n5UEfSnU6hWMbT0FAYVvDbL9RrRgpUeQIvA==", 129 | "requires": { 130 | "debug": "^2.6.9", 131 | "pkg-dir": "^2.0.0" 132 | } 133 | }, 134 | "eslint-plugin-import": { 135 | "version": "2.20.2", 136 | "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.20.2.tgz", 137 | "integrity": "sha512-FObidqpXrR8OnCh4iNsxy+WACztJLXAHBO5hK79T1Hc77PgQZkyDGA5Ag9xAvRpglvLNxhH/zSmZ70/pZ31dHg==", 138 | "requires": { 139 | "array-includes": "^3.0.3", 140 | "array.prototype.flat": "^1.2.1", 141 | "contains-path": "^0.1.0", 142 | "debug": "^2.6.9", 143 | "doctrine": "1.5.0", 144 | "eslint-import-resolver-node": "^0.3.2", 145 | "eslint-module-utils": "^2.4.1", 146 | "has": "^1.0.3", 147 | "minimatch": "^3.0.4", 148 | "object.values": "^1.1.0", 149 | "read-pkg-up": "^2.0.0", 150 | "resolve": "^1.12.0" 151 | } 152 | }, 153 | "esutils": { 154 | "version": "2.0.3", 155 | "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", 156 | "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==" 157 | }, 158 | "find-up": { 159 | "version": "2.1.0", 160 | "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", 161 | "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", 162 | "requires": { 163 | "locate-path": "^2.0.0" 164 | } 165 | }, 166 | "function-bind": { 167 | "version": "1.1.1", 168 | "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", 169 | "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" 170 | }, 171 | "graceful-fs": { 172 | "version": "4.2.4", 173 | "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz", 174 | "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==" 175 | }, 176 | "has": { 177 | "version": "1.0.3", 178 | "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", 179 | "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", 180 | "requires": { 181 | "function-bind": "^1.1.1" 182 | } 183 | }, 184 | "has-symbols": { 185 | "version": "1.0.1", 186 | "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", 187 | "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==" 188 | }, 189 | "hosted-git-info": { 190 | "version": "2.8.8", 191 | "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz", 192 | "integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==" 193 | }, 194 | "is-arrayish": { 195 | "version": "0.2.1", 196 | "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", 197 | "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=" 198 | }, 199 | "is-callable": { 200 | "version": "1.1.5", 201 | "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.5.tgz", 202 | "integrity": "sha512-ESKv5sMCJB2jnHTWZ3O5itG+O128Hsus4K4Qh1h2/cgn2vbgnLSVqfV46AeJA9D5EeeLa9w81KUXMtn34zhX+Q==" 203 | }, 204 | "is-date-object": { 205 | "version": "1.0.2", 206 | "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.2.tgz", 207 | "integrity": "sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g==" 208 | }, 209 | "is-regex": { 210 | "version": "1.0.5", 211 | "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.5.tgz", 212 | "integrity": "sha512-vlKW17SNq44owv5AQR3Cq0bQPEb8+kF3UKZ2fiZNOWtztYE5i0CzCZxFDwO58qAOWtxdBRVO/V5Qin1wjCqFYQ==", 213 | "requires": { 214 | "has": "^1.0.3" 215 | } 216 | }, 217 | "is-string": { 218 | "version": "1.0.5", 219 | "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.5.tgz", 220 | "integrity": "sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ==" 221 | }, 222 | "is-symbol": { 223 | "version": "1.0.3", 224 | "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz", 225 | "integrity": "sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ==", 226 | "requires": { 227 | "has-symbols": "^1.0.1" 228 | } 229 | }, 230 | "isarray": { 231 | "version": "1.0.0", 232 | "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", 233 | "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" 234 | }, 235 | "load-json-file": { 236 | "version": "2.0.0", 237 | "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", 238 | "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", 239 | "requires": { 240 | "graceful-fs": "^4.1.2", 241 | "parse-json": "^2.2.0", 242 | "pify": "^2.0.0", 243 | "strip-bom": "^3.0.0" 244 | } 245 | }, 246 | "locate-path": { 247 | "version": "2.0.0", 248 | "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", 249 | "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", 250 | "requires": { 251 | "p-locate": "^2.0.0", 252 | "path-exists": "^3.0.0" 253 | } 254 | }, 255 | "minimatch": { 256 | "version": "3.0.4", 257 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", 258 | "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", 259 | "requires": { 260 | "brace-expansion": "^1.1.7" 261 | } 262 | }, 263 | "ms": { 264 | "version": "2.0.0", 265 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 266 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" 267 | }, 268 | "normalize-package-data": { 269 | "version": "2.5.0", 270 | "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", 271 | "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", 272 | "requires": { 273 | "hosted-git-info": "^2.1.4", 274 | "resolve": "^1.10.0", 275 | "semver": "2 || 3 || 4 || 5", 276 | "validate-npm-package-license": "^3.0.1" 277 | } 278 | }, 279 | "object-inspect": { 280 | "version": "1.7.0", 281 | "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.7.0.tgz", 282 | "integrity": "sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw==" 283 | }, 284 | "object-keys": { 285 | "version": "1.1.1", 286 | "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", 287 | "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==" 288 | }, 289 | "object.assign": { 290 | "version": "4.1.0", 291 | "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", 292 | "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", 293 | "requires": { 294 | "define-properties": "^1.1.2", 295 | "function-bind": "^1.1.1", 296 | "has-symbols": "^1.0.0", 297 | "object-keys": "^1.0.11" 298 | } 299 | }, 300 | "object.values": { 301 | "version": "1.1.1", 302 | "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.1.tgz", 303 | "integrity": "sha512-WTa54g2K8iu0kmS/us18jEmdv1a4Wi//BZ/DTVYEcH0XhLM5NYdpDHja3gt57VrZLcNAO2WGA+KpWsDBaHt6eA==", 304 | "requires": { 305 | "define-properties": "^1.1.3", 306 | "es-abstract": "^1.17.0-next.1", 307 | "function-bind": "^1.1.1", 308 | "has": "^1.0.3" 309 | } 310 | }, 311 | "p-limit": { 312 | "version": "1.3.0", 313 | "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", 314 | "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", 315 | "requires": { 316 | "p-try": "^1.0.0" 317 | } 318 | }, 319 | "p-locate": { 320 | "version": "2.0.0", 321 | "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", 322 | "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", 323 | "requires": { 324 | "p-limit": "^1.1.0" 325 | } 326 | }, 327 | "p-try": { 328 | "version": "1.0.0", 329 | "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", 330 | "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=" 331 | }, 332 | "parse-json": { 333 | "version": "2.2.0", 334 | "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", 335 | "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", 336 | "requires": { 337 | "error-ex": "^1.2.0" 338 | } 339 | }, 340 | "path-exists": { 341 | "version": "3.0.0", 342 | "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", 343 | "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=" 344 | }, 345 | "path-parse": { 346 | "version": "1.0.6", 347 | "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", 348 | "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" 349 | }, 350 | "path-type": { 351 | "version": "2.0.0", 352 | "resolved": "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz", 353 | "integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=", 354 | "requires": { 355 | "pify": "^2.0.0" 356 | } 357 | }, 358 | "pify": { 359 | "version": "2.3.0", 360 | "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", 361 | "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" 362 | }, 363 | "pkg-dir": { 364 | "version": "2.0.0", 365 | "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-2.0.0.tgz", 366 | "integrity": "sha1-9tXREJ4Z1j7fQo4L1X4Sd3YVM0s=", 367 | "requires": { 368 | "find-up": "^2.1.0" 369 | } 370 | }, 371 | "read-pkg": { 372 | "version": "2.0.0", 373 | "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", 374 | "integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=", 375 | "requires": { 376 | "load-json-file": "^2.0.0", 377 | "normalize-package-data": "^2.3.2", 378 | "path-type": "^2.0.0" 379 | } 380 | }, 381 | "read-pkg-up": { 382 | "version": "2.0.0", 383 | "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-2.0.0.tgz", 384 | "integrity": "sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=", 385 | "requires": { 386 | "find-up": "^2.0.0", 387 | "read-pkg": "^2.0.0" 388 | } 389 | }, 390 | "resolve": { 391 | "version": "1.17.0", 392 | "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", 393 | "integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==", 394 | "requires": { 395 | "path-parse": "^1.0.6" 396 | } 397 | }, 398 | "semver": { 399 | "version": "5.7.1", 400 | "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", 401 | "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" 402 | }, 403 | "spdx-correct": { 404 | "version": "3.1.1", 405 | "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.1.tgz", 406 | "integrity": "sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w==", 407 | "requires": { 408 | "spdx-expression-parse": "^3.0.0", 409 | "spdx-license-ids": "^3.0.0" 410 | } 411 | }, 412 | "spdx-exceptions": { 413 | "version": "2.3.0", 414 | "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz", 415 | "integrity": "sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A==" 416 | }, 417 | "spdx-expression-parse": { 418 | "version": "3.0.1", 419 | "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz", 420 | "integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==", 421 | "requires": { 422 | "spdx-exceptions": "^2.1.0", 423 | "spdx-license-ids": "^3.0.0" 424 | } 425 | }, 426 | "spdx-license-ids": { 427 | "version": "3.0.5", 428 | "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.5.tgz", 429 | "integrity": "sha512-J+FWzZoynJEXGphVIS+XEh3kFSjZX/1i9gFBaWQcB+/tmpe2qUsSBABpcxqxnAxFdiUFEgAX1bjYGQvIZmoz9Q==" 430 | }, 431 | "string.prototype.trimend": { 432 | "version": "1.0.1", 433 | "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.1.tgz", 434 | "integrity": "sha512-LRPxFUaTtpqYsTeNKaFOw3R4bxIzWOnbQ837QfBylo8jIxtcbK/A/sMV7Q+OAV/vWo+7s25pOE10KYSjaSO06g==", 435 | "requires": { 436 | "define-properties": "^1.1.3", 437 | "es-abstract": "^1.17.5" 438 | } 439 | }, 440 | "string.prototype.trimleft": { 441 | "version": "2.1.2", 442 | "resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.2.tgz", 443 | "integrity": "sha512-gCA0tza1JBvqr3bfAIFJGqfdRTyPae82+KTnm3coDXkZN9wnuW3HjGgN386D7hfv5CHQYCI022/rJPVlqXyHSw==", 444 | "requires": { 445 | "define-properties": "^1.1.3", 446 | "es-abstract": "^1.17.5", 447 | "string.prototype.trimstart": "^1.0.0" 448 | } 449 | }, 450 | "string.prototype.trimright": { 451 | "version": "2.1.2", 452 | "resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.2.tgz", 453 | "integrity": "sha512-ZNRQ7sY3KroTaYjRS6EbNiiHrOkjihL9aQE/8gfQ4DtAC/aEBRHFJa44OmoWxGGqXuJlfKkZW4WcXErGr+9ZFg==", 454 | "requires": { 455 | "define-properties": "^1.1.3", 456 | "es-abstract": "^1.17.5", 457 | "string.prototype.trimend": "^1.0.0" 458 | } 459 | }, 460 | "string.prototype.trimstart": { 461 | "version": "1.0.1", 462 | "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.1.tgz", 463 | "integrity": "sha512-XxZn+QpvrBI1FOcg6dIpxUPgWCPuNXvMD72aaRaUQv1eD4e/Qy8i/hFTe0BUmD60p/QA6bh1avmuPTfNjqVWRw==", 464 | "requires": { 465 | "define-properties": "^1.1.3", 466 | "es-abstract": "^1.17.5" 467 | } 468 | }, 469 | "strip-bom": { 470 | "version": "3.0.0", 471 | "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", 472 | "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=" 473 | }, 474 | "validate-npm-package-license": { 475 | "version": "3.0.4", 476 | "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", 477 | "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", 478 | "requires": { 479 | "spdx-correct": "^3.0.0", 480 | "spdx-expression-parse": "^3.0.0" 481 | } 482 | } 483 | } 484 | } 485 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "eslint-config-linter", 3 | "version": "0.0.3", 4 | "description": "React", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/exceedteam/js-linter" 12 | }, 13 | "author": "Paul", 14 | "license": "ISC", 15 | "dependencies": { 16 | "confusing-browser-globals": "1.0.9", 17 | "eslint-plugin-import": "2.20.2" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /react.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: [ 3 | './index', 4 | './rules/react/react', 5 | './rules/react/react-a11y', 6 | ].map(require.resolve), 7 | rules: {} 8 | }; 9 | -------------------------------------------------------------------------------- /rules/base/best-practices.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | rules: { 3 | // enforces getter/setter pairs in objects 4 | 'accessor-pairs': 'off', 5 | 6 | // enforces return statements in callbacks of array's methods 7 | // https://eslint.org/docs/rules/array-callback-return 8 | 'array-callback-return': ['error', { allowImplicit: true }], 9 | 10 | // treat var statements as if they were block scoped 11 | 'block-scoped-var': 'error', 12 | 13 | // specify the maximum cyclomatic complexity allowed in a program 14 | complexity: ['off', 11], 15 | 16 | // enforce that class methods use "this" 17 | // https://eslint.org/docs/rules/class-methods-use-this 18 | 'class-methods-use-this': ['error', { 19 | exceptMethods: [], 20 | }], 21 | 22 | // require return statements to either always or never specify values 23 | 'consistent-return': 'error', 24 | 25 | // specify curly brace conventions for all control statements 26 | curly: ['error', 'multi-line'], // multiline 27 | 28 | // require default case in switch statements 29 | 'default-case': ['error', { commentPattern: '^no default$' }], 30 | 31 | // https://eslint.org/docs/rules/default-param-last 32 | // TODO: enable, semver-minor, when eslint v6.4 is required (which is a major) 33 | 'default-param-last': 'off', 34 | 35 | // encourages use of dot notation whenever possible 36 | 'dot-notation': ['error', { allowKeywords: true }], 37 | 38 | // enforces consistent newlines before or after dots 39 | // https://eslint.org/docs/rules/dot-location 40 | 'dot-location': ['error', 'property'], 41 | 42 | // require the use of === and !== 43 | // https://eslint.org/docs/rules/eqeqeq 44 | eqeqeq: ['error', 'always', { null: 'ignore' }], 45 | 46 | // Require grouped accessor pairs in object literals and classes 47 | // https://eslint.org/docs/rules/grouped-accessor-pairs 48 | // TODO: enable in next major, altho the guide forbids getters/setters anyways 49 | 'grouped-accessor-pairs': 'off', 50 | 51 | // make sure for-in loops have an if statement 52 | 'guard-for-in': 'error', 53 | 54 | // enforce a maximum number of classes per file 55 | // https://eslint.org/docs/rules/max-classes-per-file 56 | 'max-classes-per-file': ['error', 1], 57 | 58 | // disallow the use of alert, confirm, and prompt 59 | 'no-alert': 'warn', 60 | 61 | // disallow use of arguments.caller or arguments.callee 62 | 'no-caller': 'error', 63 | 64 | // disallow lexical declarations in case/default clauses 65 | // https://eslint.org/docs/rules/no-case-declarations.html 66 | 'no-case-declarations': 'error', 67 | 68 | // Disallow returning value in constructor 69 | // https://eslint.org/docs/rules/no-constructor-return 70 | // TODO: enable, semver-major 71 | 'no-constructor-return': 'off', 72 | 73 | // disallow division operators explicitly at beginning of regular expression 74 | // https://eslint.org/docs/rules/no-div-regex 75 | 'no-div-regex': 'off', 76 | 77 | // disallow else after a return in an if 78 | // https://eslint.org/docs/rules/no-else-return 79 | 'no-else-return': ['error', { allowElseIf: false }], 80 | 81 | // disallow empty functions, except for standalone funcs/arrows 82 | // https://eslint.org/docs/rules/no-empty-function 83 | 'no-empty-function': ['error', { 84 | allow: [ 85 | 'arrowFunctions', 86 | 'functions', 87 | 'methods', 88 | ] 89 | }], 90 | 91 | // disallow empty destructuring patterns 92 | // https://eslint.org/docs/rules/no-empty-pattern 93 | 'no-empty-pattern': 'error', 94 | 95 | // disallow comparisons to null without a type-checking operator 96 | 'no-eq-null': 'off', 97 | 98 | // disallow use of eval() 99 | 'no-eval': 'error', 100 | 101 | // disallow adding to native types 102 | 'no-extend-native': 'error', 103 | 104 | // disallow unnecessary function binding 105 | 'no-extra-bind': 'error', 106 | 107 | // disallow Unnecessary Labels 108 | // https://eslint.org/docs/rules/no-extra-label 109 | 'no-extra-label': 'error', 110 | 111 | // disallow fallthrough of case statements 112 | 'no-fallthrough': 'error', 113 | 114 | // disallow the use of leading or trailing decimal points in numeric literals 115 | 'no-floating-decimal': 'error', 116 | 117 | // disallow reassignments of native objects or read-only globals 118 | // https://eslint.org/docs/rules/no-global-assign 119 | 'no-global-assign': ['error', { exceptions: [] }], 120 | // deprecated in favor of no-global-assign 121 | 'no-native-reassign': 'off', 122 | 123 | // disallow implicit type conversions 124 | // https://eslint.org/docs/rules/no-implicit-coercion 125 | 'no-implicit-coercion': ['off', { 126 | boolean: false, 127 | number: true, 128 | string: true, 129 | allow: [], 130 | }], 131 | 132 | // disallow var and named functions in global scope 133 | // https://eslint.org/docs/rules/no-implicit-globals 134 | 'no-implicit-globals': 'off', 135 | 136 | // disallow use of eval()-like methods 137 | 'no-implied-eval': 'error', 138 | 139 | // disallow this keywords outside of classes or class-like objects 140 | 'no-invalid-this': 'off', 141 | 142 | // disallow usage of __iterator__ property 143 | 'no-iterator': 'error', 144 | 145 | // disallow use of labels for anything other then loops and switches 146 | 'no-labels': ['error', { allowLoop: false, allowSwitch: false }], 147 | 148 | // disallow unnecessary nested blocks 149 | 'no-lone-blocks': 'error', 150 | 151 | // disallow creation of functions within loops 152 | 'no-loop-func': 'error', 153 | 154 | // disallow magic numbers 155 | // https://eslint.org/docs/rules/no-magic-numbers 156 | 'no-magic-numbers': ['off', { 157 | ignore: [], 158 | ignoreArrayIndexes: true, 159 | enforceConst: true, 160 | detectObjects: false, 161 | }], 162 | 163 | // disallow use of multiple spaces 164 | 'no-multi-spaces': ['error', { 165 | ignoreEOLComments: false, 166 | }], 167 | 168 | // disallow use of multiline strings 169 | 'no-multi-str': 'error', 170 | 171 | // disallow use of new operator when not part of the assignment or comparison 172 | 'no-new': 'error', 173 | 174 | // disallow use of new operator for Function object 175 | 'no-new-func': 'error', 176 | 177 | // disallows creating new instances of String, Number, and Boolean 178 | 'no-new-wrappers': 'error', 179 | 180 | // disallow use of (old style) octal literals 181 | 'no-octal': 'error', 182 | 183 | // disallow use of octal escape sequences in string literals, such as 184 | // var foo = 'Copyright \251'; 185 | 'no-octal-escape': 'error', 186 | 187 | // disallow reassignment of function parameters 188 | // disallow parameter object manipulation except for specific exclusions 189 | // rule: https://eslint.org/docs/rules/no-param-reassign.html 190 | 'no-param-reassign': ['error', { 191 | props: true, 192 | ignorePropertyModificationsFor: [ 193 | 'acc', // for reduce accumulators 194 | 'accumulator', // for reduce accumulators 195 | 'e', // for e.returnvalue 196 | 'ctx', // for Koa routing 197 | 'req', // for Express requests 198 | 'request', // for Express requests 199 | 'res', // for Express responses 200 | 'response', // for Express responses 201 | '$scope', // for Angular 1 scopes 202 | 'staticContext', // for ReactRouter context 203 | ] 204 | }], 205 | 206 | // disallow usage of __proto__ property 207 | 'no-proto': 'error', 208 | 209 | // disallow declaring the same variable more then once 210 | 'no-redeclare': 'error', 211 | 212 | // disallow certain object properties 213 | // https://eslint.org/docs/rules/no-restricted-properties 214 | 'no-restricted-properties': ['error', { 215 | object: 'arguments', 216 | property: 'callee', 217 | message: 'arguments.callee is deprecated', 218 | }, { 219 | object: 'global', 220 | property: 'isFinite', 221 | message: 'Please use Number.isFinite instead', 222 | }, { 223 | object: 'self', 224 | property: 'isFinite', 225 | message: 'Please use Number.isFinite instead', 226 | }, { 227 | object: 'window', 228 | property: 'isFinite', 229 | message: 'Please use Number.isFinite instead', 230 | }, { 231 | object: 'global', 232 | property: 'isNaN', 233 | message: 'Please use Number.isNaN instead', 234 | }, { 235 | object: 'self', 236 | property: 'isNaN', 237 | message: 'Please use Number.isNaN instead', 238 | }, { 239 | object: 'window', 240 | property: 'isNaN', 241 | message: 'Please use Number.isNaN instead', 242 | }, { 243 | property: '__defineGetter__', 244 | message: 'Please use Object.defineProperty instead.', 245 | }, { 246 | property: '__defineSetter__', 247 | message: 'Please use Object.defineProperty instead.', 248 | }, { 249 | object: 'Math', 250 | property: 'pow', 251 | message: 'Use the exponentiation operator (**) instead.', 252 | }], 253 | 254 | // disallow use of assignment in return statement 255 | 'no-return-assign': ['error', 'always'], 256 | 257 | // disallow redundant `return await` 258 | 'no-return-await': 'error', 259 | 260 | // disallow use of `javascript:` urls. 261 | 'no-script-url': 'error', 262 | 263 | // disallow self assignment 264 | // https://eslint.org/docs/rules/no-self-assign 265 | 'no-self-assign': ['error', { 266 | props: true, 267 | }], 268 | 269 | // disallow comparisons where both sides are exactly the same 270 | 'no-self-compare': 'error', 271 | 272 | // disallow use of comma operator 273 | 'no-sequences': 'error', 274 | 275 | // restrict what can be thrown as an exception 276 | 'no-throw-literal': 'error', 277 | 278 | // disallow unmodified conditions of loops 279 | // https://eslint.org/docs/rules/no-unmodified-loop-condition 280 | 'no-unmodified-loop-condition': 'off', 281 | 282 | // disallow usage of expressions in statement position 283 | 'no-unused-expressions': ['error', { 284 | allowShortCircuit: false, 285 | allowTernary: false, 286 | allowTaggedTemplates: false, 287 | }], 288 | 289 | // disallow unused labels 290 | // https://eslint.org/docs/rules/no-unused-labels 291 | 'no-unused-labels': 'error', 292 | 293 | // disallow unnecessary .call() and .apply() 294 | 'no-useless-call': 'off', 295 | 296 | // Disallow unnecessary catch clauses 297 | // https://eslint.org/docs/rules/no-useless-catch 298 | 'no-useless-catch': 'error', 299 | 300 | // disallow useless string concatenation 301 | // https://eslint.org/docs/rules/no-useless-concat 302 | 'no-useless-concat': 'error', 303 | 304 | // disallow unnecessary string escaping 305 | // https://eslint.org/docs/rules/no-useless-escape 306 | 'no-useless-escape': 'error', 307 | 308 | // disallow redundant return; keywords 309 | // https://eslint.org/docs/rules/no-useless-return 310 | 'no-useless-return': 'error', 311 | 312 | // disallow use of void operator 313 | // https://eslint.org/docs/rules/no-void 314 | 'no-void': 'error', 315 | 316 | // disallow usage of configurable warning terms in comments: e.g. todo 317 | 'no-warning-comments': ['off', { terms: ['todo', 'fixme', 'xxx'], location: 'start' }], 318 | 319 | // disallow use of the with statement 320 | 'no-with': 'error', 321 | 322 | // require using Error objects as Promise rejection reasons 323 | // https://eslint.org/docs/rules/prefer-promise-reject-errors 324 | 'prefer-promise-reject-errors': ['error', { allowEmptyReject: true }], 325 | 326 | // Suggest using named capture group in regular expression 327 | // https://eslint.org/docs/rules/prefer-named-capture-group 328 | 'prefer-named-capture-group': 'off', 329 | 330 | // https://eslint.org/docs/rules/prefer-regex-literals 331 | // TODO; enable, semver-minor, once eslint v6.4 is required (which is a major) 332 | 'prefer-regex-literals': 'off', 333 | 334 | // require use of the second argument for parseInt() 335 | radix: 'error', 336 | 337 | // require `await` in `async function` (note: this is a horrible rule that should never be used) 338 | // https://eslint.org/docs/rules/require-await 339 | 'require-await': 'off', 340 | 341 | // Enforce the use of u flag on RegExp 342 | // https://eslint.org/docs/rules/require-unicode-regexp 343 | 'require-unicode-regexp': 'off', 344 | 345 | // requires to declare all vars on top of their containing scope 346 | 'vars-on-top': 'error', 347 | 348 | // require immediate function invocation to be wrapped in parentheses 349 | // https://eslint.org/docs/rules/wrap-iife.html 350 | 'wrap-iife': ['error', 'outside', { functionPrototypeMethods: false }], 351 | 352 | // require or disallow Yoda conditions 353 | yoda: 'error' 354 | } 355 | }; 356 | -------------------------------------------------------------------------------- /rules/base/errors.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | rules: { 3 | // Enforce “for” loop update clause moving the counter in the right direction 4 | // https://eslint.org/docs/rules/for-direction 5 | 'for-direction': 'error', 6 | 7 | // Enforces that a return statement is present in property getters 8 | // https://eslint.org/docs/rules/getter-return 9 | 'getter-return': ['error', { allowImplicit: true }], 10 | 11 | // disallow using an async function as a Promise executor 12 | // https://eslint.org/docs/rules/no-async-promise-executor 13 | 'no-async-promise-executor': 'error', 14 | 15 | // Disallow await inside of loops 16 | // https://eslint.org/docs/rules/no-await-in-loop 17 | 'no-await-in-loop': 'error', 18 | 19 | // Disallow comparisons to negative zero 20 | // https://eslint.org/docs/rules/no-compare-neg-zero 21 | 'no-compare-neg-zero': 'error', 22 | 23 | // disallow assignment in conditional expressions 24 | 'no-cond-assign': ['error', 'always'], 25 | 26 | // disallow use of console 27 | 'no-console': 'warn', 28 | 29 | // disallow use of constant expressions in conditions 30 | 'no-constant-condition': 'warn', 31 | 32 | // disallow control characters in regular expressions 33 | 'no-control-regex': 'error', 34 | 35 | // disallow use of debugger 36 | 'no-debugger': 'error', 37 | 38 | // disallow duplicate arguments in functions 39 | 'no-dupe-args': 'error', 40 | 41 | // Disallow duplicate conditions in if-else-if chains 42 | // https://eslint.org/docs/rules/no-dupe-else-if 43 | // TODO: enable, semver-major 44 | 'no-dupe-else-if': 'off', 45 | 46 | // disallow duplicate keys when creating object literals 47 | 'no-dupe-keys': 'error', 48 | 49 | // disallow a duplicate case label. 50 | 'no-duplicate-case': 'error', 51 | 52 | // disallow empty statements 53 | 'no-empty': 'error', 54 | 55 | // disallow the use of empty character classes in regular expressions 56 | 'no-empty-character-class': 'error', 57 | 58 | // disallow assigning to the exception in a catch block 59 | 'no-ex-assign': 'error', 60 | 61 | // disallow double-negation boolean casts in a boolean context 62 | // https://eslint.org/docs/rules/no-extra-boolean-cast 63 | 'no-extra-boolean-cast': 'error', 64 | 65 | // disallow unnecessary parentheses 66 | // https://eslint.org/docs/rules/no-extra-parens 67 | 'no-extra-parens': ['off', 'all', { 68 | conditionalAssign: true, 69 | nestedBinaryExpressions: false, 70 | returnAssign: false, 71 | ignoreJSX: 'all', // delegate to eslint-plugin-react 72 | enforceForArrowConditionals: false, 73 | }], 74 | 75 | // disallow unnecessary semicolons 76 | 'no-extra-semi': 'error', 77 | 78 | // disallow overwriting functions written as function declarations 79 | 'no-func-assign': 'error', 80 | 81 | // https://eslint.org/docs/rules/no-import-assign 82 | // TODO: enable, semver-minor, once eslint v6.4 is required (which is a major) 83 | 'no-import-assign': 'off', 84 | 85 | // disallow function or variable declarations in nested blocks 86 | 'no-inner-declarations': 'error', 87 | 88 | // disallow invalid regular expression strings in the RegExp constructor 89 | 'no-invalid-regexp': 'error', 90 | 91 | // disallow irregular whitespace outside of strings and comments 92 | 'no-irregular-whitespace': 'error', 93 | 94 | // Disallow characters which are made with multiple code points in character class syntax 95 | // https://eslint.org/docs/rules/no-misleading-character-class 96 | 'no-misleading-character-class': 'error', 97 | 98 | // disallow the use of object properties of the global object (Math and JSON) as functions 99 | 'no-obj-calls': 'error', 100 | 101 | // disallow use of Object.prototypes builtins directly 102 | // https://eslint.org/docs/rules/no-prototype-builtins 103 | 'no-prototype-builtins': 'error', 104 | 105 | // disallow multiple spaces in a regular expression literal 106 | 'no-regex-spaces': 'error', 107 | 108 | // Disallow returning values from setters 109 | // https://eslint.org/docs/rules/no-setter-return 110 | // TODO: enable, semver-major (altho the guide forbids getters/setters already) 111 | 'no-setter-return': 'off', 112 | 113 | // disallow sparse arrays 114 | 'no-sparse-arrays': 'error', 115 | 116 | // Disallow template literal placeholder syntax in regular strings 117 | // https://eslint.org/docs/rules/no-template-curly-in-string 118 | 'no-template-curly-in-string': 'error', 119 | 120 | // Avoid code that looks like two expressions but is actually one 121 | // https://eslint.org/docs/rules/no-unexpected-multiline 122 | 'no-unexpected-multiline': 'error', 123 | 124 | // disallow unreachable statements after a return, throw, continue, or break statement 125 | 'no-unreachable': 'error', 126 | 127 | // disallow return/throw/break/continue inside finally blocks 128 | // https://eslint.org/docs/rules/no-unsafe-finally 129 | 'no-unsafe-finally': 'error', 130 | 131 | // disallow negating the left operand of relational operators 132 | // https://eslint.org/docs/rules/no-unsafe-negation 133 | 'no-unsafe-negation': 'error', 134 | // disallow negation of the left operand of an in expression 135 | // deprecated in favor of no-unsafe-negation 136 | 'no-negated-in-lhs': 'off', 137 | 138 | // Disallow assignments that can lead to race conditions due to usage of await or yield 139 | // https://eslint.org/docs/rules/require-atomic-updates 140 | // TODO: enable, semver-major 141 | 'require-atomic-updates': 'off', 142 | 143 | // disallow comparisons with the value NaN 144 | 'use-isnan': 'error', 145 | 146 | // ensure JSDoc comments are valid 147 | // https://eslint.org/docs/rules/valid-jsdoc 148 | 'valid-jsdoc': 'off', 149 | 150 | // ensure that the results of typeof are compared against a valid string 151 | // https://eslint.org/docs/rules/valid-typeof 152 | 'valid-typeof': ['error', { requireStringLiterals: true }], 153 | } 154 | }; 155 | -------------------------------------------------------------------------------- /rules/base/es6.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | es6: true 4 | }, 5 | parserOptions: { 6 | ecmaVersion: 6, 7 | sourceType: 'module', 8 | ecmaFeatures: { 9 | generators: false, 10 | objectLiteralDuplicateProperties: false 11 | } 12 | }, 13 | 14 | rules: { 15 | // enforces no braces where they can be omitted 16 | // https://eslint.org/docs/rules/arrow-body-style 17 | // TODO: enable requireReturnForObjectLiteral? 18 | 'arrow-body-style': ['error', 'as-needed', { 19 | requireReturnForObjectLiteral: false, 20 | }], 21 | 22 | // require parens in arrow function arguments 23 | // https://eslint.org/docs/rules/arrow-parens 24 | 'arrow-parens': ['error', 'always'], 25 | 26 | // require space before/after arrow function's arrow 27 | // https://eslint.org/docs/rules/arrow-spacing 28 | 'arrow-spacing': ['error', { before: true, after: true }], 29 | 30 | // verify super() callings in constructors 31 | 'constructor-super': 'error', 32 | 33 | // enforce the spacing around the * in generator functions 34 | // https://eslint.org/docs/rules/generator-star-spacing 35 | 'generator-star-spacing': ['error', { before: false, after: true }], 36 | 37 | // disallow modifying variables of class declarations 38 | // https://eslint.org/docs/rules/no-class-assign 39 | 'no-class-assign': 'error', 40 | 41 | // disallow arrow functions where they could be confused with comparisons 42 | // https://eslint.org/docs/rules/no-confusing-arrow 43 | 'no-confusing-arrow': ['error', { 44 | allowParens: true, 45 | }], 46 | 47 | // disallow modifying variables that are declared using const 48 | 'no-const-assign': 'error', 49 | 50 | // disallow duplicate class members 51 | // https://eslint.org/docs/rules/no-dupe-class-members 52 | 'no-dupe-class-members': 'error', 53 | 54 | // disallow importing from the same path more than once 55 | // https://eslint.org/docs/rules/no-duplicate-imports 56 | // replaced by https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md 57 | 'no-duplicate-imports': 'off', 58 | 59 | // disallow symbol constructor 60 | // https://eslint.org/docs/rules/no-new-symbol 61 | 'no-new-symbol': 'error', 62 | 63 | // disallow specific imports 64 | // https://eslint.org/docs/rules/no-restricted-imports 65 | 'no-restricted-imports': ['off', { 66 | paths: [], 67 | patterns: [] 68 | }], 69 | 70 | // disallow to use this/super before super() calling in constructors. 71 | // https://eslint.org/docs/rules/no-this-before-super 72 | 'no-this-before-super': 'error', 73 | 74 | // disallow useless computed property keys 75 | // https://eslint.org/docs/rules/no-useless-computed-key 76 | 'no-useless-computed-key': 'error', 77 | 78 | // disallow unnecessary constructor 79 | // https://eslint.org/docs/rules/no-useless-constructor 80 | 'no-useless-constructor': 'error', 81 | 82 | // disallow renaming import, export, and destructured assignments to the same name 83 | // https://eslint.org/docs/rules/no-useless-rename 84 | 'no-useless-rename': ['error', { 85 | ignoreDestructuring: false, 86 | ignoreImport: false, 87 | ignoreExport: false, 88 | }], 89 | 90 | // require let or const instead of var 91 | 'no-var': 'error', 92 | 93 | // require method and property shorthand syntax for object literals 94 | // https://eslint.org/docs/rules/object-shorthand 95 | 'object-shorthand': ['error', 'always', { 96 | ignoreConstructors: false, 97 | avoidQuotes: true, 98 | }], 99 | 100 | // suggest using arrow functions as callbacks 101 | 'prefer-arrow-callback': ['error', { 102 | allowNamedFunctions: false, 103 | allowUnboundThis: true, 104 | }], 105 | 106 | // suggest using of const declaration for variables that are never modified after declared 107 | 'prefer-const': ['error', { 108 | destructuring: 'any', 109 | ignoreReadBeforeAssign: true, 110 | }], 111 | 112 | // Prefer destructuring from arrays and objects 113 | // https://eslint.org/docs/rules/prefer-destructuring 114 | 'prefer-destructuring': ['error', { 115 | VariableDeclarator: { 116 | array: false, 117 | object: true, 118 | }, 119 | AssignmentExpression: { 120 | array: true, 121 | object: false, 122 | }, 123 | }, { 124 | enforceForRenamedProperties: false, 125 | }], 126 | 127 | // disallow parseInt() in favor of binary, octal, and hexadecimal literals 128 | // https://eslint.org/docs/rules/prefer-numeric-literals 129 | 'prefer-numeric-literals': 'error', 130 | 131 | // suggest using Reflect methods where applicable 132 | // https://eslint.org/docs/rules/prefer-reflect 133 | 'prefer-reflect': 'off', 134 | 135 | // use rest parameters instead of arguments 136 | // https://eslint.org/docs/rules/prefer-rest-params 137 | 'prefer-rest-params': 'error', 138 | 139 | // suggest using the spread operator instead of .apply() 140 | // https://eslint.org/docs/rules/prefer-spread 141 | 'prefer-spread': 'error', 142 | 143 | // suggest using template literals instead of string concatenation 144 | // https://eslint.org/docs/rules/prefer-template 145 | 'prefer-template': 'error', 146 | 147 | // disallow generator functions that do not have yield 148 | // https://eslint.org/docs/rules/require-yield 149 | 'require-yield': 'error', 150 | 151 | // enforce spacing between object rest-spread 152 | // https://eslint.org/docs/rules/rest-spread-spacing 153 | 'rest-spread-spacing': ['error', 'never'], 154 | 155 | // import sorting 156 | // https://eslint.org/docs/rules/sort-imports 157 | 'sort-imports': ['off', { 158 | ignoreCase: false, 159 | ignoreDeclarationSort: false, 160 | ignoreMemberSort: false, 161 | memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'], 162 | }], 163 | 164 | // require a Symbol description 165 | // https://eslint.org/docs/rules/symbol-description 166 | 'symbol-description': 'error', 167 | 168 | // enforce usage of spacing in template strings 169 | // https://eslint.org/docs/rules/template-curly-spacing 170 | 'template-curly-spacing': 'error', 171 | 172 | // enforce spacing around the * in yield* expressions 173 | // https://eslint.org/docs/rules/yield-star-spacing 174 | 'yield-star-spacing': ['error', 'after'] 175 | } 176 | }; 177 | -------------------------------------------------------------------------------- /rules/base/imports.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | es6: true 4 | }, 5 | parserOptions: { 6 | ecmaVersion: 6, 7 | sourceType: 'module' 8 | }, 9 | plugins: [ 10 | 'import' 11 | ], 12 | 13 | settings: { 14 | 'import/resolver': { 15 | node: { 16 | extensions: ['.mjs', '.js', '.json'] 17 | } 18 | }, 19 | 'import/extensions': [ 20 | '.js', 21 | '.mjs', 22 | '.jsx', 23 | ], 24 | 'import/core-modules': [ 25 | ], 26 | 'import/ignore': [ 27 | 'node_modules', 28 | '\\.(coffee|scss|css|less|hbs|svg|json)$', 29 | ], 30 | }, 31 | 32 | rules: { 33 | // Static analysis: 34 | 35 | // ensure imports point to files/modules that can be resolved 36 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unresolved.md 37 | 'import/no-unresolved': ['error', { commonjs: true, caseSensitive: true }], 38 | 39 | // ensure named imports coupled with named exports 40 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/named.md#when-not-to-use-it 41 | 'import/named': 'error', 42 | 43 | // ensure default import coupled with default export 44 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/default.md#when-not-to-use-it 45 | 'import/default': 'off', 46 | 47 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/namespace.md 48 | 'import/namespace': 'off', 49 | 50 | // Helpful warnings: 51 | 52 | // disallow invalid exports, e.g. multiple defaults 53 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/export.md 54 | 'import/export': 'error', 55 | 56 | // do not allow a default import name to match a named export 57 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-as-default.md 58 | 'import/no-named-as-default': 'error', 59 | 60 | // warn on accessing default export property names that are also named exports 61 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-as-default-member.md 62 | 'import/no-named-as-default-member': 'error', 63 | 64 | // disallow use of jsdoc-marked-deprecated imports 65 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-deprecated.md 66 | 'import/no-deprecated': 'off', 67 | 68 | // Forbid the use of extraneous packages 69 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md 70 | // paths are treated both as absolute paths, and relative to process.cwd() 71 | 'import/no-extraneous-dependencies': ['error', { 72 | devDependencies: [ 73 | 'test/**', // tape, common npm pattern 74 | 'tests/**', // also common npm pattern 75 | 'spec/**', // mocha, rspec-like pattern 76 | '**/__tests__/**', // jest pattern 77 | '**/__mocks__/**', // jest pattern 78 | 'test.{js,jsx}', // repos with a single test file 79 | 'test-*.{js,jsx}', // repos with multiple top-level test files 80 | '**/*{.,_}{test,spec}.{js,jsx}', // tests where the extension or filename suffix denotes that it is a test 81 | '**/jest.config.js', // jest config 82 | '**/jest.setup.js', // jest setup 83 | '**/vue.config.js', // vue-cli config 84 | '**/webpack.config.js', // webpack config 85 | '**/webpack.config.*.js', // webpack config 86 | '**/rollup.config.js', // rollup config 87 | '**/rollup.config.*.js', // rollup config 88 | '**/gulpfile.js', // gulp config 89 | '**/gulpfile.*.js', // gulp config 90 | '**/Gruntfile{,.js}', // grunt config 91 | '**/protractor.conf.js', // protractor config 92 | '**/protractor.conf.*.js', // protractor config 93 | '**/karma.conf.js' // karma config 94 | ], 95 | optionalDependencies: false, 96 | }], 97 | 98 | // Forbid mutable exports 99 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-mutable-exports.md 100 | 'import/no-mutable-exports': 'error', 101 | 102 | // Module systems: 103 | 104 | // disallow require() 105 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-commonjs.md 106 | 'import/no-commonjs': 'off', 107 | 108 | // disallow AMD require/define 109 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-amd.md 110 | 'import/no-amd': 'error', 111 | 112 | // No Node.js builtin modules 113 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-nodejs-modules.md 114 | // TODO: enable? 115 | 'import/no-nodejs-modules': 'off', 116 | 117 | // Style guide: 118 | 119 | // disallow non-import statements appearing before import statements 120 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/first.md 121 | 'import/first': 'error', 122 | 123 | // disallow non-import statements appearing before import statements 124 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/imports-first.md 125 | // deprecated: use `import/first` 126 | 'import/imports-first': 'off', 127 | 128 | // disallow duplicate imports 129 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md 130 | 'import/no-duplicates': 'error', 131 | 132 | // disallow namespace imports 133 | // TODO: enable? 134 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-namespace.md 135 | 'import/no-namespace': 'off', 136 | 137 | // Ensure consistent use of file extension within the import path 138 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md 139 | 'import/extensions': ['error', 'ignorePackages', { 140 | js: 'never', 141 | mjs: 'never', 142 | jsx: 'never', 143 | }], 144 | 145 | // ensure absolute imports are above relative imports and that unassigned imports are ignored 146 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md 147 | // TODO: enforce a stricter convention in module import order? 148 | 'import/order': ['error', { groups: [['builtin', 'external', 'internal']] }], 149 | 150 | // Require a newline after the last import/require in a group 151 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/newline-after-import.md 152 | 'import/newline-after-import': 'error', 153 | 154 | // Require modules with a single export to use a default export 155 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md 156 | 'import/prefer-default-export': 'error', 157 | 158 | // Restrict which files can be imported in a given folder 159 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-restricted-paths.md 160 | 'import/no-restricted-paths': 'off', 161 | 162 | // Forbid modules to have too many dependencies 163 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/max-dependencies.md 164 | 'import/max-dependencies': ['off', { max: 10 }], 165 | 166 | // Forbid import of modules using absolute paths 167 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-absolute-path.md 168 | 'import/no-absolute-path': 'error', 169 | 170 | // Forbid require() calls with expressions 171 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-dynamic-require.md 172 | 'import/no-dynamic-require': 'error', 173 | 174 | // prevent importing the submodules of other modules 175 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-internal-modules.md 176 | 'import/no-internal-modules': ['off', { 177 | allow: [], 178 | }], 179 | 180 | // Warn if a module could be mistakenly parsed as a script by a consumer 181 | // leveraging Unambiguous JavaScript Grammar 182 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/unambiguous.md 183 | // this should not be enabled until this proposal has at least been *presented* to TC39. 184 | // At the moment, it's not a thing. 185 | 'import/unambiguous': 'off', 186 | 187 | // Forbid Webpack loader syntax in imports 188 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-webpack-loader-syntax.md 189 | 'import/no-webpack-loader-syntax': 'error', 190 | 191 | // Prevent unassigned imports 192 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unassigned-import.md 193 | // importing for side effects is perfectly acceptable, if you need side effects. 194 | 'import/no-unassigned-import': 'off', 195 | 196 | // Prevent importing the default as if it were named 197 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-named-default.md 198 | 'import/no-named-default': 'error', 199 | 200 | // Reports if a module's default export is unnamed 201 | // https://github.com/benmosher/eslint-plugin-import/blob/d9b712ac7fd1fddc391f7b234827925c160d956f/docs/rules/no-anonymous-default-export.md 202 | 'import/no-anonymous-default-export': ['off', { 203 | allowArray: false, 204 | allowArrowFunction: false, 205 | allowAnonymousClass: false, 206 | allowAnonymousFunction: false, 207 | allowLiteral: false, 208 | allowObject: false, 209 | }], 210 | 211 | // This rule enforces that all exports are declared at the bottom of the file. 212 | // https://github.com/benmosher/eslint-plugin-import/blob/98acd6afd04dcb6920b81330114e146dc8532ea4/docs/rules/exports-last.md 213 | // TODO: enable? 214 | 'import/exports-last': 'off', 215 | 216 | // Reports when named exports are not grouped together in a single export declaration 217 | // or when multiple assignments to CommonJS module.exports or exports object are present 218 | // in a single file. 219 | // https://github.com/benmosher/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/group-exports.md 220 | 'import/group-exports': 'off', 221 | 222 | // forbid default exports. this is a terrible rule, do not use it. 223 | // https://github.com/benmosher/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/no-default-export.md 224 | 'import/no-default-export': 'off', 225 | 226 | // Prohibit named exports. this is a terrible rule, do not use it. 227 | // https://github.com/benmosher/eslint-plugin-import/blob/1ec80fa35fa1819e2d35a70e68fb6a149fb57c5e/docs/rules/no-named-export.md 228 | 'import/no-named-export': 'off', 229 | 230 | // Forbid a module from importing itself 231 | // https://github.com/benmosher/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/no-self-import.md 232 | 'import/no-self-import': 'error', 233 | 234 | // Forbid cyclical dependencies between modules 235 | // https://github.com/benmosher/eslint-plugin-import/blob/d81f48a2506182738409805f5272eff4d77c9348/docs/rules/no-cycle.md 236 | 'import/no-cycle': ['error', { maxDepth: Infinity }], 237 | 238 | // Ensures that there are no useless path segments 239 | // https://github.com/benmosher/eslint-plugin-import/blob/ebafcbf59ec9f653b2ac2a0156ca3bcba0a7cf57/docs/rules/no-useless-path-segments.md 240 | 'import/no-useless-path-segments': ['error', { commonjs: true }], 241 | 242 | // dynamic imports require a leading comment with a webpackChunkName 243 | // https://github.com/benmosher/eslint-plugin-import/blob/ebafcbf59ec9f653b2ac2a0156ca3bcba0a7cf57/docs/rules/dynamic-import-chunkname.md 244 | 'import/dynamic-import-chunkname': ['off', { 245 | importFunctions: [], 246 | webpackChunknameFormat: '[0-9a-zA-Z-_/.]+', 247 | }], 248 | 249 | // Use this rule to prevent imports to folders in relative parent paths. 250 | // https://github.com/benmosher/eslint-plugin-import/blob/c34f14f67f077acd5a61b3da9c0b0de298d20059/docs/rules/no-relative-parent-imports.md 251 | 'import/no-relative-parent-imports': 'off', 252 | 253 | // Reports modules without any exports, or with unused exports 254 | // https://github.com/benmosher/eslint-plugin-import/blob/f63dd261809de6883b13b6b5b960e6d7f42a7813/docs/rules/no-unused-modules.md 255 | // TODO: enable, semver-major 256 | 'import/no-unused-modules': ['off', { 257 | ignoreExports: [], 258 | missingExports: true, 259 | unusedExports: true, 260 | }], 261 | }, 262 | }; 263 | -------------------------------------------------------------------------------- /rules/base/node.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | node: true 4 | }, 5 | 6 | rules: { 7 | // enforce return after a callback 8 | 'callback-return': 'off', 9 | 10 | // require all requires be top-level 11 | // https://eslint.org/docs/rules/global-require 12 | 'global-require': 'off', 13 | 14 | // enforces error handling in callbacks (node environment) 15 | 'handle-callback-err': 'off', 16 | 17 | // disallow use of the Buffer() constructor 18 | // https://eslint.org/docs/rules/no-buffer-constructor 19 | 'no-buffer-constructor': 'error', 20 | 21 | // disallow mixing regular variable and require declarations 22 | 'no-mixed-requires': ['off', false], 23 | 24 | // disallow use of new operator with the require function 25 | 'no-new-require': 'error', 26 | 27 | // disallow string concatenation with __dirname and __filename 28 | // https://eslint.org/docs/rules/no-path-concat 29 | 'no-path-concat': 'error', 30 | 31 | // disallow use of process.env 32 | 'no-process-env': 'off', 33 | 34 | // disallow process.exit() 35 | 'no-process-exit': 'off', 36 | 37 | // restrict usage of specified node modules 38 | 'no-restricted-modules': 'off', 39 | 40 | // disallow use of synchronous methods (off by default) 41 | 'no-sync': 'off', 42 | } 43 | }; 44 | -------------------------------------------------------------------------------- /rules/base/strict.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | rules: { 3 | // babel inserts `'use strict';` for us 4 | strict: ['error', 'never'] 5 | } 6 | }; 7 | -------------------------------------------------------------------------------- /rules/base/style.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | rules: { 3 | // enforce line breaks after opening and before closing array brackets 4 | // https://eslint.org/docs/rules/array-bracket-newline 5 | // TODO: enable? semver-major 6 | 'array-bracket-newline': ['off', 'consistent'], // object option alternative: { multiline: true, minItems: 3 } 7 | 8 | // enforce line breaks between array elements 9 | // https://eslint.org/docs/rules/array-element-newline 10 | // TODO: enable? semver-major 11 | 'array-element-newline': ['off', { multiline: true, minItems: 3 }], 12 | 13 | // enforce spacing inside array brackets 14 | 'array-bracket-spacing': ['error', 'never'], 15 | 16 | // enforce spacing inside single-line blocks 17 | // https://eslint.org/docs/rules/block-spacing 18 | 'block-spacing': ['error', 'always'], 19 | 20 | // enforce one true brace style 21 | 'brace-style': ['error', '1tbs', { allowSingleLine: true }], 22 | 23 | // require camel case names 24 | camelcase: ['error', { properties: 'never', ignoreDestructuring: false }], 25 | 26 | // enforce or disallow capitalization of the first letter of a comment 27 | // https://eslint.org/docs/rules/capitalized-comments 28 | 'capitalized-comments': ['off', 'never', { 29 | line: { 30 | ignorePattern: '.*', 31 | ignoreInlineComments: true, 32 | ignoreConsecutiveComments: true, 33 | }, 34 | block: { 35 | ignorePattern: '.*', 36 | ignoreInlineComments: true, 37 | ignoreConsecutiveComments: true, 38 | }, 39 | }], 40 | 41 | // require trailing commas in multiline object literals 42 | 'comma-dangle': ['error', { 43 | arrays: 'always-multiline', 44 | objects: 'always-multiline', 45 | imports: 'always-multiline', 46 | exports: 'always-multiline', 47 | functions: 'always-multiline', 48 | }], 49 | 50 | // enforce spacing before and after comma 51 | 'comma-spacing': ['error', { before: false, after: true }], 52 | 53 | // enforce one true comma style 54 | 'comma-style': ['error', 'last', { 55 | exceptions: { 56 | ArrayExpression: false, 57 | ArrayPattern: false, 58 | ArrowFunctionExpression: false, 59 | CallExpression: false, 60 | FunctionDeclaration: false, 61 | FunctionExpression: false, 62 | ImportDeclaration: false, 63 | ObjectExpression: false, 64 | ObjectPattern: false, 65 | VariableDeclaration: false, 66 | NewExpression: false, 67 | } 68 | }], 69 | 70 | // disallow padding inside computed properties 71 | 'computed-property-spacing': ['error', 'never'], 72 | 73 | // enforces consistent naming when capturing the current execution context 74 | 'consistent-this': 'off', 75 | 76 | // enforce newline at the end of file, with no multiple empty lines 77 | 'eol-last': ['error', 'always'], 78 | 79 | // https://eslint.org/docs/rules/function-call-argument-newline 80 | // TODO: enable, semver-minor, once eslint v6.2 is required (which is a major) 81 | 'function-call-argument-newline': ['off', 'consistent'], 82 | 83 | // enforce spacing between functions and their invocations 84 | // https://eslint.org/docs/rules/func-call-spacing 85 | 'func-call-spacing': ['error', 'never'], 86 | 87 | // requires function names to match the name of the variable or property to which they are 88 | // assigned 89 | // https://eslint.org/docs/rules/func-name-matching 90 | 'func-name-matching': ['off', 'always', { 91 | includeCommonJSModuleExports: false, 92 | considerPropertyDescriptor: true, 93 | }], 94 | 95 | // require function expressions to have a name 96 | // https://eslint.org/docs/rules/func-names 97 | 'func-names': 'warn', 98 | 99 | // enforces use of function declarations or expressions 100 | // https://eslint.org/docs/rules/func-style 101 | // TODO: enable 102 | 'func-style': ['off', 'expression'], 103 | 104 | // enforce consistent line breaks inside function parentheses 105 | // https://eslint.org/docs/rules/function-paren-newline 106 | 'function-paren-newline': ['error', 'consistent'], 107 | 108 | // Blacklist certain identifiers to prevent them being used 109 | // https://eslint.org/docs/rules/id-blacklist 110 | 'id-blacklist': 'off', 111 | 112 | // this option enforces minimum and maximum identifier lengths 113 | // (variable names, property names etc.) 114 | 'id-length': 'off', 115 | 116 | // require identifiers to match the provided regular expression 117 | 'id-match': 'off', 118 | 119 | // Enforce the location of arrow function bodies with implicit returns 120 | // https://eslint.org/docs/rules/implicit-arrow-linebreak 121 | 'implicit-arrow-linebreak': ['error', 'beside'], 122 | 123 | // this option sets a specific tab width for your code 124 | // https://eslint.org/docs/rules/indent 125 | indent: ['error', 2, { 126 | SwitchCase: 1, 127 | VariableDeclarator: 1, 128 | outerIIFEBody: 1, 129 | // MemberExpression: null, 130 | FunctionDeclaration: { 131 | parameters: 1, 132 | body: 1 133 | }, 134 | FunctionExpression: { 135 | parameters: 1, 136 | body: 1 137 | }, 138 | CallExpression: { 139 | arguments: 1 140 | }, 141 | ArrayExpression: 1, 142 | ObjectExpression: 1, 143 | ImportDeclaration: 1, 144 | flatTernaryExpressions: false, 145 | // list derived from https://github.com/benjamn/ast-types/blob/HEAD/def/jsx.js 146 | ignoredNodes: ['JSXElement', 'JSXElement > *', 'JSXAttribute', 'JSXIdentifier', 'JSXNamespacedName', 'JSXMemberExpression', 'JSXSpreadAttribute', 'JSXExpressionContainer', 'JSXOpeningElement', 'JSXClosingElement', 'JSXFragment', 'JSXOpeningFragment', 'JSXClosingFragment', 'JSXText', 'JSXEmptyExpression', 'JSXSpreadChild'], 147 | ignoreComments: false 148 | }], 149 | 150 | // specify whether double or single quotes should be used in JSX attributes 151 | // https://eslint.org/docs/rules/jsx-quotes 152 | 'jsx-quotes': ['off', 'prefer-double'], 153 | 154 | // enforces spacing between keys and values in object literal properties 155 | 'key-spacing': ['error', { beforeColon: false, afterColon: true }], 156 | 157 | // require a space before & after certain keywords 158 | 'keyword-spacing': ['error', { 159 | before: true, 160 | after: true, 161 | overrides: { 162 | return: { after: true }, 163 | throw: { after: true }, 164 | case: { after: true } 165 | } 166 | }], 167 | 168 | // enforce position of line comments 169 | // https://eslint.org/docs/rules/line-comment-position 170 | // TODO: enable? 171 | 'line-comment-position': ['off', { 172 | position: 'above', 173 | ignorePattern: '', 174 | applyDefaultPatterns: true, 175 | }], 176 | 177 | // disallow mixed 'LF' and 'CRLF' as linebreaks 178 | // https://eslint.org/docs/rules/linebreak-style 179 | 'linebreak-style': ['error', 'unix'], 180 | 181 | // require or disallow an empty line between class members 182 | // https://eslint.org/docs/rules/lines-between-class-members 183 | 'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: false }], 184 | 185 | // enforces empty lines around comments 186 | 'lines-around-comment': 'off', 187 | 188 | // require or disallow newlines around directives 189 | // https://eslint.org/docs/rules/lines-around-directive 190 | 'lines-around-directive': ['error', { 191 | before: 'always', 192 | after: 'always', 193 | }], 194 | 195 | // specify the maximum depth that blocks can be nested 196 | 'max-depth': ['off', 4], 197 | 198 | // specify the maximum length of a line in your program 199 | // https://eslint.org/docs/rules/max-len 200 | 'max-len': ['error', 100, 2, { 201 | ignoreUrls: true, 202 | ignoreComments: true, 203 | ignoreRegExpLiterals: true, 204 | ignoreStrings: true, 205 | ignoreTemplateLiterals: true, 206 | }], 207 | 208 | // specify the max number of lines in a file 209 | // https://eslint.org/docs/rules/max-lines 210 | 'max-lines': ['off', { 211 | max: 300, 212 | skipBlankLines: true, 213 | skipComments: true 214 | }], 215 | 216 | // enforce a maximum function length 217 | // https://eslint.org/docs/rules/max-lines-per-function 218 | 'max-lines-per-function': ['off', { 219 | max: 50, 220 | skipBlankLines: true, 221 | skipComments: true, 222 | IIFEs: true, 223 | }], 224 | 225 | // specify the maximum depth callbacks can be nested 226 | 'max-nested-callbacks': 'off', 227 | 228 | // limits the number of parameters that can be used in the function declaration. 229 | 'max-params': ['off', 3], 230 | 231 | // specify the maximum number of statement allowed in a function 232 | 'max-statements': ['off', 10], 233 | 234 | // restrict the number of statements per line 235 | // https://eslint.org/docs/rules/max-statements-per-line 236 | 'max-statements-per-line': ['off', { max: 1 }], 237 | 238 | // enforce a particular style for multiline comments 239 | // https://eslint.org/docs/rules/multiline-comment-style 240 | 'multiline-comment-style': ['off', 'starred-block'], 241 | 242 | // require multiline ternary 243 | // https://eslint.org/docs/rules/multiline-ternary 244 | // TODO: enable? 245 | 'multiline-ternary': ['off', 'never'], 246 | 247 | // require a capital letter for constructors 248 | 'new-cap': ['error', { 249 | newIsCap: true, 250 | newIsCapExceptions: [], 251 | capIsNew: false, 252 | capIsNewExceptions: ['Immutable.Map', 'Immutable.Set', 'Immutable.List'], 253 | }], 254 | 255 | // disallow the omission of parentheses when invoking a constructor with no arguments 256 | // https://eslint.org/docs/rules/new-parens 257 | 'new-parens': 'error', 258 | 259 | // allow/disallow an empty newline after var statement 260 | 'newline-after-var': 'off', 261 | 262 | // https://eslint.org/docs/rules/newline-before-return 263 | 'newline-before-return': 'off', 264 | 265 | // enforces new line after each method call in the chain to make it 266 | // more readable and easy to maintain 267 | // https://eslint.org/docs/rules/newline-per-chained-call 268 | 'newline-per-chained-call': ['error', { ignoreChainWithDepth: 4 }], 269 | 270 | // disallow use of the Array constructor 271 | 'no-array-constructor': 'error', 272 | 273 | // disallow use of bitwise operators 274 | // https://eslint.org/docs/rules/no-bitwise 275 | 'no-bitwise': 'error', 276 | 277 | // disallow use of the continue statement 278 | // https://eslint.org/docs/rules/no-continue 279 | 'no-continue': 'error', 280 | 281 | // disallow comments inline after code 282 | 'no-inline-comments': 'off', 283 | 284 | // disallow if as the only statement in an else block 285 | // https://eslint.org/docs/rules/no-lonely-if 286 | 'no-lonely-if': 'error', 287 | 288 | // disallow un-paren'd mixes of different operators 289 | // https://eslint.org/docs/rules/no-mixed-operators 290 | 'no-mixed-operators': ['error', { 291 | // the list of arthmetic groups disallows mixing `%` and `**` 292 | // with other arithmetic operators. 293 | groups: [ 294 | ['%', '**'], 295 | ['%', '+'], 296 | ['%', '-'], 297 | ['%', '*'], 298 | ['%', '/'], 299 | ['/', '*'], 300 | ['&', '|', '<<', '>>', '>>>'], 301 | ['==', '!=', '===', '!=='], 302 | ['&&', '||'], 303 | ], 304 | allowSamePrecedence: false 305 | }], 306 | 307 | // disallow mixed spaces and tabs for indentation 308 | 'no-mixed-spaces-and-tabs': 'error', 309 | 310 | // disallow use of chained assignment expressions 311 | // https://eslint.org/docs/rules/no-multi-assign 312 | 'no-multi-assign': ['error'], 313 | 314 | // disallow multiple empty lines, only one newline at the end, and no new lines at the beginning 315 | // https://eslint.org/docs/rules/no-multiple-empty-lines 316 | 'no-multiple-empty-lines': ['error', { max: 2, maxBOF: 1, maxEOF: 0 }], 317 | 318 | // disallow negated conditions 319 | // https://eslint.org/docs/rules/no-negated-condition 320 | 'no-negated-condition': 'off', 321 | 322 | // disallow nested ternary expressions 323 | 'no-nested-ternary': 'error', 324 | 325 | // disallow use of the Object constructor 326 | 'no-new-object': 'error', 327 | 328 | // disallow use of unary operators, ++ and -- 329 | // https://eslint.org/docs/rules/no-plusplus 330 | 'no-plusplus': 'error', 331 | 332 | // disallow certain syntax forms 333 | // https://eslint.org/docs/rules/no-restricted-syntax 334 | 'no-restricted-syntax': [ 335 | 'error', 336 | { 337 | selector: 'ForInStatement', 338 | message: 'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.', 339 | }, 340 | { 341 | selector: 'ForOfStatement', 342 | message: 'iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations.', 343 | }, 344 | { 345 | selector: 'LabeledStatement', 346 | message: 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.', 347 | }, 348 | { 349 | selector: 'WithStatement', 350 | message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.', 351 | }, 352 | ], 353 | 354 | // disallow space between function identifier and application 355 | 'no-spaced-func': 'error', 356 | 357 | // disallow tab characters entirely 358 | 'no-tabs': 'error', 359 | 360 | // disallow the use of ternary operators 361 | 'no-ternary': 'off', 362 | 363 | // disallow trailing whitespace at the end of lines 364 | 'no-trailing-spaces': ['error', { 365 | skipBlankLines: false, 366 | ignoreComments: false, 367 | }], 368 | 369 | // disallow dangling underscores in identifiers 370 | // https://eslint.org/docs/rules/no-underscore-dangle 371 | 'no-underscore-dangle': ['error', { 372 | allow: [], 373 | allowAfterThis: false, 374 | allowAfterSuper: false, 375 | enforceInMethodNames: true, 376 | }], 377 | 378 | // disallow the use of Boolean literals in conditional expressions 379 | // also, prefer `a || b` over `a ? a : b` 380 | // https://eslint.org/docs/rules/no-unneeded-ternary 381 | 'no-unneeded-ternary': ['error', { defaultAssignment: false }], 382 | 383 | // disallow whitespace before properties 384 | // https://eslint.org/docs/rules/no-whitespace-before-property 385 | 'no-whitespace-before-property': 'error', 386 | 387 | // enforce the location of single-line statements 388 | // https://eslint.org/docs/rules/nonblock-statement-body-position 389 | 'nonblock-statement-body-position': ['error', 'beside', { overrides: {} }], 390 | 391 | // require padding inside curly braces 392 | 'object-curly-spacing': ['error', 'always'], 393 | 394 | // enforce line breaks between braces 395 | // https://eslint.org/docs/rules/object-curly-newline 396 | 'object-curly-newline': ['error', { 397 | ObjectExpression: { minProperties: 4, multiline: true, consistent: true }, 398 | ObjectPattern: { minProperties: 4, multiline: true, consistent: true }, 399 | ImportDeclaration: { minProperties: 4, multiline: true, consistent: true }, 400 | ExportDeclaration: { minProperties: 4, multiline: true, consistent: true }, 401 | }], 402 | 403 | // enforce "same line" or "multiple line" on object properties. 404 | // https://eslint.org/docs/rules/object-property-newline 405 | 'object-property-newline': ['error', { 406 | allowAllPropertiesOnSameLine: true, 407 | }], 408 | 409 | // allow just one var statement per function 410 | 'one-var': ['error', 'never'], 411 | 412 | // require a newline around variable declaration 413 | // https://eslint.org/docs/rules/one-var-declaration-per-line 414 | 'one-var-declaration-per-line': ['error', 'always'], 415 | 416 | // require assignment operator shorthand where possible or prohibit it entirely 417 | // https://eslint.org/docs/rules/operator-assignment 418 | 'operator-assignment': ['error', 'always'], 419 | 420 | // Requires operator at the beginning of the line in multiline statements 421 | // https://eslint.org/docs/rules/operator-linebreak 422 | 'operator-linebreak': ['error', 'before', { overrides: { '=': 'none' } }], 423 | 424 | // disallow padding within blocks 425 | 'padded-blocks': ['error', { 426 | blocks: 'never', 427 | classes: 'never', 428 | switches: 'never', 429 | }, { 430 | allowSingleLineBlocks: true, 431 | }], 432 | 433 | // Require or disallow padding lines between statements 434 | // https://eslint.org/docs/rules/padding-line-between-statements 435 | 'padding-line-between-statements': 'off', 436 | 437 | // Disallow the use of Math.pow in favor of the ** operator 438 | // https://eslint.org/docs/rules/prefer-exponentiation-operator 439 | // TODO: enable, semver-major when eslint 5 is dropped 440 | 'prefer-exponentiation-operator': 'off', 441 | 442 | // Prefer use of an object spread over Object.assign 443 | // https://eslint.org/docs/rules/prefer-object-spread 444 | 'prefer-object-spread': 'error', 445 | 446 | // require quotes around object literal property names 447 | // https://eslint.org/docs/rules/quote-props.html 448 | 'quote-props': ['error', 'as-needed', { keywords: false, unnecessary: true, numbers: false }], 449 | 450 | // specify whether double or single quotes should be used 451 | quotes: ['error', 'single', { avoidEscape: true }], 452 | 453 | // do not require jsdoc 454 | // https://eslint.org/docs/rules/require-jsdoc 455 | 'require-jsdoc': 'off', 456 | 457 | // require or disallow use of semicolons instead of ASI 458 | semi: ['error', 'always'], 459 | 460 | // enforce spacing before and after semicolons 461 | 'semi-spacing': ['error', { before: false, after: true }], 462 | 463 | // Enforce location of semicolons 464 | // https://eslint.org/docs/rules/semi-style 465 | 'semi-style': ['error', 'last'], 466 | 467 | // requires object keys to be sorted 468 | 'sort-keys': ['off', 'asc', { caseSensitive: false, natural: true }], 469 | 470 | // sort variables within the same declaration block 471 | 'sort-vars': 'off', 472 | 473 | // require or disallow space before blocks 474 | 'space-before-blocks': 'error', 475 | 476 | // require or disallow space before function opening parenthesis 477 | // https://eslint.org/docs/rules/space-before-function-paren 478 | 'space-before-function-paren': ['error', { 479 | anonymous: 'always', 480 | named: 'never', 481 | asyncArrow: 'always' 482 | }], 483 | 484 | // require or disallow spaces inside parentheses 485 | 'space-in-parens': ['error', 'never'], 486 | 487 | // require spaces around operators 488 | 'space-infix-ops': 'error', 489 | 490 | // Require or disallow spaces before/after unary operators 491 | // https://eslint.org/docs/rules/space-unary-ops 492 | 'space-unary-ops': ['error', { 493 | words: true, 494 | nonwords: false, 495 | overrides: { 496 | }, 497 | }], 498 | 499 | // require or disallow a space immediately following the // or /* in a comment 500 | // https://eslint.org/docs/rules/spaced-comment 501 | 'spaced-comment': ['error', 'always', { 502 | line: { 503 | exceptions: ['-', '+'], 504 | markers: ['=', '!'], // space here to support sprockets directives 505 | }, 506 | block: { 507 | exceptions: ['-', '+'], 508 | markers: ['=', '!', ':', '::'], // space here to support sprockets directives and flow comment types 509 | balanced: true, 510 | } 511 | }], 512 | 513 | // Enforce spacing around colons of switch statements 514 | // https://eslint.org/docs/rules/switch-colon-spacing 515 | 'switch-colon-spacing': ['error', { after: true, before: false }], 516 | 517 | // Require or disallow spacing between template tags and their literals 518 | // https://eslint.org/docs/rules/template-tag-spacing 519 | 'template-tag-spacing': ['error', 'never'], 520 | 521 | // require or disallow the Unicode Byte Order Mark 522 | // https://eslint.org/docs/rules/unicode-bom 523 | 'unicode-bom': ['error', 'never'], 524 | 525 | // require regex literals to be wrapped in parentheses 526 | 'wrap-regex': 'off' 527 | } 528 | }; 529 | -------------------------------------------------------------------------------- /rules/base/variables.js: -------------------------------------------------------------------------------- 1 | const confusingBrowserGlobals = require('confusing-browser-globals'); 2 | 3 | module.exports = { 4 | rules: { 5 | // enforce or disallow variable initializations at definition 6 | 'init-declarations': 'off', 7 | 8 | // disallow the catch clause parameter name being the same as a variable in the outer scope 9 | 'no-catch-shadow': 'off', 10 | 11 | // disallow deletion of variables 12 | 'no-delete-var': 'error', 13 | 14 | // disallow labels that share a name with a variable 15 | // https://eslint.org/docs/rules/no-label-var 16 | 'no-label-var': 'error', 17 | 18 | // disallow specific globals 19 | 'no-restricted-globals': ['error', 'isFinite', 'isNaN'].concat(confusingBrowserGlobals), 20 | 21 | // disallow declaration of variables already declared in the outer scope 22 | 'no-shadow': 'error', 23 | 24 | // disallow shadowing of names such as arguments 25 | 'no-shadow-restricted-names': 'error', 26 | 27 | // disallow use of undeclared variables unless mentioned in a /*global */ block 28 | 'no-undef': 'error', 29 | 30 | // disallow use of undefined when initializing variables 31 | 'no-undef-init': 'error', 32 | 33 | // disallow use of undefined variable 34 | // https://eslint.org/docs/rules/no-undefined 35 | // TODO: enable? 36 | 'no-undefined': 'off', 37 | 38 | // disallow declaration of variables that are not used in the code 39 | 'no-unused-vars': ['error', { vars: 'all', args: 'after-used', ignoreRestSiblings: true }], 40 | 41 | // disallow use of variables before they are defined 42 | 'no-use-before-define': ['error', { functions: true, classes: true, variables: true }], 43 | } 44 | }; 45 | -------------------------------------------------------------------------------- /rules/react/react-a11y.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: [ 3 | 'jsx-a11y', 4 | 'react' 5 | ], 6 | 7 | parserOptions: { 8 | ecmaFeatures: { 9 | jsx: true, 10 | }, 11 | }, 12 | 13 | rules: { 14 | // Enforce that anchors have content 15 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-has-content.md 16 | 'jsx-a11y/anchor-has-content': ['error', { components: [] }], 17 | 18 | // Require ARIA roles to be valid and non-abstract 19 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-role.md 20 | 'jsx-a11y/aria-role': ['error', { ignoreNonDom: false }], 21 | 22 | // Enforce all aria-* props are valid. 23 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-props.md 24 | 'jsx-a11y/aria-props': 'error', 25 | 26 | // Enforce ARIA state and property values are valid. 27 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-proptypes.md 28 | 'jsx-a11y/aria-proptypes': 'error', 29 | 30 | // Enforce that elements that do not support ARIA roles, states, and 31 | // properties do not have those attributes. 32 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-unsupported-elements.md 33 | 'jsx-a11y/aria-unsupported-elements': 'error', 34 | 35 | // Enforce that all elements that require alternative text have meaningful information 36 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/alt-text.md 37 | 'jsx-a11y/alt-text': ['error', { 38 | elements: ['img', 'object', 'area', 'input[type="image"]'], 39 | img: [], 40 | object: [], 41 | area: [], 42 | 'input[type="image"]': [], 43 | }], 44 | 45 | // Prevent img alt text from containing redundant words like "image", "picture", or "photo" 46 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/img-redundant-alt.md 47 | 'jsx-a11y/img-redundant-alt': 'error', 48 | 49 | // require that JSX labels use "htmlFor" 50 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/label-has-for.md 51 | // deprecated: replaced by `label-has-associated-control` rule 52 | 'jsx-a11y/label-has-for': ['off', { 53 | components: [], 54 | required: { 55 | every: ['nesting', 'id'], 56 | }, 57 | allowChildren: false, 58 | }], 59 | 60 | // Enforce that a label tag has a text label and an associated control. 61 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/b800f40a2a69ad48015ae9226fbe879f946757ed/docs/rules/label-has-associated-control.md 62 | 'jsx-a11y/label-has-associated-control': ['error', { 63 | labelComponents: [], 64 | labelAttributes: [], 65 | controlComponents: [], 66 | assert: 'both', 67 | depth: 25 68 | }], 69 | 70 | // Enforce that a control (an interactive element) has a text label. 71 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/control-has-associated-label.md 72 | 'jsx-a11y/control-has-associated-label': ['error', { 73 | labelAttributes: ['label'], 74 | controlComponents: [], 75 | ignoreElements: [ 76 | 'audio', 77 | 'canvas', 78 | 'embed', 79 | 'input', 80 | 'textarea', 81 | 'tr', 82 | 'video', 83 | ], 84 | ignoreRoles: [ 85 | 'grid', 86 | 'listbox', 87 | 'menu', 88 | 'menubar', 89 | 'radiogroup', 90 | 'row', 91 | 'tablist', 92 | 'toolbar', 93 | 'tree', 94 | 'treegrid', 95 | ], 96 | depth: 5, 97 | }], 98 | 99 | // require that mouseover/out come with focus/blur, for keyboard-only users 100 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/mouse-events-have-key-events.md 101 | 'jsx-a11y/mouse-events-have-key-events': 'error', 102 | 103 | // Prevent use of `accessKey` 104 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-access-key.md 105 | 'jsx-a11y/no-access-key': 'error', 106 | 107 | // require onBlur instead of onChange 108 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-onchange.md 109 | 'jsx-a11y/no-onchange': 'off', 110 | 111 | // Elements with an interactive role and interaction handlers must be focusable 112 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/interactive-supports-focus.md 113 | 'jsx-a11y/interactive-supports-focus': 'error', 114 | 115 | // Enforce that elements with ARIA roles must have all required attributes 116 | // for that role. 117 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-has-required-aria-props.md 118 | 'jsx-a11y/role-has-required-aria-props': 'error', 119 | 120 | // Enforce that elements with explicit or implicit roles defined contain 121 | // only aria-* properties supported by that role. 122 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-supports-aria-props.md 123 | 'jsx-a11y/role-supports-aria-props': 'error', 124 | 125 | // Enforce tabIndex value is not greater than zero. 126 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/tabindex-no-positive.md 127 | 'jsx-a11y/tabindex-no-positive': 'error', 128 | 129 | // ensure tags have content and are not aria-hidden 130 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/heading-has-content.md 131 | 'jsx-a11y/heading-has-content': ['error', { components: [''] }], 132 | 133 | // require HTML elements to have a "lang" prop 134 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/html-has-lang.md 135 | 'jsx-a11y/html-has-lang': 'error', 136 | 137 | // require HTML element's lang prop to be valid 138 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/lang.md 139 | 'jsx-a11y/lang': 'error', 140 | 141 | // prevent distracting elements, like and 142 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-distracting-elements.md 143 | 'jsx-a11y/no-distracting-elements': ['error', { 144 | elements: ['marquee', 'blink'], 145 | }], 146 | 147 | // only allow to have the "scope" attr 148 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/scope.md 149 | 'jsx-a11y/scope': 'error', 150 | 151 | // require onClick be accompanied by onKeyUp/onKeyDown/onKeyPress 152 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/click-events-have-key-events.md 153 | 'jsx-a11y/click-events-have-key-events': 'error', 154 | 155 | // Enforce that DOM elements without semantic behavior not have interaction handlers 156 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-static-element-interactions.md 157 | 'jsx-a11y/no-static-element-interactions': ['error', { 158 | handlers: [ 159 | 'onClick', 160 | 'onMouseDown', 161 | 'onMouseUp', 162 | 'onKeyPress', 163 | 'onKeyDown', 164 | 'onKeyUp', 165 | ] 166 | }], 167 | 168 | // A non-interactive element does not support event handlers (mouse and key handlers) 169 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-noninteractive-element-interactions.md 170 | 'jsx-a11y/no-noninteractive-element-interactions': ['error', { 171 | handlers: [ 172 | 'onClick', 173 | 'onMouseDown', 174 | 'onMouseUp', 175 | 'onKeyPress', 176 | 'onKeyDown', 177 | 'onKeyUp', 178 | ] 179 | }], 180 | 181 | // ensure emoji are accessible 182 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/accessible-emoji.md 183 | 'jsx-a11y/accessible-emoji': 'error', 184 | 185 | // elements with aria-activedescendant must be tabbable 186 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-activedescendant-has-tabindex.md 187 | 'jsx-a11y/aria-activedescendant-has-tabindex': 'error', 188 | 189 | // ensure iframe elements have a unique title 190 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/iframe-has-title.md 191 | 'jsx-a11y/iframe-has-title': 'error', 192 | 193 | // prohibit autoFocus prop 194 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-autofocus.md 195 | 'jsx-a11y/no-autofocus': ['error', { ignoreNonDOM: true }], 196 | 197 | // ensure HTML elements do not specify redundant ARIA roles 198 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-redundant-roles.md 199 | 'jsx-a11y/no-redundant-roles': 'error', 200 | 201 | // media elements must have captions 202 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/media-has-caption.md 203 | 'jsx-a11y/media-has-caption': ['error', { 204 | audio: [], 205 | video: [], 206 | track: [], 207 | }], 208 | 209 | // WAI-ARIA roles should not be used to convert an interactive element to non-interactive 210 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-interactive-element-to-noninteractive-role.md 211 | 'jsx-a11y/no-interactive-element-to-noninteractive-role': ['error', { 212 | tr: ['none', 'presentation'], 213 | }], 214 | 215 | // WAI-ARIA roles should not be used to convert a non-interactive element to interactive 216 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-noninteractive-element-to-interactive-role.md 217 | 'jsx-a11y/no-noninteractive-element-to-interactive-role': ['error', { 218 | ul: ['listbox', 'menu', 'menubar', 'radiogroup', 'tablist', 'tree', 'treegrid'], 219 | ol: ['listbox', 'menu', 'menubar', 'radiogroup', 'tablist', 'tree', 'treegrid'], 220 | li: ['menuitem', 'option', 'row', 'tab', 'treeitem'], 221 | table: ['grid'], 222 | td: ['gridcell'], 223 | }], 224 | 225 | // Tab key navigation should be limited to elements on the page that can be interacted with. 226 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-noninteractive-tabindex.md 227 | 'jsx-a11y/no-noninteractive-tabindex': ['error', { 228 | tags: [], 229 | roles: ['tabpanel'], 230 | }], 231 | 232 | // ensure tags are valid 233 | // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/0745af376cdc8686d85a361ce36952b1fb1ccf6e/docs/rules/anchor-is-valid.md 234 | 'jsx-a11y/anchor-is-valid': ['error', { 235 | components: ['Link'], 236 | specialLink: ['to'], 237 | aspects: ['noHref', 'invalidHref', 'preferButton'], 238 | }], 239 | 240 | // Ensure the autocomplete attribute is correct and suitable for the form field it is used with 241 | // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/29c68596b15c4ff0a40daae6d4a2670e36e37d35/docs/rules/autocomplete-valid.md 242 | 'jsx-a11y/autocomplete-valid': ['off', { 243 | inputComponents: [], 244 | }], 245 | }, 246 | }; 247 | -------------------------------------------------------------------------------- /rules/react/react-hooks.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: [ 3 | 'react-hooks', 4 | ], 5 | 6 | parserOptions: { 7 | ecmaFeatures: { 8 | jsx: true, 9 | }, 10 | }, 11 | 12 | rules: { 13 | // Enforce Rules of Hooks 14 | // https://github.com/facebook/react/blob/c11015ff4f610ac2924d1fc6d569a17657a404fd/packages/eslint-plugin-react-hooks/src/RulesOfHooks.js 15 | 'react-hooks/rules-of-hooks': 'error', 16 | 17 | // Verify the list of the dependencies for Hooks like useEffect and similar 18 | // https://github.com/facebook/react/blob/1204c789776cb01fbaf3e9f032e7e2ba85a44137/packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js 19 | 'react-hooks/exhaustive-deps': 'error', 20 | }, 21 | }; 22 | -------------------------------------------------------------------------------- /rules/react/react.js: -------------------------------------------------------------------------------- 1 | const assign = require('object.assign'); 2 | const baseStyleRules = require('../base/style').rules; 3 | 4 | const dangleRules = baseStyleRules['no-underscore-dangle']; 5 | 6 | module.exports = { 7 | plugins: [ 8 | 'react', 9 | ], 10 | 11 | parserOptions: { 12 | ecmaFeatures: { 13 | jsx: true, 14 | }, 15 | }, 16 | 17 | // View link below for react rules documentation 18 | // https://github.com/yannickcr/eslint-plugin-react#list-of-supported-rules 19 | rules: { 20 | 'no-underscore-dangle': [dangleRules[0], assign({}, dangleRules[1], { 21 | allow: dangleRules[1].allow.concat(['__REDUX_DEVTOOLS_EXTENSION_COMPOSE__']), 22 | })], 23 | 24 | // Specify whether double or single quotes should be used in JSX attributes 25 | // https://eslint.org/docs/rules/jsx-quotes 26 | 'jsx-quotes': ['error', 'prefer-double'], 27 | 28 | 'class-methods-use-this': ['error', { 29 | exceptMethods: [ 30 | 'render', 31 | 'getInitialState', 32 | 'getDefaultProps', 33 | 'getChildContext', 34 | 'componentWillMount', 35 | 'UNSAFE_componentWillMount', 36 | 'componentDidMount', 37 | 'componentWillReceiveProps', 38 | 'UNSAFE_componentWillReceiveProps', 39 | 'shouldComponentUpdate', 40 | 'componentWillUpdate', 41 | 'UNSAFE_componentWillUpdate', 42 | 'componentDidUpdate', 43 | 'componentWillUnmount', 44 | 'componentDidCatch', 45 | 'getSnapshotBeforeUpdate' 46 | ], 47 | }], 48 | 49 | // Prevent missing displayName in a React component definition 50 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/display-name.md 51 | 'react/display-name': ['off', { ignoreTranspilerName: false }], 52 | 53 | // Forbid certain propTypes (any, array, object) 54 | // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/forbid-prop-types.md 55 | 'react/forbid-prop-types': ['error', { 56 | forbid: ['any', 'array', 'object'], 57 | checkContextTypes: true, 58 | checkChildContextTypes: true, 59 | }], 60 | 61 | // Forbid certain props on DOM Nodes 62 | // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/forbid-dom-props.md 63 | 'react/forbid-dom-props': ['off', { forbid: [] }], 64 | 65 | // Enforce boolean attributes notation in JSX 66 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md 67 | 'react/jsx-boolean-value': ['error', 'never', { always: [] }], 68 | 69 | // Validate closing bracket location in JSX 70 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md 71 | 'react/jsx-closing-bracket-location': ['error', 'line-aligned'], 72 | 73 | // Validate closing tag location in JSX 74 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-tag-location.md 75 | 'react/jsx-closing-tag-location': 'error', 76 | 77 | // Enforce or disallow spaces inside of curly braces in JSX attributes 78 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-spacing.md 79 | 'react/jsx-curly-spacing': ['error', 'never', { allowMultiline: true }], 80 | 81 | // Enforce event handler naming conventions in JSX 82 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-handler-names.md 83 | 'react/jsx-handler-names': ['off', { 84 | eventHandlerPrefix: 'handle', 85 | eventHandlerPropPrefix: 'on', 86 | }], 87 | 88 | // Validate props indentation in JSX 89 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-indent-props.md 90 | 'react/jsx-indent-props': ['error', 2], 91 | 92 | // Validate JSX has key prop when in array or iterator 93 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-key.md 94 | 'react/jsx-key': 'off', 95 | 96 | // Limit maximum of props on a single line in JSX 97 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-max-props-per-line.md 98 | 'react/jsx-max-props-per-line': ['error', { maximum: 1, when: 'multiline' }], 99 | 100 | // Prevent usage of .bind() in JSX props 101 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md 102 | 'react/jsx-no-bind': ['error', { 103 | ignoreRefs: true, 104 | allowArrowFunctions: true, 105 | allowFunctions: false, 106 | allowBind: false, 107 | ignoreDOMComponents: true, 108 | }], 109 | 110 | // Prevent duplicate props in JSX 111 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-duplicate-props.md 112 | 'react/jsx-no-duplicate-props': ['error', { ignoreCase: true }], 113 | 114 | // Prevent usage of unwrapped JSX strings 115 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-literals.md 116 | 'react/jsx-no-literals': ['off', { noStrings: true }], 117 | 118 | // Disallow undeclared variables in JSX 119 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-undef.md 120 | 'react/jsx-no-undef': 'error', 121 | 122 | // Enforce PascalCase for user-defined JSX components 123 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md 124 | 'react/jsx-pascal-case': ['error', { 125 | allowAllCaps: true, 126 | ignore: [], 127 | }], 128 | 129 | // Enforce propTypes declarations alphabetical sorting 130 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-prop-types.md 131 | 'react/sort-prop-types': ['off', { 132 | ignoreCase: true, 133 | callbacksLast: false, 134 | requiredFirst: false, 135 | sortShapeProp: true, 136 | }], 137 | 138 | // Deprecated in favor of react/jsx-sort-props 139 | 'react/jsx-sort-prop-types': 'off', 140 | 141 | // Enforce props alphabetical sorting 142 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md 143 | 'react/jsx-sort-props': ['off', { 144 | ignoreCase: true, 145 | callbacksLast: false, 146 | shorthandFirst: false, 147 | shorthandLast: false, 148 | noSortAlphabetically: false, 149 | reservedFirst: true, 150 | }], 151 | 152 | // Enforce defaultProps declarations alphabetical sorting 153 | // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/jsx-sort-default-props.md 154 | 'react/jsx-sort-default-props': ['off', { 155 | ignoreCase: true, 156 | }], 157 | 158 | // Prevent React to be incorrectly marked as unused 159 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-react.md 160 | 'react/jsx-uses-react': ['error'], 161 | 162 | // Prevent variables used in JSX to be incorrectly marked as unused 163 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-vars.md 164 | 'react/jsx-uses-vars': 'error', 165 | 166 | // Prevent usage of dangerous JSX properties 167 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-danger.md 168 | 'react/no-danger': 'warn', 169 | 170 | // Prevent usage of deprecated methods 171 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-deprecated.md 172 | 'react/no-deprecated': ['error'], 173 | 174 | // Prevent usage of setState in componentDidMount 175 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-mount-set-state.md 176 | // this is necessary for server-rendering 177 | 'react/no-did-mount-set-state': 'off', 178 | 179 | // Prevent usage of setState in componentDidUpdate 180 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-update-set-state.md 181 | 'react/no-did-update-set-state': 'error', 182 | 183 | // Prevent usage of setState in componentWillUpdate 184 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-will-update-set-state.md 185 | 'react/no-will-update-set-state': 'error', 186 | 187 | // Prevent direct mutation of this.state 188 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-direct-mutation-state.md 189 | 'react/no-direct-mutation-state': 'off', 190 | 191 | // Prevent usage of isMounted 192 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-is-mounted.md 193 | 'react/no-is-mounted': 'error', 194 | 195 | // Prevent multiple component definition per file 196 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md 197 | 'react/no-multi-comp': 'off', 198 | 199 | // Prevent usage of setState 200 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-set-state.md 201 | 'react/no-set-state': 'off', 202 | 203 | // Prevent using string references 204 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-string-refs.md 205 | 'react/no-string-refs': 'error', 206 | 207 | // Prevent usage of unknown DOM property 208 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md 209 | 'react/no-unknown-property': 'error', 210 | 211 | // Require ES6 class declarations over React.createClass 212 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-es6-class.md 213 | 'react/prefer-es6-class': ['error', 'always'], 214 | 215 | // Require stateless functions when not using lifecycle methods, setState or ref 216 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-stateless-function.md 217 | 'react/prefer-stateless-function': ['error', { ignorePureComponents: true }], 218 | 219 | // Prevent missing props validation in a React component definition 220 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prop-types.md 221 | 'react/prop-types': ['error', { 222 | ignore: [], 223 | customValidators: [], 224 | skipUndeclared: false 225 | }], 226 | 227 | // Prevent missing React when using JSX 228 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md 229 | 'react/react-in-jsx-scope': 'error', 230 | 231 | // Require render() methods to return something 232 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-render-return.md 233 | 'react/require-render-return': 'error', 234 | 235 | // Prevent extra closing tags for components without children 236 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md 237 | 'react/self-closing-comp': 'error', 238 | 239 | // Enforce component methods order 240 | // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/sort-comp.md 241 | 'react/sort-comp': ['error', { 242 | order: [ 243 | 'static-variables', 244 | 'static-methods', 245 | 'instance-variables', 246 | 'lifecycle', 247 | '/^on.+$/', 248 | 'getters', 249 | 'setters', 250 | '/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/', 251 | 'instance-methods', 252 | 'everything-else', 253 | 'rendering', 254 | ], 255 | groups: { 256 | lifecycle: [ 257 | 'displayName', 258 | 'propTypes', 259 | 'contextTypes', 260 | 'childContextTypes', 261 | 'mixins', 262 | 'statics', 263 | 'defaultProps', 264 | 'constructor', 265 | 'getDefaultProps', 266 | 'getInitialState', 267 | 'state', 268 | 'getChildContext', 269 | 'getDerivedStateFromProps', 270 | 'componentWillMount', 271 | 'UNSAFE_componentWillMount', 272 | 'componentDidMount', 273 | 'componentWillReceiveProps', 274 | 'UNSAFE_componentWillReceiveProps', 275 | 'shouldComponentUpdate', 276 | 'componentWillUpdate', 277 | 'UNSAFE_componentWillUpdate', 278 | 'getSnapshotBeforeUpdate', 279 | 'componentDidUpdate', 280 | 'componentDidCatch', 281 | 'componentWillUnmount' 282 | ], 283 | rendering: [ 284 | '/^render.+$/', 285 | 'render' 286 | ], 287 | }, 288 | }], 289 | 290 | // Prevent missing parentheses around multilines JSX 291 | // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/jsx-wrap-multilines.md 292 | 'react/jsx-wrap-multilines': ['error', { 293 | declaration: 'parens-new-line', 294 | assignment: 'parens-new-line', 295 | return: 'parens-new-line', 296 | arrow: 'parens-new-line', 297 | condition: 'parens-new-line', 298 | logical: 'parens-new-line', 299 | prop: 'parens-new-line', 300 | }], 301 | 302 | // Require that the first prop in a JSX element be on a new line when the element is multiline 303 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-first-prop-new-line.md 304 | 'react/jsx-first-prop-new-line': ['error', 'multiline-multiprop'], 305 | 306 | // Enforce spacing around jsx equals signs 307 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-equals-spacing.md 308 | 'react/jsx-equals-spacing': ['error', 'never'], 309 | 310 | // Enforce JSX indentation 311 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-indent.md 312 | 'react/jsx-indent': ['error', 2], 313 | 314 | // Disallow target="_blank" on links 315 | // https://github.com/yannickcr/eslint-plugin-react/blob/ac102885765be5ff37847a871f239c6703e1c7cc/docs/rules/jsx-no-target-blank.md 316 | 'react/jsx-no-target-blank': ['error', { enforceDynamicLinks: 'always' }], 317 | 318 | // only .jsx files may have JSX 319 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md 320 | 'react/jsx-filename-extension': ['error', { extensions: ['.jsx'] }], 321 | 322 | // prevent accidental JS comments from being injected into JSX as text 323 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-comment-textnodes.md 324 | 'react/jsx-no-comment-textnodes': 'error', 325 | 326 | // disallow using React.render/ReactDOM.render's return value 327 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-render-return-value.md 328 | 'react/no-render-return-value': 'error', 329 | 330 | // require a shouldComponentUpdate method, or PureRenderMixin 331 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-optimization.md 332 | 'react/require-optimization': ['off', { allowDecorators: [] }], 333 | 334 | // warn against using findDOMNode() 335 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-find-dom-node.md 336 | 'react/no-find-dom-node': 'error', 337 | 338 | // Forbid certain props on Components 339 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-component-props.md 340 | 'react/forbid-component-props': ['off', { forbid: [] }], 341 | 342 | // Forbid certain elements 343 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-elements.md 344 | 'react/forbid-elements': ['off', { forbid: [], }], 345 | 346 | // Prevent problem with children and props.dangerouslySetInnerHTML 347 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-danger-with-children.md 348 | 'react/no-danger-with-children': 'error', 349 | 350 | // Prevent unused propType definitions 351 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unused-prop-types.md 352 | 'react/no-unused-prop-types': ['error', { 353 | customValidators: [ 354 | ], 355 | skipShapeProps: true, 356 | }], 357 | 358 | // Require style prop value be an object or var 359 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/style-prop-object.md 360 | 'react/style-prop-object': 'error', 361 | 362 | // Prevent invalid characters from appearing in markup 363 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unescaped-entities.md 364 | 'react/no-unescaped-entities': 'error', 365 | 366 | // Prevent passing of children as props 367 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-children-prop.md 368 | 'react/no-children-prop': 'error', 369 | 370 | // Validate whitespace in and around the JSX opening and closing brackets 371 | // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/jsx-tag-spacing.md 372 | 'react/jsx-tag-spacing': ['error', { 373 | closingSlash: 'never', 374 | beforeSelfClosing: 'always', 375 | afterOpening: 'never', 376 | beforeClosing: 'never', 377 | }], 378 | 379 | // Enforce spaces before the closing bracket of self-closing JSX elements 380 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-space-before-closing.md 381 | // Deprecated in favor of jsx-tag-spacing 382 | 'react/jsx-space-before-closing': ['off', 'always'], 383 | 384 | // Prevent usage of Array index in keys 385 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md 386 | 'react/no-array-index-key': 'error', 387 | 388 | // Enforce a defaultProps definition for every prop that is not a required prop 389 | // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/require-default-props.md 390 | 'react/require-default-props': ['error', { 391 | forbidDefaultForRequired: true, 392 | }], 393 | 394 | // Forbids using non-exported propTypes 395 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-foreign-prop-types.md 396 | // this is intentionally set to "warn". it would be "error", 397 | // but it's only critical if you're stripping propTypes in production. 398 | 'react/forbid-foreign-prop-types': ['warn', { allowInPropTypes: true }], 399 | 400 | // Prevent void DOM elements from receiving children 401 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/void-dom-elements-no-children.md 402 | 'react/void-dom-elements-no-children': 'error', 403 | 404 | // Enforce all defaultProps have a corresponding non-required PropType 405 | // https://github.com/yannickcr/eslint-plugin-react/blob/9e13ae2c51e44872b45cc15bf1ac3a72105bdd0e/docs/rules/default-props-match-prop-types.md 406 | 'react/default-props-match-prop-types': ['error', { allowRequiredDefaults: false }], 407 | 408 | // Prevent usage of shouldComponentUpdate when extending React.PureComponent 409 | // https://github.com/yannickcr/eslint-plugin-react/blob/9e13ae2c51e44872b45cc15bf1ac3a72105bdd0e/docs/rules/no-redundant-should-component-update.md 410 | 'react/no-redundant-should-component-update': 'error', 411 | 412 | // Prevent unused state values 413 | // https://github.com/yannickcr/eslint-plugin-react/pull/1103/ 414 | 'react/no-unused-state': 'error', 415 | 416 | // Enforces consistent naming for boolean props 417 | // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/boolean-prop-naming.md 418 | 'react/boolean-prop-naming': ['off', { 419 | propTypeNames: ['bool', 'mutuallyExclusiveTrueProps'], 420 | rule: '^(is|has)[A-Z]([A-Za-z0-9]?)+', 421 | message: '', 422 | }], 423 | 424 | // Prevents common casing typos 425 | // https://github.com/yannickcr/eslint-plugin-react/blob/73abadb697034b5ccb514d79fb4689836fe61f91/docs/rules/no-typos.md 426 | 'react/no-typos': 'error', 427 | 428 | // Enforce curly braces or disallow unnecessary curly braces in JSX props and/or children 429 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-brace-presence.md 430 | 'react/jsx-curly-brace-presence': ['error', { props: 'never', children: 'never' }], 431 | 432 | // One JSX Element Per Line 433 | // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/jsx-one-expression-per-line.md 434 | 'react/jsx-one-expression-per-line': ['error', { allow: 'single-child' }], 435 | 436 | // Enforce consistent usage of destructuring assignment of props, state, and context 437 | // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/destructuring-assignment.md 438 | 'react/destructuring-assignment': ['error', 'always'], 439 | 440 | // Prevent using this.state within a this.setState 441 | // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/no-access-state-in-setstate.md 442 | 'react/no-access-state-in-setstate': 'error', 443 | 444 | // Prevent usage of button elements without an explicit type attribute 445 | // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/button-has-type.md 446 | 'react/button-has-type': ['error', { 447 | button: true, 448 | submit: true, 449 | reset: false, 450 | }], 451 | 452 | // Ensures inline tags are not rendered without spaces between them 453 | 'react/jsx-child-element-spacing': 'off', 454 | 455 | // Prevent this from being used in stateless functional components 456 | // https://github.com/yannickcr/eslint-plugin-react/blob/843d71a432baf0f01f598d7cf1eea75ad6896e4b/docs/rules/no-this-in-sfc.md 457 | 'react/no-this-in-sfc': 'error', 458 | 459 | // Validate JSX maximum depth 460 | // https://github.com/yannickcr/eslint-plugin-react/blob/abe8381c0d6748047224c430ce47f02e40160ed0/docs/rules/jsx-max-depth.md 461 | 'react/jsx-max-depth': 'off', 462 | 463 | // Disallow multiple spaces between inline JSX props 464 | // https://github.com/yannickcr/eslint-plugin-react/blob/ac102885765be5ff37847a871f239c6703e1c7cc/docs/rules/jsx-props-no-multi-spaces.md 465 | 'react/jsx-props-no-multi-spaces': 'error', 466 | 467 | // Prevent usage of UNSAFE_ methods 468 | // https://github.com/yannickcr/eslint-plugin-react/blob/157cc932be2cfaa56b3f5b45df6f6d4322a2f660/docs/rules/no-unsafe.md 469 | 'react/no-unsafe': 'off', 470 | 471 | // Enforce shorthand or standard form for React fragments 472 | // https://github.com/yannickcr/eslint-plugin-react/blob/bc976b837abeab1dffd90ac6168b746a83fc83cc/docs/rules/jsx-fragments.md 473 | 'react/jsx-fragments': ['error', 'syntax'], 474 | 475 | // Enforce linebreaks in curly braces in JSX attributes and expressions. 476 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-newline.md 477 | 'react/jsx-curly-newline': ['error', { 478 | multiline: 'consistent', 479 | singleline: 'consistent', 480 | }], 481 | 482 | // Enforce state initialization style 483 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/state-in-constructor.md 484 | // TODO: set to "never" once babel-preset-airbnb supports public class fields 485 | 'react/state-in-constructor': ['error', 'always'], 486 | 487 | // Enforces where React component static properties should be positioned 488 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/static-property-placement.md 489 | // TODO: set to "static public field" once babel-preset-airbnb supports public class fields 490 | 'react/static-property-placement': ['error', 'property assignment'], 491 | 492 | // Disallow JSX props spreading 493 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-spreading.md 494 | 'react/jsx-props-no-spreading': ['error', { 495 | html: 'enforce', 496 | custom: 'enforce', 497 | explicitSpread: 'ignore', 498 | exceptions: [], 499 | }], 500 | 501 | // Enforce that props are read-only 502 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prefer-read-only-props.md 503 | 'react/prefer-read-only-props': 'off', 504 | 505 | // Prevent usage of `javascript:` URLs 506 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-script-url.md 507 | // TODO: enable, semver-major 508 | 'react/jsx-no-script-url': ['off', [ 509 | { 510 | name: 'Link', 511 | props: ['to'], 512 | }, 513 | ]], 514 | 515 | // Disallow unnecessary fragments 516 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-useless-fragment.md 517 | // TODO: enable, semver-major 518 | 'react/jsx-no-useless-fragment': 'off', 519 | 520 | // Prevent adjacent inline elements not separated by whitespace 521 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-adjacent-inline-elements.md 522 | // TODO: enable? semver-major 523 | 'react/no-adjacent-inline-elements': 'off', 524 | 525 | // Enforce a specific function type for function components 526 | // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/function-component-definition.md 527 | // TODO: enable! semver-minor, but do it in a major to be safe 528 | // TODO: investigate if setting namedComponents to expression vs declaration is problematic 529 | 'react/function-component-definition': ['off', { 530 | namedComponents: 'function-expression', 531 | unnamedComponents: 'function-expression', 532 | }], 533 | }, 534 | 535 | settings: { 536 | 'import/resolver': { 537 | node: { 538 | extensions: ['.js', '.jsx', '.json'] 539 | } 540 | }, 541 | react: { 542 | pragma: 'React', 543 | version: 'detect', 544 | }, 545 | propWrapperFunctions: [ 546 | 'forbidExtraProps', // https://www.npmjs.com/package/airbnb-prop-types 547 | 'exact', // https://www.npmjs.com/package/prop-types-exact 548 | 'Object.freeze', // https://tc39.github.io/ecma262/#sec-object.freeze 549 | ], 550 | } 551 | }; 552 | --------------------------------------------------------------------------------