eslint-config-tamia 8.1.2 → 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/Readme.md +33 -38
- package/package.json +47 -46
- package/rules/best-practices.mjs +118 -0
- package/rules/errors.mjs +13 -0
- package/rules/es6.mjs +37 -0
- package/rules/legacy.mjs +17 -0
- package/rules/node.mjs +16 -0
- package/rules/react.mjs +193 -0
- package/rules/strict.mjs +9 -0
- package/rules/style.mjs +41 -0
- package/rules/typescript.mjs +95 -0
- package/rules/variables.mjs +15 -0
- package/index.js +0 -4
- package/legacy.js +0 -18
- package/react.js +0 -14
- package/rules/best-practices.js +0 -115
- package/rules/errors.js +0 -10
- package/rules/es6.js +0 -30
- package/rules/legacy.js +0 -14
- package/rules/node.js +0 -9
- package/rules/react.js +0 -186
- package/rules/strict.js +0 -6
- package/rules/style.js +0 -38
- package/rules/typescript.js +0 -93
- package/rules/variables.js +0 -12
- package/typescript-react.js +0 -7
- package/typescript.js +0 -4
package/Readme.md
CHANGED
|
@@ -16,54 +16,50 @@ Our default export contains all of our ESLint rules, including EcmaScript 6+. It
|
|
|
16
16
|
|
|
17
17
|
`npm install --save-dev eslint-config-tamia eslint`
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
`eslint.config.mjs`:
|
|
20
20
|
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
21
|
+
```js
|
|
22
|
+
import tamia from 'eslint-config-tamia';
|
|
23
|
+
export default [...tamia];
|
|
25
24
|
```
|
|
26
25
|
|
|
27
26
|
### eslint-config-tamia/react
|
|
28
27
|
|
|
29
|
-
Lints ES6+ and React.
|
|
28
|
+
Lints ES6+ and React. Uses `eslint-plugin-react`.
|
|
30
29
|
|
|
31
|
-
`npm install --save-dev eslint-config-tamia eslint
|
|
30
|
+
`npm install --save-dev eslint-config-tamia eslint`
|
|
32
31
|
|
|
33
|
-
|
|
32
|
+
`eslint.config.mjs`:
|
|
34
33
|
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
34
|
+
```js
|
|
35
|
+
import tamiaReact from 'eslint-config-tamia/react';
|
|
36
|
+
export default [...tamiaReact];
|
|
39
37
|
```
|
|
40
38
|
|
|
41
39
|
### eslint-config-tamia/typescript
|
|
42
40
|
|
|
43
|
-
Lints TypeScript.
|
|
41
|
+
Lints TypeScript. Uses `typescript-eslint`.
|
|
44
42
|
|
|
45
|
-
`npm install --save-dev eslint-config-tamia
|
|
43
|
+
`npm install --save-dev eslint-config-tamia eslint`
|
|
46
44
|
|
|
47
|
-
|
|
45
|
+
`eslint.config.mjs`:
|
|
48
46
|
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
47
|
+
```js
|
|
48
|
+
import tamiaTypeScript from 'eslint-config-tamia/typescript';
|
|
49
|
+
export default [...tamiaTypeScript];
|
|
53
50
|
```
|
|
54
51
|
|
|
55
52
|
### eslint-config-tamia/typescript-react
|
|
56
53
|
|
|
57
|
-
Lints TypeScript and React.
|
|
54
|
+
Lints TypeScript and React. Uses `typescript-eslint` and `eslint-plugin-react`.
|
|
58
55
|
|
|
59
|
-
`npm install --save-dev eslint-config-tamia
|
|
56
|
+
`npm install --save-dev eslint-config-tamia eslint`
|
|
60
57
|
|
|
61
|
-
|
|
58
|
+
`eslint.config.mjs`:
|
|
62
59
|
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
60
|
+
```js
|
|
61
|
+
import tamiaTypeScriptReact from 'eslint-config-tamia/typescript-react';
|
|
62
|
+
export default [...tamiaTypeScriptReact];
|
|
67
63
|
```
|
|
68
64
|
|
|
69
65
|
### eslint-config-tamia/legacy
|
|
@@ -72,21 +68,20 @@ Lints ES5 and below. Only requires `eslint`.
|
|
|
72
68
|
|
|
73
69
|
`npm install --save-dev eslint-config-tamia eslint`
|
|
74
70
|
|
|
75
|
-
|
|
71
|
+
`eslint.config.mjs`:
|
|
76
72
|
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
73
|
+
```js
|
|
74
|
+
import tamiaTypeScript from 'eslint-config-tamia/typescript';
|
|
75
|
+
export default [...tamiaTypeScript];
|
|
81
76
|
```
|
|
82
77
|
|
|
83
78
|
## Code style at a glance
|
|
84
79
|
|
|
85
|
-
- Tab indentation
|
|
80
|
+
- ~~Tab indentation.~~
|
|
86
81
|
- Single-quotes.
|
|
87
82
|
- Semicolons.
|
|
88
83
|
- Declare variables just before their first usage.
|
|
89
|
-
- Multiple variable statements.
|
|
84
|
+
- Multiple variable statements over multiple variable in a single statement.
|
|
90
85
|
- Make `const`, not `var`.
|
|
91
86
|
- Use `===` and `!==` over `==` and `!=`.
|
|
92
87
|
- Return early.
|
|
@@ -98,14 +93,14 @@ Example:
|
|
|
98
93
|
|
|
99
94
|
```javascript
|
|
100
95
|
function eatFood(food) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
96
|
+
if (food.length === 0) {
|
|
97
|
+
return ['No food'];
|
|
98
|
+
}
|
|
104
99
|
|
|
105
|
-
|
|
100
|
+
return food.map(dish => `No ${dish.toLowerCase()}`);
|
|
106
101
|
}
|
|
107
102
|
|
|
108
|
-
const food = ['Pizza', '
|
|
103
|
+
const food = ['Pizza', 'Burger', 'Coffee'];
|
|
109
104
|
console.log(eatFood(food));
|
|
110
105
|
```
|
|
111
106
|
|
package/package.json
CHANGED
|
@@ -1,48 +1,49 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
2
|
+
"name": "eslint-config-tamia",
|
|
3
|
+
"description": "Tâmia ESLint config",
|
|
4
|
+
"version": "9.0.0",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"pretest": "npm run lint",
|
|
8
|
+
"test": "npm run test:vitest",
|
|
9
|
+
"lint": "eslint . --cache --fix",
|
|
10
|
+
"test:vitest": "vitest run",
|
|
11
|
+
"test:watch": "vitest"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/tamiadev/eslint-config-tamia"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"rules",
|
|
19
|
+
"*.js"
|
|
20
|
+
],
|
|
21
|
+
"keywords": [
|
|
22
|
+
"eslintconfig",
|
|
23
|
+
"tamia"
|
|
24
|
+
],
|
|
25
|
+
"author": {
|
|
26
|
+
"name": "Artem Sapegin",
|
|
27
|
+
"url": "https://sapegin.me/"
|
|
28
|
+
},
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/tamiadev/eslint-config-tamia/issues"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://github.com/tamiadev/eslint-config-tamia",
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/eslint__js": "^8.42.3",
|
|
36
|
+
"eslint": "^9.7.0",
|
|
37
|
+
"react": "^18.3.1",
|
|
38
|
+
"vitest": "^2.0.4"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"eslint": ">=9.7"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@eslint/js": "^9.7.0",
|
|
45
|
+
"eslint-plugin-react": "^7.35.0",
|
|
46
|
+
"globals": "^15.8.0",
|
|
47
|
+
"typescript-eslint": "^8.0.0-alpha.10"
|
|
48
|
+
}
|
|
48
49
|
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/** @type { import("eslint").Linter.FlatConfig[] } */
|
|
2
|
+
export default [
|
|
3
|
+
{
|
|
4
|
+
rules: {
|
|
5
|
+
// Enforces return statements in callbacks of array’s methods
|
|
6
|
+
'array-callback-return': 'error',
|
|
7
|
+
// Treat var statements as if they were block scoped
|
|
8
|
+
'block-scoped-var': 'error',
|
|
9
|
+
// Require return statements to either always or never specify values
|
|
10
|
+
'consistent-return': 'error',
|
|
11
|
+
// Require curly braces for all control statements
|
|
12
|
+
curly: ['error', 'all'],
|
|
13
|
+
// Encourages use of dot notation whenever possible
|
|
14
|
+
'dot-notation': [
|
|
15
|
+
'error',
|
|
16
|
+
{
|
|
17
|
+
allowKeywords: true,
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
// Require the use of === and !==
|
|
21
|
+
eqeqeq: ['error', 'allow-null'],
|
|
22
|
+
// Disallow the use of alert, confirm, and prompt
|
|
23
|
+
'no-alert': 'error',
|
|
24
|
+
// Disallow using an async function as a Promise executor
|
|
25
|
+
'no-async-promise-executor': 'error',
|
|
26
|
+
// Disallow use of arguments.caller or arguments.callee
|
|
27
|
+
'no-caller': 'error',
|
|
28
|
+
// Disallow else after a return in an if
|
|
29
|
+
'no-else-return': 'off',
|
|
30
|
+
// Disallow use of eval()
|
|
31
|
+
'no-eval': 'error',
|
|
32
|
+
// Disallow adding to native types
|
|
33
|
+
'no-extend-native': 'error',
|
|
34
|
+
// Disallow unnecessary function binding
|
|
35
|
+
'no-extra-bind': 'error',
|
|
36
|
+
// Disallow the use of leading or trailing decimal points in numeric literals
|
|
37
|
+
'no-floating-decimal': 'error',
|
|
38
|
+
// Disallow the type conversions with shorter notations
|
|
39
|
+
'no-implicit-coercion': [
|
|
40
|
+
'error',
|
|
41
|
+
{
|
|
42
|
+
boolean: false,
|
|
43
|
+
number: true,
|
|
44
|
+
string: true,
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
// Disallow use of eval()-like methods
|
|
48
|
+
'no-implied-eval': 'error',
|
|
49
|
+
// Disallow usage of __iterator__ property
|
|
50
|
+
'no-iterator': 'error',
|
|
51
|
+
// Disallow use of labels for anything other then loops and switches
|
|
52
|
+
'no-labels': [
|
|
53
|
+
'error',
|
|
54
|
+
{
|
|
55
|
+
allowLoop: true,
|
|
56
|
+
allowSwitch: true,
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
// Disallow unnecessary nested blocks
|
|
60
|
+
'no-lone-blocks': 'error',
|
|
61
|
+
// Disallow creation of functions within loops
|
|
62
|
+
'no-loop-func': 'error',
|
|
63
|
+
// Disallow characters which are made with multiple code points in character class syntax
|
|
64
|
+
'no-misleading-character-class': 'error',
|
|
65
|
+
// Disallow use of multiline strings
|
|
66
|
+
'no-multi-str': 'error',
|
|
67
|
+
// Disallow use of new operator for Function object
|
|
68
|
+
'no-new-func': 'error',
|
|
69
|
+
// Disallows creating new instances of String, Number, and Boolean
|
|
70
|
+
'no-new-wrappers': 'error',
|
|
71
|
+
// Disallow use of octal escape sequences in string literals, such as var foo = 'Copyright \251';
|
|
72
|
+
'no-octal-escape': 'error',
|
|
73
|
+
// Disallow usage of __proto__ property
|
|
74
|
+
'no-proto': 'error',
|
|
75
|
+
// Disallow use of assignment in return statement
|
|
76
|
+
'no-return-assign': 'error',
|
|
77
|
+
// Disallow use of `javascript:` urls.
|
|
78
|
+
'no-script-url': 'error',
|
|
79
|
+
// Disallow comparisons where both sides are exactly the same
|
|
80
|
+
'no-self-compare': 'error',
|
|
81
|
+
// Disallow use of comma operator
|
|
82
|
+
'no-sequences': 'error',
|
|
83
|
+
// Restrict what can be thrown as an exception
|
|
84
|
+
'no-throw-literal': 'error',
|
|
85
|
+
// Disallow unmodified conditions of loops
|
|
86
|
+
'no-unmodified-loop-condition': 'error',
|
|
87
|
+
// Disallow usage of expressions in statement position
|
|
88
|
+
'no-unused-expressions': 'error',
|
|
89
|
+
// Disallow unnecessary .call() and .apply()
|
|
90
|
+
'no-useless-call': 'error',
|
|
91
|
+
// Disallow unnecessary catch clauses
|
|
92
|
+
'no-useless-catch': 'error',
|
|
93
|
+
// Disallow unnecessary concatenation of literals or template literals
|
|
94
|
+
'no-useless-concat': 'error',
|
|
95
|
+
// Disallow redundant return statements
|
|
96
|
+
'no-useless-return': 'error',
|
|
97
|
+
// Disallow use of void operator
|
|
98
|
+
'no-void': [
|
|
99
|
+
'error',
|
|
100
|
+
{
|
|
101
|
+
allowAsStatement: true,
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
// Disallow use of the with statement
|
|
105
|
+
'no-with': 'error',
|
|
106
|
+
// Disallow async functions which have no await expression
|
|
107
|
+
'require-await': 'error',
|
|
108
|
+
// Require or disallow Yoda conditions
|
|
109
|
+
yoda: [
|
|
110
|
+
'error',
|
|
111
|
+
'never',
|
|
112
|
+
{
|
|
113
|
+
exceptRange: true,
|
|
114
|
+
},
|
|
115
|
+
],
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
];
|
package/rules/errors.mjs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** @type { import("eslint").Linter.FlatConfig[] } */
|
|
2
|
+
export default [
|
|
3
|
+
{
|
|
4
|
+
// Most of possible error rules are inherited from eslint:recommended preset
|
|
5
|
+
rules: {
|
|
6
|
+
// Enforce “for” loop update clause moving the counter
|
|
7
|
+
// in the right direction
|
|
8
|
+
'for-direction': 2,
|
|
9
|
+
// Disallow use of Object.prototypes builtins directly
|
|
10
|
+
'no-prototype-builtins': 2,
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
];
|
package/rules/es6.mjs
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import globals from 'globals';
|
|
2
|
+
|
|
3
|
+
/** @type { import("eslint").Linter.FlatConfig[] } */
|
|
4
|
+
export default [
|
|
5
|
+
{
|
|
6
|
+
languageOptions: {
|
|
7
|
+
parserOptions: {
|
|
8
|
+
ecmaVersion: 2024,
|
|
9
|
+
sourceType: 'module',
|
|
10
|
+
requireConfigFile: false,
|
|
11
|
+
},
|
|
12
|
+
globals: {
|
|
13
|
+
...globals.es2024,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
rules: {
|
|
17
|
+
// Disallow duplicate imports
|
|
18
|
+
'no-duplicate-imports': 2,
|
|
19
|
+
// Disallow unnecessary constructor
|
|
20
|
+
'no-useless-constructor': 2,
|
|
21
|
+
// Disallow unnecessary computed property keys on objects
|
|
22
|
+
'no-useless-computed-key': 2,
|
|
23
|
+
// Require let or const instead of var
|
|
24
|
+
'no-var': 2,
|
|
25
|
+
// Require method and property shorthand syntax for object literals
|
|
26
|
+
'object-shorthand': [2, 'always'],
|
|
27
|
+
// Suggest using of const declaration for variables that are never modified after declared
|
|
28
|
+
'prefer-const': 2,
|
|
29
|
+
// Suggest using the spread operator instead of .apply()
|
|
30
|
+
'prefer-spread': 2,
|
|
31
|
+
// Suggest using the rest parameters instead of arguments
|
|
32
|
+
'prefer-rest-params': 2,
|
|
33
|
+
// Disallow renaming import, export, and destructured assignments to the same name
|
|
34
|
+
'no-useless-rename': 2,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
];
|
package/rules/legacy.mjs
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** @type { import("eslint").Linter.FlatConfig[] } */
|
|
2
|
+
export default [
|
|
3
|
+
{
|
|
4
|
+
rules: {
|
|
5
|
+
// Specify the maximum depth that blocks can be nested
|
|
6
|
+
'max-depth': [0, 5],
|
|
7
|
+
// Limits the number of parameters that can be used in the function declaration
|
|
8
|
+
'max-params': [0, 5],
|
|
9
|
+
// Specify the maximum number of statement allowed in a function
|
|
10
|
+
'max-statements': [0, 500],
|
|
11
|
+
// Disallow use of bitwise operators
|
|
12
|
+
'no-bitwise': 0,
|
|
13
|
+
// Disallow use of unary operators, ++ and --
|
|
14
|
+
'no-plusplus': 0,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
];
|
package/rules/node.mjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import globals from 'globals';
|
|
2
|
+
|
|
3
|
+
/** @type { import("eslint").Linter.FlatConfig[] } */
|
|
4
|
+
export default [
|
|
5
|
+
{
|
|
6
|
+
languageOptions: {
|
|
7
|
+
globals: {
|
|
8
|
+
...globals.node,
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
rules: {
|
|
12
|
+
// Disallow string concatenation with __dirname and __filename
|
|
13
|
+
'no-path-concat': 2,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
];
|
package/rules/react.mjs
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import react from 'eslint-plugin-react';
|
|
2
|
+
|
|
3
|
+
/** @type { import("eslint").Linter.FlatConfig[] } */
|
|
4
|
+
export default [
|
|
5
|
+
{
|
|
6
|
+
plugins: { react },
|
|
7
|
+
languageOptions: {
|
|
8
|
+
parserOptions: {
|
|
9
|
+
ecmaFeatures: {
|
|
10
|
+
jsx: true,
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
settings: {
|
|
15
|
+
react: {
|
|
16
|
+
version: 'detect',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
// View link below for react rules documentation
|
|
20
|
+
// https://github.com/yannickcr/eslint-plugin-react#list-of-supported-rules
|
|
21
|
+
rules: {
|
|
22
|
+
// Prevent missing displayName in a React component definition
|
|
23
|
+
'react/display-name': 0,
|
|
24
|
+
// Forbid certain propTypes (any, array, object)
|
|
25
|
+
'react/forbid-prop-types': 0,
|
|
26
|
+
// Enforce boolean attributes notation in JSX
|
|
27
|
+
'react/jsx-boolean-value': [2, 'never'],
|
|
28
|
+
// Validate closing bracket location in JSX
|
|
29
|
+
'react/jsx-closing-bracket-location': 0,
|
|
30
|
+
// Enforce or disallow spaces inside of curly braces in JSX attributes
|
|
31
|
+
'react/jsx-curly-spacing': 0,
|
|
32
|
+
// Disallow spaces around equal signs in JSX attributes
|
|
33
|
+
'react/jsx-equals-spacing': 0,
|
|
34
|
+
// Enforce event handler naming conventions in JSX
|
|
35
|
+
'react/jsx-handler-names': [
|
|
36
|
+
2,
|
|
37
|
+
{
|
|
38
|
+
eventHandlerPrefix: 'handle',
|
|
39
|
+
eventHandlerPropPrefix: 'on',
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
// Validate JSX indentation
|
|
43
|
+
'react/jsx-indent': 0,
|
|
44
|
+
// Validate props indentation in JSX
|
|
45
|
+
'react/jsx-indent-props': 0,
|
|
46
|
+
// Validate JSX has key prop when in array or iterator
|
|
47
|
+
'react/jsx-key': 2,
|
|
48
|
+
// Limit maximum of props on a single line in JSX
|
|
49
|
+
'react/jsx-max-props-per-line': 0,
|
|
50
|
+
// Prevent usage of .bind() and arrow functions in JSX props
|
|
51
|
+
'react/jsx-no-bind': [
|
|
52
|
+
2,
|
|
53
|
+
{
|
|
54
|
+
allowArrowFunctions: true,
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
// Prevent duplicate props in JSX
|
|
58
|
+
'react/jsx-no-duplicate-props': [
|
|
59
|
+
2,
|
|
60
|
+
{
|
|
61
|
+
ignoreCase: false,
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
// Prevent usage of unwrapped JSX strings
|
|
65
|
+
'react/jsx-no-literals': 0,
|
|
66
|
+
// Prevent usage of unsafe target='_blank'
|
|
67
|
+
'react/jsx-no-target-blank': 2,
|
|
68
|
+
// Disallow undeclared variables in JSX
|
|
69
|
+
'react/jsx-no-undef': 2,
|
|
70
|
+
// Enforce PascalCase for user-defined JSX components
|
|
71
|
+
'react/jsx-pascal-case': 2,
|
|
72
|
+
// Enforce propTypes declarations alphabetical sorting
|
|
73
|
+
'react/jsx-sort-prop-types': 0,
|
|
74
|
+
// Enforce props alphabetical sorting
|
|
75
|
+
'react/jsx-sort-props': 0,
|
|
76
|
+
// Prevent React to be incorrectly marked as unused
|
|
77
|
+
'react/jsx-uses-react': 2,
|
|
78
|
+
// Prevent variables used in JSX to be incorrectly marked as unused
|
|
79
|
+
'react/jsx-uses-vars': 2,
|
|
80
|
+
// Prevent usage of dangerous JSX properties
|
|
81
|
+
'react/no-danger': 0,
|
|
82
|
+
// Prevent usage of deprecated methods
|
|
83
|
+
'react/no-deprecated': 2,
|
|
84
|
+
// Prevent usage of setState in componentDidMount
|
|
85
|
+
'react/no-did-mount-set-state': 2,
|
|
86
|
+
// Prevent usage of setState in componentDidUpdate
|
|
87
|
+
'react/no-did-update-set-state': 2,
|
|
88
|
+
// Prevent direct mutation of this.state
|
|
89
|
+
'react/no-direct-mutation-state': 2,
|
|
90
|
+
// Prevent usage of isMounted
|
|
91
|
+
'react/no-is-mounted': 2,
|
|
92
|
+
// Prevent multiple component definition per file
|
|
93
|
+
'react/no-multi-comp': [
|
|
94
|
+
2,
|
|
95
|
+
{
|
|
96
|
+
ignoreStateless: true,
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
// Prevent usage of setState
|
|
100
|
+
'react/no-set-state': 0,
|
|
101
|
+
// Prevent using string references
|
|
102
|
+
'react/no-string-refs': 2,
|
|
103
|
+
// Prevent usage of unknown DOM property
|
|
104
|
+
'react/no-unknown-property': 2,
|
|
105
|
+
// Require ES6 class declarations over React.createClass
|
|
106
|
+
'react/prefer-es6-class': [2, 'always'],
|
|
107
|
+
// Enforce stateless React Components to be written as a pure function
|
|
108
|
+
'react/prefer-stateless-function': 2,
|
|
109
|
+
// Prevent missing props validation in a React component definition
|
|
110
|
+
'react/prop-types': [
|
|
111
|
+
2,
|
|
112
|
+
{
|
|
113
|
+
ignore: [],
|
|
114
|
+
customValidators: [],
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
// Prevent missing React when using JSX
|
|
118
|
+
'react/react-in-jsx-scope': 2,
|
|
119
|
+
// Prevent extra closing tags for components without children
|
|
120
|
+
'react/self-closing-comp': [
|
|
121
|
+
2,
|
|
122
|
+
{
|
|
123
|
+
component: true,
|
|
124
|
+
html: false,
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
// Enforce component methods order
|
|
128
|
+
'react/sort-comp': [
|
|
129
|
+
2,
|
|
130
|
+
{
|
|
131
|
+
order: [
|
|
132
|
+
'static-variables',
|
|
133
|
+
'instance-variables',
|
|
134
|
+
'lifecycle',
|
|
135
|
+
'everything-else',
|
|
136
|
+
'render',
|
|
137
|
+
],
|
|
138
|
+
groups: {
|
|
139
|
+
lifecycle: [
|
|
140
|
+
'constructor',
|
|
141
|
+
'getDefaultProps',
|
|
142
|
+
'getInitialState',
|
|
143
|
+
'getChildContext',
|
|
144
|
+
'getDerivedStateFromProps',
|
|
145
|
+
'componentWillMount',
|
|
146
|
+
'UNSAFE_componentWillMount',
|
|
147
|
+
'componentDidMount',
|
|
148
|
+
'componentWillReceiveProps',
|
|
149
|
+
'UNSAFE_componentWillReceiveProps',
|
|
150
|
+
'shouldComponentUpdate',
|
|
151
|
+
'componentWillUpdate',
|
|
152
|
+
'UNSAFE_componentWillUpdate',
|
|
153
|
+
'getSnapshotBeforeUpdate',
|
|
154
|
+
'componentDidUpdate',
|
|
155
|
+
'componentDidCatch',
|
|
156
|
+
'componentWillUnmount',
|
|
157
|
+
],
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
// Prevent missing parentheses around multilines JSX
|
|
162
|
+
'react/jsx-wrap-multilines': 0,
|
|
163
|
+
// Restrict file extensions that may contain JSX
|
|
164
|
+
'react/jsx-filename-extension': 0,
|
|
165
|
+
// Prevent usage of the return value of React.render
|
|
166
|
+
'react/no-render-return-value': 2,
|
|
167
|
+
// Prevent comments from being inserted as text nodes
|
|
168
|
+
'react/jsx-no-comment-textnodes': 2,
|
|
169
|
+
// Prevent usage of findDOMNode
|
|
170
|
+
'react/no-find-dom-node': 2,
|
|
171
|
+
// Prevent problem with children and props.dangerouslySetInnerHTML
|
|
172
|
+
'react/no-danger-with-children': 2,
|
|
173
|
+
// Prevent passing of children as props
|
|
174
|
+
'react/no-children-prop': 2,
|
|
175
|
+
// Prevent invalid characters from appearing in markup
|
|
176
|
+
'react/no-unescaped-entities': 2,
|
|
177
|
+
// Configure the position of the first property
|
|
178
|
+
'react/jsx-first-prop-new-line': 0,
|
|
179
|
+
// Validate whitespace in and around the JSX opening and closing brackets
|
|
180
|
+
'react/jsx-tag-spacing': 0,
|
|
181
|
+
// Prevent void DOM elements (e.g. <img />, <br />) from receiving children
|
|
182
|
+
'react/void-dom-elements-no-children': 2,
|
|
183
|
+
// Enforce style prop value being an object
|
|
184
|
+
'react/style-prop-object': 2,
|
|
185
|
+
// Prevent usage of setState in componentWillUpdate
|
|
186
|
+
'react/no-will-update-set-state': 2,
|
|
187
|
+
// Enforce all defaultProps have a corresponding non-required PropType
|
|
188
|
+
'react/default-props-match-prop-types': 2,
|
|
189
|
+
// Prevents common typos
|
|
190
|
+
'react/no-typos': 2,
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
];
|
package/rules/strict.mjs
ADDED
package/rules/style.mjs
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** @type { import("eslint").Linter.FlatConfig[] } */
|
|
2
|
+
export default [
|
|
3
|
+
{
|
|
4
|
+
// Code style should be handled by Prettier
|
|
5
|
+
rules: {
|
|
6
|
+
// Require camel case names
|
|
7
|
+
camelcase: [
|
|
8
|
+
2,
|
|
9
|
+
{
|
|
10
|
+
properties: 'never',
|
|
11
|
+
},
|
|
12
|
+
],
|
|
13
|
+
// Disallow mixed 'LF' and 'CRLF' as linebreaks
|
|
14
|
+
'linebreak-style': [2, 'unix'],
|
|
15
|
+
// Require a capital letter for constructors
|
|
16
|
+
'new-cap': [
|
|
17
|
+
2,
|
|
18
|
+
{
|
|
19
|
+
newIsCap: true,
|
|
20
|
+
capIsNew: false,
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
// Disallow use of the Array constructor
|
|
24
|
+
'no-array-constructor': 2,
|
|
25
|
+
// Disallow if as the only statement in an else block
|
|
26
|
+
'no-lonely-if': 2,
|
|
27
|
+
// Disallow use of the Object constructor
|
|
28
|
+
'no-new-object': 2,
|
|
29
|
+
// Disallow Use of Chained Assignment Expressions
|
|
30
|
+
'no-multi-assign': 2,
|
|
31
|
+
// Disallow the use of Boolean literals in conditional expressions
|
|
32
|
+
'no-unneeded-ternary': 2,
|
|
33
|
+
// Allow just one var statement per variable
|
|
34
|
+
'one-var': [2, 'never'],
|
|
35
|
+
// Disallow the Unicode Byte Order Mark (BOM)
|
|
36
|
+
'unicode-bom': [2, 'never'],
|
|
37
|
+
// Disallow mixed spaces and tabs (disabled because of Prettier)
|
|
38
|
+
'no-mixed-spaces-and-tabs': 0,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
];
|