eslint-config-jc 2.2.0 → 2.3.2
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/index.js +0 -2
- package/package.json +14 -7
- package/rules/base.js +19 -7
- package/rules/import.js +3 -1
- package/rules/jsx.js +6 -3
- package/rules/typescript-typecheck.js +114 -2
- package/rules/typescript.js +20 -4
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-jc",
|
|
3
|
-
"version": "2.2
|
|
3
|
+
"version": "2.3.2",
|
|
4
4
|
"description": "Josh-Cena's personal coding style",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -12,8 +12,12 @@
|
|
|
12
12
|
"eslint",
|
|
13
13
|
"eslint-config"
|
|
14
14
|
],
|
|
15
|
-
"author": "Joshua Chen",
|
|
15
|
+
"author": "Joshua Chen <sidachen2003@gmail.com>",
|
|
16
16
|
"license": "MIT",
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public",
|
|
19
|
+
"registry": "https://registry.npmjs.org"
|
|
20
|
+
},
|
|
17
21
|
"bugs": {
|
|
18
22
|
"url": "https://github.com/jc-verse/js-style-guide/issues"
|
|
19
23
|
},
|
|
@@ -31,16 +35,19 @@
|
|
|
31
35
|
"eslint-config-prettier": "^8.5.0"
|
|
32
36
|
},
|
|
33
37
|
"peerDependencies": {
|
|
34
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
35
|
-
"@typescript-eslint/parser": "^5.
|
|
36
|
-
"eslint": "^8.
|
|
38
|
+
"@typescript-eslint/eslint-plugin": "^5.28.0",
|
|
39
|
+
"@typescript-eslint/parser": "^5.28.0",
|
|
40
|
+
"eslint": "^8.17.0",
|
|
37
41
|
"eslint-plugin-header": "^3.1.1",
|
|
38
42
|
"eslint-plugin-import": "^2.26.0",
|
|
39
43
|
"eslint-plugin-jsx-a11y": "^6.5.1",
|
|
40
|
-
"eslint-plugin-react": "^7.
|
|
41
|
-
"eslint-plugin-react-hooks": "^4.
|
|
44
|
+
"eslint-plugin-react": "^7.30.0",
|
|
45
|
+
"eslint-plugin-react-hooks": "^4.6.0"
|
|
42
46
|
},
|
|
43
47
|
"peerDependenciesMeta": {
|
|
48
|
+
"eslint-plugin-header": {
|
|
49
|
+
"optional": true
|
|
50
|
+
},
|
|
44
51
|
"eslint-plugin-jsx-a11y": {
|
|
45
52
|
"optional": true
|
|
46
53
|
},
|
package/rules/base.js
CHANGED
|
@@ -2,8 +2,10 @@ module.exports = {
|
|
|
2
2
|
env: {
|
|
3
3
|
browser: true,
|
|
4
4
|
commonjs: true,
|
|
5
|
+
es6: true,
|
|
5
6
|
node: true,
|
|
6
7
|
},
|
|
8
|
+
reportUnusedDisableDirectives: true,
|
|
7
9
|
rules: {
|
|
8
10
|
"accessor-pairs": [
|
|
9
11
|
"error",
|
|
@@ -34,9 +36,14 @@ module.exports = {
|
|
|
34
36
|
// Properties are hard to check because they may come from other APIs
|
|
35
37
|
camelcase: ["error", { properties: "never" }],
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
"capitalized-comments": [
|
|
40
|
+
"warn",
|
|
41
|
+
"always",
|
|
42
|
+
{
|
|
43
|
+
ignoreConsecutiveComments: true,
|
|
44
|
+
ignorePattern: "prettier-ignore|cSpell:ignore",
|
|
45
|
+
},
|
|
46
|
+
],
|
|
40
47
|
|
|
41
48
|
// It's a way of allowing private methods. (`this.myPrivateMethod()`)
|
|
42
49
|
"class-methods-use-this": "off",
|
|
@@ -69,7 +76,7 @@ module.exports = {
|
|
|
69
76
|
// Shadowed by TS-ESLint rule
|
|
70
77
|
"default-param-last": "off",
|
|
71
78
|
|
|
72
|
-
//
|
|
79
|
+
// E.g. `foo.bar` instead of `foo["bar"]`
|
|
73
80
|
"dot-notation": ["error", { allowKeywords: true }],
|
|
74
81
|
|
|
75
82
|
eqeqeq: ["error", "always", { null: "ignore" }],
|
|
@@ -170,6 +177,8 @@ module.exports = {
|
|
|
170
177
|
// Also checked by TypeScript
|
|
171
178
|
"no-const-assign": "error",
|
|
172
179
|
|
|
180
|
+
"no-constant-binary-expression": "error",
|
|
181
|
+
|
|
173
182
|
"no-constant-condition": ["error", { checkLoops: true }],
|
|
174
183
|
|
|
175
184
|
"no-constructor-return": "error",
|
|
@@ -203,7 +212,7 @@ module.exports = {
|
|
|
203
212
|
// This rule is also in plugin-imports
|
|
204
213
|
"no-duplicate-imports": "off",
|
|
205
214
|
|
|
206
|
-
// else-if is able to save one line, and also makes the flow more natural.
|
|
215
|
+
// `else-if` is able to save one line, and also makes the flow more natural.
|
|
207
216
|
"no-else-return": ["error", { allowElseIf: true }],
|
|
208
217
|
|
|
209
218
|
// Empty catch is useful.
|
|
@@ -345,6 +354,7 @@ module.exports = {
|
|
|
345
354
|
"closed",
|
|
346
355
|
"confirm",
|
|
347
356
|
"defaultStatus",
|
|
357
|
+
// cSpell:ignore defaultstatus
|
|
348
358
|
"defaultstatus",
|
|
349
359
|
"event",
|
|
350
360
|
"external",
|
|
@@ -588,11 +598,13 @@ module.exports = {
|
|
|
588
598
|
block: {
|
|
589
599
|
balanced: true,
|
|
590
600
|
exceptions: ["-", "+"],
|
|
591
|
-
|
|
601
|
+
// Space here to support sprockets directives and flow comment types
|
|
602
|
+
markers: ["=", "!", ":", "::"],
|
|
592
603
|
},
|
|
593
604
|
line: {
|
|
594
605
|
exceptions: ["-", "+"],
|
|
595
|
-
|
|
606
|
+
// Space here to support sprockets directives, slash for /// comments
|
|
607
|
+
markers: ["=", "!", "/"],
|
|
596
608
|
},
|
|
597
609
|
},
|
|
598
610
|
],
|
package/rules/import.js
CHANGED
|
@@ -20,7 +20,9 @@ module.exports = {
|
|
|
20
20
|
|
|
21
21
|
"import/no-duplicates": "error",
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
// This rule doesn't play well with TypeScript + ESM. TS is able to catch
|
|
24
|
+
// missing import anyways.
|
|
25
|
+
"import/no-unresolved": ["off", { caseSensitive: true, commonjs: true }],
|
|
24
26
|
|
|
25
27
|
// Going one directory above ensures transpilation doesn't mess with paths
|
|
26
28
|
"import/no-useless-path-segments": "off",
|
package/rules/jsx.js
CHANGED
|
@@ -204,7 +204,7 @@ module.exports = {
|
|
|
204
204
|
|
|
205
205
|
"react/jsx-curly-brace-presence": "error",
|
|
206
206
|
|
|
207
|
-
//
|
|
207
|
+
// Js, jsx, tsx are all acceptable
|
|
208
208
|
"react/jsx-filename-extension": "off",
|
|
209
209
|
|
|
210
210
|
"react/jsx-fragments": "error",
|
|
@@ -216,7 +216,7 @@ module.exports = {
|
|
|
216
216
|
|
|
217
217
|
"react/jsx-max-depth": "off",
|
|
218
218
|
|
|
219
|
-
"react/jsx-no-bind": "error",
|
|
219
|
+
"react/jsx-no-bind": ["error", { ignoreDOMComponents: true }],
|
|
220
220
|
|
|
221
221
|
"react/jsx-no-comment-textnodes": "error",
|
|
222
222
|
|
|
@@ -224,6 +224,9 @@ module.exports = {
|
|
|
224
224
|
|
|
225
225
|
"react/jsx-no-duplicate-props": "error",
|
|
226
226
|
|
|
227
|
+
// We'll use strict-boolean-expressions instead
|
|
228
|
+
"react/jsx-no-leaked-render": "off",
|
|
229
|
+
|
|
227
230
|
"react/jsx-no-literals": "off",
|
|
228
231
|
|
|
229
232
|
"react/jsx-no-script-url": "error",
|
|
@@ -235,7 +238,7 @@ module.exports = {
|
|
|
235
238
|
|
|
236
239
|
"react/jsx-no-useless-fragment": ["error", { allowExpressions: true }],
|
|
237
240
|
|
|
238
|
-
"react/jsx-pascal-case": "error",
|
|
241
|
+
"react/jsx-pascal-case": ["error", { allowAllCaps: true }],
|
|
239
242
|
|
|
240
243
|
"react/jsx-props-no-spreading": "off",
|
|
241
244
|
|
|
@@ -1,2 +1,114 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
module.exports = {
|
|
2
|
+
rules: {
|
|
3
|
+
"@typescript-eslint/await-thenable": "error",
|
|
4
|
+
|
|
5
|
+
// Also enforced by --isolatedModules
|
|
6
|
+
"@typescript-eslint/consistent-type-exports": "error",
|
|
7
|
+
|
|
8
|
+
// TODO figure out how this should be configured
|
|
9
|
+
"@typescript-eslint/naming-convention": 0,
|
|
10
|
+
|
|
11
|
+
"@typescript-eslint/no-base-to-string": [
|
|
12
|
+
"warn",
|
|
13
|
+
{ ignoredTypeNames: ["RegExp", "Error"] },
|
|
14
|
+
],
|
|
15
|
+
|
|
16
|
+
"@typescript-eslint/no-confusing-void-expression": [
|
|
17
|
+
"error",
|
|
18
|
+
{
|
|
19
|
+
ignoreArrowShorthand: true,
|
|
20
|
+
ignoreVoidOperator: false,
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
|
|
24
|
+
"@typescript-eslint/no-floating-promises": [
|
|
25
|
+
"warn",
|
|
26
|
+
{
|
|
27
|
+
ignoreIIFE: false,
|
|
28
|
+
ignoreVoid: true,
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
|
|
32
|
+
"@typescript-eslint/no-for-in-array": "error",
|
|
33
|
+
|
|
34
|
+
"@typescript-eslint/no-meaningless-void-operator": "error",
|
|
35
|
+
|
|
36
|
+
"@typescript-eslint/no-misused-promises": "error",
|
|
37
|
+
|
|
38
|
+
"@typescript-eslint/no-redundant-type-constituents": "error",
|
|
39
|
+
|
|
40
|
+
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "warn",
|
|
41
|
+
|
|
42
|
+
"@typescript-eslint/no-unnecessary-condition": [
|
|
43
|
+
"error",
|
|
44
|
+
{ allowConstantLoopConditions: true },
|
|
45
|
+
],
|
|
46
|
+
|
|
47
|
+
// Enums & namespaces aren't allowed anyway.
|
|
48
|
+
"@typescript-eslint/no-unnecessary-qualifier": "warn",
|
|
49
|
+
|
|
50
|
+
"@typescript-eslint/no-unnecessary-type-arguments": "warn",
|
|
51
|
+
|
|
52
|
+
"@typescript-eslint/no-unnecessary-type-assertion": "error",
|
|
53
|
+
|
|
54
|
+
"@typescript-eslint/no-unsafe-argument": "error",
|
|
55
|
+
|
|
56
|
+
"@typescript-eslint/no-unsafe-assignment": "error",
|
|
57
|
+
|
|
58
|
+
"@typescript-eslint/no-unsafe-call": "error",
|
|
59
|
+
|
|
60
|
+
"@typescript-eslint/no-unsafe-member-access": "error",
|
|
61
|
+
|
|
62
|
+
"@typescript-eslint/no-unsafe-return": "error",
|
|
63
|
+
|
|
64
|
+
"@typescript-eslint/non-nullable-type-assertion-style": "error",
|
|
65
|
+
|
|
66
|
+
"@typescript-eslint/prefer-includes": "error",
|
|
67
|
+
|
|
68
|
+
// This has a significant number of false-positives.
|
|
69
|
+
"@typescript-eslint/prefer-nullish-coalescing": "warn",
|
|
70
|
+
|
|
71
|
+
// Isn't useful.
|
|
72
|
+
"@typescript-eslint/prefer-readonly": "off",
|
|
73
|
+
|
|
74
|
+
// Isn't useful. If there's a readonly-by-default tsconfig option we would
|
|
75
|
+
// happily try it instead
|
|
76
|
+
"@typescript-eslint/prefer-readonly-parameter-types": "off",
|
|
77
|
+
|
|
78
|
+
"@typescript-eslint/prefer-reduce-type-parameter": "error",
|
|
79
|
+
|
|
80
|
+
"@typescript-eslint/prefer-regexp-exec": "warn",
|
|
81
|
+
|
|
82
|
+
"@typescript-eslint/prefer-return-this-type": "warn",
|
|
83
|
+
|
|
84
|
+
"@typescript-eslint/prefer-string-starts-ends-with": "warn",
|
|
85
|
+
|
|
86
|
+
// Not useful. Sometimes we intentionally make the function non-async.
|
|
87
|
+
"@typescript-eslint/promise-function-async": "off",
|
|
88
|
+
|
|
89
|
+
"@typescript-eslint/require-array-sort-compare": "error",
|
|
90
|
+
|
|
91
|
+
// Implicit casting is fine.
|
|
92
|
+
"@typescript-eslint/restrict-plus-operands": "off",
|
|
93
|
+
|
|
94
|
+
// Default options work fine. However, not allowing `never` is a pain
|
|
95
|
+
"@typescript-eslint/restrict-template-expressions": [
|
|
96
|
+
"warn",
|
|
97
|
+
{
|
|
98
|
+
allowAny: false,
|
|
99
|
+
allowBoolean: false,
|
|
100
|
+
allowNullish: false,
|
|
101
|
+
allowNumber: true,
|
|
102
|
+
allowRegExp: false,
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
|
|
106
|
+
// TODO configure it properly
|
|
107
|
+
"@typescript-eslint/strict-boolean-expressions": "off",
|
|
108
|
+
|
|
109
|
+
"@typescript-eslint/switch-exhaustiveness-check": "error",
|
|
110
|
+
|
|
111
|
+
// Not very useful in practice... A lot of false-positives
|
|
112
|
+
"@typescript-eslint/unbound-method": "off",
|
|
113
|
+
},
|
|
114
|
+
};
|
package/rules/typescript.js
CHANGED
|
@@ -11,6 +11,13 @@ module.exports = {
|
|
|
11
11
|
"@typescript-eslint/no-var-requires": "off",
|
|
12
12
|
},
|
|
13
13
|
},
|
|
14
|
+
{
|
|
15
|
+
files: ["**/*.{ts,tsx,cts,mts}"],
|
|
16
|
+
rules: {
|
|
17
|
+
// Use TypeScript's checker instead
|
|
18
|
+
"no-undef": "off",
|
|
19
|
+
},
|
|
20
|
+
},
|
|
14
21
|
],
|
|
15
22
|
parser: "@typescript-eslint/parser",
|
|
16
23
|
parserOptions: {
|
|
@@ -27,6 +34,11 @@ module.exports = {
|
|
|
27
34
|
|
|
28
35
|
"@typescript-eslint/ban-types": "error",
|
|
29
36
|
|
|
37
|
+
"@typescript-eslint/consistent-generic-constructors": [
|
|
38
|
+
"error",
|
|
39
|
+
"constructor",
|
|
40
|
+
],
|
|
41
|
+
|
|
30
42
|
// Index signatures allows annotating the semantics of the key, while record
|
|
31
43
|
// is more concise
|
|
32
44
|
"@typescript-eslint/consistent-indexed-object-style": "off",
|
|
@@ -66,9 +78,6 @@ module.exports = {
|
|
|
66
78
|
|
|
67
79
|
"@typescript-eslint/method-signature-style": ["error", "property"],
|
|
68
80
|
|
|
69
|
-
// TODO figure out how this should be configured
|
|
70
|
-
"@typescript-eslint/naming-convention": 0,
|
|
71
|
-
|
|
72
81
|
"@typescript-eslint/no-array-constructor": "error",
|
|
73
82
|
|
|
74
83
|
// This doesn't make much sense to me
|
|
@@ -147,7 +156,14 @@ module.exports = {
|
|
|
147
156
|
{ allowTaggedTemplates: true },
|
|
148
157
|
],
|
|
149
158
|
|
|
150
|
-
"@typescript-eslint/no-unused-vars":
|
|
159
|
+
"@typescript-eslint/no-unused-vars": [
|
|
160
|
+
"error",
|
|
161
|
+
{
|
|
162
|
+
args: "after-used",
|
|
163
|
+
ignoreRestSiblings: true,
|
|
164
|
+
vars: "all",
|
|
165
|
+
},
|
|
166
|
+
],
|
|
151
167
|
|
|
152
168
|
// This reports a lot of valid cases, e.g. function declarations
|
|
153
169
|
// TypeScript does a much better job
|