eslint-config-jc 2.3.0 → 2.3.3
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/package.json +7 -7
- package/rules/base.js +10 -4
- package/rules/import.js +3 -1
- package/rules/jsx.js +1 -1
- package/rules/typescript-typecheck.js +77 -73
- package/rules/typescript.js +20 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-jc",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.3",
|
|
4
4
|
"description": "Josh-Cena's personal coding style",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -35,14 +35,14 @@
|
|
|
35
35
|
"eslint-config-prettier": "^8.5.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
39
|
-
"@typescript-eslint/parser": "^5.
|
|
40
|
-
"eslint": "^8.
|
|
38
|
+
"@typescript-eslint/eslint-plugin": "^5.32.0",
|
|
39
|
+
"@typescript-eslint/parser": "^5.32.0",
|
|
40
|
+
"eslint": "^8.21.0",
|
|
41
41
|
"eslint-plugin-header": "^3.1.1",
|
|
42
42
|
"eslint-plugin-import": "^2.26.0",
|
|
43
|
-
"eslint-plugin-jsx-a11y": "^6.
|
|
44
|
-
"eslint-plugin-react": "^7.30.
|
|
45
|
-
"eslint-plugin-react-hooks": "^4.
|
|
43
|
+
"eslint-plugin-jsx-a11y": "^6.6.1",
|
|
44
|
+
"eslint-plugin-react": "^7.30.1",
|
|
45
|
+
"eslint-plugin-react-hooks": "^4.6.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependenciesMeta": {
|
|
48
48
|
"eslint-plugin-header": {
|
package/rules/base.js
CHANGED
|
@@ -2,6 +2,7 @@ module.exports = {
|
|
|
2
2
|
env: {
|
|
3
3
|
browser: true,
|
|
4
4
|
commonjs: true,
|
|
5
|
+
es6: true,
|
|
5
6
|
node: true,
|
|
6
7
|
},
|
|
7
8
|
reportUnusedDisableDirectives: true,
|
|
@@ -38,7 +39,10 @@ module.exports = {
|
|
|
38
39
|
"capitalized-comments": [
|
|
39
40
|
"warn",
|
|
40
41
|
"always",
|
|
41
|
-
{
|
|
42
|
+
{
|
|
43
|
+
ignoreConsecutiveComments: true,
|
|
44
|
+
ignorePattern: "prettier-ignore|cSpell:ignore",
|
|
45
|
+
},
|
|
42
46
|
],
|
|
43
47
|
|
|
44
48
|
// It's a way of allowing private methods. (`this.myPrivateMethod()`)
|
|
@@ -164,8 +168,9 @@ module.exports = {
|
|
|
164
168
|
|
|
165
169
|
"no-cond-assign": ["error", "always"],
|
|
166
170
|
|
|
167
|
-
//
|
|
168
|
-
|
|
171
|
+
// This conflicts with Prettier, and syntax highlighting should be
|
|
172
|
+
// sufficient to catch this
|
|
173
|
+
"no-confusing-arrow": "off",
|
|
169
174
|
|
|
170
175
|
// In projects with a wrapped logger, this can be enabled
|
|
171
176
|
"no-console": 0,
|
|
@@ -350,6 +355,7 @@ module.exports = {
|
|
|
350
355
|
"closed",
|
|
351
356
|
"confirm",
|
|
352
357
|
"defaultStatus",
|
|
358
|
+
// cSpell:ignore defaultstatus
|
|
353
359
|
"defaultstatus",
|
|
354
360
|
"event",
|
|
355
361
|
"external",
|
|
@@ -524,7 +530,7 @@ module.exports = {
|
|
|
524
530
|
|
|
525
531
|
"no-var": "error",
|
|
526
532
|
|
|
527
|
-
"no-void": "error",
|
|
533
|
+
"no-void": ["error", { allowAsStatement: true }],
|
|
528
534
|
|
|
529
535
|
"no-warning-comments": "off",
|
|
530
536
|
|
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
|
@@ -1,110 +1,114 @@
|
|
|
1
|
-
// TODO enforce linting with typecheck
|
|
2
1
|
module.exports = {
|
|
3
|
-
|
|
2
|
+
rules: {
|
|
3
|
+
"@typescript-eslint/await-thenable": "error",
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
// Also enforced by --isolatedModules
|
|
6
|
+
"@typescript-eslint/consistent-type-exports": "error",
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
// TODO figure out how this should be configured
|
|
9
|
+
"@typescript-eslint/naming-convention": 0,
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
"@typescript-eslint/no-base-to-string": [
|
|
12
|
+
"warn",
|
|
13
|
+
{ ignoredTypeNames: ["RegExp", "Error"] },
|
|
14
|
+
],
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
"@typescript-eslint/no-confusing-void-expression": [
|
|
17
|
+
"error",
|
|
18
|
+
{
|
|
19
|
+
ignoreArrowShorthand: true,
|
|
20
|
+
ignoreVoidOperator: false,
|
|
21
|
+
},
|
|
22
|
+
],
|
|
20
23
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
"@typescript-eslint/no-floating-promises": [
|
|
25
|
+
"warn",
|
|
26
|
+
{
|
|
27
|
+
ignoreIIFE: false,
|
|
28
|
+
ignoreVoid: true,
|
|
29
|
+
},
|
|
30
|
+
],
|
|
28
31
|
|
|
29
|
-
|
|
32
|
+
"@typescript-eslint/no-for-in-array": "error",
|
|
30
33
|
|
|
31
|
-
|
|
34
|
+
"@typescript-eslint/no-meaningless-void-operator": "error",
|
|
32
35
|
|
|
33
|
-
|
|
36
|
+
"@typescript-eslint/no-misused-promises": "error",
|
|
34
37
|
|
|
35
|
-
|
|
38
|
+
"@typescript-eslint/no-redundant-type-constituents": "error",
|
|
36
39
|
|
|
37
|
-
|
|
40
|
+
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "warn",
|
|
38
41
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
"@typescript-eslint/no-unnecessary-condition": [
|
|
43
|
+
"error",
|
|
44
|
+
{ allowConstantLoopConditions: true },
|
|
45
|
+
],
|
|
43
46
|
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
// Enums & namespaces aren't allowed anyway.
|
|
48
|
+
"@typescript-eslint/no-unnecessary-qualifier": "warn",
|
|
46
49
|
|
|
47
|
-
|
|
50
|
+
"@typescript-eslint/no-unnecessary-type-arguments": "warn",
|
|
48
51
|
|
|
49
|
-
|
|
52
|
+
"@typescript-eslint/no-unnecessary-type-assertion": "error",
|
|
50
53
|
|
|
51
|
-
|
|
54
|
+
"@typescript-eslint/no-unsafe-argument": "error",
|
|
52
55
|
|
|
53
|
-
|
|
56
|
+
"@typescript-eslint/no-unsafe-assignment": "error",
|
|
54
57
|
|
|
55
|
-
|
|
58
|
+
"@typescript-eslint/no-unsafe-call": "error",
|
|
56
59
|
|
|
57
|
-
|
|
60
|
+
"@typescript-eslint/no-unsafe-member-access": "error",
|
|
58
61
|
|
|
59
|
-
|
|
62
|
+
"@typescript-eslint/no-unsafe-return": "error",
|
|
60
63
|
|
|
61
|
-
|
|
64
|
+
"@typescript-eslint/non-nullable-type-assertion-style": "error",
|
|
62
65
|
|
|
63
|
-
|
|
66
|
+
"@typescript-eslint/prefer-includes": "error",
|
|
64
67
|
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
// This has a significant number of false-positives.
|
|
69
|
+
"@typescript-eslint/prefer-nullish-coalescing": "warn",
|
|
67
70
|
|
|
68
|
-
|
|
69
|
-
|
|
71
|
+
// Isn't useful.
|
|
72
|
+
"@typescript-eslint/prefer-readonly": "off",
|
|
70
73
|
|
|
71
|
-
|
|
72
|
-
|
|
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",
|
|
74
77
|
|
|
75
|
-
|
|
78
|
+
"@typescript-eslint/prefer-reduce-type-parameter": "error",
|
|
76
79
|
|
|
77
|
-
|
|
80
|
+
"@typescript-eslint/prefer-regexp-exec": "warn",
|
|
78
81
|
|
|
79
|
-
|
|
82
|
+
"@typescript-eslint/prefer-return-this-type": "warn",
|
|
80
83
|
|
|
81
|
-
|
|
84
|
+
"@typescript-eslint/prefer-string-starts-ends-with": "warn",
|
|
82
85
|
|
|
83
|
-
|
|
84
|
-
|
|
86
|
+
// Not useful. Sometimes we intentionally make the function non-async.
|
|
87
|
+
"@typescript-eslint/promise-function-async": "off",
|
|
85
88
|
|
|
86
|
-
|
|
89
|
+
"@typescript-eslint/require-array-sort-compare": "error",
|
|
87
90
|
|
|
88
|
-
|
|
89
|
-
|
|
91
|
+
// Implicit casting is fine.
|
|
92
|
+
"@typescript-eslint/restrict-plus-operands": "off",
|
|
90
93
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
+
],
|
|
102
105
|
|
|
103
|
-
|
|
104
|
-
|
|
106
|
+
// TODO configure it properly
|
|
107
|
+
"@typescript-eslint/strict-boolean-expressions": "off",
|
|
105
108
|
|
|
106
|
-
|
|
109
|
+
"@typescript-eslint/switch-exhaustiveness-check": "error",
|
|
107
110
|
|
|
108
|
-
|
|
109
|
-
|
|
111
|
+
// Not very useful in practice... A lot of false-positives
|
|
112
|
+
"@typescript-eslint/unbound-method": "off",
|
|
113
|
+
},
|
|
110
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",
|
|
@@ -144,7 +156,14 @@ module.exports = {
|
|
|
144
156
|
{ allowTaggedTemplates: true },
|
|
145
157
|
],
|
|
146
158
|
|
|
147
|
-
"@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
|
+
],
|
|
148
167
|
|
|
149
168
|
// This reports a lot of valid cases, e.g. function declarations
|
|
150
169
|
// TypeScript does a much better job
|