-
Notifications
You must be signed in to change notification settings - Fork 0
/
base.js
150 lines (141 loc) · 4.65 KB
/
base.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
import { FlatCompat } from '@eslint/eslintrc'
import airbnbBase from 'eslint-config-airbnb-base'
import airbnbTypescriptBase from 'eslint-config-airbnb-typescript/base.js'
import typescript from '@typescript-eslint/eslint-plugin'
import comments from 'eslint-plugin-eslint-comments'
import unusedImports from 'eslint-plugin-unused-imports'
const compat = new FlatCompat()
export default [
...compat.config(airbnbBase),
...compat.config(airbnbTypescriptBase),
...compat.extends(
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/stylistic',
'plugin:eslint-comments/recommended',
),
{
plugins: {
'unused-imports': unusedImports,
typescript,
comments,
},
rules: {
/**
* eslint
*/
'arrow-body-style': 'off',
camelcase: [
'error',
{
properties: 'never',
ignoreDestructuring: false,
allow: ['^[A-Z].*_[A-Z].*'],
},
],
'default-case-last': 'error', // 統一したいだけなのでfirstでもいい
'default-param-last': 'off', // optional paramを最後尾にしたいのでoff
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
'max-lines': [
'error',
{
max: 250,
skipBlankLines: true,
skipComments: true,
},
],
'no-alert': 'error',
'no-console': 'error',
'no-promise-executor-return': 'error',
// NOTE: import/no-relative-parent-importsだと@でのimportもNGになるのでno-restricted-importsで../を禁止する
'no-restricted-imports': ['error', { patterns: ['..*'] }],
'no-unused-expressions': 'off', // duplidate @typescript-eslint/no-unused-expressions
'no-useless-constructor': 'off',
'no-use-before-define': 'off', // duplidate @typescript-eslint/no-use-before-define
'no-param-reassign': [
'error',
{
props: false,
},
],
/**
* @typescript-eslint
*/
'@typescript-eslint/consistent-type-assertions': ['error', { assertionStyle: 'never' }],
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/explicit-function-return-type': 'off', // annoying to force return type
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-unused-expressions': [
'error',
{
allowShortCircuit: true,
allowTernary: true,
},
], // https://github.com/facebook/create-react-app/issues/8107
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'@typescript-eslint/no-useless-constructor': ['error'],
// @typescript-eslint v6でrecommendedからアラートが出なくなったルールを有効化
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/no-explicit-any': 'error',
/**
* eslint-comments
*/
'eslint-comments/disable-enable-pair': ['error', { allowWholeFile: true }],
'eslint-comments/no-unused-disable': 'error',
'eslint-comments/no-use': [
'error',
{
allow: ['eslint-disable', 'eslint-enable', 'eslint-disable-next-line'],
},
],
'eslint-comments/require-description': ['error', { ignore: ['eslint-enable'] }],
/**
* import
*/
'import/extensions': 'off',
'import/named': 'off',
'import/no-cycle': 'error',
'import/no-default-export': 'error',
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: ['**/*.stories.tsx', '**/*.test.tsx'],
optionalDependencies: false,
},
],
'import/no-relative-packages': 'off',
'import/no-relative-parent-imports': 'off',
'import/no-unresolved': 'off',
'import/order': [
'error',
{
groups: [
'builtin',
'external',
'internal',
['parent', 'sibling'],
'object',
'type',
'index',
],
'newlines-between': 'always',
pathGroupsExcludedImportTypes: ['builtin'],
alphabetize: { order: 'asc', caseInsensitive: true },
pathGroups: [],
},
],
'import/prefer-default-export': 'off',
/**
* unused-imports
*/
'unused-imports/no-unused-imports': 'error',
},
},
{
files: ['**/*.test.tsx?', '**/*mock.ts', 'src/mocks/**/*'],
rules: {
'max-lines': 'off',
},
},
]