@aliexme/eslint-config 0.1.0 → 0.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/README.md +40 -2
- package/index.js +1 -4
- package/package.json +31 -4
- package/rules/base.js +32 -30
- package/rules/import.js +11 -14
- package/rules/prettier.js +7 -0
- package/rules/react.js +31 -0
- package/rules/typescript.js +15 -14
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ Rule set for ESLint
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```
|
|
8
|
-
npm
|
|
8
|
+
npm i --save-dev eslint @aliexme/eslint-config eslint-plugin-import
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
@@ -25,7 +25,7 @@ Extend your ESLint config file:
|
|
|
25
25
|
To check ts-files, install additional packages:
|
|
26
26
|
|
|
27
27
|
```
|
|
28
|
-
npm
|
|
28
|
+
npm i --save-dev @typescript-eslint/parser @typescript-eslint/eslint-plugin
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
And add the following lines to your ESLint config file:
|
|
@@ -38,3 +38,41 @@ And add the following lines to your ESLint config file:
|
|
|
38
38
|
],
|
|
39
39
|
}
|
|
40
40
|
```
|
|
41
|
+
|
|
42
|
+
## React
|
|
43
|
+
|
|
44
|
+
Install additional packages:
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
npm i --save-dev eslint-plugin-react eslint-plugin-react-hooks
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
And add the following lines to your ESLint config file:
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
{
|
|
54
|
+
"extends": [
|
|
55
|
+
"@aliexme/eslint-config",
|
|
56
|
+
"@aliexme/eslint-config/react",
|
|
57
|
+
],
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Prettier
|
|
62
|
+
|
|
63
|
+
Install additional packages:
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
npm i --save-dev prettier eslint-plugin-prettier eslint-config-prettier
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
And add the following lines to your ESLint config file:
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
{
|
|
73
|
+
"extends": [
|
|
74
|
+
"@aliexme/eslint-config",
|
|
75
|
+
"@aliexme/eslint-config/prettier",
|
|
76
|
+
],
|
|
77
|
+
}
|
|
78
|
+
```
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aliexme/eslint-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Rule set for ESLint",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Alexander Smirnov <al.smirnov996@gmail.com>",
|
|
@@ -22,30 +22,42 @@
|
|
|
22
22
|
".": "./index.js",
|
|
23
23
|
"./base": "./rules/base.js",
|
|
24
24
|
"./import": "./rules/import.js",
|
|
25
|
-
"./typescript": "./rules/typescript.js"
|
|
25
|
+
"./typescript": "./rules/typescript.js",
|
|
26
|
+
"./react": "./rules/react.js",
|
|
27
|
+
"./prettier": "./rules/prettier.js"
|
|
26
28
|
},
|
|
27
29
|
"publishConfig": {
|
|
28
30
|
"access": "public"
|
|
29
31
|
},
|
|
30
32
|
"scripts": {
|
|
31
33
|
"prepare": "husky install",
|
|
32
|
-
"lint:check": "eslint --ext .js,.mjs,.ts --ignore-path .gitignore --cache ./",
|
|
34
|
+
"lint:check": "eslint --ext .js,.mjs,.jsx,.ts,.tsx --ignore-path .gitignore --cache ./",
|
|
33
35
|
"lint:fix": "pnpm lint:check --fix"
|
|
34
36
|
},
|
|
35
37
|
"devDependencies": {
|
|
36
38
|
"@typescript-eslint/eslint-plugin": "5.52.0",
|
|
37
39
|
"@typescript-eslint/parser": "5.52.0",
|
|
38
40
|
"eslint": "8.34.0",
|
|
41
|
+
"eslint-config-prettier": "8.6.0",
|
|
39
42
|
"eslint-plugin-import": "2.27.5",
|
|
43
|
+
"eslint-plugin-prettier": "4.2.1",
|
|
44
|
+
"eslint-plugin-react": "7.32.2",
|
|
45
|
+
"eslint-plugin-react-hooks": "4.6.0",
|
|
40
46
|
"husky": "8.0.3",
|
|
41
47
|
"lint-staged": "13.1.2",
|
|
48
|
+
"prettier": "2.8.4",
|
|
42
49
|
"typescript": "4.9.5"
|
|
43
50
|
},
|
|
44
51
|
"peerDependencies": {
|
|
45
52
|
"@typescript-eslint/eslint-plugin": "^5.52.0",
|
|
46
53
|
"@typescript-eslint/parser": "^5.52.0",
|
|
47
54
|
"eslint": ">=8",
|
|
48
|
-
"eslint-
|
|
55
|
+
"eslint-config-prettier": "^8.6.0",
|
|
56
|
+
"eslint-plugin-import": "^2.27.5",
|
|
57
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
58
|
+
"eslint-plugin-react": "^7.32.2",
|
|
59
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
60
|
+
"prettier": "^2.8.4"
|
|
49
61
|
},
|
|
50
62
|
"peerDependenciesMeta": {
|
|
51
63
|
"@typescript-eslint/eslint-plugin": {
|
|
@@ -53,6 +65,21 @@
|
|
|
53
65
|
},
|
|
54
66
|
"@typescript-eslint/parser": {
|
|
55
67
|
"optional": true
|
|
68
|
+
},
|
|
69
|
+
"eslint-config-prettier": {
|
|
70
|
+
"optional": true
|
|
71
|
+
},
|
|
72
|
+
"eslint-plugin-prettier": {
|
|
73
|
+
"optional": true
|
|
74
|
+
},
|
|
75
|
+
"eslint-plugin-react": {
|
|
76
|
+
"optional": true
|
|
77
|
+
},
|
|
78
|
+
"eslint-plugin-react-hooks": {
|
|
79
|
+
"optional": true
|
|
80
|
+
},
|
|
81
|
+
"prettier": {
|
|
82
|
+
"optional": true
|
|
56
83
|
}
|
|
57
84
|
}
|
|
58
85
|
}
|
package/rules/base.js
CHANGED
|
@@ -8,11 +8,10 @@ module.exports = {
|
|
|
8
8
|
"node": true,
|
|
9
9
|
"es6": true,
|
|
10
10
|
},
|
|
11
|
-
"extends": [
|
|
12
|
-
"eslint:recommended",
|
|
13
|
-
],
|
|
11
|
+
"extends": ["eslint:recommended"],
|
|
14
12
|
"rules": {
|
|
15
13
|
"quotes": ["error", "single"],
|
|
14
|
+
"jsx-quotes": ["error", "prefer-single"],
|
|
16
15
|
"quote-props": ["error", "as-needed"],
|
|
17
16
|
"semi": ["error", "never"],
|
|
18
17
|
"indent": ["error", 2, { "SwitchCase": 1 }],
|
|
@@ -29,20 +28,16 @@ module.exports = {
|
|
|
29
28
|
"arrow-spacing": "error",
|
|
30
29
|
"switch-colon-spacing": ["error", { "after": true, "before": false }],
|
|
31
30
|
"space-in-parens": ["error", "never"],
|
|
32
|
-
"space-before-function-paren": [
|
|
33
|
-
"anonymous": "never",
|
|
34
|
-
"named": "never",
|
|
35
|
-
"asyncArrow": "always",
|
|
36
|
-
}],
|
|
37
|
-
"space-before-blocks": ["error", "always"],
|
|
38
|
-
"no-constant-condition": ["error", { "checkLoops": false }],
|
|
39
|
-
"no-restricted-syntax": [
|
|
31
|
+
"space-before-function-paren": [
|
|
40
32
|
"error",
|
|
41
33
|
{
|
|
42
|
-
"
|
|
43
|
-
"
|
|
34
|
+
"anonymous": "never",
|
|
35
|
+
"named": "never",
|
|
36
|
+
"asyncArrow": "always",
|
|
44
37
|
},
|
|
45
38
|
],
|
|
39
|
+
"space-before-blocks": ["error", "always"],
|
|
40
|
+
"no-constant-condition": ["error", { "checkLoops": false }],
|
|
46
41
|
"no-trailing-spaces": "error",
|
|
47
42
|
"no-multi-spaces": "error",
|
|
48
43
|
"eol-last": "error",
|
|
@@ -55,11 +50,7 @@ module.exports = {
|
|
|
55
50
|
"prefer-object-spread": "error",
|
|
56
51
|
"no-array-constructor": "error",
|
|
57
52
|
"array-callback-return": ["error", { "checkForEach": true }],
|
|
58
|
-
"prefer-destructuring": [
|
|
59
|
-
"error",
|
|
60
|
-
{ "array": false, "object": true },
|
|
61
|
-
{ "enforceForRenamedProperties": false },
|
|
62
|
-
],
|
|
53
|
+
"prefer-destructuring": ["error", { "array": false, "object": true }, { "enforceForRenamedProperties": false }],
|
|
63
54
|
"prefer-template": "error",
|
|
64
55
|
"template-curly-spacing": ["error", "never"],
|
|
65
56
|
"no-eval": "error",
|
|
@@ -79,29 +70,40 @@ module.exports = {
|
|
|
79
70
|
"dot-notation": "error",
|
|
80
71
|
"one-var": ["error", "never"],
|
|
81
72
|
"no-multi-assign": "error",
|
|
82
|
-
"operator-linebreak": [
|
|
83
|
-
"
|
|
84
|
-
|
|
73
|
+
"operator-linebreak": [
|
|
74
|
+
"error",
|
|
75
|
+
"before",
|
|
76
|
+
{
|
|
77
|
+
"overrides": { "=": "after" },
|
|
78
|
+
},
|
|
79
|
+
],
|
|
85
80
|
"eqeqeq": "error",
|
|
86
81
|
"no-unneeded-ternary": ["error", { "defaultAssignment": false }],
|
|
87
82
|
"no-nested-ternary": "error",
|
|
88
83
|
"no-mixed-operators": "error",
|
|
89
84
|
"brace-style": ["error", "1tbs"],
|
|
90
|
-
"spaced-comment": [
|
|
91
|
-
"
|
|
92
|
-
|
|
93
|
-
|
|
85
|
+
"spaced-comment": [
|
|
86
|
+
"error",
|
|
87
|
+
"always",
|
|
88
|
+
{
|
|
89
|
+
"markers": ["!", "?"],
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
"newline-per-chained-call": ["error", { "ignoreChainWithDepth": 2 }],
|
|
94
93
|
"no-whitespace-before-property": "error",
|
|
95
94
|
"padded-blocks": ["error", "never"],
|
|
96
95
|
"block-spacing": ["error", "always"],
|
|
97
96
|
"func-call-spacing": ["error", "never"],
|
|
98
97
|
"no-new-wrappers": "error",
|
|
99
98
|
"radix": ["error", "as-needed"],
|
|
100
|
-
"id-length": [
|
|
101
|
-
"
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
99
|
+
"id-length": [
|
|
100
|
+
"error",
|
|
101
|
+
{
|
|
102
|
+
"min": 2,
|
|
103
|
+
"exceptions": ["i", "e"],
|
|
104
|
+
"exceptionPatterns": ["[x-z]"],
|
|
105
|
+
},
|
|
106
|
+
],
|
|
105
107
|
"new-cap": "error",
|
|
106
108
|
"no-restricted-globals": [
|
|
107
109
|
"error",
|
package/rules/import.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
"plugins": [
|
|
3
|
-
|
|
4
|
-
],
|
|
5
|
-
"extends": [
|
|
6
|
-
"plugin:import/recommended",
|
|
7
|
-
],
|
|
2
|
+
"plugins": ["import"],
|
|
3
|
+
"extends": ["plugin:import/recommended"],
|
|
8
4
|
"settings": {
|
|
9
5
|
"import/resolver": {
|
|
10
6
|
"node": {
|
|
@@ -12,17 +8,18 @@ module.exports = {
|
|
|
12
8
|
"moduleDirectory": ["src/", "node_modules"],
|
|
13
9
|
},
|
|
14
10
|
},
|
|
15
|
-
"import/ignore": [
|
|
16
|
-
"node_modules",
|
|
17
|
-
],
|
|
11
|
+
"import/ignore": ["node_modules"],
|
|
18
12
|
},
|
|
19
13
|
"rules": {
|
|
20
14
|
"import/no-useless-path-segments": ["error", { "noUselessIndex": false }],
|
|
21
|
-
"import/order": [
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
15
|
+
"import/order": [
|
|
16
|
+
"error",
|
|
17
|
+
{
|
|
18
|
+
"groups": [["builtin", "external"], "internal", ["parent", "sibling"], "index", "object"],
|
|
19
|
+
"newlines-between": "always",
|
|
20
|
+
"warnOnUnassignedImports": true,
|
|
21
|
+
},
|
|
22
|
+
],
|
|
26
23
|
"import/no-duplicates": ["error", { "prefer-inline": true }],
|
|
27
24
|
"import/no-self-import": "error",
|
|
28
25
|
"import/no-mutable-exports": "error",
|
package/rules/react.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
"overrides": [
|
|
3
|
+
{
|
|
4
|
+
"files": ["**/*.{jsx,tsx}"],
|
|
5
|
+
"parserOptions": {
|
|
6
|
+
"ecmaFeatures": {
|
|
7
|
+
"jsx": true,
|
|
8
|
+
},
|
|
9
|
+
},
|
|
10
|
+
"plugins": ["react", "react-hooks"],
|
|
11
|
+
"extends": ["plugin:import/react", "plugin:react/recommended", "plugin:react-hooks/recommended"],
|
|
12
|
+
"rules": {
|
|
13
|
+
"react/jsx-tag-spacing": [
|
|
14
|
+
"error",
|
|
15
|
+
{
|
|
16
|
+
"closingSlash": "never",
|
|
17
|
+
"beforeSelfClosing": "proportional-always",
|
|
18
|
+
"afterOpening": "never",
|
|
19
|
+
"beforeClosing": "never",
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
"react/jsx-max-props-per-line": ["error", { "when": "multiline" }],
|
|
23
|
+
"react/jsx-curly-spacing": ["error", { "when": "never", "children": true }],
|
|
24
|
+
"react/jsx-curly-brace-presence": ["error", "never"],
|
|
25
|
+
"react/jsx-closing-bracket-location": "error",
|
|
26
|
+
"react/self-closing-comp": "error",
|
|
27
|
+
"react/no-unused-prop-types": "error",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
}
|
package/rules/typescript.js
CHANGED
|
@@ -3,13 +3,8 @@ module.exports = {
|
|
|
3
3
|
{
|
|
4
4
|
"files": ["**/*.{ts,tsx}"],
|
|
5
5
|
"parser": "@typescript-eslint/parser",
|
|
6
|
-
"plugins": [
|
|
7
|
-
|
|
8
|
-
],
|
|
9
|
-
"extends": [
|
|
10
|
-
"plugin:import/typescript",
|
|
11
|
-
"plugin:@typescript-eslint/recommended",
|
|
12
|
-
],
|
|
6
|
+
"plugins": ["@typescript-eslint"],
|
|
7
|
+
"extends": ["plugin:import/typescript", "plugin:@typescript-eslint/recommended"],
|
|
13
8
|
"rules": {
|
|
14
9
|
"@typescript-eslint/naming-convention": [
|
|
15
10
|
"error",
|
|
@@ -19,13 +14,19 @@ module.exports = {
|
|
|
19
14
|
},
|
|
20
15
|
],
|
|
21
16
|
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
|
|
22
|
-
"@typescript-eslint/member-delimiter-style": [
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
17
|
+
"@typescript-eslint/member-delimiter-style": [
|
|
18
|
+
"error",
|
|
19
|
+
{
|
|
20
|
+
"multiline": { "delimiter": "none" },
|
|
21
|
+
"singleline": { "delimiter": "comma" },
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
"@typescript-eslint/no-empty-interface": [
|
|
25
|
+
"error",
|
|
26
|
+
{
|
|
27
|
+
"allowSingleExtends": true,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
29
30
|
"@typescript-eslint/consistent-type-imports": ["error", { "prefer": "type-imports" }],
|
|
30
31
|
"@typescript-eslint/type-annotation-spacing": "error",
|
|
31
32
|
},
|