@mlaursen/eslint-config 2.1.1 → 2.2.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 +80 -77
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,90 +1,93 @@
|
|
|
1
|
-
const confusingBrowserGlobals = require(
|
|
1
|
+
const confusingBrowserGlobals = require("confusing-browser-globals");
|
|
2
2
|
|
|
3
3
|
let react = false;
|
|
4
4
|
let isNewJsx = false;
|
|
5
5
|
try {
|
|
6
|
-
require.resolve(
|
|
6
|
+
require.resolve("react");
|
|
7
7
|
react = true;
|
|
8
|
-
isNewJsx = parseInt(require(
|
|
8
|
+
isNewJsx = parseInt(require("react").version, 10) > 16;
|
|
9
9
|
} catch (e) {}
|
|
10
10
|
|
|
11
11
|
module.exports = {
|
|
12
|
-
parser:
|
|
12
|
+
parser: "@typescript-eslint/parser",
|
|
13
13
|
parserOptions: {
|
|
14
14
|
ecmaVersion: 2018,
|
|
15
|
-
sourceType:
|
|
15
|
+
sourceType: "module",
|
|
16
16
|
},
|
|
17
17
|
extends: [
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
isNewJsx &&
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
"eslint:recommended",
|
|
19
|
+
"plugin:react/recommended",
|
|
20
|
+
"plugin:react-hooks/recommended",
|
|
21
|
+
isNewJsx && "plugin:react/jsx-runtime",
|
|
22
|
+
"plugin:import/errors",
|
|
23
|
+
"plugin:import/warnings",
|
|
24
|
+
"plugin:import/typescript",
|
|
25
|
+
"plugin:jsx-a11y/recommended",
|
|
26
|
+
"prettier",
|
|
27
27
|
].filter(Boolean),
|
|
28
|
-
plugins: [
|
|
28
|
+
plugins: ["@typescript-eslint", "jest", "jsx-a11y", "react-hooks", "tsdoc"],
|
|
29
29
|
env: {
|
|
30
30
|
es6: true,
|
|
31
31
|
node: true,
|
|
32
32
|
browser: true,
|
|
33
33
|
},
|
|
34
34
|
settings: {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
"import/extensions": [".js", ".jsx", ".ts", ".tsx", ".d.ts"],
|
|
36
|
+
"import/parsers": {
|
|
37
|
+
"@typescript-eslint/parser": [".ts", ".tsx"],
|
|
38
38
|
},
|
|
39
|
-
|
|
39
|
+
"import/resolver": {
|
|
40
40
|
node: {
|
|
41
|
-
extensions: [
|
|
41
|
+
extensions: [".js", ".jsx", ".ts", ".tsx"],
|
|
42
42
|
},
|
|
43
43
|
},
|
|
44
44
|
react: {
|
|
45
|
-
version: react ?
|
|
45
|
+
version: react ? "detect" : "17.0.0",
|
|
46
46
|
},
|
|
47
47
|
},
|
|
48
48
|
rules: {
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
"no-console": "warn",
|
|
50
|
+
"no-use-before-define": "warn",
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
"no-restricted-globals": ["error", "isFinite", "isNaN"].concat(
|
|
53
53
|
confusingBrowserGlobals
|
|
54
54
|
),
|
|
55
55
|
|
|
56
56
|
// too many false positives with aliases/root dirs
|
|
57
|
-
|
|
57
|
+
"import/no-unresolved": "off",
|
|
58
58
|
|
|
59
|
-
curly:
|
|
59
|
+
curly: "error",
|
|
60
|
+
|
|
61
|
+
"object-shorthand": ["error", "always"],
|
|
62
|
+
"no-useless-rename": ["error"],
|
|
60
63
|
},
|
|
61
64
|
overrides: [
|
|
62
65
|
{
|
|
63
|
-
files: [
|
|
64
|
-
extends: [
|
|
66
|
+
files: ["**/*.ts", "**/*.tsx"],
|
|
67
|
+
extends: ["plugin:@typescript-eslint/recommended"],
|
|
65
68
|
rules: {
|
|
66
69
|
// I want correct tsdoc syntax
|
|
67
|
-
|
|
70
|
+
"tsdoc/syntax": "warn",
|
|
68
71
|
|
|
69
|
-
|
|
72
|
+
"react/prop-types": "off",
|
|
70
73
|
|
|
71
74
|
// have to disable since it can report incorrect errors
|
|
72
|
-
|
|
75
|
+
"no-empty-function": "off",
|
|
73
76
|
|
|
74
77
|
// I prefer shorthand syntax
|
|
75
|
-
|
|
78
|
+
"@typescript-eslint/array-type": ["error", { default: "array" }],
|
|
76
79
|
|
|
77
80
|
// I prefer using `interface` over `type = {}`
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
"@typescript-eslint/consistent-type-definitions": [
|
|
82
|
+
"error",
|
|
83
|
+
"interface",
|
|
81
84
|
],
|
|
82
85
|
|
|
83
86
|
// Allow expressions to work with react hooks. Annoying to have to
|
|
84
87
|
// typedef each arrow function in a `useEffect` or `useCallback` when
|
|
85
88
|
// it can be derived.
|
|
86
|
-
|
|
87
|
-
|
|
89
|
+
"@typescript-eslint/explicit-function-return-type": [
|
|
90
|
+
"error",
|
|
88
91
|
{
|
|
89
92
|
allowExpressions: true,
|
|
90
93
|
// allow FC definitions for React
|
|
@@ -93,78 +96,78 @@ module.exports = {
|
|
|
93
96
|
],
|
|
94
97
|
|
|
95
98
|
// not a big fan of requiring unknown objects to require the index signature
|
|
96
|
-
|
|
99
|
+
"@typescript-eslint/ban-types": "off",
|
|
97
100
|
|
|
98
101
|
// This is a "better" version of the `noUnusedLocals` and
|
|
99
102
|
// `noUnusedParameters` from the tsconfig.json since it can catch
|
|
100
103
|
// unused vars in rest parameters that weren't meant to be omitted. I
|
|
101
104
|
// must manually rename to be _name so I know it was intentionally
|
|
102
105
|
// omitted
|
|
103
|
-
|
|
104
|
-
|
|
106
|
+
"@typescript-eslint/no-unused-vars": [
|
|
107
|
+
"error",
|
|
105
108
|
{
|
|
106
|
-
argsIgnorePattern:
|
|
107
|
-
varsIgnorePattern:
|
|
109
|
+
argsIgnorePattern: "^_",
|
|
110
|
+
varsIgnorePattern: "^_",
|
|
108
111
|
},
|
|
109
112
|
],
|
|
110
113
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
+
"no-use-before-define": "off",
|
|
115
|
+
"@typescript-eslint/no-use-before-define": [
|
|
116
|
+
"warn",
|
|
114
117
|
{ ignoreTypeReferences: true },
|
|
115
118
|
],
|
|
116
119
|
},
|
|
117
120
|
},
|
|
118
121
|
{
|
|
119
122
|
files: [
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
123
|
+
"src/setupTests.js",
|
|
124
|
+
"src/setupTests.ts",
|
|
125
|
+
"**/__tests__/**",
|
|
126
|
+
"**/*.test.*",
|
|
124
127
|
],
|
|
125
128
|
env: {
|
|
126
129
|
jest: true,
|
|
127
130
|
},
|
|
128
131
|
// allow for less strict rules when writing tests
|
|
129
132
|
rules: {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
133
|
+
"prefer-template": "off",
|
|
134
|
+
|
|
135
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
136
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
137
|
+
"@typescript-eslint/no-object-literal-type-assertion": "off",
|
|
138
|
+
"@typescript-eslint/no-var-requires": "off",
|
|
139
|
+
"@typescript-eslint/no-empty-function": "off",
|
|
140
|
+
"@typescript-eslint/ban-ts-comment": "off",
|
|
141
|
+
"@typescript-eslint/no-empty-function": "off",
|
|
142
|
+
|
|
143
|
+
"jsx-a11y/no-autofocus": "off",
|
|
144
|
+
"jsx-a11y/no-static-element-interactions": "off",
|
|
145
|
+
"jsx-a11y/anchor-is-valid": "off",
|
|
146
|
+
"jsx-a11y/control-has-associated-label": "off",
|
|
147
|
+
|
|
148
|
+
"react/prop-types": "off",
|
|
149
|
+
"react/display-name": "off",
|
|
150
|
+
"react/prefer-stateless-function": "off",
|
|
148
151
|
},
|
|
149
152
|
},
|
|
150
153
|
{
|
|
151
|
-
files: [
|
|
152
|
-
extends: [
|
|
154
|
+
files: ["**/__tests__/**", "**/*.test.*"],
|
|
155
|
+
extends: ["plugin:jest/recommended"],
|
|
153
156
|
rules: {
|
|
154
157
|
// it's valid to do @jest-environment or other things in tests
|
|
155
|
-
|
|
158
|
+
"tsdoc/syntax": 0,
|
|
156
159
|
},
|
|
157
160
|
},
|
|
158
161
|
{
|
|
159
|
-
files: [
|
|
162
|
+
files: ["**/*.js", "**/*.jsx"],
|
|
160
163
|
rules: {
|
|
161
|
-
|
|
162
|
-
|
|
164
|
+
"no-unused-vars": [
|
|
165
|
+
"error",
|
|
163
166
|
{
|
|
164
|
-
vars:
|
|
165
|
-
varsIgnorePattern:
|
|
166
|
-
args:
|
|
167
|
-
varsIgnorePattern:
|
|
167
|
+
vars: "all",
|
|
168
|
+
varsIgnorePattern: "^_",
|
|
169
|
+
args: "after-used",
|
|
170
|
+
varsIgnorePattern: "^_",
|
|
168
171
|
ignoreRestSiblings: true,
|
|
169
172
|
},
|
|
170
173
|
],
|
package/package.json
CHANGED