eslint-config-matsuri 4.0.1 → 4.1.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 +2 -0
- package/index.js +51 -20
- package/package.json +4 -12
package/README.md
CHANGED
|
@@ -25,6 +25,7 @@ Flat configをv3からサポートしています。eslint.config.jsに次のよ
|
|
|
25
25
|
```js
|
|
26
26
|
import config from "eslint-config-matsuri";
|
|
27
27
|
|
|
28
|
+
/** @type { import("eslint").Linter.FlatConfig[] } */
|
|
28
29
|
export default config
|
|
29
30
|
```
|
|
30
31
|
|
|
@@ -33,6 +34,7 @@ export default config
|
|
|
33
34
|
```js
|
|
34
35
|
import config from "eslint-config-matsuri";
|
|
35
36
|
|
|
37
|
+
/** @type { import("eslint").Linter.FlatConfig[] } */
|
|
36
38
|
export default [
|
|
37
39
|
...config,
|
|
38
40
|
{
|
package/index.js
CHANGED
|
@@ -9,8 +9,7 @@ import pluginReactHooks from "eslint-plugin-react-hooks";
|
|
|
9
9
|
import pluginReactRefresh from "eslint-plugin-react-refresh";
|
|
10
10
|
import pluginSortImports from "eslint-plugin-sort-imports-es6-autofix";
|
|
11
11
|
import pluginUnusedImport from "eslint-plugin-unused-imports";
|
|
12
|
-
import
|
|
13
|
-
import tsParser from "@typescript-eslint/parser";
|
|
12
|
+
import tseslint from "typescript-eslint";
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
15
|
* @see https://github.com/storybookjs/eslint-plugin-storybook/issues/135
|
|
@@ -20,9 +19,48 @@ const pluginStorybookRecommended = compat.extends(
|
|
|
20
19
|
"plugin:storybook/recommended"
|
|
21
20
|
);
|
|
22
21
|
|
|
22
|
+
/**
|
|
23
|
+
* NOTE: typescript-eslintは、推奨設定をルール単位で返しておらず、parserOptionsやpluginなどを設定を含んだconfigの配列のみを返している。
|
|
24
|
+
* これを以前のESLintにおけるextendsのような記述できるようにするために、tseslint.configという関数を提供しているが、
|
|
25
|
+
* 記述が自明な上に、現状シンプルなケースでは問題が既存の設定を取り込むとエラーが見られるため、ルールのみを抽出して返す関数を作成した。
|
|
26
|
+
*/
|
|
27
|
+
const getRulesFromConfigArray = (configs) => {
|
|
28
|
+
return configs.reduce((rules, config) => {
|
|
29
|
+
return { ...rules, ...config.rules };
|
|
30
|
+
}, {});
|
|
31
|
+
};
|
|
32
|
+
const tseslintRecommendedTypeChckedRules = getRulesFromConfigArray(
|
|
33
|
+
tseslint.configs.recommendedTypeChecked
|
|
34
|
+
);
|
|
35
|
+
const tseslintStylisticTypeCheckedRules = getRulesFromConfigArray(
|
|
36
|
+
tseslint.configs.stylisticTypeChecked
|
|
37
|
+
);
|
|
38
|
+
|
|
23
39
|
/** @type { import("eslint").Linter.FlatConfig[] } */
|
|
24
40
|
const config = [
|
|
25
41
|
{
|
|
42
|
+
linterOptions: {
|
|
43
|
+
reportUnusedDisableDirectives: true,
|
|
44
|
+
},
|
|
45
|
+
/**
|
|
46
|
+
* NOTE: pluginsをfilesと紐付けると、利用側でのルール変更が困難になる。
|
|
47
|
+
*
|
|
48
|
+
* Pluginをfilesを指定したconfigで読み込むとfilesと紐づいてしまうため、
|
|
49
|
+
* eslint-config-matsuriを利用する側でルールを上書きしようとした際に、filesまたはpluginの再指定が必要になってしまう。
|
|
50
|
+
* また、pluginがlanguageOptionsなどに依存している場合、その指定も必要になる。
|
|
51
|
+
* さらには、eslint側のアップデートで、同じpluginを再指定するとエラーが出るようになった。
|
|
52
|
+
* このため、pluginをfiles指定なしで、まとめて読み込んでおく。
|
|
53
|
+
*/
|
|
54
|
+
plugins: {
|
|
55
|
+
"sort-imports-es6-autofix": pluginSortImports,
|
|
56
|
+
"@typescript-eslint": tseslint.plugin,
|
|
57
|
+
"unused-imports": pluginUnusedImport,
|
|
58
|
+
"css-reorder": pluginCssReorder,
|
|
59
|
+
"jsx-a11y": pluginJsxA11y,
|
|
60
|
+
react: pluginReact,
|
|
61
|
+
"react-hooks": pluginReactHooks,
|
|
62
|
+
"react-refresh": pluginReactRefresh,
|
|
63
|
+
},
|
|
26
64
|
ignores: [
|
|
27
65
|
"**/node_modules",
|
|
28
66
|
"**/public",
|
|
@@ -45,9 +83,6 @@ const config = [
|
|
|
45
83
|
],
|
|
46
84
|
},
|
|
47
85
|
{
|
|
48
|
-
linterOptions: {
|
|
49
|
-
reportUnusedDisableDirectives: true,
|
|
50
|
-
},
|
|
51
86
|
languageOptions: {
|
|
52
87
|
ecmaVersion: "latest",
|
|
53
88
|
sourceType: "module",
|
|
@@ -57,9 +92,6 @@ const config = [
|
|
|
57
92
|
...globals.node,
|
|
58
93
|
},
|
|
59
94
|
},
|
|
60
|
-
plugins: {
|
|
61
|
-
"sort-imports-es6-autofix": pluginSortImports,
|
|
62
|
-
},
|
|
63
95
|
rules: {
|
|
64
96
|
...js.configs.recommended.rules,
|
|
65
97
|
"no-console": ["error", { allow: ["error", "warn"] }],
|
|
@@ -87,7 +119,7 @@ const config = [
|
|
|
87
119
|
React: true,
|
|
88
120
|
JSX: true,
|
|
89
121
|
},
|
|
90
|
-
parser:
|
|
122
|
+
parser: tseslint.parser,
|
|
91
123
|
parserOptions: {
|
|
92
124
|
project: true,
|
|
93
125
|
},
|
|
@@ -97,21 +129,12 @@ const config = [
|
|
|
97
129
|
version: "detect",
|
|
98
130
|
},
|
|
99
131
|
},
|
|
100
|
-
plugins: {
|
|
101
|
-
"@typescript-eslint": ts,
|
|
102
|
-
"unused-imports": pluginUnusedImport,
|
|
103
|
-
"css-reorder": pluginCssReorder,
|
|
104
|
-
"jsx-a11y": pluginJsxA11y,
|
|
105
|
-
react: pluginReact,
|
|
106
|
-
"react-hooks": pluginReactHooks,
|
|
107
|
-
"react-refresh": pluginReactRefresh,
|
|
108
|
-
},
|
|
109
132
|
rules: {
|
|
133
|
+
...tseslintRecommendedTypeChckedRules,
|
|
134
|
+
...tseslintStylisticTypeCheckedRules,
|
|
110
135
|
...pluginReact.configs.recommended.rules,
|
|
111
136
|
...pluginReactHooks.configs.recommended.rules,
|
|
112
137
|
...pluginReact.configs["jsx-runtime"].rules,
|
|
113
|
-
...ts.configs["recommended-type-checked"].rules,
|
|
114
|
-
...ts.configs["stylistic-type-checked"].rules,
|
|
115
138
|
...pluginJsxA11y.configs.recommended.rules,
|
|
116
139
|
...pluginPrettier.rules,
|
|
117
140
|
"css-reorder/property-reorder": "error",
|
|
@@ -191,6 +214,14 @@ const config = [
|
|
|
191
214
|
// 字幕を付加することはあまり想定されず、無意味なtrack要素の挿入を招くため無効化する
|
|
192
215
|
"jsx-a11y/media-has-caption": "off",
|
|
193
216
|
|
|
217
|
+
"jsx-a11y/label-has-associated-control": [
|
|
218
|
+
"error",
|
|
219
|
+
{
|
|
220
|
+
// デフォルトの2だと、そこそこラベルのテキストが検知できないケースがあるため。
|
|
221
|
+
depth: 7,
|
|
222
|
+
},
|
|
223
|
+
],
|
|
224
|
+
|
|
194
225
|
/**
|
|
195
226
|
* settings for unused-imports
|
|
196
227
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-matsuri",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "index.js",
|
|
@@ -23,17 +23,8 @@
|
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"eslint": "^8.43.0"
|
|
25
25
|
},
|
|
26
|
-
"devDependencies": {
|
|
27
|
-
"@emotion/react": "11.11.3",
|
|
28
|
-
"@types/react": "18.2.57",
|
|
29
|
-
"eslint": "8.56.0",
|
|
30
|
-
"react": "18.2.0",
|
|
31
|
-
"typescript": "5.3.3"
|
|
32
|
-
},
|
|
33
26
|
"dependencies": {
|
|
34
|
-
"@eslint/js": "8.
|
|
35
|
-
"@typescript-eslint/eslint-plugin": "7.0.2",
|
|
36
|
-
"@typescript-eslint/parser": "7.0.2",
|
|
27
|
+
"@eslint/js": "8.57.0",
|
|
37
28
|
"eslint-config-prettier": "9.1.0",
|
|
38
29
|
"eslint-plugin-css-reorder": "0.5.1",
|
|
39
30
|
"eslint-plugin-jsx-a11y": "6.8.0",
|
|
@@ -43,6 +34,7 @@
|
|
|
43
34
|
"eslint-plugin-sort-imports-es6-autofix": "0.6.0",
|
|
44
35
|
"eslint-plugin-storybook": "0.8.0",
|
|
45
36
|
"eslint-plugin-unused-imports": "3.1.0",
|
|
46
|
-
"globals": "14.0.0"
|
|
37
|
+
"globals": "14.0.0",
|
|
38
|
+
"typescript-eslint": "7.1.1"
|
|
47
39
|
}
|
|
48
40
|
}
|