eslint-config-matsuri 4.0.0 → 4.1.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.
Files changed (3) hide show
  1. package/README.md +2 -0
  2. package/index.js +22 -6
  3. package/package.json +7 -8
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 ts from "@typescript-eslint/eslint-plugin";
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,6 +19,23 @@ 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
  {
@@ -87,7 +103,7 @@ const config = [
87
103
  React: true,
88
104
  JSX: true,
89
105
  },
90
- parser: tsParser,
106
+ parser: tseslint.parser,
91
107
  parserOptions: {
92
108
  project: true,
93
109
  },
@@ -98,7 +114,7 @@ const config = [
98
114
  },
99
115
  },
100
116
  plugins: {
101
- "@typescript-eslint": ts,
117
+ "@typescript-eslint": tseslint.plugin,
102
118
  "unused-imports": pluginUnusedImport,
103
119
  "css-reorder": pluginCssReorder,
104
120
  "jsx-a11y": pluginJsxA11y,
@@ -107,11 +123,11 @@ const config = [
107
123
  "react-refresh": pluginReactRefresh,
108
124
  },
109
125
  rules: {
126
+ ...tseslintRecommendedTypeChckedRules,
127
+ ...tseslintStylisticTypeCheckedRules,
110
128
  ...pluginReact.configs.recommended.rules,
111
129
  ...pluginReactHooks.configs.recommended.rules,
112
130
  ...pluginReact.configs["jsx-runtime"].rules,
113
- ...ts.configs["recommended-type-checked"].rules,
114
- ...ts.configs["stylistic-type-checked"].rules,
115
131
  ...pluginJsxA11y.configs.recommended.rules,
116
132
  ...pluginPrettier.rules,
117
133
  "css-reorder/property-reorder": "error",
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "eslint-config-matsuri",
3
- "version": "4.0.0",
3
+ "version": "4.1.0",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "index.js",
7
7
  "types": "index.d.ts",
8
8
  "engines": {
9
- "node": ">=20.0.0"
9
+ "node": ">=18.0.0"
10
10
  },
11
11
  "files": [
12
12
  "index.js",
@@ -25,15 +25,13 @@
25
25
  },
26
26
  "devDependencies": {
27
27
  "@emotion/react": "11.11.3",
28
- "@types/react": "18.2.56",
29
- "eslint": "8.56.0",
28
+ "@types/react": "18.2.58",
29
+ "eslint": "8.57.0",
30
30
  "react": "18.2.0",
31
31
  "typescript": "5.3.3"
32
32
  },
33
33
  "dependencies": {
34
- "@eslint/js": "8.56.0",
35
- "@typescript-eslint/eslint-plugin": "7.0.1",
36
- "@typescript-eslint/parser": "7.0.1",
34
+ "@eslint/js": "8.57.0",
37
35
  "eslint-config-prettier": "9.1.0",
38
36
  "eslint-plugin-css-reorder": "0.5.1",
39
37
  "eslint-plugin-jsx-a11y": "6.8.0",
@@ -43,6 +41,7 @@
43
41
  "eslint-plugin-sort-imports-es6-autofix": "0.6.0",
44
42
  "eslint-plugin-storybook": "0.8.0",
45
43
  "eslint-plugin-unused-imports": "3.1.0",
46
- "globals": "14.0.0"
44
+ "globals": "14.0.0",
45
+ "typescript-eslint": "7.0.2"
47
46
  }
48
47
  }