@wistia/eslint-config 0.9.3 → 0.10.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/configs/eslint/default.js +5 -5
- package/configs/eslint/react.js +0 -2
- package/configs/eslint/typescript.js +27 -0
- package/package.json +4 -2
- package/rules/eslint/imports.js +3 -1
- package/rules/eslint/react.js +3 -2
- package/rules/eslint/typescript-imports.js +21 -0
- package/rules/eslint/typescript.js +8 -0
|
@@ -3,11 +3,6 @@ require('@rushstack/eslint-patch/modern-module-resolution');
|
|
|
3
3
|
module.exports = {
|
|
4
4
|
parser: '@babel/eslint-parser',
|
|
5
5
|
|
|
6
|
-
env: {
|
|
7
|
-
es2022: true,
|
|
8
|
-
node: true,
|
|
9
|
-
},
|
|
10
|
-
|
|
11
6
|
parserOptions: {
|
|
12
7
|
sourceType: 'module',
|
|
13
8
|
ecmaFeatures: {
|
|
@@ -17,6 +12,11 @@ module.exports = {
|
|
|
17
12
|
ecmaVersion: 13,
|
|
18
13
|
},
|
|
19
14
|
|
|
15
|
+
env: {
|
|
16
|
+
es2022: true,
|
|
17
|
+
node: true,
|
|
18
|
+
},
|
|
19
|
+
|
|
20
20
|
extends: [
|
|
21
21
|
'../../rules/eslint/best-practices',
|
|
22
22
|
'../../rules/eslint/errors',
|
package/configs/eslint/react.js
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require('@rushstack/eslint-patch/modern-module-resolution');
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
parser: '@typescript-eslint/parser',
|
|
5
|
+
|
|
6
|
+
parserOptions: {
|
|
7
|
+
sourceType: 'module',
|
|
8
|
+
ecmaVersion: 13,
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
env: {
|
|
12
|
+
es2022: true,
|
|
13
|
+
node: true,
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
extends: [
|
|
17
|
+
'../../rules/eslint/best-practices',
|
|
18
|
+
'../../rules/eslint/errors',
|
|
19
|
+
'../../rules/eslint/es6',
|
|
20
|
+
'../../rules/eslint/node',
|
|
21
|
+
'../../rules/eslint/imports',
|
|
22
|
+
'../../rules/eslint/style',
|
|
23
|
+
'../../rules/eslint/variables',
|
|
24
|
+
'../../rules/eslint/typescript',
|
|
25
|
+
'../../rules/eslint/typescript-imports',
|
|
26
|
+
].map(require.resolve),
|
|
27
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wistia/eslint-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Wistia's ESLint configurations",
|
|
5
5
|
"main": "react.js",
|
|
6
6
|
"exports": {
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
"./stylelint": "./configs/stylelint/default.js",
|
|
16
16
|
"./stylelint/scss": "./configs/stylelint/scss.js",
|
|
17
17
|
"./stylelint/styled-components": "./configs/stylelint/styled-components.js",
|
|
18
|
-
"./testing-library": "./configs/eslint/testing-library.js"
|
|
18
|
+
"./testing-library": "./configs/eslint/testing-library.js",
|
|
19
|
+
"./typescript": "./configs/eslint/typescript.js"
|
|
19
20
|
},
|
|
20
21
|
"scripts": {
|
|
21
22
|
"lint": "eslint --fix .",
|
|
@@ -34,6 +35,7 @@
|
|
|
34
35
|
"confusing-browser-globals": "^1.0.11",
|
|
35
36
|
"eslint": "^8.20.0",
|
|
36
37
|
"eslint-config-prettier": "^8.5.0",
|
|
38
|
+
"eslint-import-resolver-typescript": "^3.3.0",
|
|
37
39
|
"eslint-plugin-better-styled-components": "^1.1.2",
|
|
38
40
|
"eslint-plugin-cypress": "^2.12.1",
|
|
39
41
|
"eslint-plugin-import": "^2.26.0",
|
package/rules/eslint/imports.js
CHANGED
|
@@ -7,7 +7,7 @@ module.exports = {
|
|
|
7
7
|
extensions: ['.js', '.mjs', '.cjs', '.json'],
|
|
8
8
|
},
|
|
9
9
|
},
|
|
10
|
-
'import/extensions': ['.js', '.jsx', '.mjs', '.cjs'],
|
|
10
|
+
'import/extensions': ['.js', '.jsx', '.ts', '.tsx', '.mjs', '.cjs'],
|
|
11
11
|
'import/core-modules': [],
|
|
12
12
|
'import/ignore': ['node_modules', '\\.(coffee|scss|css|less|svg|json)$'],
|
|
13
13
|
},
|
|
@@ -128,6 +128,8 @@ module.exports = {
|
|
|
128
128
|
js: 'never',
|
|
129
129
|
mjs: 'never',
|
|
130
130
|
jsx: 'never',
|
|
131
|
+
ts: 'never',
|
|
132
|
+
tsx: 'never',
|
|
131
133
|
},
|
|
132
134
|
],
|
|
133
135
|
|
package/rules/eslint/react.js
CHANGED
|
@@ -346,7 +346,8 @@ module.exports = {
|
|
|
346
346
|
|
|
347
347
|
// only .jsx files may have JSX
|
|
348
348
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md
|
|
349
|
-
|
|
349
|
+
// decision: include typescript extensions to allow interop
|
|
350
|
+
'react/jsx-filename-extension': ['error', { extensions: ['.jsx', '.tsx'] }],
|
|
350
351
|
|
|
351
352
|
// prevent accidental JS comments from being injected into JSX as text
|
|
352
353
|
// https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-comment-textnodes.md
|
|
@@ -628,7 +629,7 @@ module.exports = {
|
|
|
628
629
|
settings: {
|
|
629
630
|
'import/resolver': {
|
|
630
631
|
node: {
|
|
631
|
-
extensions: ['.js', '.jsx', '.json'],
|
|
632
|
+
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json'],
|
|
632
633
|
},
|
|
633
634
|
},
|
|
634
635
|
react: {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
plugins: ['import'],
|
|
3
|
+
|
|
4
|
+
rules: {
|
|
5
|
+
// turn on errors for missing imports
|
|
6
|
+
'import/no-unresolved': 'error',
|
|
7
|
+
},
|
|
8
|
+
|
|
9
|
+
settings: {
|
|
10
|
+
'import/parsers': {
|
|
11
|
+
'@typescript-eslint/parser': ['.ts', '.tsx'],
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
'import/resolver': {
|
|
15
|
+
typescript: {
|
|
16
|
+
// always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
|
|
17
|
+
alwaysTryTypes: true,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
};
|