@slashnephy/eslint-config 2.3.204 → 3.0.1
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 +20 -6
- package/package.json +24 -40
- package/src/base/common.js +37 -0
- package/src/base/common.ts +42 -0
- package/src/base/graphql.js +41 -8
- package/src/base/graphql.ts +48 -15
- package/src/base/javascript.js +155 -70
- package/src/base/javascript.ts +218 -180
- package/src/base/package.json.js +15 -0
- package/src/base/package.json.ts +16 -0
- package/src/base/typescript.js +90 -46
- package/src/base/typescript.ts +229 -212
- package/src/base/yaml.js +20 -14
- package/src/base/yaml.ts +24 -16
- package/src/environments/cloudflareWorkers.js +9 -0
- package/src/environments/cloudflareWorkers.ts +10 -0
- package/src/environments/node.js +50 -0
- package/src/environments/node.ts +55 -0
- package/src/{presets → environments}/userscript.js +10 -5
- package/src/{presets → environments}/userscript.ts +10 -7
- package/src/frameworks/jest.js +10 -0
- package/src/frameworks/jest.ts +11 -0
- package/src/frameworks/next.js.js +24 -0
- package/src/frameworks/next.js.ts +25 -0
- package/src/frameworks/react.js +128 -0
- package/src/frameworks/react.ts +134 -0
- package/src/frameworks/relay.js +13 -0
- package/src/frameworks/relay.ts +14 -0
- package/src/frameworks/storybook.js +7 -0
- package/src/frameworks/storybook.ts +8 -0
- package/src/frameworks/vite.js +7 -0
- package/src/frameworks/vite.ts +8 -0
- package/src/frameworks/vitest.js +20 -0
- package/src/frameworks/vitest.ts +21 -0
- package/src/index.js +60 -102
- package/src/index.ts +65 -130
- package/src/framework/emotion.js +0 -17
- package/src/framework/emotion.ts +0 -20
- package/src/framework/jest.js +0 -14
- package/src/framework/jest.ts +0 -17
- package/src/framework/next.js.js +0 -14
- package/src/framework/next.js.ts +0 -13
- package/src/framework/react.js +0 -79
- package/src/framework/react.ts +0 -98
- package/src/framework/relay.js +0 -9
- package/src/framework/relay.ts +0 -10
- package/src/framework/vite.js +0 -8
- package/src/framework/vite.ts +0 -8
- package/src/framework/vitest.js +0 -6
- package/src/framework/vitest.ts +0 -9
- package/src/presets/a11y.js +0 -28
- package/src/presets/a11y.ts +0 -27
- package/src/presets/allow-default-export.js +0 -8
- package/src/presets/allow-default-export.ts +0 -9
- package/src/presets/build-configuration.js +0 -12
- package/src/presets/build-configuration.ts +0 -13
- package/src/presets/node.js +0 -7
- package/src/presets/node.ts +0 -8
- package/src/presets/package.json.js +0 -17
- package/src/presets/package.json.ts +0 -17
- package/src/presets/style.js +0 -23
- package/src/presets/style.ts +0 -39
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import userScriptsPlugin from 'eslint-plugin-userscripts';
|
|
2
|
+
import { config } from 'typescript-eslint';
|
|
3
|
+
export const userScript = config({
|
|
4
|
+
name: 'eslint-plugin-userscripts',
|
|
5
|
+
files: ['**/*.user.js'],
|
|
6
|
+
plugins: {
|
|
7
|
+
userScripts: userScriptsPlugin,
|
|
8
|
+
},
|
|
5
9
|
rules: {
|
|
10
|
+
...userScriptsPlugin.configs.recommended.rules,
|
|
6
11
|
'no-undef': 'off',
|
|
7
12
|
'xss/no-mixed-html': 'off',
|
|
8
13
|
'xss/no-location-href-assign': 'off',
|
|
@@ -19,4 +24,4 @@ module.exports = {
|
|
|
19
24
|
},
|
|
20
25
|
],
|
|
21
26
|
},
|
|
22
|
-
};
|
|
27
|
+
});
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import userScriptsPlugin from 'eslint-plugin-userscripts'
|
|
2
|
+
import { config } from 'typescript-eslint'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export const userScript = config({
|
|
5
|
+
name: 'eslint-plugin-userscripts',
|
|
6
|
+
files: ['**/*.user.js'],
|
|
7
|
+
plugins: {
|
|
8
|
+
userScripts: userScriptsPlugin,
|
|
9
|
+
},
|
|
8
10
|
rules: {
|
|
11
|
+
...userScriptsPlugin.configs.recommended.rules,
|
|
9
12
|
'no-undef': 'off',
|
|
10
13
|
'xss/no-mixed-html': 'off',
|
|
11
14
|
'xss/no-location-href-assign': 'off',
|
|
@@ -22,4 +25,4 @@ module.exports = {
|
|
|
22
25
|
},
|
|
23
26
|
],
|
|
24
27
|
},
|
|
25
|
-
}
|
|
28
|
+
})
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import jestPlugin from 'eslint-plugin-jest';
|
|
2
|
+
import { config } from 'typescript-eslint';
|
|
3
|
+
export const jest = config({
|
|
4
|
+
name: 'eslint-plugin-jest',
|
|
5
|
+
files: [
|
|
6
|
+
'**/*.test.{js,cjs,mjs,jsx,ts,cts,mts,tsx}',
|
|
7
|
+
'**/test/**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}',
|
|
8
|
+
],
|
|
9
|
+
extends: [jestPlugin.configs['flat/all']],
|
|
10
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import jestPlugin from 'eslint-plugin-jest'
|
|
2
|
+
import { config } from 'typescript-eslint'
|
|
3
|
+
|
|
4
|
+
export const jest = config({
|
|
5
|
+
name: 'eslint-plugin-jest',
|
|
6
|
+
files: [
|
|
7
|
+
'**/*.test.{js,cjs,mjs,jsx,ts,cts,mts,tsx}',
|
|
8
|
+
'**/test/**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}',
|
|
9
|
+
],
|
|
10
|
+
extends: [jestPlugin.configs['flat/all']],
|
|
11
|
+
})
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// @ts-expect-error 型定義ファイルがない
|
|
2
|
+
import nextPlugin from '@next/eslint-plugin-next';
|
|
3
|
+
import { config } from 'typescript-eslint';
|
|
4
|
+
export const nextJs = config({
|
|
5
|
+
name: '@next/eslint-plugin-next',
|
|
6
|
+
files: [
|
|
7
|
+
// Pages Router
|
|
8
|
+
'**/pages/**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}',
|
|
9
|
+
// App Router
|
|
10
|
+
'**/app/**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}',
|
|
11
|
+
],
|
|
12
|
+
plugins: {
|
|
13
|
+
'@next/next': nextPlugin,
|
|
14
|
+
},
|
|
15
|
+
extends: [
|
|
16
|
+
nextPlugin.configs.recommended,
|
|
17
|
+
nextPlugin.configs['core-web-vitals'],
|
|
18
|
+
],
|
|
19
|
+
rules: {
|
|
20
|
+
'import-x/no-default-export': 'off',
|
|
21
|
+
'react-refresh/only-export-components': 'off',
|
|
22
|
+
},
|
|
23
|
+
ignores: ['**/.next/**'],
|
|
24
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// @ts-expect-error 型定義ファイルがない
|
|
2
|
+
import nextPlugin from '@next/eslint-plugin-next'
|
|
3
|
+
import { config } from 'typescript-eslint'
|
|
4
|
+
|
|
5
|
+
export const nextJs = config({
|
|
6
|
+
name: '@next/eslint-plugin-next',
|
|
7
|
+
files: [
|
|
8
|
+
// Pages Router
|
|
9
|
+
'**/pages/**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}',
|
|
10
|
+
// App Router
|
|
11
|
+
'**/app/**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}',
|
|
12
|
+
],
|
|
13
|
+
plugins: {
|
|
14
|
+
'@next/next': nextPlugin,
|
|
15
|
+
},
|
|
16
|
+
extends: [
|
|
17
|
+
nextPlugin.configs.recommended,
|
|
18
|
+
nextPlugin.configs['core-web-vitals'],
|
|
19
|
+
],
|
|
20
|
+
rules: {
|
|
21
|
+
'import-x/no-default-export': 'off',
|
|
22
|
+
'react-refresh/only-export-components': 'off',
|
|
23
|
+
},
|
|
24
|
+
ignores: ['**/.next/**'],
|
|
25
|
+
})
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// @ts-expect-error 型定義ファイルがない
|
|
2
|
+
import jsxA11y from 'eslint-plugin-jsx-a11y';
|
|
3
|
+
import reactPlugin from 'eslint-plugin-react';
|
|
4
|
+
import reactHooksPlugin from 'eslint-plugin-react-hooks';
|
|
5
|
+
import reactRefreshPlugin from 'eslint-plugin-react-refresh';
|
|
6
|
+
import globals from 'globals';
|
|
7
|
+
import { config } from 'typescript-eslint';
|
|
8
|
+
export const react = config([
|
|
9
|
+
{
|
|
10
|
+
name: 'eslint-plugin-react',
|
|
11
|
+
files: ['**/*.{jsx,tsx}'],
|
|
12
|
+
extends: [
|
|
13
|
+
reactPlugin.configs.flat.recommended,
|
|
14
|
+
reactPlugin.configs.flat['jsx-runtime'],
|
|
15
|
+
],
|
|
16
|
+
languageOptions: {
|
|
17
|
+
parserOptions: {
|
|
18
|
+
ecmaFeatures: {
|
|
19
|
+
jsx: true,
|
|
20
|
+
},
|
|
21
|
+
lib: ['dom'],
|
|
22
|
+
},
|
|
23
|
+
globals: globals.browser,
|
|
24
|
+
},
|
|
25
|
+
settings: {
|
|
26
|
+
react: {
|
|
27
|
+
version: 'detect',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
rules: {
|
|
31
|
+
// <div flag={true} /> 👉 <div flag />
|
|
32
|
+
'react/jsx-boolean-value': 'error',
|
|
33
|
+
// <div value={'test'} /> 👉 <div value='test' />
|
|
34
|
+
'react/jsx-curly-brace-presence': 'error',
|
|
35
|
+
// <div></div> 👉 <div />
|
|
36
|
+
'react/self-closing-comp': [
|
|
37
|
+
'error',
|
|
38
|
+
{
|
|
39
|
+
component: true,
|
|
40
|
+
html: true,
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
// コンポーネント名を PascalCase に強制
|
|
44
|
+
'react/jsx-pascal-case': 'error',
|
|
45
|
+
// ハンドラーの名前規則
|
|
46
|
+
'react/jsx-handler-names': 'error',
|
|
47
|
+
// useState の分解宣言 & setXXX という名前を強制
|
|
48
|
+
'react/hook-use-state': 'error',
|
|
49
|
+
// <React.Fragment /> 👉 </>
|
|
50
|
+
'react/jsx-fragments': 'error',
|
|
51
|
+
// ステートレス関数を優先
|
|
52
|
+
'react/prefer-stateless-function': 'error',
|
|
53
|
+
// props を並び替える
|
|
54
|
+
'react/jsx-sort-props': [
|
|
55
|
+
'error',
|
|
56
|
+
{
|
|
57
|
+
callbacksLast: true,
|
|
58
|
+
shorthandFirst: true,
|
|
59
|
+
multiline: 'last',
|
|
60
|
+
reservedFirst: true,
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
// JSX を .tsx でも使えるように
|
|
64
|
+
'react/jsx-filename-extension': [
|
|
65
|
+
'error',
|
|
66
|
+
{
|
|
67
|
+
extensions: ['.jsx', '.tsx'],
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
// props に対してスプレッド演算子を使えるように
|
|
71
|
+
'react/jsx-props-no-spreading': 'off',
|
|
72
|
+
// <></> を使えるように
|
|
73
|
+
'react/jsx-no-useless-fragment': 'off',
|
|
74
|
+
// defaultProps を使わない
|
|
75
|
+
'react/require-default-props': 'off',
|
|
76
|
+
// useCallback でコールバックを宣言させる
|
|
77
|
+
'react/jsx-no-bind': 'warn',
|
|
78
|
+
// コンポーネントの宣言を function Component() {} に強制
|
|
79
|
+
'react/function-component-definition': [
|
|
80
|
+
'error',
|
|
81
|
+
{
|
|
82
|
+
namedComponents: 'function-declaration',
|
|
83
|
+
unnamedComponents: 'arrow-function',
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: 'eslint-plugin-react',
|
|
90
|
+
files: ['**/*.jsx'],
|
|
91
|
+
rules: {
|
|
92
|
+
'react/prop-types': 'error',
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
], {
|
|
96
|
+
name: 'eslint-plugin-react-hooks',
|
|
97
|
+
files: ['**/*.{jsx,tsx}'],
|
|
98
|
+
extends: [reactHooksPlugin.configs['recommended-latest']],
|
|
99
|
+
rules: {
|
|
100
|
+
// https://recoiljs.org/docs/introduction/installation/#eslint
|
|
101
|
+
'react-hooks/rules-of-hooks': 'error',
|
|
102
|
+
'react-hooks/exhaustive-deps': [
|
|
103
|
+
'warn',
|
|
104
|
+
{
|
|
105
|
+
additionalHooks: '(useRecoilCallback|useRecoilTransaction_UNSTABLE)',
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
},
|
|
109
|
+
}, {
|
|
110
|
+
name: 'eslint-plugin-jsx-a11y',
|
|
111
|
+
files: ['**/*.{jsx,tsx}'],
|
|
112
|
+
extends: [jsxA11y.flatConfigs.recommended],
|
|
113
|
+
rules: {
|
|
114
|
+
'jsx-a11y/alt-text': [
|
|
115
|
+
'warn',
|
|
116
|
+
{
|
|
117
|
+
elements: ['img', 'object', 'area'],
|
|
118
|
+
img: ['Image'],
|
|
119
|
+
object: [],
|
|
120
|
+
area: [],
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
},
|
|
124
|
+
}, {
|
|
125
|
+
name: 'eslint-plugin-react-refresh',
|
|
126
|
+
files: ['**/*.{jsx,tsx}'],
|
|
127
|
+
extends: [reactRefreshPlugin.configs.recommended],
|
|
128
|
+
});
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// @ts-expect-error 型定義ファイルがない
|
|
2
|
+
import jsxA11y from 'eslint-plugin-jsx-a11y'
|
|
3
|
+
import reactPlugin from 'eslint-plugin-react'
|
|
4
|
+
import reactHooksPlugin from 'eslint-plugin-react-hooks'
|
|
5
|
+
import reactRefreshPlugin from 'eslint-plugin-react-refresh'
|
|
6
|
+
import globals from 'globals'
|
|
7
|
+
import { config } from 'typescript-eslint'
|
|
8
|
+
|
|
9
|
+
export const react = config(
|
|
10
|
+
[
|
|
11
|
+
{
|
|
12
|
+
name: 'eslint-plugin-react',
|
|
13
|
+
files: ['**/*.{jsx,tsx}'],
|
|
14
|
+
extends: [
|
|
15
|
+
reactPlugin.configs.flat.recommended,
|
|
16
|
+
reactPlugin.configs.flat['jsx-runtime'],
|
|
17
|
+
],
|
|
18
|
+
languageOptions: {
|
|
19
|
+
parserOptions: {
|
|
20
|
+
ecmaFeatures: {
|
|
21
|
+
jsx: true,
|
|
22
|
+
},
|
|
23
|
+
lib: ['dom'],
|
|
24
|
+
},
|
|
25
|
+
globals: globals.browser,
|
|
26
|
+
},
|
|
27
|
+
settings: {
|
|
28
|
+
react: {
|
|
29
|
+
version: 'detect',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
rules: {
|
|
33
|
+
// <div flag={true} /> 👉 <div flag />
|
|
34
|
+
'react/jsx-boolean-value': 'error',
|
|
35
|
+
// <div value={'test'} /> 👉 <div value='test' />
|
|
36
|
+
'react/jsx-curly-brace-presence': 'error',
|
|
37
|
+
// <div></div> 👉 <div />
|
|
38
|
+
'react/self-closing-comp': [
|
|
39
|
+
'error',
|
|
40
|
+
{
|
|
41
|
+
component: true,
|
|
42
|
+
html: true,
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
// コンポーネント名を PascalCase に強制
|
|
46
|
+
'react/jsx-pascal-case': 'error',
|
|
47
|
+
// ハンドラーの名前規則
|
|
48
|
+
'react/jsx-handler-names': 'error',
|
|
49
|
+
// useState の分解宣言 & setXXX という名前を強制
|
|
50
|
+
'react/hook-use-state': 'error',
|
|
51
|
+
// <React.Fragment /> 👉 </>
|
|
52
|
+
'react/jsx-fragments': 'error',
|
|
53
|
+
// ステートレス関数を優先
|
|
54
|
+
'react/prefer-stateless-function': 'error',
|
|
55
|
+
// props を並び替える
|
|
56
|
+
'react/jsx-sort-props': [
|
|
57
|
+
'error',
|
|
58
|
+
{
|
|
59
|
+
callbacksLast: true,
|
|
60
|
+
shorthandFirst: true,
|
|
61
|
+
multiline: 'last',
|
|
62
|
+
reservedFirst: true,
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
// JSX を .tsx でも使えるように
|
|
66
|
+
'react/jsx-filename-extension': [
|
|
67
|
+
'error',
|
|
68
|
+
{
|
|
69
|
+
extensions: ['.jsx', '.tsx'],
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
// props に対してスプレッド演算子を使えるように
|
|
73
|
+
'react/jsx-props-no-spreading': 'off',
|
|
74
|
+
// <></> を使えるように
|
|
75
|
+
'react/jsx-no-useless-fragment': 'off',
|
|
76
|
+
// defaultProps を使わない
|
|
77
|
+
'react/require-default-props': 'off',
|
|
78
|
+
// useCallback でコールバックを宣言させる
|
|
79
|
+
'react/jsx-no-bind': 'warn',
|
|
80
|
+
// コンポーネントの宣言を function Component() {} に強制
|
|
81
|
+
'react/function-component-definition': [
|
|
82
|
+
'error',
|
|
83
|
+
{
|
|
84
|
+
namedComponents: 'function-declaration',
|
|
85
|
+
unnamedComponents: 'arrow-function',
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: 'eslint-plugin-react',
|
|
92
|
+
files: ['**/*.jsx'],
|
|
93
|
+
rules: {
|
|
94
|
+
'react/prop-types': 'error',
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
{
|
|
99
|
+
name: 'eslint-plugin-react-hooks',
|
|
100
|
+
files: ['**/*.{jsx,tsx}'],
|
|
101
|
+
extends: [reactHooksPlugin.configs['recommended-latest']],
|
|
102
|
+
rules: {
|
|
103
|
+
// https://recoiljs.org/docs/introduction/installation/#eslint
|
|
104
|
+
'react-hooks/rules-of-hooks': 'error',
|
|
105
|
+
'react-hooks/exhaustive-deps': [
|
|
106
|
+
'warn',
|
|
107
|
+
{
|
|
108
|
+
additionalHooks: '(useRecoilCallback|useRecoilTransaction_UNSTABLE)',
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: 'eslint-plugin-jsx-a11y',
|
|
115
|
+
files: ['**/*.{jsx,tsx}'],
|
|
116
|
+
extends: [jsxA11y.flatConfigs.recommended],
|
|
117
|
+
rules: {
|
|
118
|
+
'jsx-a11y/alt-text': [
|
|
119
|
+
'warn',
|
|
120
|
+
{
|
|
121
|
+
elements: ['img', 'object', 'area'],
|
|
122
|
+
img: ['Image'],
|
|
123
|
+
object: [],
|
|
124
|
+
area: [],
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: 'eslint-plugin-react-refresh',
|
|
131
|
+
files: ['**/*.{jsx,tsx}'],
|
|
132
|
+
extends: [reactRefreshPlugin.configs.recommended],
|
|
133
|
+
},
|
|
134
|
+
)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { config } from 'typescript-eslint';
|
|
2
|
+
export const relay = config({
|
|
3
|
+
name: 'eslint-plugin-relay',
|
|
4
|
+
files: ['**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}'],
|
|
5
|
+
// TODO: eslint-plugin-relay が Flat Configs に対応したら移行する
|
|
6
|
+
// https://github.com/relayjs/eslint-plugin-relay/issues/156
|
|
7
|
+
// extends: ['plugin:relay/recommended'],
|
|
8
|
+
// plugins: ['relay'],
|
|
9
|
+
// rules: {
|
|
10
|
+
// // 未使用の GraphQL フィールドを禁止
|
|
11
|
+
// 'relay/unused-fields': 'error',
|
|
12
|
+
// },
|
|
13
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { config } from 'typescript-eslint'
|
|
2
|
+
|
|
3
|
+
export const relay = config({
|
|
4
|
+
name: 'eslint-plugin-relay',
|
|
5
|
+
files: ['**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}'],
|
|
6
|
+
// TODO: eslint-plugin-relay が Flat Configs に対応したら移行する
|
|
7
|
+
// https://github.com/relayjs/eslint-plugin-relay/issues/156
|
|
8
|
+
// extends: ['plugin:relay/recommended'],
|
|
9
|
+
// plugins: ['relay'],
|
|
10
|
+
// rules: {
|
|
11
|
+
// // 未使用の GraphQL フィールドを禁止
|
|
12
|
+
// 'relay/unused-fields': 'error',
|
|
13
|
+
// },
|
|
14
|
+
})
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import storybookPlugin from 'eslint-plugin-storybook';
|
|
2
|
+
import { config } from 'typescript-eslint';
|
|
3
|
+
export const storybook = config({
|
|
4
|
+
name: 'eslint-plugin-storybook',
|
|
5
|
+
files: ['**/*.stories.{jsx,tsx}'],
|
|
6
|
+
extends: [storybookPlugin.configs['flat/recommended']],
|
|
7
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import storybookPlugin from 'eslint-plugin-storybook'
|
|
2
|
+
import { config } from 'typescript-eslint'
|
|
3
|
+
|
|
4
|
+
export const storybook = config({
|
|
5
|
+
name: 'eslint-plugin-storybook',
|
|
6
|
+
files: ['**/*.stories.{jsx,tsx}'],
|
|
7
|
+
extends: [storybookPlugin.configs['flat/recommended']],
|
|
8
|
+
})
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import vitestPlugin from '@vitest/eslint-plugin';
|
|
2
|
+
import { config } from 'typescript-eslint';
|
|
3
|
+
export const vitest = config({
|
|
4
|
+
name: '@vitest/eslint-plugin',
|
|
5
|
+
files: [
|
|
6
|
+
'**/*.test.{js,cjs,mjs,jsx,ts,cts,mts,tsx}',
|
|
7
|
+
'**/test/**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}',
|
|
8
|
+
],
|
|
9
|
+
extends: [vitestPlugin.configs.recommended],
|
|
10
|
+
settings: {
|
|
11
|
+
vitest: {
|
|
12
|
+
typecheck: true,
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
languageOptions: {
|
|
16
|
+
globals: {
|
|
17
|
+
...vitestPlugin.environments.env.globals,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import vitestPlugin from '@vitest/eslint-plugin'
|
|
2
|
+
import { config } from 'typescript-eslint'
|
|
3
|
+
|
|
4
|
+
export const vitest = config({
|
|
5
|
+
name: '@vitest/eslint-plugin',
|
|
6
|
+
files: [
|
|
7
|
+
'**/*.test.{js,cjs,mjs,jsx,ts,cts,mts,tsx}',
|
|
8
|
+
'**/test/**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}',
|
|
9
|
+
],
|
|
10
|
+
extends: [vitestPlugin.configs.recommended],
|
|
11
|
+
settings: {
|
|
12
|
+
vitest: {
|
|
13
|
+
typecheck: true,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
languageOptions: {
|
|
17
|
+
globals: {
|
|
18
|
+
...vitestPlugin.environments.env.globals,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
})
|
package/src/index.js
CHANGED
|
@@ -1,102 +1,60 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
extends: [
|
|
62
|
-
(0, path_1.resolve)(__dirname, 'framework/jest.js'),
|
|
63
|
-
(0, path_1.resolve)(__dirname, 'framework/vitest.js'),
|
|
64
|
-
],
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
files: '**/*.{jsx,tsx}',
|
|
68
|
-
extends: (0, path_1.resolve)(__dirname, 'presets/a11y.js'),
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
files: '**/bin/**/*.{js,mjs,cjs,ts,mts,cts}',
|
|
72
|
-
extends: (0, path_1.resolve)(__dirname, 'presets/node.js'),
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
files: ['**/src/worker.{js,ts}', '**/functions/**/*.{js,ts}'],
|
|
76
|
-
extends: (0, path_1.resolve)(__dirname, 'presets/allow-default-export.js'),
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
files: [
|
|
80
|
-
'**/{webpack,rollup,vite,postcss,next}.config.{js,mjs,cjs,ts,mts,cts}',
|
|
81
|
-
'**/codegen.{js,mjs,cjs,ts,mts,cts}',
|
|
82
|
-
],
|
|
83
|
-
extends: [
|
|
84
|
-
(0, path_1.resolve)(__dirname, 'presets/allow-default-export.js'),
|
|
85
|
-
(0, path_1.resolve)(__dirname, 'presets/build-configuration.js'),
|
|
86
|
-
(0, path_1.resolve)(__dirname, 'presets/node.js'),
|
|
87
|
-
],
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
files: '**/package.json',
|
|
91
|
-
extends: (0, path_1.resolve)(__dirname, 'presets/package.json.js'),
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
files: '**/*.user.js',
|
|
95
|
-
extends: (0, path_1.resolve)(__dirname, 'presets/userscript.js'),
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
files: '**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx}',
|
|
99
|
-
extends: (0, path_1.resolve)(__dirname, 'presets/style.js'),
|
|
100
|
-
},
|
|
101
|
-
],
|
|
102
|
-
};
|
|
1
|
+
import tseslint from 'typescript-eslint';
|
|
2
|
+
import { common } from './base/common.js';
|
|
3
|
+
import { graphql } from './base/graphql.js';
|
|
4
|
+
import { javaScript } from './base/javascript.js';
|
|
5
|
+
import { packageJson } from './base/package.json.js';
|
|
6
|
+
import { typeScript } from './base/typescript.js';
|
|
7
|
+
import { yaml } from './base/yaml.js';
|
|
8
|
+
import { cloudflareWorkers } from './environments/cloudflareWorkers.js';
|
|
9
|
+
import { node } from './environments/node.js';
|
|
10
|
+
import { userScript } from './environments/userscript.js';
|
|
11
|
+
import { jest } from './frameworks/jest.js';
|
|
12
|
+
import { nextJs } from './frameworks/next.js.js';
|
|
13
|
+
import { react } from './frameworks/react.js';
|
|
14
|
+
import { relay } from './frameworks/relay.js';
|
|
15
|
+
import { storybook } from './frameworks/storybook.js';
|
|
16
|
+
import { vite } from './frameworks/vite.js';
|
|
17
|
+
import { vitest } from './frameworks/vitest.js';
|
|
18
|
+
export function config(_options, ...overrides) {
|
|
19
|
+
return tseslint.config(
|
|
20
|
+
// ベース
|
|
21
|
+
[
|
|
22
|
+
common,
|
|
23
|
+
// JavaScript
|
|
24
|
+
javaScript,
|
|
25
|
+
// TypeScript
|
|
26
|
+
typeScript,
|
|
27
|
+
// GraphQL
|
|
28
|
+
graphql,
|
|
29
|
+
// YAML
|
|
30
|
+
yaml,
|
|
31
|
+
// package.json
|
|
32
|
+
packageJson,
|
|
33
|
+
],
|
|
34
|
+
// フレームワーク
|
|
35
|
+
[
|
|
36
|
+
// React
|
|
37
|
+
react,
|
|
38
|
+
// Next.js
|
|
39
|
+
nextJs,
|
|
40
|
+
// Vite
|
|
41
|
+
vite,
|
|
42
|
+
// Relay
|
|
43
|
+
relay,
|
|
44
|
+
// Storybook
|
|
45
|
+
storybook,
|
|
46
|
+
// Jest
|
|
47
|
+
jest,
|
|
48
|
+
// Vitest
|
|
49
|
+
vitest,
|
|
50
|
+
],
|
|
51
|
+
// 環境
|
|
52
|
+
[
|
|
53
|
+
// Node.js
|
|
54
|
+
node,
|
|
55
|
+
// Cloudflare Worker
|
|
56
|
+
cloudflareWorkers,
|
|
57
|
+
// UserScript
|
|
58
|
+
userScript,
|
|
59
|
+
], ...overrides);
|
|
60
|
+
}
|