@innovixx/eslint-config 3.0.13 → 4.0.0-alpha.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/README.md +370 -20
- package/config/configs/base/index.mjs +40 -40
- package/config/configs/base/rules/best-practices.mjs +331 -333
- package/config/configs/base/rules/errors.mjs +115 -115
- package/config/configs/base/rules/es6.mjs +176 -176
- package/config/configs/base/rules/imports.mjs +238 -238
- package/config/configs/base/rules/variables.mjs +31 -31
- package/config/configs/jest/index.mjs +19 -19
- package/config/configs/jest/rules/jest-dom.mjs +8 -8
- package/config/configs/jest/rules/jest.mjs +33 -33
- package/config/configs/react/index.mjs +31 -42
- package/config/configs/react/rules/custom-rules.mjs +332 -0
- package/config/configs/react/rules/react-a11y.mjs +227 -227
- package/config/configs/react/rules/react-hooks.mjs +6 -6
- package/config/configs/react/rules/react.mjs +49 -452
- package/config/configs/typescript/index.mjs +24 -24
- package/config/configs/typescript/rules/all.mjs +14 -14
- package/config/configs/typescript/settings/typescript.mjs +8 -11
- package/config/deepMerge.mjs +47 -47
- package/config/index.mjs +117 -117
- package/demo/components/ComponentTest/index.tsx +1 -1
- package/demo/components/ComponentTestWithProps/index.tsx +2 -2
- package/package.json +19 -20
- package/tsconfig.json +1 -1
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
/** @type {import('eslint').Linter.Config} */
|
|
2
2
|
|
|
3
3
|
const typeScriptSettings = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
version: 'detect',
|
|
13
|
-
},
|
|
14
|
-
},
|
|
4
|
+
settings: {
|
|
5
|
+
'import/resolver': {
|
|
6
|
+
node: {
|
|
7
|
+
extensions: ['.mjs', '.js', '.jsx', '.ts', '.tsx', '.json'],
|
|
8
|
+
},
|
|
9
|
+
typescript: {},
|
|
10
|
+
},
|
|
11
|
+
},
|
|
15
12
|
};
|
|
16
13
|
|
|
17
14
|
export default typeScriptSettings;
|
package/config/deepMerge.mjs
CHANGED
|
@@ -4,59 +4,59 @@
|
|
|
4
4
|
* Merges obj2 into obj1
|
|
5
5
|
*/
|
|
6
6
|
export function _deepMerge(obj1, obj2, doNotMergeInNulls = true) {
|
|
7
|
-
|
|
7
|
+
const output = { ...obj1 };
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
9
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
10
|
+
for (const key in obj2) {
|
|
11
|
+
if (Object.prototype.hasOwnProperty.call(obj2, key)) {
|
|
12
|
+
if (doNotMergeInNulls) {
|
|
13
|
+
if (
|
|
14
|
+
(obj2[key] === null || obj2[key] === undefined)
|
|
15
|
+
&& obj1[key] !== null
|
|
16
|
+
&& obj1[key] !== undefined
|
|
17
|
+
) {
|
|
18
|
+
// eslint-disable-next-line no-continue
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
// Check if both are arrays
|
|
24
|
+
if (Array.isArray(obj1[key]) && Array.isArray(obj2[key])) {
|
|
25
|
+
// Merge each element in the arrays
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
27
|
+
// We need the Array.from, map rather than a normal map because this handles holes in arrays properly. A simple .map would skip holes.
|
|
28
|
+
output[key] = Array.from(obj2[key], (item, index) => {
|
|
29
|
+
if (doNotMergeInNulls) {
|
|
30
|
+
if (
|
|
31
|
+
(item === undefined || item === null)
|
|
32
|
+
&& obj1[key][index] !== null
|
|
33
|
+
&& obj1[key][index] !== undefined
|
|
34
|
+
) {
|
|
35
|
+
return obj1[key][index];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
39
|
+
if (typeof item === 'object' && !Array.isArray(item) && obj1[key][index]) {
|
|
40
|
+
// Deep merge for objects in arrays
|
|
41
|
+
// eslint-disable-next-line no-use-before-define
|
|
42
|
+
return deepMerge(obj1[key][index], item, doNotMergeInNulls);
|
|
43
|
+
}
|
|
44
|
+
return item;
|
|
45
|
+
});
|
|
46
|
+
} else if (typeof obj2[key] === 'object' && !Array.isArray(obj2[key]) && obj1[key]) {
|
|
47
|
+
// Existing behavior for objects
|
|
48
|
+
// eslint-disable-next-line no-use-before-define
|
|
49
|
+
output[key] = deepMerge(obj1[key], obj2[key], doNotMergeInNulls);
|
|
50
|
+
} else {
|
|
51
|
+
// Direct assignment for values
|
|
52
|
+
output[key] = obj2[key];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
return output;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
export function deepMerge(...objs) {
|
|
61
|
-
|
|
61
|
+
return objs.reduce((acc, obj) => _deepMerge(acc, obj), {});
|
|
62
62
|
}
|
package/config/index.mjs
CHANGED
|
@@ -6,137 +6,137 @@ import jestExtends from './configs/jest/index.mjs';
|
|
|
6
6
|
import { deepMerge } from './deepMerge.mjs';
|
|
7
7
|
|
|
8
8
|
const baseRules = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
9
|
+
'class-methods-use-this': 'off',
|
|
10
|
+
curly: ['warn', 'all'],
|
|
11
|
+
'arrow-body-style': ['error', 'as-needed', {
|
|
12
|
+
requireReturnForObjectLiteral: false,
|
|
13
|
+
}],
|
|
14
|
+
'no-restricted-exports': ['warn', { restrictDefaultExports: { direct: true } }],
|
|
15
|
+
'no-console': 'warn',
|
|
16
|
+
'no-sparse-arrays': 'off',
|
|
17
|
+
'no-underscore-dangle': 'off',
|
|
18
|
+
'no-use-before-define': 'off',
|
|
19
|
+
'object-shorthand': 'warn',
|
|
20
|
+
'no-useless-escape': 'warn',
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
const reactA11yRules = {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
'jsx-a11y/anchor-is-valid': 'warn',
|
|
25
|
+
'jsx-a11y/control-has-associated-label': 'warn',
|
|
26
|
+
'jsx-a11y/no-static-element-interactions': 'warn',
|
|
27
|
+
'jsx-a11y/label-has-associated-control': 'warn',
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
const typeScriptRules = {
|
|
31
|
-
|
|
31
|
+
'@typescript-eslint/no-use-before-define': 'off',
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
// Type-aware any rules:
|
|
34
|
+
'@typescript-eslint/no-unsafe-assignment': 'off',
|
|
35
|
+
'@typescript-eslint/no-unsafe-member-access': 'off',
|
|
36
|
+
'@typescript-eslint/no-unsafe-call': 'off',
|
|
37
|
+
'@typescript-eslint/no-unsafe-argument': 'off',
|
|
38
|
+
'@typescript-eslint/no-unsafe-return': 'off',
|
|
39
|
+
'@typescript-eslint/unbound-method': 'warn',
|
|
40
|
+
'@typescript-eslint/consistent-type-imports': 'warn',
|
|
41
|
+
'@typescript-eslint/no-explicit-any': 'warn',
|
|
42
|
+
// Type-aware any rules end
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
44
|
+
// ts-expect preferred over ts-ignore. It will error if the expected error is no longer present.
|
|
45
|
+
'@typescript-eslint/ban-ts-comment': 'warn', // Recommended over deprecated @typescript-eslint/prefer-ts-expect-error: https://github.com/typescript-eslint/typescript-eslint/issues/8333. Set to warn to ease migration.
|
|
46
|
+
// By default, it errors for unused variables. This is annoying, warnings are enough.
|
|
47
|
+
'@typescript-eslint/no-unused-vars': [
|
|
48
|
+
'warn',
|
|
49
|
+
{
|
|
50
|
+
vars: 'all',
|
|
51
|
+
args: 'after-used',
|
|
52
|
+
ignoreRestSiblings: false,
|
|
53
|
+
argsIgnorePattern: '^_',
|
|
54
|
+
varsIgnorePattern: '^_',
|
|
55
|
+
destructuredArrayIgnorePattern: '^_',
|
|
56
|
+
caughtErrorsIgnorePattern: '^(_|ignore)',
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
'@typescript-eslint/no-base-to-string': 'warn',
|
|
60
|
+
'@typescript-eslint/restrict-template-expressions': 'warn',
|
|
61
|
+
'@typescript-eslint/no-redundant-type-constituents': 'warn',
|
|
62
|
+
'@typescript-eslint/no-unnecessary-type-constraint': 'warn',
|
|
63
|
+
'@typescript-eslint/no-misused-promises': [
|
|
64
|
+
'error',
|
|
65
|
+
{
|
|
66
|
+
// See https://github.com/typescript-eslint/typescript-eslint/issues/4619 and https://github.com/typescript-eslint/typescript-eslint/pull/4623
|
|
67
|
+
// Don't want something like <button onClick={someAsyncFunction}> to error
|
|
68
|
+
checksVoidReturn: {
|
|
69
|
+
attributes: false,
|
|
70
|
+
arguments: false,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
'@typescript-eslint/no-empty-object-type': 'warn',
|
|
75
75
|
};
|
|
76
76
|
|
|
77
77
|
/** @typedef {import('eslint').Linter.Config} Config */
|
|
78
78
|
|
|
79
79
|
/** @type {Config[]} */
|
|
80
80
|
export const rootEslintConfig = [
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
81
|
+
{
|
|
82
|
+
name: 'Settings',
|
|
83
|
+
languageOptions: {
|
|
84
|
+
parserOptions: {
|
|
85
|
+
ecmaFeatures: {
|
|
86
|
+
jsx: true,
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
ecmaVersion: 'latest',
|
|
90
|
+
sourceType: 'module',
|
|
91
|
+
globals: {
|
|
92
|
+
...globals.node,
|
|
93
|
+
},
|
|
94
|
+
parser: typescriptParser,
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: 'TypeScript',
|
|
99
|
+
// has 3 entries: https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/typescript-eslint/src/configs/recommended-type-checked.ts
|
|
100
|
+
...deepMerge(
|
|
101
|
+
tseslint.configs.recommendedTypeCheckedOnly[0],
|
|
102
|
+
tseslint.configs.recommendedTypeCheckedOnly[1],
|
|
103
|
+
tseslint.configs.recommendedTypeCheckedOnly[2],
|
|
104
|
+
{
|
|
105
|
+
rules: {
|
|
106
|
+
...baseRules,
|
|
107
|
+
...typeScriptRules,
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
),
|
|
111
|
+
files: ['**/*.ts'],
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: 'TypeScript-React',
|
|
115
|
+
...deepMerge(
|
|
116
|
+
tseslint.configs.recommendedTypeCheckedOnly[0],
|
|
117
|
+
tseslint.configs.recommendedTypeCheckedOnly[1],
|
|
118
|
+
tseslint.configs.recommendedTypeCheckedOnly[2],
|
|
119
|
+
reactExtends,
|
|
120
|
+
{
|
|
121
|
+
rules: {
|
|
122
|
+
...baseRules,
|
|
123
|
+
...typeScriptRules,
|
|
124
|
+
...reactA11yRules,
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
),
|
|
128
|
+
files: ['**/*.tsx'],
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
name: 'Unit Tests',
|
|
132
|
+
...deepMerge(jestExtends, {
|
|
133
|
+
rules: {
|
|
134
|
+
...baseRules,
|
|
135
|
+
...typeScriptRules,
|
|
136
|
+
},
|
|
137
|
+
}),
|
|
138
|
+
files: ['**/*.test.ts', '**/*.test.tsx'],
|
|
139
|
+
},
|
|
140
140
|
];
|
|
141
141
|
|
|
142
142
|
export default rootEslintConfig;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
interface Props {
|
|
4
|
-
|
|
4
|
+
title: string;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
export const AnotherComponentTest: React.FC<Props> = ({ title }) => <
|
|
7
|
+
export const AnotherComponentTest: React.FC<Props> = ({ title }) => <p style={{ textAlign: 'center' }}>{title}</p>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@innovixx/eslint-config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.0",
|
|
4
4
|
"main": "configs/index.mjs",
|
|
5
5
|
"repository": "git@github.com:innovixx/eslint-config.git",
|
|
6
6
|
"description": "Opinionated ESLint config for JavaScript developers",
|
|
@@ -17,31 +17,30 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@types/eslint": "9.6.1",
|
|
20
|
-
"@types/node": "^26.
|
|
21
|
-
"@types/react": "^19.
|
|
22
|
-
"@types/react-dom": "^19.
|
|
23
|
-
"globals": "17.
|
|
24
|
-
"typescript": "6.0.3"
|
|
20
|
+
"@types/node": "^26.6.6",
|
|
21
|
+
"@types/react": "^19.3.0",
|
|
22
|
+
"@types/react-dom": "^19.3.0",
|
|
23
|
+
"globals": "17.14.0"
|
|
25
24
|
},
|
|
26
25
|
"peerDependencies": {
|
|
27
|
-
"@eslint-react/eslint-plugin": "^5.
|
|
28
|
-
"@eslint/
|
|
29
|
-
"@
|
|
30
|
-
"@typescript-eslint/
|
|
31
|
-
"eslint": "
|
|
26
|
+
"@eslint-react/eslint-plugin": "^5.28.8",
|
|
27
|
+
"@eslint-react/kit": "5.28.8",
|
|
28
|
+
"@stylistic/eslint-plugin": "^5.10.0",
|
|
29
|
+
"@typescript-eslint/eslint-plugin": "^8.72.1",
|
|
30
|
+
"@typescript-eslint/parser": "^8.72.1",
|
|
31
|
+
"eslint": "^10.14.0",
|
|
32
32
|
"eslint-import-resolver-typescript": "^4.4.5",
|
|
33
33
|
"eslint-plugin-import": "^2.32.0",
|
|
34
|
-
"eslint-plugin-jest": "^29.
|
|
35
|
-
"eslint-plugin-jest-dom": "^5.
|
|
34
|
+
"eslint-plugin-jest": "^29.17.0",
|
|
35
|
+
"eslint-plugin-jest-dom": "^5.10.1",
|
|
36
36
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
37
|
-
"eslint-plugin-n": "^18.
|
|
38
|
-
"eslint-plugin-react": "^7.37.5",
|
|
37
|
+
"eslint-plugin-n": "^18.5.0",
|
|
39
38
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
40
|
-
"eslint-plugin-react-refresh": "^0.5.
|
|
39
|
+
"eslint-plugin-react-refresh": "^0.5.7",
|
|
41
40
|
"eslint-plugin-sort-export-all": "^2.1.0",
|
|
42
|
-
"eslint
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"typescript
|
|
41
|
+
"typescript-eslint": "^8.72.1"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"typescript": "6.0.3"
|
|
46
45
|
}
|
|
47
46
|
}
|