eslint-config-jc 2.2.0 → 2.3.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/index.js +0 -2
- package/package.json +14 -7
- package/rules/base.js +14 -7
- package/rules/jsx.js +6 -3
- package/rules/typescript-typecheck.js +109 -1
- package/rules/typescript.js +0 -3
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-jc",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
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.26.0",
|
|
39
|
+
"@typescript-eslint/parser": "^5.26.0",
|
|
40
|
+
"eslint": "^8.16.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.5.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
|
@@ -4,6 +4,7 @@ module.exports = {
|
|
|
4
4
|
commonjs: true,
|
|
5
5
|
node: true,
|
|
6
6
|
},
|
|
7
|
+
reportUnusedDisableDirectives: true,
|
|
7
8
|
rules: {
|
|
8
9
|
"accessor-pairs": [
|
|
9
10
|
"error",
|
|
@@ -34,9 +35,11 @@ module.exports = {
|
|
|
34
35
|
// Properties are hard to check because they may come from other APIs
|
|
35
36
|
camelcase: ["error", { properties: "never" }],
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
"capitalized-comments": [
|
|
39
|
+
"warn",
|
|
40
|
+
"always",
|
|
41
|
+
{ ignoreConsecutiveComments: true },
|
|
42
|
+
],
|
|
40
43
|
|
|
41
44
|
// It's a way of allowing private methods. (`this.myPrivateMethod()`)
|
|
42
45
|
"class-methods-use-this": "off",
|
|
@@ -69,7 +72,7 @@ module.exports = {
|
|
|
69
72
|
// Shadowed by TS-ESLint rule
|
|
70
73
|
"default-param-last": "off",
|
|
71
74
|
|
|
72
|
-
//
|
|
75
|
+
// E.g. `foo.bar` instead of `foo["bar"]`
|
|
73
76
|
"dot-notation": ["error", { allowKeywords: true }],
|
|
74
77
|
|
|
75
78
|
eqeqeq: ["error", "always", { null: "ignore" }],
|
|
@@ -170,6 +173,8 @@ module.exports = {
|
|
|
170
173
|
// Also checked by TypeScript
|
|
171
174
|
"no-const-assign": "error",
|
|
172
175
|
|
|
176
|
+
"no-constant-binary-expression": "error",
|
|
177
|
+
|
|
173
178
|
"no-constant-condition": ["error", { checkLoops: true }],
|
|
174
179
|
|
|
175
180
|
"no-constructor-return": "error",
|
|
@@ -203,7 +208,7 @@ module.exports = {
|
|
|
203
208
|
// This rule is also in plugin-imports
|
|
204
209
|
"no-duplicate-imports": "off",
|
|
205
210
|
|
|
206
|
-
// else-if is able to save one line, and also makes the flow more natural.
|
|
211
|
+
// `else-if` is able to save one line, and also makes the flow more natural.
|
|
207
212
|
"no-else-return": ["error", { allowElseIf: true }],
|
|
208
213
|
|
|
209
214
|
// Empty catch is useful.
|
|
@@ -588,11 +593,13 @@ module.exports = {
|
|
|
588
593
|
block: {
|
|
589
594
|
balanced: true,
|
|
590
595
|
exceptions: ["-", "+"],
|
|
591
|
-
|
|
596
|
+
// Space here to support sprockets directives and flow comment types
|
|
597
|
+
markers: ["=", "!", ":", "::"],
|
|
592
598
|
},
|
|
593
599
|
line: {
|
|
594
600
|
exceptions: ["-", "+"],
|
|
595
|
-
|
|
601
|
+
// Space here to support sprockets directives, slash for /// comments
|
|
602
|
+
markers: ["=", "!", "/"],
|
|
596
603
|
},
|
|
597
604
|
},
|
|
598
605
|
],
|
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,110 @@
|
|
|
1
1
|
// TODO enforce linting with typecheck
|
|
2
|
-
module.exports = {
|
|
2
|
+
module.exports = {
|
|
3
|
+
"@typescript-eslint/await-thenable": "error",
|
|
4
|
+
|
|
5
|
+
// Already enforced by --isolatedModules
|
|
6
|
+
"@typescript-eslint/consistent-type-exports": "off",
|
|
7
|
+
|
|
8
|
+
// TODO figure out how this should be configured
|
|
9
|
+
"@typescript-eslint/naming-convention": 0,
|
|
10
|
+
|
|
11
|
+
"@typescript-eslint/no-base-to-string": "warn",
|
|
12
|
+
|
|
13
|
+
"@typescript-eslint/no-confusing-void-expression": [
|
|
14
|
+
"error",
|
|
15
|
+
{
|
|
16
|
+
ignoreArrowShorthand: true,
|
|
17
|
+
ignoreVoidOperator: false,
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
|
|
21
|
+
"@typescript-eslint/no-floating-promises": [
|
|
22
|
+
"warn",
|
|
23
|
+
{
|
|
24
|
+
ignoreIIFE: false,
|
|
25
|
+
ignoreVoid: true,
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
|
|
29
|
+
"@typescript-eslint/no-for-in-array": "error",
|
|
30
|
+
|
|
31
|
+
"@typescript-eslint/no-meaningless-void-operator": "error",
|
|
32
|
+
|
|
33
|
+
"@typescript-eslint/no-misused-promises": "error",
|
|
34
|
+
|
|
35
|
+
"@typescript-eslint/no-redundant-type-constituents": "error",
|
|
36
|
+
|
|
37
|
+
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "warn",
|
|
38
|
+
|
|
39
|
+
"@typescript-eslint/no-unnecessary-condition": [
|
|
40
|
+
"error",
|
|
41
|
+
{ allowConstantLoopConditions: true },
|
|
42
|
+
],
|
|
43
|
+
|
|
44
|
+
// Enums & namespaces aren't allowed anyway.
|
|
45
|
+
"@typescript-eslint/no-unnecessary-qualifier": "warn",
|
|
46
|
+
|
|
47
|
+
"@typescript-eslint/no-unnecessary-type-arguments": "warn",
|
|
48
|
+
|
|
49
|
+
"@typescript-eslint/no-unnecessary-type-assertion": "error",
|
|
50
|
+
|
|
51
|
+
"@typescript-eslint/no-unsafe-argument": "error",
|
|
52
|
+
|
|
53
|
+
"@typescript-eslint/no-unsafe-assignment": "error",
|
|
54
|
+
|
|
55
|
+
"@typescript-eslint/no-unsafe-call": "error",
|
|
56
|
+
|
|
57
|
+
"@typescript-eslint/no-unsafe-member-access": "error",
|
|
58
|
+
|
|
59
|
+
"@typescript-eslint/no-unsafe-return": "error",
|
|
60
|
+
|
|
61
|
+
"@typescript-eslint/non-nullable-type-assertion-style": "error",
|
|
62
|
+
|
|
63
|
+
"@typescript-eslint/prefer-includes": "error",
|
|
64
|
+
|
|
65
|
+
// This has a significant number of false-positives.
|
|
66
|
+
"@typescript-eslint/prefer-nullish-coalescing": "warn",
|
|
67
|
+
|
|
68
|
+
// Isn't useful.
|
|
69
|
+
"@typescript-eslint/prefer-readonly": "off",
|
|
70
|
+
|
|
71
|
+
// Isn't useful. If there's a readonly-by-default tsconfig option we would
|
|
72
|
+
// happily try it instead
|
|
73
|
+
"@typescript-eslint/prefer-readonly-parameter-types": "off",
|
|
74
|
+
|
|
75
|
+
"@typescript-eslint/prefer-reduce-type-parameter": "error",
|
|
76
|
+
|
|
77
|
+
"@typescript-eslint/prefer-regexp-exec": "warn",
|
|
78
|
+
|
|
79
|
+
"@typescript-eslint/prefer-return-this-type": "warn",
|
|
80
|
+
|
|
81
|
+
"@typescript-eslint/prefer-string-starts-ends-with": "warn",
|
|
82
|
+
|
|
83
|
+
// Not useful. Sometimes we intentionally make the function non-async.
|
|
84
|
+
"@typescript-eslint/promise-function-async": "off",
|
|
85
|
+
|
|
86
|
+
"@typescript-eslint/require-array-sort-compare": "error",
|
|
87
|
+
|
|
88
|
+
// Implicit casting is fine.
|
|
89
|
+
"@typescript-eslint/restrict-plus-operands": "off",
|
|
90
|
+
|
|
91
|
+
// Default options work fine. However, not allowing `never` is quite annoying
|
|
92
|
+
"@typescript-eslint/restrict-template-expressions": [
|
|
93
|
+
"warn",
|
|
94
|
+
{
|
|
95
|
+
allowAny: false,
|
|
96
|
+
allowBoolean: false,
|
|
97
|
+
allowNullish: false,
|
|
98
|
+
allowNumber: true,
|
|
99
|
+
allowRegExp: false,
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
|
|
103
|
+
// TODO configure it properly
|
|
104
|
+
"@typescript-eslint/strict-boolean-expressions": "off",
|
|
105
|
+
|
|
106
|
+
"@typescript-eslint/switch-exhaustiveness-check": "error",
|
|
107
|
+
|
|
108
|
+
// Not very useful in practice... A lot of false-positives
|
|
109
|
+
"@typescript-eslint/unbound-method": "off",
|
|
110
|
+
};
|
package/rules/typescript.js
CHANGED
|
@@ -66,9 +66,6 @@ module.exports = {
|
|
|
66
66
|
|
|
67
67
|
"@typescript-eslint/method-signature-style": ["error", "property"],
|
|
68
68
|
|
|
69
|
-
// TODO figure out how this should be configured
|
|
70
|
-
"@typescript-eslint/naming-convention": 0,
|
|
71
|
-
|
|
72
69
|
"@typescript-eslint/no-array-constructor": "error",
|
|
73
70
|
|
|
74
71
|
// This doesn't make much sense to me
|