@@ -5,13 +5,14 @@ module.exports = {
55 node : true ,
66 } ,
77 extends : [
8- 'plugin:react/recommended' ,
9- 'standard' ,
108 'eslint:recommended' ,
119 'plugin:@typescript-eslint/recommended' ,
10+ 'plugin:react/recommended' ,
11+ 'plugin:react-hooks/recommended' ,
12+ 'plugin:jsx-a11y/recommended' ,
13+ 'plugin:import/typescript' ,
1214 // 競合を避けるため、prettierは一番最後に書く
1315 'plugin:prettier/recommended' ,
14- 'prettier/react' ,
1516 'prettier/@typescript-eslint' ,
1617 ] ,
1718 globals : {
@@ -23,78 +24,84 @@ module.exports = {
2324 ecmaFeatures : {
2425 jsx : true ,
2526 } ,
26- ecmaVersion : 2018 ,
27+ ecmaVersion : 2021 ,
2728 sourceType : 'module' ,
2829 project : './tsconfig.json' ,
2930 } ,
3031 settings : {
3132 react : {
3233 version : 'detect' ,
3334 } ,
35+ 'import/resolver' : {
36+ node : {
37+ extensions : [ '.js' , '.ts' , '.tsx' ] ,
38+ } ,
39+ } ,
3440 } ,
35- plugins : [ '@typescript-eslint ' , 'react' , 'react-hooks' , 'prettier '] ,
41+ plugins : [ 'jsx-a11y ' , 'import ' ] ,
3642 rules : {
37- // prettierを実行する
38- 'import-name' : 'off' ,
39- align : 'off' ,
40- // 「import Link from 'next/link'」で引っかかるため無効化
41- 'no-submodule-imports' : 'off' ,
42- // css['foo--bar']で引っかかるため無効化
43- 'no-string-literal' : 'off' ,
44- // onClick={e => handleClick(e)}で引っかかるため無効化
45- 'jsx-no-lambda' : 'off' ,
46- 'react-hooks/rules-of-hooks' : 'error' ,
47- 'react/jsx-filename-extension' : [
43+ // prettier の設定
44+ 'prettier/prettier' : [
4845 'error' ,
4946 {
50- extensions : [ '.js' , '.jsx' , '.ts' , '.tsx' ] ,
51- } ,
52- ] ,
53- // import構文でエラーが出るため
54- 'import/extensions' : [
55- 'off' ,
56- {
57- js : 'never' ,
58- jsx : 'never' ,
59- ts : 'never' ,
60- tsx : 'never' ,
47+ trailingComma : 'es5' ,
48+ tabWidth : 2 ,
49+ semi : false ,
50+ singleQuote : true ,
51+ printWidth : 120 ,
6152 } ,
6253 ] ,
63- 'import/no-unresolved' : 'off' ,
64- 'react/prop-types' : [ 'off' ] ,
65- // windowやlocationを使えなくなるためoff
66- 'no-restricted-globals' : 'off' ,
67- // [1, 2].map((item, index) => <li key={index}>{item}</li>)
68- // のように、indexをkeyとして使えなくなるためoff
69- 'react/no-array-index-key' : 'off' ,
70- // 毎回Reactをインポートしなくてもよくするためにoff
54+ // React Hooks のための設定
55+ 'react-hooks/rules-of-hooks' : 'error' ,
56+ 'react-hooks/exhaustive-deps' : 'warn' ,
57+ // prop types を使っていないので off
58+ 'react/prop-types' : 'off' ,
59+ // Next.js では React を import しなくてもよいので off にする
7160 'react/react-in-jsx-scope' : 'off' ,
72- 'react/jsx-one-expression-per-line' : 'off' ,
61+ // 関数の引数や返り値に必ず型をつけるルールを off にする
62+ // アプリケーションをより堅牢にしたい場合は、このルールを on にしてください
63+ '@typescript-eslint/explicit-module-boundary-types' : 'off' ,
7364 // next/linkのchildのaタグの空hrefを許容する
7465 'jsx-a11y/anchor-is-valid' : 'off' ,
75- // コメントの前後にスペースがないことを許容
76- 'spaced-comment' : 'off' ,
77- '@typescript-eslint/explicit-function-return-type' : 'off' ,
78- // 使っていない変数はエラーにする
66+ // 未使用の変数がある場合エラーにする(デフォルトは warning)
7967 '@typescript-eslint/no-unused-vars' : 'error' ,
80- // referrerをつけれるようにする
81- 'react/jsx-no-target-blank' : 'off' ,
82- // 関数の型定義を必ず書かなくてもよくする
83- '@typescript-eslint/explicit-module-boundary-types' : 'off' ,
84- // stylesをComponentとContainerの間に置くため
85- 'no-use-before-define' : 'off' ,
86- // TypeScriptのconstructorのfieldは空でOK
87- 'no-useless-constructor' : 'off' ,
88- // 依存モジュールを並び替える
89- 'sort-imports' : [ 'error' , { ignoreDeclarationSort : true } ] ,
68+ // named-exportを許可
69+ 'import/prefer-default-export' : 'off' ,
70+ // 絶対パスでのモジュールの読み込みをokにする
71+ 'import/no-unresolved' : 'off' ,
72+ // 「import Link from 'next/link'」で引っかかるため無効化
73+ 'no-submodule-imports' : 'off' ,
74+ // importの順番を整理する
9075 'import/order' : [
9176 'error' ,
9277 {
78+ pathGroups : [
79+ {
80+ pattern : '~/**' ,
81+ group : 'external' ,
82+ position : 'after' ,
83+ } ,
84+ ] ,
85+ 'newlines-between' : 'always' ,
9386 alphabetize : {
9487 order : 'asc' ,
9588 caseInsensitive : false ,
9689 } ,
9790 } ,
9891 ] ,
99- } ,
92+ // if文内のcontinueをokにする
93+ 'no-continue' : 'off' ,
94+ // for (const a of A) を許可
95+ 'no-restricted-syntax' : 'off' ,
96+ // onClick={e => handleClick(e)} で引っかかるため無効化
97+ 'jsx-no-lambda' : 'off' ,
98+ // <Component {...props}>を許可する
99+ 'react/jsx-props-no-spreading' : 'off' ,
100+ // 順序の入れ替えがない場合はok
101+ 'react/no-array-index-key' : 'off' ,
102+ // component の props の destructuring を非必須にする
103+ 'react/destructuring-assignment' : 'off' ,
104+ // console.errorを許容する
105+ 'no-console' : [ 'error' , { allow : [ 'warn' , 'error' ] } ] ,
106+ }
100107}
0 commit comments