@jabworks/eslint-plugin 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/README.md +74 -0
- package/package.json +60 -0
- package/src/configs/base.js +60 -0
- package/src/configs/comments.js +13 -0
- package/src/configs/next.js +86 -0
- package/src/configs/react.js +52 -0
- package/src/configs/typescript.js +30 -0
- package/src/configs/vitest.js +28 -0
- package/src/index.js +25 -0
- package/src/lib/constants.js +3 -0
- package/src/rules/best-practice.js +228 -0
- package/src/rules/comments.js +12 -0
- package/src/rules/es6.js +66 -0
- package/src/rules/import.js +116 -0
- package/src/rules/jsx-a11y.js +6 -0
- package/src/rules/possible-errors.js +35 -0
- package/src/rules/react.js +122 -0
- package/src/rules/stylistic.js +119 -0
- package/src/rules/typescript.extension.js +39 -0
- package/src/rules/typescript.import.js +19 -0
- package/src/rules/typescript.js +137 -0
- package/src/rules/unicorn.js +16 -0
- package/src/rules/variables.js +31 -0
- package/src/rules/vitest.js +10 -0
- package/src/types/index.d.ts +17 -0
- package/tsconfig.json +3 -0
package/src/rules/es6.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/** @type {import('eslint').Linter.RulesRecord} */
|
|
2
|
+
const rules = {
|
|
3
|
+
/**
|
|
4
|
+
* Disallow useless computed property keys.
|
|
5
|
+
*
|
|
6
|
+
* 🔧 Fixable - https://eslint.org/docs/rules/no-useless-computed-key
|
|
7
|
+
*/
|
|
8
|
+
'no-useless-computed-key': 'warn',
|
|
9
|
+
/**
|
|
10
|
+
* Disallow renaming import, export, and destructured assignments to the
|
|
11
|
+
* same name.
|
|
12
|
+
*
|
|
13
|
+
* 🔧 Fixable - https://eslint.org/docs/rules/no-useless-rename
|
|
14
|
+
*/
|
|
15
|
+
'no-useless-rename': 'warn',
|
|
16
|
+
/**
|
|
17
|
+
* Require `let` or `const` instead of `var`.
|
|
18
|
+
*
|
|
19
|
+
* 🔧 Fixable - https://eslint.org/docs/rules/no-var
|
|
20
|
+
*/
|
|
21
|
+
'no-var': 'error',
|
|
22
|
+
/**
|
|
23
|
+
* Require object literal shorthand syntax.
|
|
24
|
+
*
|
|
25
|
+
* 🔧 Fixable - https://eslint.org/docs/rules/object-shorthand
|
|
26
|
+
*/
|
|
27
|
+
'object-shorthand': 'warn',
|
|
28
|
+
/**
|
|
29
|
+
* Require default to `const` instead of `let`.
|
|
30
|
+
*
|
|
31
|
+
* 🔧 Fixable - https://eslint.org/docs/rules/prefer-const
|
|
32
|
+
*/
|
|
33
|
+
'prefer-const': 'warn',
|
|
34
|
+
/**
|
|
35
|
+
* Disallow parseInt() in favor of binary, octal, and hexadecimal literals.
|
|
36
|
+
*
|
|
37
|
+
* 🔧 Fixable - https://eslint.org/docs/rules/prefer-numeric-literals
|
|
38
|
+
*/
|
|
39
|
+
'prefer-numeric-literals': 'error',
|
|
40
|
+
/**
|
|
41
|
+
* Require using rest parameters instead of `arguments`.
|
|
42
|
+
*
|
|
43
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/prefer-rest-params
|
|
44
|
+
*/
|
|
45
|
+
'prefer-rest-params': 'error',
|
|
46
|
+
/**
|
|
47
|
+
* Require using spread syntax instead of `.apply()`.
|
|
48
|
+
*
|
|
49
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/prefer-spread
|
|
50
|
+
*/
|
|
51
|
+
'prefer-spread': 'error',
|
|
52
|
+
/**
|
|
53
|
+
* Require using template literals instead of string concatenation.
|
|
54
|
+
*
|
|
55
|
+
* 🔧 Fixable - https://eslint.org/docs/rules/prefer-template
|
|
56
|
+
*/
|
|
57
|
+
'prefer-template': 'warn',
|
|
58
|
+
/**
|
|
59
|
+
* Require a `Symbol` description.
|
|
60
|
+
*
|
|
61
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/symbol-description
|
|
62
|
+
*/
|
|
63
|
+
'symbol-description': 'error',
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export default rules;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/** @type {import('eslint').Linter.RulesRecord} */
|
|
2
|
+
const disabledRules = {
|
|
3
|
+
'import/named': 'off',
|
|
4
|
+
'import/no-cycle': 'off', // This rule is the most taxing on performance, so we disable it by default.
|
|
5
|
+
'import/order': 'off',
|
|
6
|
+
'sort-imports': 'off',
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
/** @type {import('eslint').Linter.RulesRecord} */
|
|
10
|
+
const rules = {
|
|
11
|
+
/**
|
|
12
|
+
* Disallow non-import statements appearing before import statements.
|
|
13
|
+
*
|
|
14
|
+
* 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/first.md
|
|
15
|
+
*/
|
|
16
|
+
'import/first': 'error',
|
|
17
|
+
/**
|
|
18
|
+
* Require a newline after the last import/require.
|
|
19
|
+
*
|
|
20
|
+
* 🔧 Fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/newline-after-import.md
|
|
21
|
+
*/
|
|
22
|
+
'import/newline-after-import': 'warn',
|
|
23
|
+
/**
|
|
24
|
+
* Disallow import of modules using absolute paths.
|
|
25
|
+
*
|
|
26
|
+
* 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-absolute-path.md
|
|
27
|
+
*/
|
|
28
|
+
'import/no-absolute-path': 'error',
|
|
29
|
+
/**
|
|
30
|
+
* Disallow default exports.
|
|
31
|
+
*
|
|
32
|
+
* 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-default-export.md
|
|
33
|
+
*/
|
|
34
|
+
'import/no-default-export': 'error',
|
|
35
|
+
/**
|
|
36
|
+
* Disallow the use of extraneous packages.
|
|
37
|
+
*
|
|
38
|
+
* 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-extraneous-dependencies.md
|
|
39
|
+
*/
|
|
40
|
+
'import/no-extraneous-dependencies': ['error', { includeTypes: true }],
|
|
41
|
+
/**
|
|
42
|
+
* Disallow mutable exports.
|
|
43
|
+
*
|
|
44
|
+
* 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-mutable-exports.md
|
|
45
|
+
*/
|
|
46
|
+
'import/no-mutable-exports': 'error',
|
|
47
|
+
/**
|
|
48
|
+
* Disallow importing packages through relative paths.
|
|
49
|
+
*
|
|
50
|
+
* 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-relative-packages.md
|
|
51
|
+
*/
|
|
52
|
+
'import/no-relative-packages': 'warn',
|
|
53
|
+
/**
|
|
54
|
+
* Disallow a module from importing itself.
|
|
55
|
+
*
|
|
56
|
+
* 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-self-import.md
|
|
57
|
+
*/
|
|
58
|
+
'import/no-self-import': 'error',
|
|
59
|
+
/**
|
|
60
|
+
* Ensures that there are no useless path segments.
|
|
61
|
+
*
|
|
62
|
+
* 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-useless-path-segments.md
|
|
63
|
+
*/
|
|
64
|
+
'import/no-useless-path-segments': ['error'],
|
|
65
|
+
/**
|
|
66
|
+
* Forbid imported names marked with @deprecated documentation tag.
|
|
67
|
+
*
|
|
68
|
+
* 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-deprecated.md
|
|
69
|
+
*/
|
|
70
|
+
'import/no-deprecated': 'error',
|
|
71
|
+
/**
|
|
72
|
+
* Forbid a module from importing a module with a dependency path back to itself.
|
|
73
|
+
*
|
|
74
|
+
* 🚫 Not fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-cycle.md
|
|
75
|
+
*/
|
|
76
|
+
'import/no-cycle': 'error',
|
|
77
|
+
/**
|
|
78
|
+
* Enforce a module import order convention.
|
|
79
|
+
*
|
|
80
|
+
* 🔧 Fixable - https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/order.md
|
|
81
|
+
*/
|
|
82
|
+
// 'import/order': [
|
|
83
|
+
// 'warn',
|
|
84
|
+
// {
|
|
85
|
+
// groups: [
|
|
86
|
+
// 'builtin', // Node.js built-in modules
|
|
87
|
+
// 'external', // Packages
|
|
88
|
+
// 'internal', // Aliased modules
|
|
89
|
+
// 'parent', // Relative parent
|
|
90
|
+
// 'sibling', // Relative sibling
|
|
91
|
+
// 'index', // Relative index
|
|
92
|
+
// ],
|
|
93
|
+
// 'newlines-between': 'never',
|
|
94
|
+
// },
|
|
95
|
+
// ],
|
|
96
|
+
/**
|
|
97
|
+
* Enforce a module export order convention.
|
|
98
|
+
*
|
|
99
|
+
* 🔧 Fixable - https://github.com/lydell/eslint-plugin-simple-import-sort
|
|
100
|
+
*/
|
|
101
|
+
'simple-import-sort/exports': 'warn',
|
|
102
|
+
/**
|
|
103
|
+
* Enforce a module import order convention.
|
|
104
|
+
*
|
|
105
|
+
* 🔧 Fixable - https://github.com/lydell/eslint-plugin-simple-import-sort
|
|
106
|
+
*/
|
|
107
|
+
'simple-import-sort/imports': [
|
|
108
|
+
'warn',
|
|
109
|
+
{
|
|
110
|
+
groups: [['^react'], ['^@?\\w'], ['^@/'], ['^\\.((?!.(css|scss)).)*$'], ['^[^.]'], ['^.+\\.(css|scss)$']],
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
...disabledRules,
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export default rules;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** @type {import('eslint').Linter.RulesRecord} */
|
|
2
|
+
const rules = {
|
|
3
|
+
/**
|
|
4
|
+
* Disallow the use of console.
|
|
5
|
+
*
|
|
6
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/no-console
|
|
7
|
+
*/
|
|
8
|
+
'no-console': ['warn', { allow: ['error', 'warn'] }],
|
|
9
|
+
/**
|
|
10
|
+
* Disallow expressions where the operation doesn't affect the value.
|
|
11
|
+
*
|
|
12
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/no-console
|
|
13
|
+
*/
|
|
14
|
+
'no-constant-binary-expression': 'error',
|
|
15
|
+
/**
|
|
16
|
+
* Disallow returning values from Promise executor functions.
|
|
17
|
+
*
|
|
18
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/no-promise-executor-return
|
|
19
|
+
*/
|
|
20
|
+
'no-promise-executor-return': 'error',
|
|
21
|
+
/**
|
|
22
|
+
* Disallow template literal placeholder syntax in regular strings, as these are likely errors.
|
|
23
|
+
*
|
|
24
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/no-template-curly-in-string
|
|
25
|
+
*/
|
|
26
|
+
'no-template-curly-in-string': 'error',
|
|
27
|
+
/**
|
|
28
|
+
* Disallow loops with a body that allows only one iteration.
|
|
29
|
+
*
|
|
30
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/no-unreachable-loop
|
|
31
|
+
*/
|
|
32
|
+
'no-unreachable-loop': 'error',
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default rules;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/** @type {import('eslint').Linter.RulesRecord} */
|
|
2
|
+
const disabledRules = {
|
|
3
|
+
'react/prop-types': 'off',
|
|
4
|
+
'react/react-in-jsx-scope': 'off',
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
/** @type {import('eslint').Linter.RulesRecord} */
|
|
8
|
+
const rules = {
|
|
9
|
+
...disabledRules,
|
|
10
|
+
/**
|
|
11
|
+
* Require an explicit type when using button elements.
|
|
12
|
+
*
|
|
13
|
+
* 🚫 Not fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/button-has-type.md
|
|
14
|
+
*/
|
|
15
|
+
'react/button-has-type': 'warn',
|
|
16
|
+
/**
|
|
17
|
+
* Require consistent function type for function components.
|
|
18
|
+
*
|
|
19
|
+
* 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/HEAD/docs/rules/function-component-definition.md
|
|
20
|
+
*/
|
|
21
|
+
'react/function-component-definition': [
|
|
22
|
+
'error',
|
|
23
|
+
{
|
|
24
|
+
namedComponents: 'arrow-function',
|
|
25
|
+
unnamedComponents: 'arrow-function',
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
/**
|
|
29
|
+
* Require destructuring and symmetric naming of `useState` hook value and setter variables.
|
|
30
|
+
*
|
|
31
|
+
* 🚫 Not fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/hook-use-state.md
|
|
32
|
+
*/
|
|
33
|
+
'react/hook-use-state': 'warn',
|
|
34
|
+
/**
|
|
35
|
+
* Require consistent boolean attributes notation in JSX.
|
|
36
|
+
*
|
|
37
|
+
* 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md
|
|
38
|
+
*/
|
|
39
|
+
'react/jsx-boolean-value': 'warn',
|
|
40
|
+
/**
|
|
41
|
+
* Disallow unnecessary curly braces in JSX props and children.
|
|
42
|
+
*
|
|
43
|
+
* 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-curly-brace-presence.md
|
|
44
|
+
*/
|
|
45
|
+
'react/jsx-curly-brace-presence': 'warn',
|
|
46
|
+
/**
|
|
47
|
+
* Require using shorthand form for React fragments, unless required.
|
|
48
|
+
*
|
|
49
|
+
* 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-fragments.md
|
|
50
|
+
*/
|
|
51
|
+
'react/jsx-fragments': 'warn',
|
|
52
|
+
/**
|
|
53
|
+
* Prevent problematic leaked values from being rendered.
|
|
54
|
+
*
|
|
55
|
+
* 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-leaked-render.md
|
|
56
|
+
*/
|
|
57
|
+
'react/jsx-no-leaked-render': 'warn',
|
|
58
|
+
/**
|
|
59
|
+
* Prevents usage of unsafe `target='_blank'`.
|
|
60
|
+
*
|
|
61
|
+
* This rule is a part of `react/recommended`, but we've modified it to
|
|
62
|
+
* allow referrer.
|
|
63
|
+
*
|
|
64
|
+
* 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-target-blank.md
|
|
65
|
+
*/
|
|
66
|
+
'react/jsx-no-target-blank': [
|
|
67
|
+
'error',
|
|
68
|
+
{
|
|
69
|
+
allowReferrer: true,
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
/**
|
|
73
|
+
* Disallow empty React fragments.
|
|
74
|
+
*
|
|
75
|
+
* 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-useless-fragment.md
|
|
76
|
+
*/
|
|
77
|
+
'react/jsx-no-useless-fragment': ['warn', { allowExpressions: true }],
|
|
78
|
+
/**
|
|
79
|
+
* Require the use of PascalCase for user-defined JSX components.
|
|
80
|
+
*
|
|
81
|
+
* 🚫 Not fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-pascal-case.md
|
|
82
|
+
*/
|
|
83
|
+
'react/jsx-pascal-case': 'warn',
|
|
84
|
+
/**
|
|
85
|
+
* Enforce props alphabetical sorting.
|
|
86
|
+
*
|
|
87
|
+
* 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md
|
|
88
|
+
*/
|
|
89
|
+
'react/jsx-sort-props': [
|
|
90
|
+
'warn',
|
|
91
|
+
{
|
|
92
|
+
callbacksLast: true,
|
|
93
|
+
shorthandFirst: true,
|
|
94
|
+
shorthandLast: false,
|
|
95
|
+
multiline: 'last',
|
|
96
|
+
ignoreCase: true,
|
|
97
|
+
noSortAlphabetically: false,
|
|
98
|
+
reservedFirst: true,
|
|
99
|
+
locale: 'auto',
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
/**
|
|
103
|
+
* Disallow usage of Array index in keys.
|
|
104
|
+
*
|
|
105
|
+
* 🚫 Not fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-array-index-key.md
|
|
106
|
+
*/
|
|
107
|
+
'react/no-array-index-key': 'warn',
|
|
108
|
+
/**
|
|
109
|
+
* Disallow creating unstable components inside components.
|
|
110
|
+
*
|
|
111
|
+
* 🚫 Not fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unstable-nested-components.md
|
|
112
|
+
*/
|
|
113
|
+
'react/no-unstable-nested-components': 'error',
|
|
114
|
+
/**
|
|
115
|
+
* Disallow closing tags for components without children.
|
|
116
|
+
*
|
|
117
|
+
* 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md
|
|
118
|
+
*/
|
|
119
|
+
'react/self-closing-comp': 'warn',
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export default rules;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/** @type {import('eslint').Linter.RulesRecord} */
|
|
2
|
+
const disabledRules = {
|
|
3
|
+
'tsdoc/syntax': 'off',
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* ESLint stylistic rules configuration.
|
|
8
|
+
*
|
|
9
|
+
* This object defines a set of stylistic rules for ESLint, including:
|
|
10
|
+
* - Enforcing camel case naming conventions, with exceptions for certain patterns and destructuring.
|
|
11
|
+
* - Requiring function expressions to have a name only when necessary.
|
|
12
|
+
* - Enforcing capitalization for constructor functions.
|
|
13
|
+
* - Warning when parentheses are omitted in constructor calls with no arguments.
|
|
14
|
+
* - Disallowing the use of the Array constructor.
|
|
15
|
+
* - Warning against lonely if statements within else blocks.
|
|
16
|
+
* - Disallowing chained assignment expressions.
|
|
17
|
+
* - Disallowing nested ternary expressions.
|
|
18
|
+
* - Disallowing unnecessary ternary operators.
|
|
19
|
+
* - Enforcing consistent blank lines between statements, especially around returns, variable declarations, and control flow statements.
|
|
20
|
+
* - Preferring object spread syntax over Object.assign.
|
|
21
|
+
* - Preferring arrow functions for callbacks.
|
|
22
|
+
*
|
|
23
|
+
* Some rules are fixable by ESLint, while others are not. See individual rule comments for details and references.
|
|
24
|
+
*
|
|
25
|
+
* @type {import('eslint').Linter.RulesRecord}
|
|
26
|
+
*/
|
|
27
|
+
const rules = {
|
|
28
|
+
...disabledRules,
|
|
29
|
+
/**
|
|
30
|
+
* Require camel case names.
|
|
31
|
+
*
|
|
32
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/camelcase
|
|
33
|
+
*/
|
|
34
|
+
camelcase: ['error', { allow: ['^UNSAFE_'], ignoreDestructuring: true, properties: 'never', ignoreImports: true }],
|
|
35
|
+
/**
|
|
36
|
+
* Require function expressions to have a name.
|
|
37
|
+
*
|
|
38
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/func-names
|
|
39
|
+
*/
|
|
40
|
+
'func-names': ['error', 'as-needed'],
|
|
41
|
+
/**
|
|
42
|
+
* Require a capital letter for constructors.
|
|
43
|
+
*
|
|
44
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/new-cap
|
|
45
|
+
*/
|
|
46
|
+
'new-cap': ['error', { capIsNew: false }],
|
|
47
|
+
/**
|
|
48
|
+
* Disallow the omission of parentheses when invoking a constructor with
|
|
49
|
+
* no arguments.
|
|
50
|
+
*
|
|
51
|
+
* 🔧 Fixable - https://eslint.style/rules/default/new-parens
|
|
52
|
+
*/
|
|
53
|
+
'@stylistic/new-parens': 'warn',
|
|
54
|
+
/**
|
|
55
|
+
* Disallow use of the Array constructor.
|
|
56
|
+
*
|
|
57
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/no-array-constructor
|
|
58
|
+
*/
|
|
59
|
+
'no-array-constructor': 'error',
|
|
60
|
+
/**
|
|
61
|
+
* Disallow use of bitwise operators.
|
|
62
|
+
*
|
|
63
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/no-bitwise
|
|
64
|
+
*/
|
|
65
|
+
'no-bitwise': 'error',
|
|
66
|
+
/**
|
|
67
|
+
* Disallow if as the only statement in an else block.
|
|
68
|
+
*
|
|
69
|
+
* 🔧 Fixable - https://eslint.org/docs/rules/no-lonely-if
|
|
70
|
+
*/
|
|
71
|
+
'no-lonely-if': 'warn',
|
|
72
|
+
/**
|
|
73
|
+
* Disallow use of chained assignment expressions.
|
|
74
|
+
*
|
|
75
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/no-multi-assign
|
|
76
|
+
*/
|
|
77
|
+
'no-multi-assign': ['error'],
|
|
78
|
+
/**
|
|
79
|
+
* Disallow nested ternary expressions.
|
|
80
|
+
*
|
|
81
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/no-nested-ternary
|
|
82
|
+
*/
|
|
83
|
+
'no-nested-ternary': 'error',
|
|
84
|
+
/**
|
|
85
|
+
* Disallow ternary operators when simpler alternatives exist.
|
|
86
|
+
*
|
|
87
|
+
* 🚫 Not fixable - https://eslint.org/docs/rules/no-unneeded-ternary
|
|
88
|
+
*/
|
|
89
|
+
'no-unneeded-ternary': 'error',
|
|
90
|
+
/**
|
|
91
|
+
* Enforces consistent blank lines between statements.
|
|
92
|
+
*
|
|
93
|
+
* 🔧 Fixable - https://eslint.style/rules/default/padding-line-between-statements
|
|
94
|
+
*/
|
|
95
|
+
'@stylistic/padding-line-between-statements': [
|
|
96
|
+
'warn',
|
|
97
|
+
{ blankLine: 'always', next: 'return', prev: '*' },
|
|
98
|
+
{ blankLine: 'always', next: '*', prev: ['const', 'let', 'var'] },
|
|
99
|
+
{ blankLine: 'any', next: ['const', 'let', 'var'], prev: ['const', 'let', 'var'] },
|
|
100
|
+
{ blankLine: 'always', next: ['if', 'try', 'switch', 'for', 'while'], prev: '*' },
|
|
101
|
+
{ blankLine: 'always', next: '*', prev: ['if', 'try', 'switch', 'for', 'while'] },
|
|
102
|
+
{ blankLine: 'always', next: 'block-like', prev: '*' },
|
|
103
|
+
{ blankLine: 'always', next: '*', prev: 'block-like' },
|
|
104
|
+
],
|
|
105
|
+
/**
|
|
106
|
+
* Require use of an object spread over Object.assign.
|
|
107
|
+
*
|
|
108
|
+
* 🔧 Fixable - https://eslint.org/docs/rules/prefer-object-spread
|
|
109
|
+
*/
|
|
110
|
+
'prefer-object-spread': 'warn',
|
|
111
|
+
/**
|
|
112
|
+
* Require using arrow functions for callbacks .
|
|
113
|
+
*
|
|
114
|
+
* 🔧 Fixable - https://eslint.org/docs/latest/rules/prefer-arrow-callback
|
|
115
|
+
*/
|
|
116
|
+
'prefer-arrow-callback': 'warn',
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export default rules;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// These share identical configuration options, so we want to keep them in sync.
|
|
2
|
+
import noUnusedVarsRules from './variables.js';
|
|
3
|
+
|
|
4
|
+
/** @type {import('eslint').Linter.RulesRecord} */
|
|
5
|
+
const rules = {
|
|
6
|
+
/**
|
|
7
|
+
* Require default parameters to be last.
|
|
8
|
+
*
|
|
9
|
+
* 🚫 Not fixable - https://typescript-eslint.io/rules/default-param-last/
|
|
10
|
+
*/
|
|
11
|
+
'@typescript-eslint/default-param-last': 'error',
|
|
12
|
+
/**
|
|
13
|
+
* Disallow creation of functions within loops.
|
|
14
|
+
*
|
|
15
|
+
* 🚫 Not fixable - https://typescript-eslint.io/rules/no-loop-func/
|
|
16
|
+
*/
|
|
17
|
+
'@typescript-eslint/no-loop-func': 'error',
|
|
18
|
+
/**
|
|
19
|
+
* Disallow variable declarations from shadowing variables declared in the
|
|
20
|
+
* outer scope.
|
|
21
|
+
*
|
|
22
|
+
* 🚫 Not fixable - https://typescript-eslint.io/rules/no-shadow/
|
|
23
|
+
*/
|
|
24
|
+
// '@typescript-eslint/no-shadow': 'error',
|
|
25
|
+
/**
|
|
26
|
+
* Disallow unused variables.
|
|
27
|
+
*
|
|
28
|
+
* 🚫 Not fixable - https://typescript-eslint.io/rules/no-unused-vars/
|
|
29
|
+
*/
|
|
30
|
+
'@typescript-eslint/no-unused-vars': noUnusedVarsRules['no-unused-vars'],
|
|
31
|
+
/**
|
|
32
|
+
* Disallow unnecessary constructors.
|
|
33
|
+
*
|
|
34
|
+
* 🚫 Not fixable - https://typescript-eslint.io/rules/no-useless-constructor/
|
|
35
|
+
*/
|
|
36
|
+
'@typescript-eslint/no-useless-constructor': 'error',
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default rules;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* These are enabled by `import/recommended`, but are better handled by
|
|
3
|
+
* TypeScript and `typescript-eslint`.
|
|
4
|
+
*
|
|
5
|
+
* @type {import('eslint').Linter.RulesRecord}
|
|
6
|
+
*/
|
|
7
|
+
const disabledRules = {
|
|
8
|
+
'import/default': 'off',
|
|
9
|
+
'import/export': 'off',
|
|
10
|
+
'import/namespace': 'off',
|
|
11
|
+
'import/no-unresolved': 'off',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/** @type {import('eslint').Linter.RulesRecord} */
|
|
15
|
+
const rules = {
|
|
16
|
+
...disabledRules,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default rules;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/** @type {import('eslint').Linter.RulesRecord} */
|
|
2
|
+
const rules = {
|
|
3
|
+
/**
|
|
4
|
+
* Require consistent usage of type exports.
|
|
5
|
+
*
|
|
6
|
+
* 🔧 Fixable - https://typescript-eslint.io/rules/consistent-type-exports/
|
|
7
|
+
*/
|
|
8
|
+
'@typescript-eslint/consistent-type-exports': ['warn', { fixMixedExportsWithInlineTypeSpecifier: true }],
|
|
9
|
+
/**
|
|
10
|
+
* Require consistent usage of type imports.
|
|
11
|
+
*
|
|
12
|
+
* 🔧 Fixable - https://typescript-eslint.io/rules/consistent-type-imports/
|
|
13
|
+
*/
|
|
14
|
+
'@typescript-eslint/consistent-type-imports': [
|
|
15
|
+
'warn',
|
|
16
|
+
{
|
|
17
|
+
disallowTypeAnnotations: true,
|
|
18
|
+
fixStyle: 'inline-type-imports',
|
|
19
|
+
prefer: 'type-imports',
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
/**
|
|
23
|
+
* Require explicit return types on functions and class methods.
|
|
24
|
+
*
|
|
25
|
+
* 🚫 Not fixable - https://typescript-eslint.io/rules/explicit-function-return-type/
|
|
26
|
+
*/
|
|
27
|
+
// '@typescript-eslint/explicit-function-return-type': ['warn', { allowExpressions: true }],
|
|
28
|
+
/**
|
|
29
|
+
* Require using function property types in method signatures.
|
|
30
|
+
*
|
|
31
|
+
* These have enhanced typechecking, whereas method signatures do not.
|
|
32
|
+
*
|
|
33
|
+
* 🔧 Fixable - https://typescript-eslint.io/rules/method-signature-style/
|
|
34
|
+
*/
|
|
35
|
+
'@typescript-eslint/method-signature-style': 'warn',
|
|
36
|
+
/**
|
|
37
|
+
* Require consistent naming conventions.
|
|
38
|
+
*
|
|
39
|
+
* Improves IntelliSense suggestions and avoids name collisions.
|
|
40
|
+
*
|
|
41
|
+
* 🚫 Not fixable - https://typescript-eslint.io/rules/naming-convention/
|
|
42
|
+
*/
|
|
43
|
+
'@typescript-eslint/naming-convention': [
|
|
44
|
+
'error',
|
|
45
|
+
// Anything type-like should be written in PascalCase.
|
|
46
|
+
{
|
|
47
|
+
format: ['PascalCase'],
|
|
48
|
+
selector: ['typeLike', 'enumMember'],
|
|
49
|
+
},
|
|
50
|
+
// Interfaces cannot be prefixed with `I`, or have restricted names.
|
|
51
|
+
{
|
|
52
|
+
custom: {
|
|
53
|
+
match: false,
|
|
54
|
+
regex: '^I[A-Z]|^(Interface|Props|State)$',
|
|
55
|
+
},
|
|
56
|
+
format: ['PascalCase'],
|
|
57
|
+
selector: 'interface',
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
/**
|
|
61
|
+
* Disallow Promises in places not designed to handle them.
|
|
62
|
+
*
|
|
63
|
+
* 🚫 Not fixable - https://typescript-eslint.io/rules/no-misused-promises/
|
|
64
|
+
*/
|
|
65
|
+
'@typescript-eslint/no-misused-promises': [
|
|
66
|
+
'error',
|
|
67
|
+
{
|
|
68
|
+
checksVoidReturn: {
|
|
69
|
+
attributes: false,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
/**
|
|
74
|
+
* Disallow members of unions and intersections that do nothing or override type information.
|
|
75
|
+
*
|
|
76
|
+
* 🚫 Not fixable - https://typescript-eslint.io/rules/no-redundant-type-constituents/
|
|
77
|
+
*/
|
|
78
|
+
'@typescript-eslint/no-redundant-type-constituents': 'warn',
|
|
79
|
+
/**
|
|
80
|
+
* Disallow unnecessary namespace qualifiers.
|
|
81
|
+
*
|
|
82
|
+
* 🔧 Fixable - https://typescript-eslint.io/rules/no-unnecessary-qualifier/
|
|
83
|
+
*/
|
|
84
|
+
'@typescript-eslint/no-unnecessary-qualifier': 'warn',
|
|
85
|
+
/**
|
|
86
|
+
* Require using `RegExp.exec()` over `String.match()` for consistency.
|
|
87
|
+
*
|
|
88
|
+
* 🔧 Fixable - https://typescript-eslint.io/rules/prefer-regexp-exec/
|
|
89
|
+
*/
|
|
90
|
+
'@typescript-eslint/prefer-regexp-exec': 'warn',
|
|
91
|
+
/**
|
|
92
|
+
* Require Array#sort calls to provide a compare function.
|
|
93
|
+
*
|
|
94
|
+
* 🚫 Not fixable - https://typescript-eslint.io/rules/require-array-sort-compare/
|
|
95
|
+
*/
|
|
96
|
+
'@typescript-eslint/require-array-sort-compare': ['error', { ignoreStringArrays: true }],
|
|
97
|
+
/**
|
|
98
|
+
* Enforce template literal expressions to be of string type.
|
|
99
|
+
*
|
|
100
|
+
* The default settings of this rule intentionally do not allow objects with a custom toString() method to be used in template literals, because the stringification result may not be user-friendly.
|
|
101
|
+
*
|
|
102
|
+
* Number is allowed because it is a common use case to use numbers in template literals.
|
|
103
|
+
*
|
|
104
|
+
* 🚫 Not fixable - https://typescript-eslint.io/rules/restrict-template-expressions/
|
|
105
|
+
*/
|
|
106
|
+
'@typescript-eslint/restrict-template-expressions': [
|
|
107
|
+
'error',
|
|
108
|
+
{
|
|
109
|
+
allowNumber: true,
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
/**
|
|
113
|
+
* Require exhaustive checks when using union types in switch statements.
|
|
114
|
+
*
|
|
115
|
+
* This ensures cases are considered when items are later added to a union.
|
|
116
|
+
*
|
|
117
|
+
* 🚫 Not fixable - https://typescript-eslint.io/rules/switch-exhaustiveness-check/
|
|
118
|
+
*/
|
|
119
|
+
'@typescript-eslint/switch-exhaustiveness-check': [
|
|
120
|
+
'warn',
|
|
121
|
+
{
|
|
122
|
+
considerDefaultExhaustiveForUnions: true,
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
/**
|
|
126
|
+
* Disallow empty object types.
|
|
127
|
+
*
|
|
128
|
+
* This rule is useful to prevent the accidental creation of empty interfaces or types that do not provide any value.
|
|
129
|
+
*
|
|
130
|
+
* Allow empty interfaces that extend from a single base interface.
|
|
131
|
+
*
|
|
132
|
+
* 🚫 Not fixable - https://typescript-eslint.io/rules/no-empty-object-type/
|
|
133
|
+
*/
|
|
134
|
+
'@typescript-eslint/no-empty-object-type': ['error', { allowInterfaces: 'with-single-extends' }],
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export default rules;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** @type {import('eslint').Linter.RulesRecord} */
|
|
2
|
+
const rules = {
|
|
3
|
+
/**
|
|
4
|
+
* Require consistent filename case for all linted files.
|
|
5
|
+
*
|
|
6
|
+
* 🚫 Not fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/filename-case.md
|
|
7
|
+
*/
|
|
8
|
+
'unicorn/filename-case': [
|
|
9
|
+
'error',
|
|
10
|
+
{
|
|
11
|
+
case: 'kebabCase',
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default rules;
|