@keeex/eslint-config 1.7.3 → 1.8.1
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 +2 -0
- package/package.json +5 -1
- package/src/config/mocha.js +8 -1
- package/src/config/typescript.js +110 -19
package/README.md
CHANGED
|
@@ -138,6 +138,7 @@ the following properties:
|
|
|
138
138
|
"test/**/*.js",
|
|
139
139
|
],
|
|
140
140
|
expectHelper: true,
|
|
141
|
+
chai: true,
|
|
141
142
|
}
|
|
142
143
|
```
|
|
143
144
|
|
|
@@ -157,6 +158,7 @@ If React Hooks is enabled, `eslint-plugin-react-hooks` must be installed.
|
|
|
157
158
|
If React Native is enabled, `eslint-plugin-react-native` must be installed.
|
|
158
159
|
Promise support requires `eslint-plugin-promise`.
|
|
159
160
|
If mocha is used as the testsuite, `eslint-plugin-mocha` must be installed.
|
|
161
|
+
If chai is used with mocha, `eslint-plugin-chai-friendly` must be installed.
|
|
160
162
|
Import support requires `eslint-plugin-import`.
|
|
161
163
|
|
|
162
164
|
If both import and typescript is used, `eslint-import-resolver-typescript` is needed.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keeex/eslint-config",
|
|
3
3
|
"description": "Common eslint configuration",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.8.1",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"src/**/*.js"
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"eslint": "8.x",
|
|
30
30
|
"eslint-plugin-import": "2.x",
|
|
31
31
|
"eslint-plugin-mocha": "10.x",
|
|
32
|
+
"eslint-plugin-chai-friendly": "0.x",
|
|
32
33
|
"eslint-plugin-promise": "6.x",
|
|
33
34
|
"eslint-plugin-react": "7.x",
|
|
34
35
|
"eslint-plugin-react-hooks": "4.x",
|
|
@@ -57,6 +58,9 @@
|
|
|
57
58
|
"eslint-plugin-react-native": {
|
|
58
59
|
"optional": true
|
|
59
60
|
},
|
|
61
|
+
"eslint-plugin-chai-friendly": {
|
|
62
|
+
"optional": true
|
|
63
|
+
},
|
|
60
64
|
"eslint-plugin-react-hooks": {
|
|
61
65
|
"optional": true
|
|
62
66
|
},
|
package/src/config/mocha.js
CHANGED
|
@@ -8,8 +8,13 @@ module.exports = {
|
|
|
8
8
|
"tests/**/*.js",
|
|
9
9
|
"test/**/*.ts",
|
|
10
10
|
"test/**/*.js",
|
|
11
|
+
"**/tests/**/*.ts",
|
|
12
|
+
"**/tests/**/*.js",
|
|
13
|
+
"**/test/**/*.ts",
|
|
14
|
+
"**/test/**/*.js",
|
|
11
15
|
],
|
|
12
16
|
expectHelper: true,
|
|
17
|
+
mocha: true,
|
|
13
18
|
};
|
|
14
19
|
if (typeof presetConfig === "object") {
|
|
15
20
|
config = {
|
|
@@ -17,10 +22,12 @@ module.exports = {
|
|
|
17
22
|
...presetConfig,
|
|
18
23
|
};
|
|
19
24
|
}
|
|
25
|
+
const extendsBase = ["plugin:mocha/recommended"];
|
|
26
|
+
if (config.chai) extendsBase.push("plugin:chai-friendly/recommended");
|
|
20
27
|
const mochaOverride = {
|
|
21
28
|
files: config.fileFilter,
|
|
22
29
|
env: {mocha: true},
|
|
23
|
-
extendsBase
|
|
30
|
+
extendsBase,
|
|
24
31
|
rules: {
|
|
25
32
|
"mocha/handle-done-callback": ["error", {"ignoreSkipped": true}],
|
|
26
33
|
"mocha/no-mocha-arrows": "off",
|
package/src/config/typescript.js
CHANGED
|
@@ -44,7 +44,109 @@ const rulesBase = {
|
|
|
44
44
|
"error",
|
|
45
45
|
indentDepth,
|
|
46
46
|
],
|
|
47
|
-
"@typescript-eslint/member-ordering": [
|
|
47
|
+
"@typescript-eslint/member-ordering": [
|
|
48
|
+
"warn",
|
|
49
|
+
{
|
|
50
|
+
"default": [
|
|
51
|
+
// Index signature
|
|
52
|
+
"signature",
|
|
53
|
+
|
|
54
|
+
// Fields
|
|
55
|
+
"public-static-field",
|
|
56
|
+
"protected-static-field",
|
|
57
|
+
"private-static-field",
|
|
58
|
+
|
|
59
|
+
"public-decorated-field",
|
|
60
|
+
"protected-decorated-field",
|
|
61
|
+
"private-decorated-field",
|
|
62
|
+
|
|
63
|
+
"public-instance-field",
|
|
64
|
+
"protected-instance-field",
|
|
65
|
+
"private-instance-field",
|
|
66
|
+
|
|
67
|
+
"public-abstract-field",
|
|
68
|
+
"protected-abstract-field",
|
|
69
|
+
"private-abstract-field",
|
|
70
|
+
|
|
71
|
+
"public-field",
|
|
72
|
+
"protected-field",
|
|
73
|
+
"private-field",
|
|
74
|
+
|
|
75
|
+
"static-field",
|
|
76
|
+
"instance-field",
|
|
77
|
+
"abstract-field",
|
|
78
|
+
|
|
79
|
+
"decorated-field",
|
|
80
|
+
|
|
81
|
+
"field",
|
|
82
|
+
|
|
83
|
+
// Constructors
|
|
84
|
+
"public-constructor",
|
|
85
|
+
"protected-constructor",
|
|
86
|
+
"private-constructor",
|
|
87
|
+
|
|
88
|
+
"constructor",
|
|
89
|
+
|
|
90
|
+
// Getters/Setters
|
|
91
|
+
["public-static-get", "public-static-set"],
|
|
92
|
+
["protected-static-get", "protected-static-set"],
|
|
93
|
+
["private-static-get", "private-static-set"],
|
|
94
|
+
|
|
95
|
+
["public-decorated-get", "public-decorated-set"],
|
|
96
|
+
["protected-decorated-get", "protected-decorated-set"],
|
|
97
|
+
["private-decorated-get", "private-decorated-set"],
|
|
98
|
+
|
|
99
|
+
["public-instance-get", "public-instance-set"],
|
|
100
|
+
["protected-instance-get", "protected-instance-set"],
|
|
101
|
+
["private-instance-get", "private-instance-set"],
|
|
102
|
+
|
|
103
|
+
["public-abstract-get", "public-abstract-set"],
|
|
104
|
+
["protected-abstract-get", "protected-abstract-set"],
|
|
105
|
+
["private-abstract-get", "private-abstract-set"],
|
|
106
|
+
|
|
107
|
+
["public-get", "public-set"],
|
|
108
|
+
["protected-get", "protected-set"],
|
|
109
|
+
["private-get", "private-set"],
|
|
110
|
+
|
|
111
|
+
["static-get", "static-set"],
|
|
112
|
+
["instance-get", "instance-set"],
|
|
113
|
+
["abstract-get", "abstract-set"],
|
|
114
|
+
|
|
115
|
+
["decorated-get", "decorated-set"],
|
|
116
|
+
|
|
117
|
+
["get", "set"],
|
|
118
|
+
|
|
119
|
+
// Methods
|
|
120
|
+
"public-static-method",
|
|
121
|
+
"protected-static-method",
|
|
122
|
+
"private-static-method",
|
|
123
|
+
|
|
124
|
+
"public-decorated-method",
|
|
125
|
+
"protected-decorated-method",
|
|
126
|
+
"private-decorated-method",
|
|
127
|
+
|
|
128
|
+
"public-instance-method",
|
|
129
|
+
"protected-instance-method",
|
|
130
|
+
"private-instance-method",
|
|
131
|
+
|
|
132
|
+
"public-abstract-method",
|
|
133
|
+
"protected-abstract-method",
|
|
134
|
+
"private-abstract-method",
|
|
135
|
+
|
|
136
|
+
"public-method",
|
|
137
|
+
"protected-method",
|
|
138
|
+
"private-method",
|
|
139
|
+
|
|
140
|
+
"static-method",
|
|
141
|
+
"instance-method",
|
|
142
|
+
"abstract-method",
|
|
143
|
+
|
|
144
|
+
"decorated-method",
|
|
145
|
+
|
|
146
|
+
"method",
|
|
147
|
+
],
|
|
148
|
+
},
|
|
149
|
+
],
|
|
48
150
|
"no-array-constructor": "off",
|
|
49
151
|
"@typescript-eslint/no-array-constructor": ["warn"],
|
|
50
152
|
"@typescript-eslint/no-dupe-class-members": ["error"],
|
|
@@ -138,19 +240,6 @@ const rulesBase = {
|
|
|
138
240
|
};
|
|
139
241
|
|
|
140
242
|
module.exports = {
|
|
141
|
-
settings: (presetConfig, allOptions) => {
|
|
142
|
-
if (useTypes(presetConfig) && allOptions["import"]) {
|
|
143
|
-
return {
|
|
144
|
-
"import/parsers": {"@typescript-eslint/parser": [".ts", ".tsx"]},
|
|
145
|
-
"import/resolver": {
|
|
146
|
-
"typescript": {
|
|
147
|
-
alwaysTryTypes: true,
|
|
148
|
-
project: presetConfig,
|
|
149
|
-
},
|
|
150
|
-
},
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
243
|
overrides: [
|
|
155
244
|
{
|
|
156
245
|
files: [
|
|
@@ -186,14 +275,16 @@ module.exports = {
|
|
|
186
275
|
];
|
|
187
276
|
},
|
|
188
277
|
rules: (presetOptions, allOptions) => {
|
|
278
|
+
// There seem to be no way for now to have import understand that ".js" imports should refer
|
|
279
|
+
// to ".ts" files.
|
|
280
|
+
// Either it complains about needing the ".ts" suffix (which is wrong) or it enforces having
|
|
281
|
+
// an extension, but doesn't actually resolve the file (since we disable the ts-specific
|
|
282
|
+
// resolver).
|
|
283
|
+
// If this change in the future, restore full ts-resolver support from import plugin.
|
|
189
284
|
const importOverride = allOptions.import
|
|
190
285
|
? {
|
|
191
286
|
"import/no-unresolved": "off",
|
|
192
|
-
"import/
|
|
193
|
-
"error",
|
|
194
|
-
"always",
|
|
195
|
-
{"ts": "never"},
|
|
196
|
-
],
|
|
287
|
+
"import/no-cycle": "off",
|
|
197
288
|
}
|
|
198
289
|
: undefined;
|
|
199
290
|
const typesOverride = useTypes(presetOptions)
|