Repository navigation
Expand file tree
/
Copy patheslint.config.mjs
More file actions
84 lines (76 loc) · 2.45 KB
/
Copy patheslint.config.mjs
File metadata and controls
84 lines (76 loc) · 2.45 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import js from '@eslint/js';
import globals from 'globals';
import tsPlugin from '@typescript-eslint/eslint-plugin';
import tsParser from '@typescript-eslint/parser';
import reactPlugin from 'eslint-plugin-react';
import reactHooksPlugin from 'eslint-plugin-react-hooks';
import jsxA11yPlugin from 'eslint-plugin-jsx-a11y';
import eslintConfigPrettier from 'eslint-config-prettier/flat';
export default [
{
ignores: ['dist/**', 'lib/**', 'node_modules/**'],
},
js.configs.recommended,
reactPlugin.configs.flat.recommended,
reactPlugin.configs.flat['jsx-runtime'], // React 17+ の新しいJSX変換用(react-in-jsx-scopeルールを自動で無効化)
reactHooksPlugin.configs.flat.recommended,
jsxA11yPlugin.flatConfigs.recommended,
eslintConfigPrettier,
{
languageOptions: {
globals: {
...globals.browser,
},
parserOptions: {
ecmaFeatures: { jsx: true },
},
},
settings: {
react: {
// ESLint 10でcontext.getFilename()が削除され、'detect'指定時のバージョン自動検出が
// eslint-plugin-react@7.37.5では動作しないため、明示的にバージョンを指定
version: '18.3.1',
},
},
rules: {
'react/prop-types': 'off',
// 関数コンポーネントは関数宣言を強制
'react/function-component-definition': [
'error',
{
namedComponents: 'function-declaration',
unnamedComponents: 'function-expression',
},
],
'jsx-a11y/label-has-associated-control': 'off',
'react/no-children-prop': 'off',
},
},
// プロジェクトにJavaScriptとTypeScriptが共存しているため、
// ts, tsxの拡張子のファイルは別途TypeScript用のルールを適用
{
files: ['**/*.ts', '**/*.tsx'],
languageOptions: {
parser: tsParser,
},
plugins: {
'@typescript-eslint': tsPlugin,
},
rules: {
...tsPlugin.configs.recommended.rules,
// 未使用変数を禁止(ただし_プレフィックスは許可)
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
// 定義前の変数の使用に警告
'@typescript-eslint/no-use-before-define': 'warn',
// any型の使用を許可
'@typescript-eslint/no-explicit-any': 'off',
},
},
];