eslint-config-jc 4.3.0 → 5.0.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 CHANGED
@@ -4,27 +4,6 @@ My personal coding style.
4
4
 
5
5
  This is designed to be a replacement for `eslint:recommended`, `plugin:react-hooks/recommended`, `plugin:@typescript-eslint/recommended`, and of course, everyone's favorite `airbnb`. It also extends `prettier`.
6
6
 
7
- ## Dependencies
8
-
9
- It requires the following plugins:
10
-
11
- ```json
12
- {
13
- "devDependencies": {
14
- "@typescript-eslint/eslint-plugin": "^5.10.2",
15
- "@typescript-eslint/parser": "^5.10.2",
16
- "eslint": "^8.8.0",
17
- "eslint-plugin-header": "^3.1.1",
18
- "eslint-plugin-import": "^2.25.3",
19
- "eslint-plugin-jsx-a11y": "^6.5.1",
20
- "eslint-plugin-react": "^7.27.0",
21
- "eslint-plugin-react-hooks": "^4.3.0"
22
- }
23
- }
24
- ```
25
-
26
- Although peer dependencies are evil, we can't self-install these plugins if the downstream user depends on a different version—the wrong one will be resolved.
27
-
28
7
  ## Configuration
29
8
 
30
9
  ESLint config:
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "eslint-config-jc",
3
- "version": "4.3.0",
3
+ "version": "5.0.0",
4
4
  "description": "Josh-Cena's personal coding style",
5
- "main": "index.js",
5
+ "type": "module",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/jc-verse/js-style-guide.git",
@@ -23,48 +23,27 @@
23
23
  },
24
24
  "homepage": "https://jc-verse.github.io/js-style-guide/",
25
25
  "exports": {
26
- ".": "./index.js",
27
- "./base": "./rules/base.js",
28
- "./regex": "./rules/regex.js",
29
- "./import": "./rules/import.js",
30
- "./node": "./rules/node.js",
31
- "./jsx": "./rules/jsx.js",
32
- "./react": "./rules/react.js",
33
- "./react-class-comps": "./rules/react-class-comps.js",
34
- "./react-prop-types": "./rules/react-prop-types.js",
35
- "./typescript": "./rules/typescript.js",
36
- "./typescript-typecheck": "./rules/typescript-typecheck.js"
26
+ ".": "./dist/index.js"
37
27
  },
38
- "dependencies": {
39
- "eslint-config-prettier": "^9.1.0"
28
+ "scripts": {
29
+ "build": "tsc",
30
+ "prepublishOnly": "yarn build"
40
31
  },
41
- "peerDependencies": {
42
- "@typescript-eslint/eslint-plugin": "^7.0.1",
43
- "@typescript-eslint/parser": "^7.0.1",
44
- "eslint": "^8.56.0",
32
+ "dependencies": {
33
+ "@typescript-eslint/eslint-plugin": "^7.7.0",
34
+ "@typescript-eslint/parser": "^7.7.0",
35
+ "eslint-config-prettier": "^9.1.0",
45
36
  "eslint-plugin-header": "^3.1.1",
46
37
  "eslint-plugin-import": "^2.29.1",
47
38
  "eslint-plugin-jsx-a11y": "^6.8.0",
48
- "eslint-plugin-n": "^16.6.2",
49
- "eslint-plugin-react": "^7.33.2",
39
+ "eslint-plugin-n": "^17.2.1",
40
+ "eslint-plugin-react": "^7.34.1",
50
41
  "eslint-plugin-react-hooks": "^4.6.0",
51
- "eslint-plugin-regexp": "^2.2.0"
42
+ "eslint-plugin-regexp": "^2.5.0",
43
+ "globals": "^15.0.0",
44
+ "typescript-eslint": "^7.7.0"
52
45
  },
53
- "peerDependenciesMeta": {
54
- "eslint-plugin-header": {
55
- "optional": true
56
- },
57
- "eslint-plugin-jsx-a11y": {
58
- "optional": true
59
- },
60
- "eslint-plugin-n": {
61
- "optional": true
62
- },
63
- "eslint-plugin-react": {
64
- "optional": true
65
- },
66
- "eslint-plugin-react-hooks": {
67
- "optional": true
68
- }
46
+ "devDependencies": {
47
+ "@types/eslint-config-prettier": "^6.11.3"
69
48
  }
70
49
  }
@@ -1,11 +1,6 @@
1
- module.exports = {
2
- env: {
3
- browser: true,
4
- commonjs: true,
5
- es6: true,
6
- node: true,
7
- },
8
- reportUnusedDisableDirectives: true,
1
+ import tseslint from "typescript-eslint";
2
+
3
+ export default tseslint.config({
9
4
  rules: {
10
5
  // https://jc-verse.github.io/js-style-guide/eslint-base/objects-classes#accessor-pairs
11
6
  "accessor-pairs": [
@@ -908,4 +903,4 @@ module.exports = {
908
903
  // https://jc-verse.github.io/js-style-guide/eslint-base/operatorss#yoda
909
904
  yoda: ["error", "never", { exceptRange: true }],
910
905
  },
911
- };
906
+ });
@@ -1,5 +1,10 @@
1
- module.exports = {
2
- plugins: ["import"],
1
+ import importPlugin from "eslint-plugin-import";
2
+ import tseslint from "typescript-eslint";
3
+
4
+ export default tseslint.config({
5
+ plugins: {
6
+ import: importPlugin,
7
+ },
3
8
  rules: {
4
9
  // We use @typescript-eslint/no-import-type-side-effects
5
10
  "import/consistent-type-specifier-style": "off",
@@ -131,4 +136,4 @@ module.exports = {
131
136
  },
132
137
  },
133
138
  },
134
- };
139
+ });
package/src/index.ts ADDED
@@ -0,0 +1,53 @@
1
+ import tseslint from "typescript-eslint";
2
+ import tseslintParser from "@typescript-eslint/parser";
3
+ import type { TSESLint } from "@typescript-eslint/utils";
4
+ import prettierRules from "eslint-config-prettier";
5
+
6
+ import baseRules from "./base.js";
7
+ import regexRules from "./regex.js";
8
+ import typescriptRules from "./typescript.js";
9
+ import importRules from "./import.js";
10
+ import reactRules from "./react.js";
11
+ import jsxRules from "./jsx.js";
12
+
13
+ import typescriptTypeCheckRules from "./typescript-typecheck.js";
14
+ import nodeRules from "./node.js";
15
+ import reactClassCompRules from "./react-class-comps.js";
16
+ import reactPropTypesRules from "./react-prop-types.js";
17
+
18
+ export default function configCreator({
19
+ react,
20
+ typescriptTypeCheck,
21
+ node,
22
+ reactClassComp,
23
+ reactPropTypes,
24
+ }: {
25
+ react?: boolean;
26
+ typescriptTypeCheck?: boolean;
27
+ node?: boolean;
28
+ reactClassComp?: boolean;
29
+ reactPropTypes?: boolean;
30
+ } = {}): TSESLint.FlatConfig.ConfigArray {
31
+ return tseslint.config(
32
+ {
33
+ linterOptions: {
34
+ reportUnusedDisableDirectives: true,
35
+ },
36
+ languageOptions: {
37
+ ecmaVersion: "latest",
38
+ parser: tseslintParser,
39
+ },
40
+ },
41
+ prettierRules,
42
+ ...baseRules,
43
+ ...regexRules,
44
+ ...typescriptRules,
45
+ ...importRules,
46
+ ...(react ? reactRules : []),
47
+ ...(react ? jsxRules : []),
48
+ ...(typescriptTypeCheck ? typescriptTypeCheckRules : []),
49
+ ...(node ? nodeRules : []),
50
+ ...(reactClassComp ? reactClassCompRules : []),
51
+ ...(reactPropTypes ? reactPropTypesRules : []),
52
+ );
53
+ }
@@ -1,5 +1,12 @@
1
- module.exports = {
2
- plugins: ["jsx-a11y", "react"],
1
+ import jsxA11yPlugin from "eslint-plugin-jsx-a11y";
2
+ import reactPlugin from "eslint-plugin-react";
3
+ import tseslint from "typescript-eslint";
4
+
5
+ export default tseslint.config({
6
+ plugins: {
7
+ "jsx-a11y": jsxA11yPlugin,
8
+ react: reactPlugin,
9
+ },
3
10
  rules: {
4
11
  // JSX a11y rules are taken from airbnb, not adjusted yet
5
12
  "jsx-a11y/alt-text": [
@@ -382,4 +389,4 @@ module.exports = {
382
389
 
383
390
  "react/void-dom-elements-no-children": "error",
384
391
  },
385
- };
392
+ });
@@ -1,5 +1,17 @@
1
- module.exports = {
2
- plugins: ["n"],
1
+ import nPlugin from "eslint-plugin-n";
2
+ import tseslint from "typescript-eslint";
3
+ import globals from "globals";
4
+
5
+ export default tseslint.config({
6
+ languageOptions: {
7
+ globals: {
8
+ ...globals.node,
9
+ ...globals.nodeBuiltin,
10
+ },
11
+ },
12
+ plugins: {
13
+ n: nPlugin,
14
+ },
3
15
  rules: {
4
16
  // Callback-related
5
17
  "n/callback-return": "off",
@@ -15,6 +27,9 @@ module.exports = {
15
27
  // Callback-related
16
28
  "n/handle-callback-err": "off",
17
29
 
30
+ // Errors on TypeScript bin
31
+ "n/hashbang": "off",
32
+
18
33
  // Callback-related
19
34
  "n/no-callback-literal": "off",
20
35
 
@@ -77,8 +92,5 @@ module.exports = {
77
92
  "n/prefer-promises/fs": "error",
78
93
 
79
94
  "n/process-exit-as-throw": "warn",
80
-
81
- // Errors on TypeScript bin
82
- "n/shebang": "off",
83
95
  },
84
- };
96
+ });
@@ -0,0 +1,4 @@
1
+ declare module "eslint-plugin-import";
2
+ declare module "eslint-plugin-jsx-a11y";
3
+ declare module "eslint-plugin-react";
4
+ declare module "eslint-plugin-react-hooks";
@@ -1,4 +1,6 @@
1
- module.exports = {
1
+ import tseslint from "typescript-eslint";
2
+
3
+ export default tseslint.config({
2
4
  rules: {
3
5
  "react/no-access-state-in-setstate": "error",
4
6
 
@@ -38,4 +40,4 @@ module.exports = {
38
40
 
39
41
  "react/static-property-placement": ["error", "static public field"],
40
42
  },
41
- };
43
+ });
@@ -1,4 +1,6 @@
1
- module.exports = {
1
+ import tseslint from "typescript-eslint";
2
+
3
+ export default tseslint.config({
2
4
  rules: {
3
5
  "react/default-props-match-prop-types": "off",
4
6
 
@@ -18,4 +20,4 @@ module.exports = {
18
20
 
19
21
  "react/sort-prop-types": "off",
20
22
  },
21
- };
23
+ });
@@ -1,10 +1,19 @@
1
- module.exports = {
2
- parserOptions: {
3
- ecmaFeatures: {
4
- jsx: true,
1
+ import reactPlugin from "eslint-plugin-react";
2
+ import reactHooksPlugin from "eslint-plugin-react-hooks";
3
+ import tseslint from "typescript-eslint";
4
+ import globals from "globals";
5
+
6
+ export default tseslint.config({
7
+ languageOptions: {
8
+ globals: {
9
+ ...globals.browser,
10
+ ...globals.node,
5
11
  },
6
12
  },
7
- plugins: ["react", "react-hooks"],
13
+ plugins: {
14
+ react: reactPlugin,
15
+ "react-hooks": reactHooksPlugin,
16
+ },
8
17
  rules: {
9
18
  "react-hooks/exhaustive-deps": "error",
10
19
 
@@ -116,4 +125,4 @@ module.exports = {
116
125
  version: "18",
117
126
  },
118
127
  },
119
- };
128
+ });
@@ -1,5 +1,10 @@
1
- module.exports = {
2
- plugins: ["regexp"],
1
+ import regexPlugin from "eslint-plugin-regexp";
2
+ import tseslint from "typescript-eslint";
3
+
4
+ export default tseslint.config({
5
+ plugins: {
6
+ regexp: regexPlugin,
7
+ },
3
8
  rules: {
4
9
  "regexp/confusing-quantifier": "error",
5
10
 
@@ -25,7 +30,7 @@ module.exports = {
25
30
 
26
31
  "regexp/no-contradiction-with-assertion": "error",
27
32
 
28
- // eslint-disable-next-line sort-keys
33
+
29
34
  "no-control-regex": "off",
30
35
  "regexp/no-control-character": "error",
31
36
 
@@ -44,7 +49,7 @@ module.exports = {
44
49
 
45
50
  "regexp/no-empty-capturing-group": "error",
46
51
 
47
- // eslint-disable-next-line sort-keys
52
+
48
53
  "no-empty-character-class": "off",
49
54
  "regexp/no-empty-character-class": "error",
50
55
 
@@ -58,7 +63,7 @@ module.exports = {
58
63
 
59
64
  "regexp/no-extra-lookaround-assertions": "error",
60
65
 
61
- // eslint-disable-next-line sort-keys
66
+
62
67
  "no-invalid-regexp": "off",
63
68
  "regexp/no-invalid-regexp": "error",
64
69
 
@@ -73,7 +78,7 @@ module.exports = {
73
78
  { reportBacktrackingEnds: true },
74
79
  ],
75
80
 
76
- // eslint-disable-next-line sort-keys
81
+
77
82
  "no-misleading-character-class": "off",
78
83
  "regexp/no-misleading-unicode-character": ["error", { fixable: false }],
79
84
 
@@ -107,7 +112,7 @@ module.exports = {
107
112
 
108
113
  "regexp/no-useless-assertions": "error",
109
114
 
110
- // eslint-disable-next-line sort-keys
115
+
111
116
  "no-useless-backreference": "off",
112
117
  "regexp/no-useless-backreference": "error",
113
118
 
@@ -152,7 +157,7 @@ module.exports = {
152
157
 
153
158
  "regexp/prefer-named-backreference": "error",
154
159
 
155
- // eslint-disable-next-line sort-keys
160
+
156
161
  "prefer-named-capture-group": "off",
157
162
  "regexp/prefer-named-capture-group": "warn",
158
163
 
@@ -185,7 +190,7 @@ module.exports = {
185
190
  "regexp/prefer-w": "error",
186
191
 
187
192
  "require-unicode-regexp": "off",
188
- // eslint-disable-next-line sort-keys
193
+
189
194
  "regexp/require-unicode-regexp": "error",
190
195
 
191
196
  // Maybe in the future?
@@ -205,4 +210,4 @@ module.exports = {
205
210
 
206
211
  "regexp/use-ignore-case": "error",
207
212
  },
208
- };
213
+ });
@@ -1,4 +1,6 @@
1
- module.exports = {
1
+ import tseslint from "typescript-eslint";
2
+
3
+ export default tseslint.config({
2
4
  rules: {
3
5
  // https://jc-verse.github.io/js-style-guide/typescript/type-checked#await-thenable
4
6
  "@typescript-eslint/await-thenable": "error",
@@ -121,4 +123,4 @@ module.exports = {
121
123
  // Not very useful in practice... A lot of false-positives
122
124
  "@typescript-eslint/unbound-method": "off",
123
125
  },
124
- };
126
+ });
@@ -0,0 +1,360 @@
1
+ import tseslintPlugin from "@typescript-eslint/eslint-plugin";
2
+ import tseslint from "typescript-eslint";
3
+
4
+ export default tseslint.config(
5
+ {
6
+ plugins: {
7
+ "@typescript-eslint": tseslintPlugin,
8
+ },
9
+ rules: {
10
+ // https://jc-verse.github.io/js-style-guide/typescript/base#adjacent-overload-signatures
11
+ "@typescript-eslint/adjacent-overload-signatures": "error",
12
+
13
+ // I wish this rule can be more flexible to allow T[] where T is a union
14
+ // https://jc-verse.github.io/js-style-guide/typescript/base#adjacent-overload-signatures
15
+ "@typescript-eslint/array-type": [
16
+ "error",
17
+ { default: "array", readonly: "array" },
18
+ ],
19
+
20
+ // https://jc-verse.github.io/js-style-guide/typescript/base#ban-ts-comment
21
+ "@typescript-eslint/ban-ts-comment": [
22
+ "error",
23
+ {
24
+ minimumDescriptionLength: 3,
25
+ "ts-check": false,
26
+ "ts-expect-error": "allow-with-description",
27
+ "ts-ignore": true,
28
+ "ts-nocheck": true,
29
+ },
30
+ ],
31
+
32
+ // We've never used TSLint anyway
33
+ // https://jc-verse.github.io/js-style-guide/typescript/base#ban-tslint-comment
34
+ "@typescript-eslint/ban-tslint-comment": "error",
35
+
36
+ // https://jc-verse.github.io/js-style-guide/typescript/base#ban-types
37
+ "@typescript-eslint/ban-types": [
38
+ "error",
39
+ {
40
+ extendDefaults: true,
41
+ types: {
42
+ "{}": false,
43
+ },
44
+ },
45
+ ],
46
+
47
+ // https://jc-verse.github.io/js-style-guide/typescript/base#class-literal-property-style
48
+ "@typescript-eslint/class-literal-property-style": ["warn", "getters"],
49
+
50
+ // We turn off the base rule too
51
+ "@typescript-eslint/class-methods-use-this": "off",
52
+
53
+ // https://jc-verse.github.io/js-style-guide/typescript/base#consistent-generic-constructors
54
+ "@typescript-eslint/consistent-generic-constructors": [
55
+ "error",
56
+ "constructor",
57
+ ],
58
+
59
+ // https://jc-verse.github.io/js-style-guide/typescript/base#consistent-indexed-object-style
60
+ "@typescript-eslint/consistent-indexed-object-style": [
61
+ "error",
62
+ "index-signature",
63
+ ],
64
+
65
+ // https://jc-verse.github.io/js-style-guide/typescript/base#consistent-type-assertions
66
+ "@typescript-eslint/consistent-type-assertions": [
67
+ "error",
68
+ { assertionStyle: "as", objectLiteralTypeAssertions: "allow" },
69
+ ],
70
+
71
+ // We sometimes allow declaration merging
72
+ // https://jc-verse.github.io/js-style-guide/typescript/base#consistent-type-definitions
73
+ "@typescript-eslint/consistent-type-definitions": "off",
74
+
75
+ // https://jc-verse.github.io/js-style-guide/typescript/base#consistent-type-imports
76
+ "@typescript-eslint/consistent-type-imports": [
77
+ "error",
78
+ {
79
+ disallowTypeAnnotations: false,
80
+ fixStyle: "inline-type-imports",
81
+ prefer: "type-imports",
82
+ },
83
+ ],
84
+
85
+ // https://jc-verse.github.io/js-style-guide/typescript/base#default-param-last
86
+ "@typescript-eslint/default-param-last": "error",
87
+
88
+ // No—too verbose
89
+ // https://jc-verse.github.io/js-style-guide/typescript/base#explicit-function-return-type
90
+ "@typescript-eslint/explicit-function-return-type": "off",
91
+
92
+ // Defaulting to public makes sense
93
+ // https://jc-verse.github.io/js-style-guide/typescript/base#explicit-member-accessibility
94
+ "@typescript-eslint/explicit-member-accessibility": "off",
95
+
96
+ // https://jc-verse.github.io/js-style-guide/typescript/base#explicit-module-boundary-types
97
+ "@typescript-eslint/explicit-module-boundary-types": "warn",
98
+
99
+ "init-declarations": "off",
100
+ // https://jc-verse.github.io/js-style-guide/typescript/base#init-declarations
101
+
102
+ "@typescript-eslint/init-declarations": ["error", "always"],
103
+
104
+ // We turn off the base rule too
105
+ "@typescript-eslint/max-params": "off",
106
+
107
+ // TODO figure out how this should be configured
108
+ "@typescript-eslint/member-ordering": 0,
109
+
110
+ // https://jc-verse.github.io/js-style-guide/typescript/base#method-signature-style
111
+ "@typescript-eslint/method-signature-style": ["error", "property"],
112
+
113
+ // TODO
114
+ "@typescript-eslint/naming-convention": 0,
115
+
116
+ // https://jc-verse.github.io/js-style-guide/typescript/base#no-array-constructor
117
+ "@typescript-eslint/no-array-constructor": "off",
118
+
119
+ // https://jc-verse.github.io/js-style-guide/typescript/base#no-confusing-non-null-assertion
120
+ "@typescript-eslint/no-confusing-non-null-assertion": "error",
121
+
122
+ "no-dupe-class-members": "off",
123
+ // https://jc-verse.github.io/js-style-guide/typescript/base#no-dupe-class-members
124
+
125
+ "@typescript-eslint/no-dupe-class-members": "error",
126
+
127
+ // This can be useful for dynamic object transformations
128
+ // https://jc-verse.github.io/js-style-guide/typescript/base#no-dynamic-delete
129
+ "@typescript-eslint/no-dynamic-delete": "off",
130
+
131
+ // We turn off the base rule too
132
+ "@typescript-eslint/no-empty-function": "off",
133
+
134
+ // https://jc-verse.github.io/js-style-guide/typescript/base#no-empty-interface
135
+ "@typescript-eslint/no-empty-interface": [
136
+ "error",
137
+ { allowSingleExtends: true },
138
+ ],
139
+
140
+ // https://jc-verse.github.io/js-style-guide/typescript/base#no-explicit-any
141
+ "@typescript-eslint/no-explicit-any": "warn",
142
+
143
+ // https://jc-verse.github.io/js-style-guide/typescript/base#no-extra-non-null-assertion
144
+ "@typescript-eslint/no-extra-non-null-assertion": "error",
145
+
146
+ // https://jc-verse.github.io/js-style-guide/typescript/base#no-extraneous-class
147
+ "@typescript-eslint/no-extraneous-class": [
148
+ "warn",
149
+ {
150
+ allowConstructorOnly: false,
151
+ allowEmpty: false,
152
+ allowStaticOnly: false,
153
+ allowWithDecorator: false,
154
+ },
155
+ ],
156
+
157
+ // https://jc-verse.github.io/js-style-guide/typescript/base#no-import-type-side-effects
158
+ "@typescript-eslint/no-import-type-side-effects": "error",
159
+
160
+ // Annotating parameters makes the code more uniform
161
+ "@typescript-eslint/no-inferrable-types": [
162
+ "error",
163
+ { ignoreParameters: true },
164
+ ],
165
+
166
+ // https://jc-verse.github.io/js-style-guide/typescript/base#no-invalid-this
167
+ "@typescript-eslint/no-invalid-this": "off",
168
+
169
+ // https://jc-verse.github.io/js-style-guide/typescript/base#no-invalid-void-type
170
+ "@typescript-eslint/no-invalid-void-type": [
171
+ "warn",
172
+ { allowAsThisParameter: false, allowInGenericTypeArguments: true },
173
+ ],
174
+
175
+ // We turn off the base rule too
176
+ "@typescript-eslint/no-loop-func": "off",
177
+
178
+ // To be deprecated
179
+ "@typescript-eslint/no-loss-of-precision": "off",
180
+
181
+ // We turn off the base rule too
182
+ "@typescript-eslint/no-magic-numbers": "off",
183
+
184
+ // https://jc-verse.github.io/js-style-guide/typescript/base#no-misused-new
185
+ "@typescript-eslint/no-misused-new": "error",
186
+
187
+ // Use namespaces to organize your code
188
+ // https://jc-verse.github.io/js-style-guide/typescript/base#no-namespace
189
+ "@typescript-eslint/no-namespace": "off",
190
+
191
+ // https://jc-verse.github.io/js-style-guide/typescript/base#no-non-null-asserted-nullish-coalescing
192
+ "@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error",
193
+
194
+ // https://jc-verse.github.io/js-style-guide/typescript/base#no-non-null-asserted-optional-chain
195
+ "@typescript-eslint/no-non-null-asserted-optional-chain": "error",
196
+
197
+ // It's useful.
198
+ // https://jc-verse.github.io/js-style-guide/typescript/base#no-non-null-assertion
199
+ "@typescript-eslint/no-non-null-assertion": "off",
200
+
201
+ "no-redeclare": "off",
202
+ // https://jc-verse.github.io/js-style-guide/typescript/base#no-redeclare
203
+
204
+ "@typescript-eslint/no-redeclare": [
205
+ "error",
206
+ {
207
+ builtinGlobals: true,
208
+ // We also allow redeclaring between variables and types although the
209
+ // rule doesn't allow that
210
+ ignoreDeclarationMerge: true,
211
+ },
212
+ ],
213
+
214
+ // https://jc-verse.github.io/js-style-guide/typescript/base#no-require-imports
215
+ "@typescript-eslint/no-require-imports": "error",
216
+
217
+ "no-shadow": "off",
218
+ // https://jc-verse.github.io/js-style-guide/typescript/base#no-shadow
219
+
220
+ "@typescript-eslint/no-shadow": [
221
+ "warn",
222
+ {
223
+ allow: [],
224
+ builtinGlobals: false,
225
+ hoist: "all",
226
+ ignoreFunctionTypeParameterNameValueShadow: false,
227
+ ignoreOnInitialization: true,
228
+ ignoreTypeValueShadow: true,
229
+ },
230
+ ],
231
+
232
+ // https://jc-verse.github.io/js-style-guide/typescript/base#no-this-alias
233
+ "@typescript-eslint/no-this-alias": [
234
+ "warn",
235
+ { allowDestructuring: true, allowedNames: [] },
236
+ ],
237
+
238
+ // Deprecated
239
+ "@typescript-eslint/no-type-alias": "off",
240
+
241
+ // https://jc-verse.github.io/js-style-guide/typescript/base#no-unnecessary-type-constraint
242
+ "@typescript-eslint/no-unnecessary-type-constraint": "error",
243
+
244
+ "no-unused-expressions": "off",
245
+ // https://jc-verse.github.io/js-style-guide/typescript/base#no-unused-expressions
246
+
247
+ "@typescript-eslint/no-unused-expressions": [
248
+ "error",
249
+ {
250
+ allowShortCircuit: true,
251
+ allowTaggedTemplates: true,
252
+ allowTernary: true,
253
+ enforceForJSX: true,
254
+ },
255
+ ],
256
+
257
+ "no-unused-vars": "off",
258
+ // https://jc-verse.github.io/js-style-guide/typescript/base#no-unused-vars
259
+
260
+ "@typescript-eslint/no-unused-vars": [
261
+ "error",
262
+ {
263
+ args: "after-used",
264
+ caughtErrors: "all",
265
+ ignoreRestSiblings: true,
266
+ vars: "all",
267
+ },
268
+ ],
269
+
270
+ "no-use-before-define": "off",
271
+
272
+ "@typescript-eslint/no-use-before-define": [
273
+ "error",
274
+ {
275
+ allowNamedExports: true,
276
+ classes: true,
277
+ enums: false,
278
+ functions: false,
279
+ ignoreTypeReferences: true,
280
+ typedefs: false,
281
+ variables: true,
282
+ },
283
+ ],
284
+
285
+ "no-useless-constructor": "off",
286
+
287
+ "@typescript-eslint/no-useless-constructor": "error",
288
+
289
+ // https://jc-verse.github.io/js-style-guide/typescript/base#no-useless-empty-export
290
+ "@typescript-eslint/no-useless-empty-export": "error",
291
+
292
+ // https://jc-verse.github.io/js-style-guide/typescript/base#no-var-requires
293
+ "@typescript-eslint/no-var-requires": "error",
294
+
295
+ // https://jc-verse.github.io/js-style-guide/typescript/base#parameter-properties
296
+ "@typescript-eslint/parameter-properties": [
297
+ "warn",
298
+ { allow: [], prefer: "class-property" },
299
+ ],
300
+
301
+ // https://jc-verse.github.io/js-style-guide/typescript/base#prefer-as-const
302
+ "@typescript-eslint/prefer-as-const": "error",
303
+
304
+ // https://jc-verse.github.io/js-style-guide/typescript/base#prefer-enum-initializers
305
+ "@typescript-eslint/prefer-enum-initializers": "error",
306
+
307
+ // https://jc-verse.github.io/js-style-guide/typescript/base#prefer-for-of
308
+ "@typescript-eslint/prefer-for-of": "error",
309
+
310
+ // https://jc-verse.github.io/js-style-guide/typescript/base#prefer-function-type
311
+ "@typescript-eslint/prefer-function-type": "error",
312
+
313
+ // https://jc-verse.github.io/js-style-guide/typescript/base#prefer-literal-enum-member
314
+ "@typescript-eslint/prefer-literal-enum-member": [
315
+ "warn",
316
+ { allowBitwiseExpressions: true },
317
+ ],
318
+
319
+ // https://jc-verse.github.io/js-style-guide/typescript/base#prefer-namespace-keyword
320
+ "@typescript-eslint/prefer-namespace-keyword": "error",
321
+
322
+ // https://jc-verse.github.io/js-style-guide/typescript/base#prefer-ts-expect-error
323
+ "@typescript-eslint/prefer-ts-expect-error": "error",
324
+
325
+ "@typescript-eslint/sort-type-constituents": 0,
326
+
327
+ // https://jc-verse.github.io/js-style-guide/typescript/base#triple-slash-reference
328
+ "@typescript-eslint/triple-slash-reference": [
329
+ "error",
330
+ { lib: "never", path: "never", types: "prefer-import" },
331
+ ],
332
+
333
+ // We use strict TS options instead.
334
+ // https://jc-verse.github.io/js-style-guide/typescript/base#typedef
335
+ "@typescript-eslint/typedef": "off",
336
+
337
+ // https://jc-verse.github.io/js-style-guide/typescript/base#unified-signatures
338
+ "@typescript-eslint/unified-signatures": [
339
+ "warn",
340
+ { ignoreDifferentlyNamedParameters: false },
341
+ ],
342
+ },
343
+ },
344
+ {
345
+ files: ["**/*.{js,cjs,mjs,jsx}"],
346
+ rules: {
347
+ "@typescript-eslint/default-param-last": "off",
348
+ "@typescript-eslint/explicit-module-boundary-types": "off",
349
+ "@typescript-eslint/no-require-imports": "off",
350
+ "@typescript-eslint/no-var-requires": "off",
351
+ },
352
+ },
353
+ {
354
+ files: ["**/*.{ts,tsx,cts,mts}"],
355
+ rules: {
356
+ // Use TypeScript's checker instead
357
+ "no-undef": "off",
358
+ },
359
+ },
360
+ );
package/tsconfig.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "tsconfig-jc",
3
+ "compilerOptions": {
4
+ "declaration": true,
5
+ "rootDir": "./src",
6
+ "outDir": "./dist"
7
+ }
8
+ }
package/index.js DELETED
@@ -1,17 +0,0 @@
1
- module.exports = {
2
- root: true,
3
- extends: [
4
- "prettier",
5
- "./rules/base.js",
6
- "./rules/regex.js",
7
- "./rules/typescript.js",
8
- "./rules/import.js",
9
- "./rules/react.js",
10
- "./rules/jsx.js",
11
- // Not included by default:
12
- // "./rules/typescript-typecheck.js",
13
- // "./rules/node.js",
14
- // "./rules/react-class-comps.js",
15
- // "./rules/react-prop-types.js",
16
- ],
17
- };
@@ -1,362 +0,0 @@
1
- module.exports = {
2
- globals: {
3
- JSX: true,
4
- },
5
- overrides: [
6
- {
7
- files: ["**/*.{js,cjs,mjs,jsx}"],
8
- rules: {
9
- "@typescript-eslint/default-param-last": "off",
10
- "@typescript-eslint/explicit-module-boundary-types": "off",
11
- "@typescript-eslint/no-require-imports": "off",
12
- "@typescript-eslint/no-var-requires": "off",
13
- },
14
- },
15
- {
16
- files: ["**/*.{ts,tsx,cts,mts}"],
17
- rules: {
18
- // Use TypeScript's checker instead
19
- "no-undef": "off",
20
- },
21
- },
22
- ],
23
- parser: "@typescript-eslint/parser",
24
- parserOptions: {
25
- sourceType: "module",
26
- },
27
- plugins: ["@typescript-eslint"],
28
- rules: {
29
- // https://jc-verse.github.io/js-style-guide/typescript/base#adjacent-overload-signatures
30
- "@typescript-eslint/adjacent-overload-signatures": "error",
31
-
32
- // I wish this rule can be more flexible to allow T[] where T is a union
33
- // https://jc-verse.github.io/js-style-guide/typescript/base#adjacent-overload-signatures
34
- "@typescript-eslint/array-type": [
35
- "error",
36
- { default: "array", readonly: "array" },
37
- ],
38
-
39
- // https://jc-verse.github.io/js-style-guide/typescript/base#ban-ts-comment
40
- "@typescript-eslint/ban-ts-comment": [
41
- "error",
42
- {
43
- minimumDescriptionLength: 3,
44
- "ts-check": false,
45
- "ts-expect-error": "allow-with-description",
46
- "ts-ignore": true,
47
- "ts-nocheck": true,
48
- },
49
- ],
50
-
51
- // We've never used TSLint anyway
52
- // https://jc-verse.github.io/js-style-guide/typescript/base#ban-tslint-comment
53
- "@typescript-eslint/ban-tslint-comment": "error",
54
-
55
- // https://jc-verse.github.io/js-style-guide/typescript/base#ban-types
56
- "@typescript-eslint/ban-types": [
57
- "error",
58
- {
59
- extendDefaults: true,
60
- types: {
61
- "{}": false,
62
- },
63
- },
64
- ],
65
-
66
- // https://jc-verse.github.io/js-style-guide/typescript/base#class-literal-property-style
67
- "@typescript-eslint/class-literal-property-style": ["warn", "getters"],
68
-
69
- // We turn off the base rule too
70
- "@typescript-eslint/class-methods-use-this": "off",
71
-
72
- // https://jc-verse.github.io/js-style-guide/typescript/base#consistent-generic-constructors
73
- "@typescript-eslint/consistent-generic-constructors": [
74
- "error",
75
- "constructor",
76
- ],
77
-
78
- // https://jc-verse.github.io/js-style-guide/typescript/base#consistent-indexed-object-style
79
- "@typescript-eslint/consistent-indexed-object-style": [
80
- "error",
81
- "index-signature",
82
- ],
83
-
84
- // https://jc-verse.github.io/js-style-guide/typescript/base#consistent-type-assertions
85
- "@typescript-eslint/consistent-type-assertions": [
86
- "error",
87
- { assertionStyle: "as", objectLiteralTypeAssertions: "allow" },
88
- ],
89
-
90
- // We sometimes allow declaration merging
91
- // https://jc-verse.github.io/js-style-guide/typescript/base#consistent-type-definitions
92
- "@typescript-eslint/consistent-type-definitions": "off",
93
-
94
- // https://jc-verse.github.io/js-style-guide/typescript/base#consistent-type-imports
95
- "@typescript-eslint/consistent-type-imports": [
96
- "error",
97
- {
98
- disallowTypeAnnotations: false,
99
- fixStyle: "inline-type-imports",
100
- prefer: "type-imports",
101
- },
102
- ],
103
-
104
- // https://jc-verse.github.io/js-style-guide/typescript/base#default-param-last
105
- "@typescript-eslint/default-param-last": "error",
106
-
107
- // No—too verbose
108
- // https://jc-verse.github.io/js-style-guide/typescript/base#explicit-function-return-type
109
- "@typescript-eslint/explicit-function-return-type": "off",
110
-
111
- // Defaulting to public makes sense
112
- // https://jc-verse.github.io/js-style-guide/typescript/base#explicit-member-accessibility
113
- "@typescript-eslint/explicit-member-accessibility": "off",
114
-
115
- // https://jc-verse.github.io/js-style-guide/typescript/base#explicit-module-boundary-types
116
- "@typescript-eslint/explicit-module-boundary-types": "warn",
117
-
118
- "init-declarations": "off",
119
- // https://jc-verse.github.io/js-style-guide/typescript/base#init-declarations
120
- // eslint-disable-next-line sort-keys
121
- "@typescript-eslint/init-declarations": ["error", "always"],
122
-
123
- // We turn off the base rule too
124
- "@typescript-eslint/max-params": "off",
125
-
126
- // TODO figure out how this should be configured
127
- "@typescript-eslint/member-ordering": 0,
128
-
129
- // https://jc-verse.github.io/js-style-guide/typescript/base#method-signature-style
130
- "@typescript-eslint/method-signature-style": ["error", "property"],
131
-
132
- // TODO
133
- "@typescript-eslint/naming-convention": 0,
134
-
135
- // https://jc-verse.github.io/js-style-guide/typescript/base#no-array-constructor
136
- "@typescript-eslint/no-array-constructor": "off",
137
-
138
- // https://jc-verse.github.io/js-style-guide/typescript/base#no-confusing-non-null-assertion
139
- "@typescript-eslint/no-confusing-non-null-assertion": "error",
140
-
141
- "no-dupe-class-members": "off",
142
- // https://jc-verse.github.io/js-style-guide/typescript/base#no-dupe-class-members
143
- // eslint-disable-next-line sort-keys
144
- "@typescript-eslint/no-dupe-class-members": "error",
145
-
146
- // This can be useful for dynamic object transformations
147
- // https://jc-verse.github.io/js-style-guide/typescript/base#no-dynamic-delete
148
- "@typescript-eslint/no-dynamic-delete": "off",
149
-
150
- // We turn off the base rule too
151
- "@typescript-eslint/no-empty-function": "off",
152
-
153
- // https://jc-verse.github.io/js-style-guide/typescript/base#no-empty-interface
154
- "@typescript-eslint/no-empty-interface": [
155
- "error",
156
- { allowSingleExtends: true },
157
- ],
158
-
159
- // https://jc-verse.github.io/js-style-guide/typescript/base#no-explicit-any
160
- "@typescript-eslint/no-explicit-any": "warn",
161
-
162
- // https://jc-verse.github.io/js-style-guide/typescript/base#no-extra-non-null-assertion
163
- "@typescript-eslint/no-extra-non-null-assertion": "error",
164
-
165
- // https://jc-verse.github.io/js-style-guide/typescript/base#no-extraneous-class
166
- "@typescript-eslint/no-extraneous-class": [
167
- "warn",
168
- {
169
- allowConstructorOnly: false,
170
- allowEmpty: false,
171
- allowStaticOnly: false,
172
- allowWithDecorator: false,
173
- },
174
- ],
175
-
176
- // https://jc-verse.github.io/js-style-guide/typescript/base#no-import-type-side-effects
177
- "@typescript-eslint/no-import-type-side-effects": "error",
178
-
179
- // Annotating parameters makes the code more uniform
180
- "@typescript-eslint/no-inferrable-types": [
181
- "error",
182
- { ignoreParameters: true },
183
- ],
184
-
185
- // https://jc-verse.github.io/js-style-guide/typescript/base#no-invalid-this
186
- "@typescript-eslint/no-invalid-this": "off",
187
-
188
- // https://jc-verse.github.io/js-style-guide/typescript/base#no-invalid-void-type
189
- "@typescript-eslint/no-invalid-void-type": [
190
- "warn",
191
- { allowAsThisParameter: false, allowInGenericTypeArguments: true },
192
- ],
193
-
194
- // We turn off the base rule too
195
- "@typescript-eslint/no-loop-func": "off",
196
-
197
- // To be deprecated
198
- "@typescript-eslint/no-loss-of-precision": "off",
199
-
200
- // We turn off the base rule too
201
- "@typescript-eslint/no-magic-numbers": "off",
202
-
203
- // https://jc-verse.github.io/js-style-guide/typescript/base#no-misused-new
204
- "@typescript-eslint/no-misused-new": "error",
205
-
206
- // Use namespaces to organize your code
207
- // https://jc-verse.github.io/js-style-guide/typescript/base#no-namespace
208
- "@typescript-eslint/no-namespace": "off",
209
-
210
- // https://jc-verse.github.io/js-style-guide/typescript/base#no-non-null-asserted-nullish-coalescing
211
- "@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error",
212
-
213
- // https://jc-verse.github.io/js-style-guide/typescript/base#no-non-null-asserted-optional-chain
214
- "@typescript-eslint/no-non-null-asserted-optional-chain": "error",
215
-
216
- // It's useful.
217
- // https://jc-verse.github.io/js-style-guide/typescript/base#no-non-null-assertion
218
- "@typescript-eslint/no-non-null-assertion": "off",
219
-
220
- "no-redeclare": "off",
221
- // https://jc-verse.github.io/js-style-guide/typescript/base#no-redeclare
222
- // eslint-disable-next-line sort-keys
223
- "@typescript-eslint/no-redeclare": [
224
- "error",
225
- {
226
- builtinGlobals: true,
227
- // We also allow redeclaring between variables and types although the
228
- // rule doesn't allow that
229
- ignoreDeclarationMerge: true,
230
- },
231
- ],
232
-
233
- // https://jc-verse.github.io/js-style-guide/typescript/base#no-require-imports
234
- "@typescript-eslint/no-require-imports": "error",
235
-
236
- "no-shadow": "off",
237
- // https://jc-verse.github.io/js-style-guide/typescript/base#no-shadow
238
- // eslint-disable-next-line sort-keys
239
- "@typescript-eslint/no-shadow": [
240
- "warn",
241
- {
242
- allow: [],
243
- builtinGlobals: false,
244
- hoist: "all",
245
- ignoreFunctionTypeParameterNameValueShadow: false,
246
- ignoreOnInitialization: true,
247
- ignoreTypeValueShadow: true,
248
- },
249
- ],
250
-
251
- // https://jc-verse.github.io/js-style-guide/typescript/base#no-this-alias
252
- "@typescript-eslint/no-this-alias": [
253
- "warn",
254
- { allowDestructuring: true, allowedNames: [] },
255
- ],
256
-
257
- // Deprecated
258
- "@typescript-eslint/no-type-alias": "off",
259
-
260
- // https://jc-verse.github.io/js-style-guide/typescript/base#no-unnecessary-type-constraint
261
- "@typescript-eslint/no-unnecessary-type-constraint": "error",
262
-
263
- "no-unused-expressions": "off",
264
- // https://jc-verse.github.io/js-style-guide/typescript/base#no-unused-expressions
265
- // eslint-disable-next-line sort-keys
266
- "@typescript-eslint/no-unused-expressions": [
267
- "error",
268
- {
269
- allowShortCircuit: true,
270
- allowTaggedTemplates: true,
271
- allowTernary: true,
272
- enforceForJSX: true,
273
- },
274
- ],
275
-
276
- "no-unused-vars": "off",
277
- // https://jc-verse.github.io/js-style-guide/typescript/base#no-unused-vars
278
- // eslint-disable-next-line sort-keys
279
- "@typescript-eslint/no-unused-vars": [
280
- "error",
281
- {
282
- args: "after-used",
283
- caughtErrors: "all",
284
- ignoreRestSiblings: true,
285
- vars: "all",
286
- },
287
- ],
288
-
289
- "no-use-before-define": "off",
290
- // eslint-disable-next-line sort-keys
291
- "@typescript-eslint/no-use-before-define": [
292
- "error",
293
- {
294
- allowNamedExports: true,
295
- classes: true,
296
- enums: false,
297
- functions: false,
298
- ignoreTypeReferences: true,
299
- typedefs: false,
300
- variables: true,
301
- },
302
- ],
303
-
304
- "no-useless-constructor": "off",
305
- // eslint-disable-next-line sort-keys
306
- "@typescript-eslint/no-useless-constructor": "error",
307
-
308
- // https://jc-verse.github.io/js-style-guide/typescript/base#no-useless-empty-export
309
- "@typescript-eslint/no-useless-empty-export": "error",
310
-
311
- // https://jc-verse.github.io/js-style-guide/typescript/base#no-var-requires
312
- "@typescript-eslint/no-var-requires": "error",
313
-
314
- // https://jc-verse.github.io/js-style-guide/typescript/base#parameter-properties
315
- "@typescript-eslint/parameter-properties": [
316
- "warn",
317
- { allow: [], prefer: "class-property" },
318
- ],
319
-
320
- // https://jc-verse.github.io/js-style-guide/typescript/base#prefer-as-const
321
- "@typescript-eslint/prefer-as-const": "error",
322
-
323
- // https://jc-verse.github.io/js-style-guide/typescript/base#prefer-enum-initializers
324
- "@typescript-eslint/prefer-enum-initializers": "error",
325
-
326
- // https://jc-verse.github.io/js-style-guide/typescript/base#prefer-for-of
327
- "@typescript-eslint/prefer-for-of": "error",
328
-
329
- // https://jc-verse.github.io/js-style-guide/typescript/base#prefer-function-type
330
- "@typescript-eslint/prefer-function-type": "error",
331
-
332
- // https://jc-verse.github.io/js-style-guide/typescript/base#prefer-literal-enum-member
333
- "@typescript-eslint/prefer-literal-enum-member": [
334
- "warn",
335
- { allowBitwiseExpressions: true },
336
- ],
337
-
338
- // https://jc-verse.github.io/js-style-guide/typescript/base#prefer-namespace-keyword
339
- "@typescript-eslint/prefer-namespace-keyword": "error",
340
-
341
- // https://jc-verse.github.io/js-style-guide/typescript/base#prefer-ts-expect-error
342
- "@typescript-eslint/prefer-ts-expect-error": "error",
343
-
344
- "@typescript-eslint/sort-type-constituents": 0,
345
-
346
- // https://jc-verse.github.io/js-style-guide/typescript/base#triple-slash-reference
347
- "@typescript-eslint/triple-slash-reference": [
348
- "error",
349
- { lib: "never", path: "never", types: "prefer-import" },
350
- ],
351
-
352
- // We use strict TS options instead.
353
- // https://jc-verse.github.io/js-style-guide/typescript/base#typedef
354
- "@typescript-eslint/typedef": "off",
355
-
356
- // https://jc-verse.github.io/js-style-guide/typescript/base#unified-signatures
357
- "@typescript-eslint/unified-signatures": [
358
- "warn",
359
- { ignoreDifferentlyNamedParameters: false },
360
- ],
361
- },
362
- };