eslint-config-matsuri 2.1.0 → 3.0.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 (4) hide show
  1. package/README.md +17 -9
  2. package/index.d.ts +5 -0
  3. package/index.js +150 -128
  4. package/package.json +7 -3
package/README.md CHANGED
@@ -18,20 +18,28 @@ ESLintを除く依存関係を別途インストールする必要はありま
18
18
  yarn add eslint eslint-config-matsuri
19
19
  ```
20
20
 
21
- 設定ファイルは次の記述のみで良くなります。他の記述は削除してください。
21
+ Flat configをv3からサポートしています。eslint.config.jsに次のように記述します。
22
22
 
23
23
  ```js
24
- /** @type {import('eslint').Linter.BaseConfig} */
25
- const config = {
26
- extends: ["matsuri"],
27
- parserOptions: {
28
- project: true,
29
- tsconfigRootDir: __dirname,
24
+ import config from "eslint-config-matsuri";
25
+
26
+ export default config
27
+ ```
28
+
29
+ 拡張する場合は、次のようにしてください。
30
+
31
+ ```js
32
+ import config from "eslint-config-matsuri";
33
+
34
+ export default [
35
+ ...config,
36
+ {
37
+ // ここに追加の設定を記述する
30
38
  }
31
- };
32
- module.exports = config;
39
+ ]
33
40
  ```
34
41
 
42
+
35
43
  ## Contributing
36
44
 
37
45
  ルールの検証などを行いたい場合は、tests以下にファイルを配置してください。
package/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { Linter } from "eslint";
2
+
3
+ declare const config: Linter.FlatConfig[];
4
+
5
+ export default config;
package/index.js CHANGED
@@ -1,148 +1,170 @@
1
- /** @type {import('eslint').Linter.BaseConfig} */
2
- const config = {
3
- reportUnusedDisableDirectives: true,
4
- root: true,
5
- env: {
6
- commonjs: true,
7
- es2021: true,
8
- node: true,
9
- },
10
- parserOptions: {
11
- ecmaVersion: 12,
12
- },
13
- extends: ["eslint:recommended"],
14
- plugins: ["sort-imports-es6-autofix"],
15
- rules: {
16
- "no-console": ["error", { allow: ["error"] }],
17
- eqeqeq: ["error", "always"],
1
+ import globals from "globals";
2
+ import js from "@eslint/js";
3
+ import pluginCssReorder from "eslint-plugin-css-reorder";
4
+ import pluginJsxA11y from "eslint-plugin-jsx-a11y";
5
+ import pluginPrettier from "eslint-config-prettier";
6
+ import pluginReact from "eslint-plugin-react";
7
+ import pluginReactHooks from "eslint-plugin-react-hooks";
8
+ import pluginSortImports from "eslint-plugin-sort-imports-es6-autofix";
9
+ import pluginUnusedImport from "eslint-plugin-unused-imports";
10
+ import ts from "@typescript-eslint/eslint-plugin";
11
+ import tsParser from "@typescript-eslint/parser";
18
12
 
19
- /**
20
- * eslint-plugin-sort-imports-es6-autofix
21
- */
22
- "sort-imports-es6-autofix/sort-imports-es6": [
23
- 2,
24
- {
25
- ignoreCase: false,
26
- ignoreMemberSort: false,
27
- memberSyntaxSortOrder: ["none", "all", "multiple", "single"],
13
+ /** @type { import("eslint").Linter.FlatConfig[] } */
14
+ const config = [
15
+ {
16
+ linterOptions: {
17
+ reportUnusedDisableDirectives: true,
18
+ },
19
+ languageOptions: {
20
+ ecmaVersion: "latest",
21
+ sourceType: "module",
22
+ globals: {
23
+ ...globals.commonjs,
24
+ ...globals.es2021,
25
+ ...globals.node,
28
26
  },
29
- ],
27
+ },
28
+ plugins: {
29
+ "sort-imports-es6-autofix": pluginSortImports,
30
+ },
31
+ rules: {
32
+ ...js.configs.recommended.rules,
33
+ "no-console": ["error", { allow: ["error"] }],
34
+ eqeqeq: ["error", "always"],
35
+
36
+ /**
37
+ * eslint-plugin-sort-imports-es6-autofix
38
+ */
39
+ "sort-imports-es6-autofix/sort-imports-es6": [
40
+ 2,
41
+ {
42
+ ignoreCase: false,
43
+ ignoreMemberSort: false,
44
+ memberSyntaxSortOrder: ["none", "all", "multiple", "single"],
45
+ },
46
+ ],
47
+ },
30
48
  },
31
- overrides: [
32
- {
33
- files: ["**/*.ts", "**/*.tsx"],
34
- env: {
35
- browser: true,
36
- es2021: true,
49
+ {
50
+ files: ["**/*.ts", "**/*.tsx"],
51
+ languageOptions: {
52
+ globals: {
53
+ ...globals.browser,
54
+ ...globals.es2021,
55
+ React: true,
37
56
  },
38
- plugins: [
39
- "css-reorder",
40
- "jsx-a11y",
41
- "unused-imports",
42
- "@typescript-eslint",
43
- ],
44
- extends: [
45
- "plugin:react/recommended",
46
- "plugin:react-hooks/recommended",
47
- "plugin:react/jsx-runtime",
48
- "plugin:@typescript-eslint/recommended-type-checked",
49
- "plugin:@typescript-eslint/stylistic-type-checked",
50
- "plugin:jsx-a11y/recommended",
51
- "prettier",
52
- ],
53
- parser: "@typescript-eslint/parser",
54
- settings: {
55
- react: {
56
- version: "detect",
57
- },
57
+ parser: tsParser,
58
+ parserOptions: {
59
+ project: true,
60
+ },
61
+ },
62
+ settings: {
63
+ react: {
64
+ version: "detect",
58
65
  },
59
- rules: {
60
- "css-reorder/property-reorder": "error",
66
+ },
67
+ plugins: {
68
+ "@typescript-eslint": ts,
69
+ "unused-imports": pluginUnusedImport,
70
+ "css-reorder": pluginCssReorder,
71
+ "jsx-a11y": pluginJsxA11y,
72
+ react: pluginReact,
73
+ "react-hooks": pluginReactHooks,
74
+ },
75
+ rules: {
76
+ ...pluginReact.configs.recommended.rules,
77
+ ...pluginReactHooks.configs.recommended.rules,
78
+ ...pluginReact.configs["jsx-runtime"].rules,
79
+ ...ts.configs["recommended-type-checked"].rules,
80
+ ...ts.configs["stylistic-type-checked"].rules,
81
+ ...pluginJsxA11y.configs.recommended.rules,
82
+ ...pluginPrettier.rules,
83
+ "css-reorder/property-reorder": "error",
61
84
 
62
- "@typescript-eslint/explicit-module-boundary-types": "off",
85
+ "@typescript-eslint/explicit-module-boundary-types": "off",
63
86
 
64
- "@typescript-eslint/no-empty-interface": "off",
87
+ "@typescript-eslint/no-empty-interface": "off",
65
88
 
66
- "@typescript-eslint/no-non-null-assertion": "error",
89
+ "@typescript-eslint/no-non-null-assertion": "error",
67
90
 
68
- "@typescript-eslint/consistent-type-exports": "error",
91
+ "@typescript-eslint/consistent-type-exports": "error",
69
92
 
70
- "@typescript-eslint/strict-boolean-expressions": [
71
- "error",
72
- {
73
- allowString: true,
74
- allowNullableObject: true,
75
- allowNullableBoolean: true,
76
- allowNullableString: true,
77
- allowAny: true,
78
- },
79
- ],
80
- "@typescript-eslint/ban-types": [
81
- "error",
82
- {
83
- types: {
84
- "React.VFC": {
85
- message: "Use React.FC instead.",
86
- fixWith: "React.FC",
87
- },
88
- VFC: {
89
- message: "Use React.FC instead.",
90
- fixWith: "React.FC",
91
- },
93
+ "@typescript-eslint/strict-boolean-expressions": [
94
+ "error",
95
+ {
96
+ allowString: true,
97
+ allowNullableObject: true,
98
+ allowNullableBoolean: true,
99
+ allowNullableString: true,
100
+ allowAny: true,
101
+ },
102
+ ],
103
+ "@typescript-eslint/ban-types": [
104
+ "error",
105
+ {
106
+ types: {
107
+ "React.VFC": {
108
+ message: "Use React.FC instead.",
109
+ fixWith: "React.FC",
92
110
  },
93
- },
94
- ],
95
-
96
- /**
97
- * Allow `() => Promise<void>` in JSX event handler.
98
- * @see https://github.com/typescript-eslint/typescript-eslint/blob/f373fac1dd0150273d98cee5bed606bbd3f55e4b/packages/eslint-plugin/docs/rules/no-misused-promises.md#checksvoidreturn
99
- */
100
- "@typescript-eslint/no-misused-promises": [
101
- "error",
102
- {
103
- checksVoidReturn: {
104
- attributes: false,
111
+ VFC: {
112
+ message: "Use React.FC instead.",
113
+ fixWith: "React.FC",
105
114
  },
106
115
  },
107
- ],
116
+ },
117
+ ],
108
118
 
109
- "react/self-closing-comp": [
110
- "error",
111
- {
112
- component: true,
113
- html: true,
119
+ /**
120
+ * Allow `() => Promise<void>` in JSX event handler.
121
+ * @see https://github.com/typescript-eslint/typescript-eslint/blob/f373fac1dd0150273d98cee5bed606bbd3f55e4b/packages/eslint-plugin/docs/rules/no-misused-promises.md#checksvoidreturn
122
+ */
123
+ "@typescript-eslint/no-misused-promises": [
124
+ "error",
125
+ {
126
+ checksVoidReturn: {
127
+ attributes: false,
114
128
  },
115
- ],
116
- "react/prop-types": "off",
117
- "react/display-name": "off",
118
- // For emotion and its css prop
119
- "react/no-unknown-property": ["error", { ignore: ["css"] }],
120
- "react-hooks/exhaustive-deps": "error",
129
+ },
130
+ ],
121
131
 
122
- "jsx-a11y/click-events-have-key-events": "off",
123
- "jsx-a11y/no-autofocus": "off",
132
+ "react/self-closing-comp": [
133
+ "error",
134
+ {
135
+ component: true,
136
+ html: true,
137
+ },
138
+ ],
139
+ "react/prop-types": "off",
140
+ "react/display-name": "off",
141
+ // For emotion and its css prop
142
+ "react/no-unknown-property": ["error", { ignore: ["css"] }],
143
+ "react-hooks/exhaustive-deps": "error",
124
144
 
125
- // 当社のサービスでは、ユーザーがアップロードした動画を表示することが主であり、
126
- // 字幕を付加することはあまり想定されず、無意味なtrack要素の挿入を招くため無効化する
127
- "jsx-a11y/media-has-caption": "off",
145
+ "jsx-a11y/click-events-have-key-events": "off",
146
+ "jsx-a11y/no-autofocus": "off",
128
147
 
129
- /**
130
- * settings for unused-imports
131
- */
132
- "@typescript-eslint/no-unused-vars": "off",
133
- "unused-imports/no-unused-imports": "error",
134
- "unused-imports/no-unused-vars": [
135
- "error",
136
- {
137
- vars: "all",
138
- varsIgnorePattern: "^_",
139
- args: "after-used",
140
- argsIgnorePattern: "^_",
141
- },
142
- ],
143
- },
148
+ // 当社のサービスでは、ユーザーがアップロードした動画を表示することが主であり、
149
+ // 字幕を付加することはあまり想定されず、無意味なtrack要素の挿入を招くため無効化する
150
+ "jsx-a11y/media-has-caption": "off",
151
+
152
+ /**
153
+ * settings for unused-imports
154
+ */
155
+ "@typescript-eslint/no-unused-vars": "off",
156
+ "unused-imports/no-unused-imports": "error",
157
+ "unused-imports/no-unused-vars": [
158
+ "error",
159
+ {
160
+ vars: "all",
161
+ varsIgnorePattern: "^_",
162
+ args: "after-used",
163
+ argsIgnorePattern: "^_",
164
+ },
165
+ ],
144
166
  },
145
- ],
146
- };
167
+ },
168
+ ];
147
169
 
148
- module.exports = config;
170
+ export default config;
package/package.json CHANGED
@@ -1,10 +1,13 @@
1
1
  {
2
2
  "name": "eslint-config-matsuri",
3
- "version": "2.1.0",
3
+ "version": "3.0.0",
4
+ "type": "module",
4
5
  "description": "",
5
6
  "main": "index.js",
7
+ "types": "index.d.ts",
6
8
  "files": [
7
- "index.js"
9
+ "index.js",
10
+ "index.d.ts"
8
11
  ],
9
12
  "scripts": {
10
13
  "test": "eslint . --max-warnings 0"
@@ -15,7 +18,7 @@
15
18
  "registry": "https://registry.npmjs.org/"
16
19
  },
17
20
  "peerDependencies": {
18
- "eslint": "8.43.0"
21
+ "eslint": "^8.43.0"
19
22
  },
20
23
  "devDependencies": {
21
24
  "@emotion/react": "11.11.1",
@@ -25,6 +28,7 @@
25
28
  "typescript": "5.1.6"
26
29
  },
27
30
  "dependencies": {
31
+ "@eslint/js": "8.53.0",
28
32
  "@typescript-eslint/eslint-plugin": "6.2.1",
29
33
  "@typescript-eslint/parser": "6.2.1",
30
34
  "eslint-config-prettier": "8.8.0",