forked from KushibikiMashu/nextjs-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc.js
107 lines (107 loc) · 3.18 KB
/
.eslintrc.js
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
module.exports = {
env: {
browser: true,
es6: true,
node: true,
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
'plugin:react-hooks/recommended',
'plugin:jsx-a11y/recommended',
'plugin:import/typescript',
'plugin:@next/next/recommended',
// 競合を避けるため、prettierは一番最後に書く
'plugin:prettier/recommended',
],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2021,
sourceType: 'module',
project: './tsconfig.json',
},
settings: {
react: {
version: 'detect',
},
'import/resolver': {
node: {
extensions: ['.js', '.ts', '.tsx'],
},
},
},
plugins: ['jsx-a11y', 'import'],
rules: {
// prettier の設定
'prettier/prettier': [
'error',
{
trailingComma: 'es5',
tabWidth: 2,
semi: false,
singleQuote: true,
printWidth: 120,
},
],
// React Hooks のための設定
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
// prop types を使っていないので off
'react/prop-types': 'off',
// Next.js では React を import しなくてもよいので off にする
'react/react-in-jsx-scope': 'off',
// 関数の引数や返り値に必ず型をつけるルールを off にする
// アプリケーションをより堅牢にしたい場合は、このルールを on にしてください
'@typescript-eslint/explicit-module-boundary-types': 'off',
// next/linkのchildのaタグの空hrefを許容する
'jsx-a11y/anchor-is-valid': 'off',
// 未使用の変数がある場合エラーにする(デフォルトは warning)
'@typescript-eslint/no-unused-vars': 'error',
// named-exportを許可
'import/prefer-default-export': 'off',
// 絶対パスでのモジュールの読み込みをokにする
'import/no-unresolved': 'off',
// 「import Link from 'next/link'」で引っかかるため無効化
'no-submodule-imports': 'off',
// importの順番を整理する
'import/order': [
'error',
{
pathGroups: [
{
pattern: '~/**',
group: 'external',
position: 'after',
},
],
'newlines-between': 'always',
alphabetize: {
order: 'asc',
caseInsensitive: false,
},
},
],
// if文内のcontinueをokにする
'no-continue': 'off',
// for (const a of A) を許可
'no-restricted-syntax': 'off',
// onClick={e => handleClick(e)} で引っかかるため無効化
'jsx-no-lambda': 'off',
// <Component {...props}>を許可する
'react/jsx-props-no-spreading': 'off',
// 順序の入れ替えがない場合はok
'react/no-array-index-key': 'off',
// component の props の destructuring を非必須にする
'react/destructuring-assignment': 'off',
// console.errorを許容する
'no-console': ['error', {allow: ['warn', 'error']}],
}
}