@newhighsco/eslint-config 5.2.0 → 5.4.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/eslint.config.js +107 -85
- package/package.json +1 -1
package/eslint.config.js
CHANGED
|
@@ -7,93 +7,115 @@ import json from '@eslint/json'
|
|
|
7
7
|
import { defineConfig } from 'eslint/config'
|
|
8
8
|
import cypress from 'eslint-plugin-cypress'
|
|
9
9
|
import prettierRecommended from 'eslint-plugin-prettier/recommended'
|
|
10
|
+
import simpleImportSort from 'eslint-plugin-simple-import-sort'
|
|
11
|
+
import testingLibrary from 'eslint-plugin-testing-library'
|
|
12
|
+
import globals from 'globals'
|
|
10
13
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
const ignore = existsSync(gitignore)
|
|
14
|
+
const existsDependency = async name =>
|
|
15
|
+
await import(name).then(() => true).catch(() => false)
|
|
14
16
|
|
|
15
|
-
const
|
|
16
|
-
await import(
|
|
17
|
+
const optionalDependency = async name =>
|
|
18
|
+
await import(name)
|
|
19
|
+
.then(({ default: plugin }) => plugin)
|
|
20
|
+
.catch(() => undefined)
|
|
17
21
|
|
|
18
|
-
|
|
19
|
-
[
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
const legacy = new FlatCompat().config({
|
|
23
|
+
overrides: [
|
|
24
|
+
// Javascript
|
|
25
|
+
{
|
|
26
|
+
files: ['*.?(c|m)js'],
|
|
27
|
+
extends: ['standard', 'plugin:prettier/recommended']
|
|
28
|
+
},
|
|
29
|
+
// Typescript
|
|
30
|
+
(await existsDependency('typescript')) && {
|
|
31
|
+
files: ['*.ts?(x)'],
|
|
32
|
+
extends: ['love', 'plugin:prettier/recommended'],
|
|
33
|
+
parserOptions: {
|
|
34
|
+
project: './tsconfig.json',
|
|
35
|
+
warnOnUnsupportedTypeScriptVersion: false
|
|
28
36
|
},
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
files: ['*.{js,ts,md}x'],
|
|
56
|
-
env: { browser: true },
|
|
57
|
-
extends: [
|
|
58
|
-
'standard-react',
|
|
59
|
-
'standard-jsx',
|
|
60
|
-
'plugin:prettier/recommended',
|
|
61
|
-
'plugin:jsx-a11y/recommended',
|
|
62
|
-
'plugin:mdx/recommended'
|
|
63
|
-
],
|
|
64
|
-
rules: {
|
|
65
|
-
// Overrides standard-react
|
|
66
|
-
'jsx-quotes': ['error', 'prefer-double']
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
// Storybook
|
|
70
|
-
(await hasDependency('storybook')) && {
|
|
71
|
-
files: ['*.stories.*'],
|
|
72
|
-
extends: [
|
|
73
|
-
'plugin:storybook/recommended',
|
|
74
|
-
'plugin:storybook/csf-strict'
|
|
75
|
-
],
|
|
76
|
-
rules: { 'storybook/meta-inline-properties': 'error' }
|
|
77
|
-
},
|
|
78
|
-
// Testing Library
|
|
79
|
-
{
|
|
80
|
-
files: ['*.spec.*'],
|
|
81
|
-
excludedFiles: ['*.spec.?(s)css'],
|
|
82
|
-
extends: ['plugin:testing-library/react'],
|
|
83
|
-
rules: {
|
|
84
|
-
'testing-library/no-node-access': [
|
|
85
|
-
'error',
|
|
86
|
-
{ allowContainerFirstChild: true }
|
|
87
|
-
]
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
].filter(Boolean)
|
|
91
|
-
}),
|
|
92
|
-
// JSON
|
|
93
|
-
{ files: ['**/*.json'], plugins: { json }, language: 'json/json' },
|
|
94
|
-
{ files: ['**/*.json'], ...prettierRecommended },
|
|
95
|
-
// Cypress
|
|
96
|
-
{ files: ['**/*.cy.*'], extends: [cypress.configs.recommended] },
|
|
97
|
-
ignore && includeIgnoreFile(gitignore)
|
|
37
|
+
rules: {
|
|
38
|
+
'@typescript-eslint/consistent-type-assertions': [
|
|
39
|
+
'error',
|
|
40
|
+
{ assertionStyle: 'as', objectLiteralTypeAssertions: 'allow' }
|
|
41
|
+
],
|
|
42
|
+
'@typescript-eslint/no-unsafe-argument': 'off',
|
|
43
|
+
'@typescript-eslint/prefer-nullish-coalescing': 'off',
|
|
44
|
+
'@typescript-eslint/strict-boolean-expressions': 'off'
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
// React
|
|
48
|
+
{
|
|
49
|
+
files: ['*.{js,ts,md}x'],
|
|
50
|
+
env: { browser: true },
|
|
51
|
+
extends: [
|
|
52
|
+
'standard-react',
|
|
53
|
+
'standard-jsx',
|
|
54
|
+
'plugin:prettier/recommended',
|
|
55
|
+
'plugin:jsx-a11y/recommended',
|
|
56
|
+
'plugin:mdx/recommended'
|
|
57
|
+
],
|
|
58
|
+
rules: {
|
|
59
|
+
// Overrides standard-react
|
|
60
|
+
'jsx-quotes': ['error', 'prefer-double']
|
|
61
|
+
}
|
|
62
|
+
}
|
|
98
63
|
].filter(Boolean)
|
|
99
|
-
)
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
// console.log(111, JSON.stringify(legacy, null, 2))
|
|
67
|
+
|
|
68
|
+
const configs = [
|
|
69
|
+
{
|
|
70
|
+
ignores: ['!.github', '!.storybook'],
|
|
71
|
+
languageOptions: { globals: { ...globals.jest } },
|
|
72
|
+
plugins: { 'simple-import-sort': simpleImportSort },
|
|
73
|
+
rules: {
|
|
74
|
+
'simple-import-sort/imports': 'error',
|
|
75
|
+
'simple-import-sort/exports': 'error'
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
...legacy,
|
|
79
|
+
// JSON
|
|
80
|
+
{ files: ['**/*.json'], plugins: { json }, language: 'json/json' },
|
|
81
|
+
{ files: ['**/*.json'], ...prettierRecommended },
|
|
82
|
+
{ files: ['**/+(j|t)sconfig?(.*).json'], language: 'json/jsonc' },
|
|
83
|
+
// Testing Library
|
|
84
|
+
{
|
|
85
|
+
files: ['**/*.spec.*'],
|
|
86
|
+
ignores: ['**/*.spec.?(s)css'],
|
|
87
|
+
...testingLibrary.configs['flat/react'],
|
|
88
|
+
rules: {
|
|
89
|
+
...testingLibrary.configs['flat/react'].rules,
|
|
90
|
+
'testing-library/no-node-access': [
|
|
91
|
+
'error',
|
|
92
|
+
{ allowContainerFirstChild: true }
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
// Cypress
|
|
97
|
+
{ files: ['**/*.cy.*'], extends: [cypress.configs.recommended] }
|
|
98
|
+
]
|
|
99
|
+
|
|
100
|
+
// Storybook
|
|
101
|
+
if (await existsDependency('storybook')) {
|
|
102
|
+
const storybook = await optionalDependency('eslint-plugin-storybook')
|
|
103
|
+
|
|
104
|
+
configs.push(
|
|
105
|
+
...storybook.configs['flat/recommended'],
|
|
106
|
+
...storybook.configs['flat/csf-strict'],
|
|
107
|
+
{
|
|
108
|
+
files: ['**/*.stories.*'],
|
|
109
|
+
rules: { 'storybook/meta-inline-properties': 'error' }
|
|
110
|
+
}
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// .gitignore
|
|
115
|
+
const gitignore = join(process.cwd(), '.gitignore')
|
|
116
|
+
|
|
117
|
+
if (existsSync(gitignore)) {
|
|
118
|
+
configs.push(includeIgnoreFile(gitignore))
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export default defineConfig(configs)
|