├── .gitignore
├── .babelrc
├── rules
├── base
│ ├── strict.js
│ ├── node.js
│ ├── variables.js
│ ├── errors.js
│ ├── es6.js
│ ├── imports.js
│ ├── best-practices.js
│ └── style.js
└── react
│ ├── react-hooks.js
│ ├── react-a11y.js
│ └── react.js
├── react.js
├── .eslintrc
├── IDE-config.xml
├── index.js
├── .editorconfig
├── package.json
├── legacy.js
├── License.md
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea
2 | node_modules
--------------------------------------------------------------------------------
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["exceed"]
3 | }
4 |
--------------------------------------------------------------------------------
/rules/base/strict.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | rules: {
3 | // babel inserts `'use strict';` for us
4 | strict: ['error', 'never']
5 | }
6 | };
7 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/IDE-config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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.
--------------------------------------------------------------------------------
/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/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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/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