@singlepixellab/eslint-config 1.0.2 → 1.2.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/eslint.config.js +2 -2
- package/package.json +3 -3
- package/rules/core.js +10 -2
- package/rules/imports.js +1 -7
- package/rules/react.js +70 -36
- package/rules/styles.js +14 -35
- package/.eslintrc +0 -3
package/eslint.config.js
CHANGED
|
@@ -11,8 +11,6 @@ export default [
|
|
|
11
11
|
// Global ignores should always be first
|
|
12
12
|
...ignores,
|
|
13
13
|
|
|
14
|
-
...core,
|
|
15
|
-
|
|
16
14
|
// styles: @stylistic/eslint-plugin
|
|
17
15
|
...styles,
|
|
18
16
|
|
|
@@ -25,6 +23,8 @@ export default [
|
|
|
25
23
|
// eslint-plugin-react, eslint-plugin-react-hooks etc
|
|
26
24
|
...react,
|
|
27
25
|
|
|
26
|
+
...core,
|
|
27
|
+
|
|
28
28
|
// Prettier should be last to have the opportunity to override other configs
|
|
29
29
|
...prettier,
|
|
30
30
|
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@singlepixellab/eslint-config",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "The ESLint rules and configs used by Single Pixel Lab",
|
|
5
5
|
"author": "Single Pixel Lab",
|
|
6
6
|
"keywords": [
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"inspect": "eslint --inspect-config"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@singlepixellab/prettier-config": "^1.
|
|
35
|
+
"@singlepixellab/prettier-config": "^1.1.0",
|
|
36
36
|
"eslint": "^9.32.0",
|
|
37
37
|
"prettier": "^3.6.2"
|
|
38
38
|
},
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@stylistic/eslint-plugin": "^5.2.2",
|
|
42
42
|
"eslint-config-prettier": "^10.1.8",
|
|
43
43
|
"eslint-plugin-import": "^2.32.0",
|
|
44
|
-
"eslint-plugin-jsdoc": "^
|
|
44
|
+
"eslint-plugin-jsdoc": "^52.0.2",
|
|
45
45
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
46
46
|
"eslint-plugin-prettier": "^5.5.3",
|
|
47
47
|
"eslint-plugin-react": "^7.37.5",
|
package/rules/core.js
CHANGED
|
@@ -44,6 +44,9 @@ export default [
|
|
|
44
44
|
// Require return statements for all code paths to avoid undefined returns
|
|
45
45
|
"consistent-return": "error",
|
|
46
46
|
|
|
47
|
+
// Enforce consistent brace style for all control statements
|
|
48
|
+
"curly": ["error", "multi-line"],
|
|
49
|
+
|
|
47
50
|
// Enforce calling super() in constructors to ensure proper initialization
|
|
48
51
|
"constructor-super": "error",
|
|
49
52
|
|
|
@@ -266,6 +269,9 @@ export default [
|
|
|
266
269
|
// Disallow unused labels to prevent dead code
|
|
267
270
|
"no-extra-label": "error",
|
|
268
271
|
|
|
272
|
+
// Disallow assignments to native objects or read-only global variables
|
|
273
|
+
"no-global-assign": "error",
|
|
274
|
+
|
|
269
275
|
// Disallow fallthroughs in `switch` to avoid bugs
|
|
270
276
|
"no-fallthrough": "error",
|
|
271
277
|
|
|
@@ -522,8 +528,10 @@ export default [
|
|
|
522
528
|
// Disallow initializing variables to undefined to avoid redundancy
|
|
523
529
|
"no-undef-init": "error",
|
|
524
530
|
|
|
525
|
-
// Disallow use of undefined variable to prevent bugs
|
|
526
|
-
|
|
531
|
+
// Disallow use of undefined variable to prevent bugs,
|
|
532
|
+
// we use the no-global-assign and no-shadow-restricted-names rules to
|
|
533
|
+
// prevent undefined from being shadowed or assigned a different value
|
|
534
|
+
"no-undefined": "off",
|
|
527
535
|
|
|
528
536
|
// Disallow dangling underscores in identifiers
|
|
529
537
|
"no-underscore-dangle": [
|
package/rules/imports.js
CHANGED
|
@@ -103,13 +103,7 @@ export default [
|
|
|
103
103
|
|
|
104
104
|
// Flags modules with exports that are unused or missing, helps maintain
|
|
105
105
|
// clean and efficient code
|
|
106
|
-
"import/no-unused-modules":
|
|
107
|
-
"error",
|
|
108
|
-
{
|
|
109
|
-
unusedExports: true,
|
|
110
|
-
missingExports: true,
|
|
111
|
-
},
|
|
112
|
-
],
|
|
106
|
+
"import/no-unused-modules": "off",
|
|
113
107
|
|
|
114
108
|
// Prevents mixing CommonJS-style exports with `import`, ensures
|
|
115
109
|
// consistency in module style
|
package/rules/react.js
CHANGED
|
@@ -29,9 +29,26 @@ export default [
|
|
|
29
29
|
...reactPlugin.configs.flat["jsx-runtime"].rules,
|
|
30
30
|
...jsxA11y.flatConfigs.recommended.rules,
|
|
31
31
|
|
|
32
|
+
// Disallow usage of button elements without an explicit type attribute
|
|
33
|
+
"react/button-has-type": "error",
|
|
34
|
+
|
|
32
35
|
// Prevent missing displayName in a React component definition
|
|
33
36
|
"react/display-name": ["off", { ignoreTranspilerName: false }],
|
|
34
37
|
|
|
38
|
+
// Enforce arrow function type for function components, ensures
|
|
39
|
+
// consistency and avoids confusion between class and function components
|
|
40
|
+
"react/function-component-definition": [
|
|
41
|
+
"error",
|
|
42
|
+
{
|
|
43
|
+
namedComponents: "arrow-function",
|
|
44
|
+
unnamedComponents: "arrow-function",
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
|
|
48
|
+
// Ensure destructuring and symmetric naming of useState hook value and
|
|
49
|
+
// setter variables
|
|
50
|
+
"react/hook-use-state": ["warn", { allowDestructuredState: true }],
|
|
51
|
+
|
|
35
52
|
// Enforce boolean attributes notation in JSX
|
|
36
53
|
"react/jsx-boolean-value": ["error", "never", { always: [] }],
|
|
37
54
|
|
|
@@ -48,7 +65,14 @@ export default [
|
|
|
48
65
|
],
|
|
49
66
|
|
|
50
67
|
// Enforce or disallow spaces around equal sign
|
|
51
|
-
"react/jsx-equals-spacing": ["
|
|
68
|
+
"react/jsx-equals-spacing": ["warn", "never"],
|
|
69
|
+
|
|
70
|
+
// No jsx extension
|
|
71
|
+
// https://github.com/facebook/create-react-app/issues/87#issuecomment-234627904
|
|
72
|
+
"react/jsx-filename-extension": ["error", { extensions: [".js"] }],
|
|
73
|
+
|
|
74
|
+
// Enforce shorthand or standard form for React fragments
|
|
75
|
+
"react/jsx-fragments": ["warn", "syntax"],
|
|
52
76
|
|
|
53
77
|
// Disable event handler naming conventions in JSX
|
|
54
78
|
"react/jsx-handler-names": "off",
|
|
@@ -74,50 +98,35 @@ export default [
|
|
|
74
98
|
},
|
|
75
99
|
],
|
|
76
100
|
|
|
101
|
+
// Disallows JSX context provider values from taking values that will
|
|
102
|
+
// cause needless rerenders
|
|
103
|
+
"react/jsx-no-constructed-context-values": "error",
|
|
104
|
+
|
|
105
|
+
// Disallow usage of javascript: URLs
|
|
106
|
+
"react/jsx-no-script-url": [
|
|
107
|
+
"error",
|
|
108
|
+
[
|
|
109
|
+
{
|
|
110
|
+
name: "Link",
|
|
111
|
+
props: ["href", "to"],
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
],
|
|
115
|
+
|
|
77
116
|
// Prevent usage of unwrapped JSX strings
|
|
78
117
|
"react/jsx-no-literals": "off",
|
|
79
118
|
|
|
119
|
+
// Disallow unnecessary fragments
|
|
120
|
+
"react/jsx-no-useless-fragment": "warn",
|
|
121
|
+
|
|
80
122
|
// Enforce PascalCase for JSX components
|
|
81
123
|
"react/jsx-pascal-case": ["error", { allowAllCaps: true }],
|
|
82
124
|
|
|
83
|
-
// Disable props sorting
|
|
84
|
-
"react/jsx-sort-props": "off",
|
|
85
|
-
|
|
86
|
-
// [Deprecated] Disable defaultProps declarations sorting
|
|
87
|
-
"react/jsx-sort-default-props": "off",
|
|
88
|
-
|
|
89
|
-
// No jsx extension
|
|
90
|
-
// https://github.com/facebook/create-react-app/issues/87#issuecomment-234627904
|
|
91
|
-
"react/jsx-filename-extension": ["error", { extensions: [".js"] }],
|
|
92
|
-
|
|
93
|
-
// This is no longer needed since React 17+ with the new JSX transform
|
|
94
|
-
// https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html
|
|
95
|
-
"react/react-in-jsx-scope": "off",
|
|
96
|
-
|
|
97
|
-
// React 18.3.0 deprecated defaultProps for function components
|
|
98
|
-
// https://github.com/facebook/react/pull/25699
|
|
99
|
-
"react/require-default-props": "off",
|
|
100
|
-
|
|
101
|
-
// We recommend using TypeScript instead of checking prop types at runtime
|
|
102
|
-
// https://react.dev/reference/react/Component#static-proptypes
|
|
103
|
-
"react/prop-types": "off",
|
|
104
|
-
|
|
105
|
-
// Enforce arrow function type for function components, ensures
|
|
106
|
-
// consistency and avoids confusion between class and function components
|
|
107
|
-
"react/function-component-definition": [
|
|
108
|
-
"error",
|
|
109
|
-
{
|
|
110
|
-
namedComponents: "arrow-function",
|
|
111
|
-
unnamedComponents: "arrow-function",
|
|
112
|
-
},
|
|
113
|
-
],
|
|
114
|
-
|
|
115
125
|
// Allow prop spreading to enable flexible and reusable components
|
|
116
126
|
"react/jsx-props-no-spreading": "off",
|
|
117
127
|
|
|
118
|
-
//
|
|
119
|
-
|
|
120
|
-
"react/no-unescaped-entities": "off",
|
|
128
|
+
// Disallow usage of Array index in keys
|
|
129
|
+
"react/no-array-index-key": "error",
|
|
121
130
|
|
|
122
131
|
// Allow use of `dangerouslySetInnerHTML`, needed in some cases and
|
|
123
132
|
// the responsibility lies with the developer
|
|
@@ -132,9 +141,34 @@ export default [
|
|
|
132
141
|
// Prevent usage of setState
|
|
133
142
|
"react/no-set-state": "off",
|
|
134
143
|
|
|
144
|
+
// Allow unescaped entities in JSX (e.g., apostrophes), prevents noise for
|
|
145
|
+
// common text content in JSX
|
|
146
|
+
"react/no-unescaped-entities": "off",
|
|
147
|
+
|
|
135
148
|
// Require ES6 class declarations over React.createClass
|
|
136
149
|
"react/prefer-es6-class": ["error", "always"],
|
|
137
150
|
|
|
151
|
+
// We recommend using TypeScript instead of checking prop types at runtime
|
|
152
|
+
// https://react.dev/reference/react/Component#static-proptypes
|
|
153
|
+
"react/prop-types": "off",
|
|
154
|
+
|
|
155
|
+
// This is no longer needed since React 17+ with the new JSX transform
|
|
156
|
+
// https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html
|
|
157
|
+
"react/react-in-jsx-scope": "off",
|
|
158
|
+
|
|
159
|
+
// React 18.3.0 deprecated defaultProps for function components
|
|
160
|
+
// https://github.com/facebook/react/pull/25699
|
|
161
|
+
"react/require-default-props": "off",
|
|
162
|
+
|
|
163
|
+
// Disallow extra closing tags for components without children
|
|
164
|
+
"react/self-closing-comp": [
|
|
165
|
+
"error",
|
|
166
|
+
{
|
|
167
|
+
component: true,
|
|
168
|
+
html: true,
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
|
|
138
172
|
// Enforce that all elements that require alternative text have meaningful
|
|
139
173
|
// information
|
|
140
174
|
"jsx-a11y/alt-text": [
|
package/rules/styles.js
CHANGED
|
@@ -64,7 +64,7 @@ export default [
|
|
|
64
64
|
"@stylistic/function-call-argument-newline": ["warn", "consistent"],
|
|
65
65
|
|
|
66
66
|
// Enforce consistent line breaks inside function parentheses
|
|
67
|
-
"@stylistic/function-paren-newline":
|
|
67
|
+
"@stylistic/function-paren-newline": "off",
|
|
68
68
|
|
|
69
69
|
// Enforce consistent spacing around `*` operators in generator functions
|
|
70
70
|
"@stylistic/generator-star-spacing": [
|
|
@@ -73,7 +73,7 @@ export default [
|
|
|
73
73
|
],
|
|
74
74
|
|
|
75
75
|
// Enforce the location of arrow function bodies
|
|
76
|
-
"@stylistic/implicit-arrow-linebreak":
|
|
76
|
+
"@stylistic/implicit-arrow-linebreak": "off",
|
|
77
77
|
|
|
78
78
|
// Enforce consistent indentation
|
|
79
79
|
"@stylistic/indent": [
|
|
@@ -170,10 +170,7 @@ export default [
|
|
|
170
170
|
],
|
|
171
171
|
|
|
172
172
|
// Require one JSX element per line
|
|
173
|
-
"@stylistic/jsx-one-expression-per-line":
|
|
174
|
-
"warn",
|
|
175
|
-
{ allow: "single-child" },
|
|
176
|
-
],
|
|
173
|
+
"@stylistic/jsx-one-expression-per-line": "off",
|
|
177
174
|
|
|
178
175
|
// Enforce PascalCase for user-defined JSX components
|
|
179
176
|
"@stylistic/jsx-pascal-case": "warn",
|
|
@@ -214,7 +211,7 @@ export default [
|
|
|
214
211
|
condition: "parens-new-line",
|
|
215
212
|
declaration: "parens-new-line",
|
|
216
213
|
logical: "parens-new-line",
|
|
217
|
-
prop: "
|
|
214
|
+
prop: "ignore",
|
|
218
215
|
propertyValue: "parens-new-line",
|
|
219
216
|
return: "parens-new-line",
|
|
220
217
|
},
|
|
@@ -272,7 +269,7 @@ export default [
|
|
|
272
269
|
code: 80,
|
|
273
270
|
tabWidth: 2,
|
|
274
271
|
ignoreUrls: true,
|
|
275
|
-
ignoreComments:
|
|
272
|
+
ignoreComments: true,
|
|
276
273
|
ignoreRegExpLiterals: true,
|
|
277
274
|
ignoreStrings: true,
|
|
278
275
|
ignoreTemplateLiterals: true,
|
|
@@ -370,31 +367,7 @@ export default [
|
|
|
370
367
|
],
|
|
371
368
|
|
|
372
369
|
// Enforce consistent line breaks after opening and before closing braces
|
|
373
|
-
"@stylistic/object-curly-newline":
|
|
374
|
-
"warn",
|
|
375
|
-
{
|
|
376
|
-
ObjectExpression: {
|
|
377
|
-
minProperties: 4,
|
|
378
|
-
multiline: true,
|
|
379
|
-
consistent: true,
|
|
380
|
-
},
|
|
381
|
-
ObjectPattern: {
|
|
382
|
-
minProperties: 4,
|
|
383
|
-
multiline: true,
|
|
384
|
-
consistent: true,
|
|
385
|
-
},
|
|
386
|
-
ImportDeclaration: {
|
|
387
|
-
minProperties: 4,
|
|
388
|
-
multiline: true,
|
|
389
|
-
consistent: true,
|
|
390
|
-
},
|
|
391
|
-
ExportDeclaration: {
|
|
392
|
-
minProperties: 4,
|
|
393
|
-
multiline: true,
|
|
394
|
-
consistent: true,
|
|
395
|
-
},
|
|
396
|
-
},
|
|
397
|
-
],
|
|
370
|
+
"@stylistic/object-curly-newline": "off",
|
|
398
371
|
|
|
399
372
|
// Enforce consistent spacing inside braces
|
|
400
373
|
"@stylistic/object-curly-spacing": ["warn", "always"],
|
|
@@ -413,8 +386,14 @@ export default [
|
|
|
413
386
|
// Enforce consistent linebreak style for operators
|
|
414
387
|
"@stylistic/operator-linebreak": [
|
|
415
388
|
"warn",
|
|
416
|
-
"
|
|
417
|
-
{
|
|
389
|
+
"after",
|
|
390
|
+
{
|
|
391
|
+
overrides: {
|
|
392
|
+
"=": "ignore",
|
|
393
|
+
"?": "before",
|
|
394
|
+
":": "before",
|
|
395
|
+
},
|
|
396
|
+
},
|
|
418
397
|
],
|
|
419
398
|
|
|
420
399
|
// Require or disallow padding within blocks
|
package/.eslintrc
DELETED