@fullstacksjs/eslint-config 8.12.0 → 9.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/base.js +213 -25
- package/cypress.js +17 -2
- package/{rules/fp.js → fp.js} +2 -0
- package/graphql.js +67 -1
- package/{rules/import.js → import.js} +11 -0
- package/index.js +10 -4
- package/init.js +57 -0
- package/jest.js +67 -2
- package/{rules/naming-convention.js → naming-convention.js} +0 -0
- package/{rules/node.js → node.js} +2 -0
- package/package.json +16 -16
- package/{rules/promise.js → promise.js} +2 -0
- package/react.js +129 -1
- package/registerOpts.js +16 -0
- package/storybook.js +17 -1
- package/strict.js +15 -0
- package/{rules/test.js → test.js} +12 -7
- package/typecheck.js +65 -1
- package/typescript.js +77 -13
- package/utils.js +20 -0
- package/nextjs.js +0 -31
- package/packages.js +0 -9
- package/rules/base.js +0 -87
- package/rules/cypress.js +0 -16
- package/rules/es2015.js +0 -30
- package/rules/forbidden.js +0 -39
- package/rules/graphql.js +0 -70
- package/rules/jest.js +0 -65
- package/rules/jsx-a11y.js +0 -40
- package/rules/react-hooks.js +0 -6
- package/rules/react.js +0 -92
- package/rules/storybook.js +0 -19
- package/rules/strict.js +0 -66
- package/rules/style.js +0 -61
- package/rules/typecheck.js +0 -67
- package/rules/typescript.js +0 -162
- package/rules/variables.js +0 -23
package/react.js
CHANGED
|
@@ -15,5 +15,133 @@ module.exports = {
|
|
|
15
15
|
env: {
|
|
16
16
|
browser: true,
|
|
17
17
|
},
|
|
18
|
-
|
|
18
|
+
rules: {
|
|
19
|
+
'react/boolean-prop-naming': 'off',
|
|
20
|
+
'react/button-has-type': 'off',
|
|
21
|
+
'react/default-props-match-prop-types': 'off',
|
|
22
|
+
'react/destructuring-assignment': 'off',
|
|
23
|
+
'react/display-name': ['off', { ignoreTranspilerName: false }],
|
|
24
|
+
'react/forbid-component-props': 'off',
|
|
25
|
+
'react/forbid-dom-props': 'off',
|
|
26
|
+
'react/forbid-elements': 'off',
|
|
27
|
+
'react/forbid-foreign-prop-types': 'error',
|
|
28
|
+
'react/forbid-prop-types': 'off',
|
|
29
|
+
'react/function-component-definition': ['warn', { namedComponents: 'arrow-function', unnamedComponents: 'arrow-function' }],
|
|
30
|
+
'react/hook-use-state': 'off',
|
|
31
|
+
'react/iframe-missing-sandbox': 'error',
|
|
32
|
+
'react/jsx-boolean-value': 'warn',
|
|
33
|
+
'react/jsx-child-element-spacing': 'warn',
|
|
34
|
+
'react/jsx-curly-brace-presence': ['warn', { props: 'never', children: 'ignore' }],
|
|
35
|
+
'react/jsx-filename-extension': ['error', { extensions: ['.jsx', '.tsx'] }],
|
|
36
|
+
'react/jsx-fragments': 'off',
|
|
37
|
+
'react/jsx-handler-names': 'off',
|
|
38
|
+
'react/jsx-key': 'error',
|
|
39
|
+
'react/jsx-max-depth': 'off',
|
|
40
|
+
'react/jsx-newline': 'off',
|
|
41
|
+
'react/jsx-no-bind': 'off',
|
|
42
|
+
'react/jsx-no-comment-textnodes': 'error',
|
|
43
|
+
'react/jsx-no-constructed-context-values': 'error',
|
|
44
|
+
'react/jsx-no-duplicate-props': 'error',
|
|
45
|
+
'react/jsx-no-leaked-render': 'error',
|
|
46
|
+
'react/jsx-no-literals': 'off',
|
|
47
|
+
'react/jsx-no-script-url': 'error',
|
|
48
|
+
'react/jsx-no-target-blank': 'error',
|
|
49
|
+
'react/jsx-no-undef': 'error',
|
|
50
|
+
'react/jsx-no-useless-fragment': 'warn',
|
|
51
|
+
'react/jsx-one-expression-per-line': ['off', { allow: 'literal' }],
|
|
52
|
+
'react/jsx-pascal-case': 'error',
|
|
53
|
+
'react/jsx-props-no-multi-spaces': 'off',
|
|
54
|
+
'react/jsx-props-no-spreading': 'off',
|
|
55
|
+
'react/jsx-sort-props': 'off',
|
|
56
|
+
'react/jsx-uses-react': 'error',
|
|
57
|
+
'react/jsx-uses-vars': 'error',
|
|
58
|
+
'react/no-access-state-in-setstate': 'error',
|
|
59
|
+
'react/no-adjacent-inline-elements': 'error',
|
|
60
|
+
'react/no-array-index-key': 'warn',
|
|
61
|
+
'react/no-arrow-function-lifecycle': 'error',
|
|
62
|
+
'react/no-children-prop': 'off',
|
|
63
|
+
'react/no-danger': 'off',
|
|
64
|
+
'react/no-danger-with-children': 'error',
|
|
65
|
+
'react/no-deprecated': 'error',
|
|
66
|
+
'react/no-did-mount-set-state': 'error',
|
|
67
|
+
'react/no-did-update-set-state': 'error',
|
|
68
|
+
'react/no-direct-mutation-state': 'error',
|
|
69
|
+
'react/no-find-dom-node': 'error',
|
|
70
|
+
'react/no-invalid-html-attribute': 'warn',
|
|
71
|
+
'react/no-is-mounted': 'error',
|
|
72
|
+
'react/no-multi-comp': 'off',
|
|
73
|
+
'react/no-namespace': 'error',
|
|
74
|
+
'react/no-object-type-as-default-prop': 'warn',
|
|
75
|
+
'react/no-redundant-should-component-update': 'error',
|
|
76
|
+
'react/no-render-return-value': 'error',
|
|
77
|
+
'react/no-set-state': 'off',
|
|
78
|
+
'react/no-string-refs': 'error',
|
|
79
|
+
'react/no-this-in-sfc': 'error',
|
|
80
|
+
'react/no-typos': 'error',
|
|
81
|
+
'react/no-unescaped-entities': 'warn',
|
|
82
|
+
'react/no-unknown-property': 'error',
|
|
83
|
+
'react/no-unsafe': 'warn',
|
|
84
|
+
'react/no-unstable-nested-components': ['error', { allowAsProps: true }],
|
|
85
|
+
'react/no-unused-class-component-methods': 'warn',
|
|
86
|
+
'react/no-unused-prop-types': 'error',
|
|
87
|
+
'react/no-unused-state': 'error',
|
|
88
|
+
'react/no-will-update-set-state': 'error',
|
|
89
|
+
'react/prefer-es6-class': 'off',
|
|
90
|
+
'react/prefer-exact-props': 'off',
|
|
91
|
+
'react/prefer-read-only-props': 'off',
|
|
92
|
+
'react/prefer-stateless-function': 'off',
|
|
93
|
+
'react/prop-types': 'off',
|
|
94
|
+
'react/react-in-jsx-scope': 'off', // jsx automatic runtime
|
|
95
|
+
'react/require-default-props': 'off',
|
|
96
|
+
'react/require-optimization': 'off',
|
|
97
|
+
'react/require-render-return': 'error',
|
|
98
|
+
'react/self-closing-comp': 'error',
|
|
99
|
+
'react/sort-comp': 'off',
|
|
100
|
+
'react/sort-default-props': 'warn',
|
|
101
|
+
'react/sort-prop-types': 'off',
|
|
102
|
+
'react/state-in-constructor': 'off',
|
|
103
|
+
'react/static-property-placement': 'off',
|
|
104
|
+
'react/style-prop-object': 'error',
|
|
105
|
+
'react/void-dom-elements-no-children': 'error',
|
|
106
|
+
|
|
107
|
+
'react-hooks/exhaustive-deps': 'warn',
|
|
108
|
+
'react-hooks/rules-of-hooks': 'error',
|
|
109
|
+
|
|
110
|
+
'jsx-a11y/alt-text': 'warn',
|
|
111
|
+
'jsx-a11y/anchor-has-content': 'error',
|
|
112
|
+
'jsx-a11y/anchor-is-valid': 'error',
|
|
113
|
+
'jsx-a11y/aria-activedescendant-has-tabindex': 'error',
|
|
114
|
+
'jsx-a11y/aria-props': 'error',
|
|
115
|
+
'jsx-a11y/aria-proptypes': 'error',
|
|
116
|
+
'jsx-a11y/aria-role': 'error',
|
|
117
|
+
'jsx-a11y/aria-unsupported-elements': 'error',
|
|
118
|
+
'jsx-a11y/autocomplete-valid': 'off',
|
|
119
|
+
'jsx-a11y/click-events-have-key-events': 'error',
|
|
120
|
+
'jsx-a11y/control-has-associated-label': 'off',
|
|
121
|
+
'jsx-a11y/heading-has-content': 'error',
|
|
122
|
+
'jsx-a11y/html-has-lang': 'error',
|
|
123
|
+
'jsx-a11y/iframe-has-title': 'error',
|
|
124
|
+
'jsx-a11y/img-redundant-alt': 'error',
|
|
125
|
+
'jsx-a11y/interactive-supports-focus': 'warn',
|
|
126
|
+
'jsx-a11y/label-has-associated-control': 'error',
|
|
127
|
+
'jsx-a11y/lang': 'error',
|
|
128
|
+
'jsx-a11y/media-has-caption': 'warn',
|
|
129
|
+
'jsx-a11y/mouse-events-have-key-events': 'error',
|
|
130
|
+
'jsx-a11y/no-access-key': 'error',
|
|
131
|
+
'jsx-a11y/no-aria-hidden-on-focusable': 'warn',
|
|
132
|
+
'jsx-a11y/no-autofocus': 'off',
|
|
133
|
+
'jsx-a11y/no-distracting-elements': 'error',
|
|
134
|
+
'jsx-a11y/no-interactive-element-to-noninteractive-role': 'warn',
|
|
135
|
+
'jsx-a11y/no-noninteractive-element-interactions': 'warn',
|
|
136
|
+
'jsx-a11y/no-noninteractive-element-to-interactive-role': 'warn',
|
|
137
|
+
'jsx-a11y/no-noninteractive-tabindex': 'off',
|
|
138
|
+
'jsx-a11y/no-redundant-roles': 'error',
|
|
139
|
+
'jsx-a11y/no-static-element-interactions': 'off',
|
|
140
|
+
'jsx-a11y/role-has-required-aria-props': 'error',
|
|
141
|
+
'jsx-a11y/role-supports-aria-props': 'error',
|
|
142
|
+
'jsx-a11y/scope': 'error',
|
|
143
|
+
'jsx-a11y/tabindex-no-positive': 'warn',
|
|
144
|
+
'jsx-a11y/anchor-ambiguous-text': 'off',
|
|
145
|
+
'jsx-a11y/prefer-tag-over-role': 'off',
|
|
146
|
+
},
|
|
19
147
|
};
|
package/registerOpts.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const { hasDep, isEsm } = require('./utils');
|
|
2
|
+
|
|
3
|
+
/** @param { import('./index.d').Options } opts */
|
|
4
|
+
const defaultOptions = {
|
|
5
|
+
esm: isEsm(),
|
|
6
|
+
cypress: hasDep('cypress'),
|
|
7
|
+
graphql: hasDep('graphql'),
|
|
8
|
+
react: hasDep('react'),
|
|
9
|
+
storybook: hasDep('storybook'),
|
|
10
|
+
test: hasDep('jest') || hasDep('vitest'),
|
|
11
|
+
typescript: hasDep('typescript'),
|
|
12
|
+
import: true,
|
|
13
|
+
node: true,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
global.fullstacksjs = defaultOptions;
|
package/storybook.js
CHANGED
|
@@ -4,7 +4,23 @@ module.exports = {
|
|
|
4
4
|
{
|
|
5
5
|
plugins: ['storybook'],
|
|
6
6
|
files: ['*.stories.+(ts|tsx|js|jsx|mjs|cjs|mdx)', '*.story.+(ts|tsx|js|jsx|mjs|cjs|mdx)'],
|
|
7
|
-
|
|
7
|
+
rules: {
|
|
8
|
+
'storybook/await-interactions': 'error',
|
|
9
|
+
'storybook/context-in-play-function': 'error',
|
|
10
|
+
'storybook/default-exports': 'error',
|
|
11
|
+
'storybook/hierarchy-separator': 'warn',
|
|
12
|
+
'storybook/no-redundant-story-name': 'warn',
|
|
13
|
+
'storybook/no-uninstalled-addons': 'error',
|
|
14
|
+
'storybook/prefer-pascal-case': 'warn',
|
|
15
|
+
'storybook/story-exports': 'error',
|
|
16
|
+
'storybook/use-storybook-expect': 'error',
|
|
17
|
+
'storybook/use-storybook-testing-library': 'error',
|
|
18
|
+
|
|
19
|
+
'storybook/csf-component': 'warn',
|
|
20
|
+
'storybook/no-stories-of': 'warn',
|
|
21
|
+
'storybook/no-title-property-in-meta': 'warn',
|
|
22
|
+
'storybook/meta-inline-properties': 'off',
|
|
23
|
+
},
|
|
8
24
|
},
|
|
9
25
|
],
|
|
10
26
|
};
|
package/strict.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** @type { import('eslint').Linter.Config } */
|
|
2
|
+
module.exports = {
|
|
3
|
+
rules: {
|
|
4
|
+
'no-console': 'warn',
|
|
5
|
+
'fp/no-delete': 'error',
|
|
6
|
+
'fp/no-get-set': 'error',
|
|
7
|
+
'fp/no-mutating-methods': 'error',
|
|
8
|
+
'fp/no-mutation': ['error', { commonjs: true, allowThis: true, exceptions: [{ property: 'propTypes' }, { property: 'defaultProps' }] }],
|
|
9
|
+
'fp/no-nil': 'error',
|
|
10
|
+
'fp/no-this': 'error',
|
|
11
|
+
'fp/no-throw': 'error',
|
|
12
|
+
'fp/no-unused-expression': ['error', { allowUseStrict: true }],
|
|
13
|
+
'@typescript-eslint/no-non-null-assertion': 'warn',
|
|
14
|
+
},
|
|
15
|
+
};
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @type { import('eslint').Linter.Config }
|
|
3
|
+
*/
|
|
3
4
|
module.exports = {
|
|
4
5
|
rules: {
|
|
5
|
-
'jest/
|
|
6
|
+
'jest/prefer-hooks-in-order': 'warn',
|
|
6
7
|
'jest/no-disabled-tests': 'error',
|
|
8
|
+
'jest/no-duplicate-hooks': 'error',
|
|
7
9
|
'jest/no-focused-tests': 'error',
|
|
8
10
|
'jest/no-identical-title': 'error',
|
|
11
|
+
'jest/prefer-comparison-matcher': 'error',
|
|
12
|
+
'jest/prefer-equality-matcher': 'error',
|
|
13
|
+
'jest/max-expects': ['off', { max: 5 }],
|
|
9
14
|
|
|
10
15
|
// formatting
|
|
11
16
|
'jest-formatting/padding-around-after-all-blocks': 'warn',
|
|
@@ -19,13 +24,13 @@ module.exports = {
|
|
|
19
24
|
|
|
20
25
|
// other modules
|
|
21
26
|
'max-lines-per-function': 'off',
|
|
22
|
-
...
|
|
27
|
+
...(global.fullstacksjs?.react && {
|
|
23
28
|
'react/jsx-no-constructed-context-values': 'off',
|
|
24
|
-
})
|
|
25
|
-
...
|
|
29
|
+
}),
|
|
30
|
+
...(global.fullstacksjs?.typescript && {
|
|
26
31
|
'@typescript-eslint/method-signature-style': 'off',
|
|
27
32
|
'@typescript-eslint/no-namespace ': 'off',
|
|
28
33
|
'@typescript-eslint/unbound-method': 'off',
|
|
29
|
-
})
|
|
34
|
+
}),
|
|
30
35
|
},
|
|
31
36
|
};
|
package/typecheck.js
CHANGED
|
@@ -3,7 +3,71 @@ module.exports = {
|
|
|
3
3
|
overrides: [
|
|
4
4
|
{
|
|
5
5
|
files: ['*.ts', '*.tsx'],
|
|
6
|
-
|
|
6
|
+
rules: {
|
|
7
|
+
'@typescript-eslint/await-thenable': 'error',
|
|
8
|
+
'@typescript-eslint/consistent-type-exports': 'warn',
|
|
9
|
+
'@typescript-eslint/dot-notation': [
|
|
10
|
+
'warn',
|
|
11
|
+
{
|
|
12
|
+
allowPrivateClassPropertyAccess: false,
|
|
13
|
+
allowProtectedClassPropertyAccess: false,
|
|
14
|
+
allowIndexSignaturePropertyAccess: true,
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
'@typescript-eslint/no-confusing-void-expression': ['warn', { ignoreArrowShorthand: true, ignoreVoidOperator: true }],
|
|
18
|
+
'@typescript-eslint/no-floating-promises': ['error', { ignoreVoid: true }],
|
|
19
|
+
'@typescript-eslint/no-for-in-array': 'error',
|
|
20
|
+
'@typescript-eslint/no-implied-eval': 'error',
|
|
21
|
+
'@typescript-eslint/no-meaningless-void-operator': ['warn', { checkNever: false }],
|
|
22
|
+
'@typescript-eslint/no-misused-promises': ['warn', { checksVoidReturn: { attributes: false } }],
|
|
23
|
+
'@typescript-eslint/no-redundant-type-constituents': 'warn',
|
|
24
|
+
'@typescript-eslint/no-throw-literal': 'error',
|
|
25
|
+
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
|
|
26
|
+
'@typescript-eslint/no-unnecessary-condition': [
|
|
27
|
+
'warn',
|
|
28
|
+
{
|
|
29
|
+
allowConstantLoopConditions: false,
|
|
30
|
+
allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing: false,
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
'@typescript-eslint/no-unnecessary-qualifier': 'error',
|
|
34
|
+
'@typescript-eslint/no-unnecessary-type-arguments': 'error',
|
|
35
|
+
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
|
|
36
|
+
'@typescript-eslint/non-nullable-type-assertion-style': 'warn',
|
|
37
|
+
'@typescript-eslint/prefer-includes': 'warn',
|
|
38
|
+
'@typescript-eslint/prefer-reduce-type-parameter': 'warn',
|
|
39
|
+
'@typescript-eslint/prefer-nullish-coalescing': [
|
|
40
|
+
'warn',
|
|
41
|
+
{
|
|
42
|
+
ignoreConditionalTests: false,
|
|
43
|
+
ignoreTernaryTests: false,
|
|
44
|
+
ignoreMixedLogicalExpressions: false,
|
|
45
|
+
allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing: false,
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
'@typescript-eslint/prefer-regexp-exec': 'warn',
|
|
49
|
+
'@typescript-eslint/prefer-return-this-type': 'warn',
|
|
50
|
+
'@typescript-eslint/prefer-string-starts-ends-with': 'warn',
|
|
51
|
+
'@typescript-eslint/require-array-sort-compare': 'error',
|
|
52
|
+
'@typescript-eslint/require-await': 'error',
|
|
53
|
+
'@typescript-eslint/return-await': 'error',
|
|
54
|
+
'@typescript-eslint/switch-exhaustiveness-check': 'error',
|
|
55
|
+
'@typescript-eslint/unbound-method': ['error', { ignoreStatic: true }],
|
|
56
|
+
'@typescript-eslint/naming-convention': [
|
|
57
|
+
'warn',
|
|
58
|
+
...require('./naming-convention'),
|
|
59
|
+
// force use is/should/has for boolean variables
|
|
60
|
+
{
|
|
61
|
+
selector: 'variable',
|
|
62
|
+
types: ['boolean'],
|
|
63
|
+
format: ['PascalCase'],
|
|
64
|
+
prefix: ['is', 'should', 'has', 'can', 'did', 'will', 'enable', 'loading'],
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
|
|
68
|
+
// collisions
|
|
69
|
+
'dot-notation': 'off',
|
|
70
|
+
},
|
|
7
71
|
},
|
|
8
72
|
],
|
|
9
73
|
};
|
package/typescript.js
CHANGED
|
@@ -1,21 +1,85 @@
|
|
|
1
1
|
/** @type { import('eslint').Linter.Config } */
|
|
2
2
|
module.exports = {
|
|
3
|
-
parser: '@typescript-eslint/parser',
|
|
4
|
-
plugins: ['@typescript-eslint/eslint-plugin'],
|
|
5
|
-
settings: {
|
|
6
|
-
'import/parsers': {
|
|
7
|
-
'@typescript-eslint/parser': ['.ts', '.tsx'],
|
|
8
|
-
},
|
|
9
|
-
'import/resolver': {
|
|
10
|
-
node: {
|
|
11
|
-
extensions: ['.js', '.jsx', '.ts', '.tsx', '.d.ts', '.json', '.mjs'],
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
3
|
overrides: [
|
|
16
4
|
{
|
|
17
5
|
files: ['*.ts', '*.tsx'],
|
|
18
|
-
|
|
6
|
+
parser: '@typescript-eslint/parser',
|
|
7
|
+
plugins: ['@typescript-eslint/eslint-plugin'],
|
|
8
|
+
settings: {
|
|
9
|
+
'import/parsers': {
|
|
10
|
+
'@typescript-eslint/parser': ['.ts', '.tsx'],
|
|
11
|
+
},
|
|
12
|
+
'import/resolver': {
|
|
13
|
+
node: {
|
|
14
|
+
extensions: ['.js', '.jsx', '.ts', '.tsx', '.d.ts', '.json', '.mjs'],
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
rules: {
|
|
19
|
+
'@typescript-eslint/await-thenable': 'error',
|
|
20
|
+
'@typescript-eslint/consistent-type-exports': 'warn',
|
|
21
|
+
'@typescript-eslint/dot-notation': [
|
|
22
|
+
'warn',
|
|
23
|
+
{
|
|
24
|
+
allowPrivateClassPropertyAccess: false,
|
|
25
|
+
allowProtectedClassPropertyAccess: false,
|
|
26
|
+
allowIndexSignaturePropertyAccess: true,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
'@typescript-eslint/no-confusing-void-expression': ['warn', { ignoreArrowShorthand: true, ignoreVoidOperator: true }],
|
|
30
|
+
'@typescript-eslint/no-floating-promises': ['error', { ignoreVoid: true }],
|
|
31
|
+
'@typescript-eslint/no-for-in-array': 'error',
|
|
32
|
+
'@typescript-eslint/no-implied-eval': 'error',
|
|
33
|
+
'@typescript-eslint/no-meaningless-void-operator': ['warn', { checkNever: false }],
|
|
34
|
+
'@typescript-eslint/no-misused-promises': ['warn', { checksVoidReturn: { attributes: false } }],
|
|
35
|
+
'@typescript-eslint/no-redundant-type-constituents': 'warn',
|
|
36
|
+
'@typescript-eslint/no-throw-literal': 'error',
|
|
37
|
+
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
|
|
38
|
+
'@typescript-eslint/no-unnecessary-condition': [
|
|
39
|
+
'warn',
|
|
40
|
+
{
|
|
41
|
+
allowConstantLoopConditions: false,
|
|
42
|
+
allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing: false,
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
'@typescript-eslint/no-unnecessary-qualifier': 'error',
|
|
46
|
+
'@typescript-eslint/no-unnecessary-type-arguments': 'error',
|
|
47
|
+
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
|
|
48
|
+
'@typescript-eslint/non-nullable-type-assertion-style': 'warn',
|
|
49
|
+
'@typescript-eslint/prefer-includes': 'warn',
|
|
50
|
+
'@typescript-eslint/prefer-reduce-type-parameter': 'warn',
|
|
51
|
+
'@typescript-eslint/prefer-nullish-coalescing': [
|
|
52
|
+
'warn',
|
|
53
|
+
{
|
|
54
|
+
ignoreConditionalTests: false,
|
|
55
|
+
ignoreTernaryTests: false,
|
|
56
|
+
ignoreMixedLogicalExpressions: false,
|
|
57
|
+
allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing: false,
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
'@typescript-eslint/prefer-regexp-exec': 'warn',
|
|
61
|
+
'@typescript-eslint/prefer-return-this-type': 'warn',
|
|
62
|
+
'@typescript-eslint/prefer-string-starts-ends-with': 'warn',
|
|
63
|
+
'@typescript-eslint/require-array-sort-compare': 'error',
|
|
64
|
+
'@typescript-eslint/require-await': 'error',
|
|
65
|
+
'@typescript-eslint/return-await': 'error',
|
|
66
|
+
'@typescript-eslint/switch-exhaustiveness-check': 'error',
|
|
67
|
+
'@typescript-eslint/unbound-method': ['error', { ignoreStatic: true }],
|
|
68
|
+
'@typescript-eslint/naming-convention': [
|
|
69
|
+
'warn',
|
|
70
|
+
...require('./naming-convention'),
|
|
71
|
+
// force use is/should/has for boolean variables
|
|
72
|
+
{
|
|
73
|
+
selector: 'variable',
|
|
74
|
+
types: ['boolean'],
|
|
75
|
+
format: ['PascalCase'],
|
|
76
|
+
prefix: ['is', 'should', 'has', 'can', 'did', 'will', 'enable', 'loading'],
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
|
|
80
|
+
// collisions
|
|
81
|
+
'dot-notation': 'off',
|
|
82
|
+
},
|
|
19
83
|
},
|
|
20
84
|
],
|
|
21
85
|
};
|
package/utils.js
CHANGED
|
@@ -1 +1,21 @@
|
|
|
1
|
+
const readPkgUp = require('read-pkg-up');
|
|
2
|
+
const fs = require('node:fs');
|
|
3
|
+
|
|
4
|
+
const { packageJson } = readPkgUp.sync({
|
|
5
|
+
cwd: fs.realpathSync(process.cwd()),
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
const hasProperty = (obj, prop) => typeof obj === 'object' && Reflect.has(obj, prop);
|
|
9
|
+
|
|
10
|
+
const hasDep = dep => {
|
|
11
|
+
const types = ['peerDependencies', 'dependencies', 'devDependencies', 'optionalDependencies'];
|
|
12
|
+
return types.some(type => hasProperty(packageJson[type], dep));
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const isEsm = () => {
|
|
16
|
+
return packageJson.type === 'module';
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
module.exports.hasDep = hasDep;
|
|
20
|
+
module.exports.isEsm = isEsm;
|
|
1
21
|
module.exports.exts = '+(js|jsx|mjs|cjs|ts|tsx|mts|cts)';
|
package/nextjs.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
const packages = require('./packages');
|
|
2
|
-
|
|
3
|
-
/** @type { import('eslint').Linter.Config } */
|
|
4
|
-
module.exports = {
|
|
5
|
-
plugins: ['prettier', 'simple-import-sort', 'promise', 'node', 'fp'],
|
|
6
|
-
parserOptions: {
|
|
7
|
-
ecmaVersion: 2020,
|
|
8
|
-
sourceType: 'module',
|
|
9
|
-
requireConfigFile: false,
|
|
10
|
-
},
|
|
11
|
-
env: {
|
|
12
|
-
browser: true,
|
|
13
|
-
es6: true,
|
|
14
|
-
node: true,
|
|
15
|
-
},
|
|
16
|
-
extends: [
|
|
17
|
-
'./rules/base',
|
|
18
|
-
'./rules/es2015',
|
|
19
|
-
'./rules/forbidden',
|
|
20
|
-
'./rules/style',
|
|
21
|
-
'./rules/variables',
|
|
22
|
-
'./rules/fp',
|
|
23
|
-
'./rules/promise',
|
|
24
|
-
'./rules/node',
|
|
25
|
-
require.resolve('./storybook'),
|
|
26
|
-
packages.ifAnyDep('jest', () => require.resolve('./jest')),
|
|
27
|
-
packages.ifAnyDep('typescript', () => require.resolve('./typescript')),
|
|
28
|
-
packages.ifAnyDep('cypress', () => require.resolve('./cypress')),
|
|
29
|
-
'prettier',
|
|
30
|
-
].filter(Boolean),
|
|
31
|
-
};
|
package/packages.js
DELETED
package/rules/base.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
rules: {
|
|
3
|
-
'accessor-pairs': 'error',
|
|
4
|
-
'array-callback-return': 'error',
|
|
5
|
-
'block-scoped-var': 'error',
|
|
6
|
-
'complexity': ['error', 14],
|
|
7
|
-
'consistent-return': 'off',
|
|
8
|
-
'default-case': 'error',
|
|
9
|
-
'dot-notation': 'error',
|
|
10
|
-
'eqeqeq': ['error', 'smart'],
|
|
11
|
-
'grouped-accessor-pairs': 'off',
|
|
12
|
-
'guard-for-in': 'error',
|
|
13
|
-
'no-alert': 'error',
|
|
14
|
-
'no-async-promise-executor': 'off',
|
|
15
|
-
'no-caller': 'error',
|
|
16
|
-
'no-case-declarations': 'error',
|
|
17
|
-
'no-console': 'off',
|
|
18
|
-
'no-constructor-return': 'error',
|
|
19
|
-
'no-div-regex': 'error',
|
|
20
|
-
'no-dupe-else-if': 'error',
|
|
21
|
-
'no-else-return': 'off',
|
|
22
|
-
'no-empty-function': 'off',
|
|
23
|
-
'no-empty-pattern': 'error',
|
|
24
|
-
'no-empty-static-block': 'warn',
|
|
25
|
-
'no-eq-null': 'off',
|
|
26
|
-
'no-eval': 'error',
|
|
27
|
-
'no-extend-native': 'error',
|
|
28
|
-
'no-extra-bind': 'error',
|
|
29
|
-
'no-extra-label': 'error',
|
|
30
|
-
'no-fallthrough': 'error',
|
|
31
|
-
'no-floating-decimal': 'error',
|
|
32
|
-
'no-global-assign': 'error',
|
|
33
|
-
'no-implicit-coercion': 'off',
|
|
34
|
-
'no-implicit-globals': 'error',
|
|
35
|
-
'no-implied-eval': 'error',
|
|
36
|
-
'no-import-assign': 'error',
|
|
37
|
-
'no-invalid-this': 'warn',
|
|
38
|
-
'no-iterator': 'error',
|
|
39
|
-
'no-labels': 'error',
|
|
40
|
-
'no-lone-blocks': 'error',
|
|
41
|
-
'no-loop-func': 'error',
|
|
42
|
-
'no-loss-of-precision': 'warn',
|
|
43
|
-
'no-magic-numbers': 'off',
|
|
44
|
-
'no-misleading-character-class': 'off',
|
|
45
|
-
'no-multi-str': 'error',
|
|
46
|
-
'no-new': 'error',
|
|
47
|
-
'no-new-func': 'error',
|
|
48
|
-
'no-new-wrappers': 'error',
|
|
49
|
-
'no-octal': 'error',
|
|
50
|
-
'no-octal-escape': 'error',
|
|
51
|
-
'no-param-reassign': 'off',
|
|
52
|
-
'no-proto': 'error',
|
|
53
|
-
'no-redeclare': 'error',
|
|
54
|
-
'no-restricted-exports': 'off',
|
|
55
|
-
'no-restricted-properties': 'off',
|
|
56
|
-
'no-restricted-syntax': ['error', 'WithStatement'],
|
|
57
|
-
'no-return-assign': 'error',
|
|
58
|
-
'no-script-url': 'error',
|
|
59
|
-
'no-self-assign': 'error',
|
|
60
|
-
'no-self-compare': 'error',
|
|
61
|
-
'no-sequences': 'error',
|
|
62
|
-
'no-setter-return': 'error',
|
|
63
|
-
'no-throw-literal': 'error',
|
|
64
|
-
'no-unmodified-loop-condition': 'error',
|
|
65
|
-
'no-unsafe-optional-chaining': 'error',
|
|
66
|
-
'no-unused-expressions': 'off',
|
|
67
|
-
'no-unused-labels': 'error',
|
|
68
|
-
'no-useless-call': 'error',
|
|
69
|
-
'no-useless-catch': 'error',
|
|
70
|
-
'no-useless-concat': 'error',
|
|
71
|
-
'no-useless-escape': 'error',
|
|
72
|
-
'no-useless-return': 'error',
|
|
73
|
-
'no-void': 'off',
|
|
74
|
-
'no-warning-comments': ['warn', { terms: ['fixme'], location: 'anywhere' }],
|
|
75
|
-
'no-with': 'off',
|
|
76
|
-
'prefer-named-capture-group': 'off',
|
|
77
|
-
'prefer-promise-reject-errors': 'off',
|
|
78
|
-
'prefer-regex-literals': 'off',
|
|
79
|
-
'radix': 'error',
|
|
80
|
-
'require-atomic-updates': 'off',
|
|
81
|
-
'require-await': 'error',
|
|
82
|
-
'require-unicode-regexp': 'off',
|
|
83
|
-
'strict': 'error',
|
|
84
|
-
'vars-on-top': 'error',
|
|
85
|
-
'yoda': 'error',
|
|
86
|
-
},
|
|
87
|
-
};
|
package/rules/cypress.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const packages = require('../packages');
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
rules: {
|
|
5
|
-
'cypress/no-assigning-return-values': 'error',
|
|
6
|
-
'cypress/no-unnecessary-waiting': 'error',
|
|
7
|
-
'cypress/assertion-before-screenshot': 'warn',
|
|
8
|
-
'cypress/no-force': 'warn',
|
|
9
|
-
'cypress/no-async-tests': 'error',
|
|
10
|
-
'cypress/no-pause': 'error',
|
|
11
|
-
|
|
12
|
-
...packages.ifAnyDep('typescript', () => ({
|
|
13
|
-
'@typescript-eslint/no-namespace': 0,
|
|
14
|
-
})),
|
|
15
|
-
},
|
|
16
|
-
};
|
package/rules/es2015.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
rules: {
|
|
3
|
-
'class-methods-use-this': 'off',
|
|
4
|
-
'constructor-super': 'error',
|
|
5
|
-
'no-await-in-loop': 'error',
|
|
6
|
-
'no-class-assign': 'error',
|
|
7
|
-
'no-const-assign': 'error',
|
|
8
|
-
'no-dupe-class-members': 'error',
|
|
9
|
-
'no-duplicate-imports': 'off', // Handled by import plugin
|
|
10
|
-
'no-new-symbol': 'error',
|
|
11
|
-
'no-restricted-imports': 'off',
|
|
12
|
-
'no-return-await': 'error',
|
|
13
|
-
'no-this-before-super': 'error',
|
|
14
|
-
'no-unused-expressions': 'off',
|
|
15
|
-
'no-unused-private-class-members': 'warn',
|
|
16
|
-
'no-useless-computed-key': 'error',
|
|
17
|
-
'no-useless-constructor': 'error',
|
|
18
|
-
'no-useless-rename': 'error',
|
|
19
|
-
'no-var': 'warn',
|
|
20
|
-
'prefer-const': 'warn',
|
|
21
|
-
'prefer-exponentiation-operator': 'warn',
|
|
22
|
-
'prefer-numeric-literals': 'error',
|
|
23
|
-
'prefer-rest-params': 'error',
|
|
24
|
-
'prefer-spread': 'error',
|
|
25
|
-
'prefer-template': 'error',
|
|
26
|
-
'require-yield': 'error',
|
|
27
|
-
'symbol-description': 'error',
|
|
28
|
-
'prefer-object-has-own': 'warn',
|
|
29
|
-
},
|
|
30
|
-
};
|
package/rules/forbidden.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
rules: {
|
|
3
|
-
'default-case-last': 'error',
|
|
4
|
-
'for-direction': 'error',
|
|
5
|
-
'getter-return': ['error', { allowImplicit: true }],
|
|
6
|
-
'no-compare-neg-zero': 'error',
|
|
7
|
-
'no-cond-assign': 'error',
|
|
8
|
-
'no-constant-binary-expression': 'warn',
|
|
9
|
-
'no-constant-condition': 'error',
|
|
10
|
-
'no-control-regex': 'error',
|
|
11
|
-
'no-debugger': 'error',
|
|
12
|
-
'no-dupe-args': 'error',
|
|
13
|
-
'no-dupe-keys': 'error',
|
|
14
|
-
'no-duplicate-case': 'error',
|
|
15
|
-
'no-empty': 'error',
|
|
16
|
-
'no-empty-character-class': 'error',
|
|
17
|
-
'no-ex-assign': 'error',
|
|
18
|
-
'no-extra-boolean-cast': 'off',
|
|
19
|
-
'no-func-assign': 'error',
|
|
20
|
-
'no-inner-declarations': 'error',
|
|
21
|
-
'no-invalid-regexp': 'error',
|
|
22
|
-
'no-irregular-whitespace': 'error',
|
|
23
|
-
'no-new-native-nonconstructor': 'error',
|
|
24
|
-
'no-nonoctal-decimal-escape': 'error',
|
|
25
|
-
'no-obj-calls': 'error',
|
|
26
|
-
'no-prototype-builtins': 'off',
|
|
27
|
-
'no-regex-spaces': 'error',
|
|
28
|
-
'no-sparse-arrays': 'error',
|
|
29
|
-
'no-template-curly-in-string': 'off', // Some libs need curly in string for internal templates.
|
|
30
|
-
'no-unexpected-multiline': 'error',
|
|
31
|
-
'no-unreachable': 'error',
|
|
32
|
-
'no-unreachable-loop': 'error',
|
|
33
|
-
'no-unsafe-finally': 'error',
|
|
34
|
-
'no-unsafe-negation': 'error',
|
|
35
|
-
'no-useless-backreference': 'error',
|
|
36
|
-
'use-isnan': 'error',
|
|
37
|
-
'valid-typeof': 'error',
|
|
38
|
-
},
|
|
39
|
-
};
|