eslint-plugin-smarthr 0.2.0 → 0.2.1
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.
- package/CHANGELOG.md +7 -0
- package/README.md +15 -574
- package/index.js +3 -6
- package/package.json +1 -1
- package/rules/a11y-clickable-element-has-text/README.md +61 -0
- package/rules/{a11y-clickable-element-has-text.js → a11y-clickable-element-has-text/index.js} +1 -1
- package/rules/a11y-image-has-alt-attribute/README.md +55 -0
- package/rules/{a11y-image-has-alt-attribute.js → a11y-image-has-alt-attribute/index.js} +1 -1
- package/rules/a11y-trigger-has-button/README.md +57 -0
- package/rules/{a11y-trigger-has-button.js → a11y-trigger-has-button/index.js} +1 -1
- package/rules/best-practice-for-date/README.md +40 -0
- package/rules/best-practice-for-date/index.js +42 -0
- package/rules/format-import-path/README.md +99 -0
- package/rules/{format-import-path.js → format-import-path/index.js} +2 -2
- package/rules/format-translate-component/README.md +58 -0
- package/rules/{format-translate-component.js → format-translate-component/index.js} +0 -0
- package/rules/jsx-start-with-spread-attributes/README.md +31 -0
- package/rules/{jsx-start-with-spread-attributes.js → jsx-start-with-spread-attributes/index.js} +0 -0
- package/rules/no-import-other-domain/README.md +85 -0
- package/rules/{no-import-other-domain.js → no-import-other-domain/index.js} +2 -2
- package/rules/prohibit-export-array-type/README.md +28 -0
- package/rules/prohibit-export-array-type/index.js +28 -0
- package/rules/prohibit-file-name/README.md +35 -0
- package/rules/prohibit-file-name/index.js +61 -0
- package/rules/prohibit-import/README.md +44 -0
- package/rules/{prohibit-import.js → prohibit-import/index.js} +0 -0
- package/rules/redundant-name/README.md +94 -0
- package/rules/{redundant-name.js → redundant-name/index.js} +1 -1
- package/rules/require-barrel-import/README.md +39 -0
- package/rules/{require-barrel-import.js → require-barrel-import/index.js} +1 -1
- package/rules/require-export/README.md +43 -0
- package/rules/require-export/index.js +90 -0
- package/rules/require-import/README.md +51 -0
- package/rules/{require-import.js → require-import/index.js} +0 -0
- package/test/best-practice-for-date.js +31 -0
- package/test/prohibit-file-name.js +45 -0
- package/test/require-export.js +83 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.2.1](https://github.com/kufu/eslint-plugin-smarthr/compare/v0.2.0...v0.2.1) (2022-08-15)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* 新しいルールの追加 (require-export, prohibit-file-name, prohibit-export-array-type, best-practice-for-date ) ([#22](https://github.com/kufu/eslint-plugin-smarthr/issues/22)) ([ddb7433](https://github.com/kufu/eslint-plugin-smarthr/commit/ddb7433c0f26d64043cdcec353143240eceeccee))
|
|
11
|
+
|
|
5
12
|
### [0.2.0](https://github.com/kufu/eslint-plugin-smarthr/compare/v0.1.2...v0.2.0) (2022-07-05)
|
|
6
13
|
|
|
7
14
|
### ⚠ BREAKING CHANGES
|
package/README.md
CHANGED
|
@@ -1,576 +1,17 @@
|
|
|
1
1
|
# eslint-plugin-smarthr
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
```jsx
|
|
20
|
-
<XxxAnchor>
|
|
21
|
-
<Xxx />
|
|
22
|
-
</XxxAnchor>
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
```jsx
|
|
26
|
-
<XxxLink>
|
|
27
|
-
<Yyy />
|
|
28
|
-
</XxxLink>
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
```jsx
|
|
32
|
-
<XxxButton>
|
|
33
|
-
<Zzz />
|
|
34
|
-
</XxxButton>
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
### ✅ Correct
|
|
38
|
-
|
|
39
|
-
```jsx
|
|
40
|
-
<XxxAnchor>
|
|
41
|
-
Hoge
|
|
42
|
-
</XxxAnchor>
|
|
43
|
-
```
|
|
44
|
-
```jsx
|
|
45
|
-
<XxxLink>
|
|
46
|
-
<YyyIcon />
|
|
47
|
-
Fuga
|
|
48
|
-
</XxxLink>
|
|
49
|
-
```
|
|
50
|
-
```jsx
|
|
51
|
-
<XxxAnchor>>
|
|
52
|
-
<YyyIcon visuallyHiddenText="hoge" />
|
|
53
|
-
</XxxAnchor>
|
|
54
|
-
```
|
|
55
|
-
```jsx
|
|
56
|
-
<XxxButton>
|
|
57
|
-
<YyyImage alt="fuga" />
|
|
58
|
-
</XxxButton>
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
```jsx
|
|
62
|
-
<YyyAnchoor />
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
## smarthr/format-import-path
|
|
66
|
-
|
|
67
|
-
- importする際のpathをフォーマットするruleです
|
|
68
|
-
- ディレクトリ構造からドメインを識別して相対パス、絶対パスいずれかにするかを判定することが出来ます
|
|
69
|
-
- 例: crews/index 以下同士でのimportは相対パス、crews/index外のファイルimportする場合は絶対パスにする
|
|
70
|
-
- eslint を `--fix` オプション付きで実行すると自動的にパスを置き換えます
|
|
71
|
-
|
|
72
|
-
### config
|
|
73
|
-
|
|
74
|
-
- tsconfig.json の compilerOptions.pathsに '@/*' としてroot path を指定する必要があります
|
|
75
|
-
- ドメインを識別するために以下の設定を記述する必要があります
|
|
76
|
-
- globalModuleDir
|
|
77
|
-
- 全体で利用するファイルを収めているディレクトリを相対パスで指定します
|
|
78
|
-
- domainModuleDir:
|
|
79
|
-
- ドメイン内で共通のファイルを収めているディレクトリ名を指定します
|
|
80
|
-
- domainConstituteDir
|
|
81
|
-
- ドメインを構築するディレクトリ名を指定します
|
|
82
|
-
|
|
83
|
-
#### ディレクトリ例
|
|
84
|
-
```
|
|
85
|
-
/ constants
|
|
86
|
-
/ modules // 全体共通ディレクトリ
|
|
87
|
-
/ crews
|
|
88
|
-
/ modules // 共通ディレクトリ
|
|
89
|
-
/ views
|
|
90
|
-
/ parts
|
|
91
|
-
/ index
|
|
92
|
-
/ adapters
|
|
93
|
-
/ index.ts
|
|
94
|
-
/ hoge.ts
|
|
95
|
-
/ slices
|
|
96
|
-
/ index.ts
|
|
97
|
-
/ views
|
|
98
|
-
/ index.ts
|
|
99
|
-
/ parts
|
|
100
|
-
/ Abc.ts
|
|
101
|
-
/ show
|
|
102
|
-
/ views
|
|
103
|
-
/ parts
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
#### 指定例
|
|
107
|
-
```
|
|
108
|
-
const DOMAIN_RULE_ARGS = {
|
|
109
|
-
globalModuleDir: [ './constants', './modules' ],
|
|
110
|
-
domainModuleDir: [ 'modules' ],
|
|
111
|
-
domainConstituteDir: [ 'adapters', 'slices', 'views', 'parts' ],
|
|
112
|
-
}
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
### rules
|
|
116
|
-
|
|
117
|
-
```js
|
|
118
|
-
{
|
|
119
|
-
rules: {
|
|
120
|
-
'smarthr/format-import-path': [
|
|
121
|
-
'error', // 'warn', 'off'
|
|
122
|
-
{
|
|
123
|
-
...DOMAIN_RULE_ARGS,
|
|
124
|
-
format: {
|
|
125
|
-
// 'relative', 'auto', 'none'
|
|
126
|
-
// all: 'absolute',
|
|
127
|
-
outside: 'auto',
|
|
128
|
-
globalModule: 'absolute',
|
|
129
|
-
module: 'relative',
|
|
130
|
-
domain: 'relative',
|
|
131
|
-
lower: 'relative',
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
],
|
|
135
|
-
},
|
|
136
|
-
}
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
### ❌ Incorrect
|
|
140
|
-
|
|
141
|
-
```js
|
|
142
|
-
// crews/index/views/index.js
|
|
143
|
-
|
|
144
|
-
import slice from '@/crews/index/slice'
|
|
145
|
-
import hoge from '@/crews/index/adapter/hoge'
|
|
146
|
-
import Abc from '@/crews/index/views/parts/Abc'
|
|
147
|
-
import modulePart from '@/crews/modules/views/part'
|
|
148
|
-
import showPart from '../../show/views/parts'
|
|
149
|
-
import globalModulePart from '../../../module/views/part'
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
### ✅ Correct
|
|
153
|
-
|
|
154
|
-
```js
|
|
155
|
-
// crews/index/views/index.js
|
|
156
|
-
|
|
157
|
-
import slice from '../slice'
|
|
158
|
-
import hoge from '../adapter/hoge'
|
|
159
|
-
import Abc from './parts/Abc'
|
|
160
|
-
import modulePart from '../../modules/views/parts'
|
|
161
|
-
import showPart from '@/crews/show/views/parts'
|
|
162
|
-
import globalModulePart from '@/modules/views/parts'
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
## smarthr/jsx-start-with-spread-attributes
|
|
166
|
-
|
|
167
|
-
- jsxを記述する際、意図しない属性の上書きを防ぐため、spread-attributesを先に指定するように強制するruleです
|
|
168
|
-
- eslint を `--fix` オプション付きで実行する際、 fix option を true にすると自動修正します
|
|
169
|
-
|
|
170
|
-
### rules
|
|
171
|
-
|
|
172
|
-
```js
|
|
173
|
-
{
|
|
174
|
-
rules: {
|
|
175
|
-
'smarthr/jsx-start-with-spread-attributes': [
|
|
176
|
-
'error', // 'warn', 'off'
|
|
177
|
-
{
|
|
178
|
-
fix: false, // true
|
|
179
|
-
},
|
|
180
|
-
]
|
|
181
|
-
},
|
|
182
|
-
}
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
### ❌ Incorrect
|
|
186
|
-
|
|
187
|
-
```jsx
|
|
188
|
-
<AnyComponent hoge="hoge" {...props} />
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
### ✅ Correct
|
|
192
|
-
|
|
193
|
-
```jsx
|
|
194
|
-
<AnyComponent {...props} hoge="hoge" />
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
## smarthr/no-import-other-domain
|
|
200
|
-
|
|
201
|
-
- ドメイン外からのimportを防ぐruleです
|
|
202
|
-
- 例: crews/index 以下からのimportはOK, crews/index から crews/show 以下をimportするとNG
|
|
203
|
-
- ディレクトリ構造からドメインを識別して判定することが出来ます
|
|
204
|
-
|
|
205
|
-
### config
|
|
206
|
-
|
|
207
|
-
- tsconfig.json の compilerOptions.pathsに '@/*' としてroot path を指定する必要があります
|
|
208
|
-
- ドメインを識別するために以下の設定を記述する必要があります
|
|
209
|
-
- globalModuleDir
|
|
210
|
-
- 全体で利用するファイルを収めているディレクトリを相対パスで指定します
|
|
211
|
-
- domainModuleDir:
|
|
212
|
-
- ドメイン内で共通のファイルを収めているディレクトリ名を指定します
|
|
213
|
-
- domainConstituteDir
|
|
214
|
-
- ドメインを構築するディレクトリ名を指定します
|
|
215
|
-
|
|
216
|
-
#### ディレクトリ例
|
|
217
|
-
```
|
|
218
|
-
/ constants
|
|
219
|
-
/ modules // 全体共通ディレクトリ
|
|
220
|
-
/ crews
|
|
221
|
-
/ modules // 共通ディレクトリ
|
|
222
|
-
/ views
|
|
223
|
-
/ parts
|
|
224
|
-
/ index
|
|
225
|
-
/ adapters
|
|
226
|
-
/ index.ts
|
|
227
|
-
/ hoge.ts
|
|
228
|
-
/ slices
|
|
229
|
-
/ index.ts
|
|
230
|
-
/ views
|
|
231
|
-
/ index.ts
|
|
232
|
-
/ parts
|
|
233
|
-
/ Abc.ts
|
|
234
|
-
/ show
|
|
235
|
-
/ views
|
|
236
|
-
/ parts
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
#### 指定例
|
|
240
|
-
```
|
|
241
|
-
const DOMAIN_RULE_ARGS = {
|
|
242
|
-
globalModuleDir: [ './constants', './modules' ],
|
|
243
|
-
domainModuleDir: [ 'modules' ],
|
|
244
|
-
domainConstituteDir: [ 'adapters', 'slices', 'views', 'parts' ],
|
|
245
|
-
}
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
### rules
|
|
249
|
-
|
|
250
|
-
```js
|
|
251
|
-
{
|
|
252
|
-
rules: {
|
|
253
|
-
'smarthr/no-import-other-domain': [
|
|
254
|
-
'error', // 'warn', 'off'
|
|
255
|
-
{
|
|
256
|
-
...DOMAIN_RULE_ARGS,
|
|
257
|
-
// analyticsMode: 'all', // 'same-domain', 'another-domain'
|
|
258
|
-
}
|
|
259
|
-
]
|
|
260
|
-
},
|
|
261
|
-
}
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
### ❌ Incorrect
|
|
265
|
-
|
|
266
|
-
```js
|
|
267
|
-
// crews/index/views/index.js
|
|
268
|
-
|
|
269
|
-
import showPart1 from '@/crews/show/views/parts'
|
|
270
|
-
import showPart2 from '../../show/views/parts'
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
### ✅ Correct
|
|
274
|
-
|
|
275
|
-
```js
|
|
276
|
-
// crews/index/views/index.js
|
|
277
|
-
|
|
278
|
-
import slice from '../slice'
|
|
279
|
-
import hoge from '../adapter/hoge'
|
|
280
|
-
import Abc from './parts/Abc'
|
|
281
|
-
import modulePart from '../../modules/views/parts'
|
|
282
|
-
import globalModulePart from '@/modules/views/parts'
|
|
283
|
-
```
|
|
284
|
-
|
|
285
|
-
## smarthr/prohibit-import
|
|
286
|
-
|
|
287
|
-
- 例えば特定の module にバグが発見されたなど、importさせたくない場合に利用するルールです
|
|
288
|
-
|
|
289
|
-
### rules
|
|
290
|
-
|
|
291
|
-
```js
|
|
292
|
-
{
|
|
293
|
-
rules: {
|
|
294
|
-
'smarthr/prohibit-import': [
|
|
295
|
-
'error', // 'warn', 'off'
|
|
296
|
-
{
|
|
297
|
-
'^.+$': {
|
|
298
|
-
'smarthr-ui': {
|
|
299
|
-
imported: ['SecondaryButtonAnchor'],
|
|
300
|
-
reportMessage: `{{module}}/{{export}} はXxxxxxなので利用せず yyyy/zzzz を利用してください`
|
|
301
|
-
},
|
|
302
|
-
}
|
|
303
|
-
'\/pages\/views\/': {
|
|
304
|
-
'query-string': {
|
|
305
|
-
imported: true,
|
|
306
|
-
},
|
|
307
|
-
},
|
|
308
|
-
}
|
|
309
|
-
]
|
|
310
|
-
},
|
|
311
|
-
}
|
|
312
|
-
```
|
|
313
|
-
|
|
314
|
-
### ❌ Incorrect
|
|
315
|
-
|
|
316
|
-
```js
|
|
317
|
-
// src/pages/views/Page.tsx
|
|
318
|
-
import queryString from 'query-string'
|
|
319
|
-
import { SecondaryButtonAnchor } from 'smarthr-ui'
|
|
320
|
-
```
|
|
321
|
-
|
|
322
|
-
### ✅ Correct
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
```js
|
|
326
|
-
// src/pages/views/Page.tsx
|
|
327
|
-
import { PrimaryButton, SecondaryButton } from 'smarthr-ui'
|
|
328
|
-
```
|
|
329
|
-
|
|
330
|
-
## smarthr/require-import
|
|
331
|
-
|
|
332
|
-
- 対象ファイルにimportを強制させたい場合に利用します
|
|
333
|
-
- 例: Page.tsx ではページタイトルを設定させたいので useTitle を必ずimportさせたい
|
|
334
|
-
|
|
335
|
-
### rules
|
|
336
|
-
|
|
337
|
-
```js
|
|
338
|
-
{
|
|
339
|
-
rules: {
|
|
340
|
-
'smarthr/require-import': [
|
|
341
|
-
'error',
|
|
342
|
-
{
|
|
343
|
-
'Buttons\/.+\.tsx': {
|
|
344
|
-
'smarthr-ui': {
|
|
345
|
-
imported: ['SecondaryButton'],
|
|
346
|
-
reportMessage: 'Buttons以下のコンポーネントでは {{module}}/{{export}} を拡張するようにしてください',
|
|
347
|
-
},
|
|
348
|
-
},
|
|
349
|
-
'Page.tsx$': {
|
|
350
|
-
'./client/src/hooks/useTitle': {
|
|
351
|
-
imported: true,
|
|
352
|
-
reportMessage: '{{module}} を利用してください(ページタイトルを設定するため必要です)',
|
|
353
|
-
},
|
|
354
|
-
},
|
|
355
|
-
},
|
|
356
|
-
]
|
|
357
|
-
},
|
|
358
|
-
}
|
|
359
|
-
```
|
|
360
|
-
|
|
361
|
-
### ❌ Incorrect
|
|
362
|
-
|
|
363
|
-
```js
|
|
364
|
-
// client/src/Buttons/SecondaryButton.tsx
|
|
365
|
-
import { SecondaryButtonAnchor } from 'smarthr-ui'
|
|
366
|
-
|
|
367
|
-
// client/src/Page.tsx
|
|
368
|
-
import { SecondaryButton } from 'smarthr-ui'
|
|
369
|
-
```
|
|
370
|
-
|
|
371
|
-
### ✅ Correct
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
```js
|
|
375
|
-
// client/src/Buttons/SecondaryButton.tsx
|
|
376
|
-
import { SecondaryButton } from 'smarthr-ui'
|
|
377
|
-
|
|
378
|
-
// client/src/Page.tsx
|
|
379
|
-
import useTitle from '.hooks/useTitle'
|
|
380
|
-
```
|
|
381
|
-
|
|
382
|
-
## smarthr/require-barrel-import
|
|
383
|
-
|
|
384
|
-
- tsconfig.json の compilerOptions.pathsに '@/*' としてroot path を指定する必要があります
|
|
385
|
-
- importした対象が本来exportされているべきであるbarrel(index.tsなど)が有る場合、import pathの変更を促します
|
|
386
|
-
- 例: Page/parts/Menu/Item の import は Page/parts/Menu から行わせたい
|
|
387
|
-
- ディレクトリ内のindexファイルを捜査し、対象を決定します
|
|
388
|
-
|
|
389
|
-
### rules
|
|
390
|
-
|
|
391
|
-
```js
|
|
392
|
-
{
|
|
393
|
-
rules: {
|
|
394
|
-
'smarthr/require-barrel-import': 'error',
|
|
395
|
-
},
|
|
396
|
-
}
|
|
397
|
-
```
|
|
398
|
-
|
|
399
|
-
### ❌ Incorrect
|
|
400
|
-
|
|
401
|
-
```js
|
|
402
|
-
// client/src/views/Page/parts/Menu/index.ts
|
|
403
|
-
export { Menu } from './Menu'
|
|
404
|
-
export { Item } from './Item'
|
|
405
|
-
|
|
406
|
-
// client/src/App.tsx
|
|
407
|
-
import { Item } from './Page/parts/Menu/Item'
|
|
408
|
-
```
|
|
409
|
-
|
|
410
|
-
### ✅ Correct
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
```js
|
|
414
|
-
// client/src/views/Page/parts/Menu/index.ts
|
|
415
|
-
export { Menu } from './Menu'
|
|
416
|
-
export { Item } from './Item'
|
|
417
|
-
|
|
418
|
-
// client/src/App.tsx
|
|
419
|
-
import { Item } from './Page/parts/Menu'
|
|
420
|
-
```
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
## smarthr/redundant-name
|
|
424
|
-
|
|
425
|
-
- ファイル、コードの冗長な部分を取り除くことを提案するruleです
|
|
426
|
-
- ファイルが設置されているディレクトリ構造からキーワードを生成し、取り除く文字列を生成します
|
|
427
|
-
|
|
428
|
-
### config
|
|
429
|
-
|
|
430
|
-
- tsconfig.json の compilerOptions.pathsに '@/*' としてroot path を指定する必要があります
|
|
431
|
-
- 以下の設定を行えます。全て省略可能です。
|
|
432
|
-
- ignoreKeywords
|
|
433
|
-
- ディレクトリ名から生成されるキーワードに含めたくない文字列を指定します
|
|
434
|
-
- betterNames
|
|
435
|
-
- 対象の名前を修正する候補を指定します
|
|
436
|
-
- allowedNames
|
|
437
|
-
- 許可する名前を指定します
|
|
438
|
-
- suffix:
|
|
439
|
-
- type のみ指定出来ます
|
|
440
|
-
- type のsuffixを指定します
|
|
441
|
-
|
|
442
|
-
#### ファイル例
|
|
443
|
-
- `@/crews/index/views/page.tsx` の場合
|
|
444
|
-
- 生成されるキーワードは `['crews', 'crew', 'index', 'page']`
|
|
445
|
-
- `@/crews/index/views/parts/Abc.tsx` の場合
|
|
446
|
-
- 生成されるキーワードは `['crews', 'crew', 'index', 'Abc']`
|
|
447
|
-
- `@/crews/index/repositories/index.ts` の場合
|
|
448
|
-
- 生成されるキーワードは `['crews', 'crew', 'index', 'repositories', 'repository']`
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
### rules
|
|
452
|
-
|
|
453
|
-
```js
|
|
454
|
-
const ignorekeywords = ['views', 'parts']
|
|
455
|
-
const betterNames = {
|
|
456
|
-
'\/repositories\/': {
|
|
457
|
-
operator: '-',
|
|
458
|
-
names: ['repository', 'Repository'],
|
|
459
|
-
},
|
|
460
|
-
'\/entities\/': {
|
|
461
|
-
operator: '+',
|
|
462
|
-
names: ['entity'],
|
|
463
|
-
},
|
|
464
|
-
'\/slices\/': {
|
|
465
|
-
operator: '=',
|
|
466
|
-
names: ['index'],
|
|
467
|
-
},
|
|
468
|
-
}
|
|
469
|
-
// const allowedNames = {
|
|
470
|
-
// '\/views\/crews\/histories\/': ['crewId'],
|
|
471
|
-
// }
|
|
472
|
-
|
|
473
|
-
{
|
|
474
|
-
rules: {
|
|
475
|
-
'smarthr/redundant-name': [
|
|
476
|
-
'error', // 'warn', 'off'
|
|
477
|
-
{
|
|
478
|
-
type: { ignorekeywords, suffix: ['Props', 'Type'] },
|
|
479
|
-
file: { ignorekeywords, betternames },
|
|
480
|
-
// property: { ignorekeywords, allowedNames },
|
|
481
|
-
// function: { ignorekeywords },
|
|
482
|
-
// variable: { ignorekeywords },
|
|
483
|
-
// class: { ignorekeywords },
|
|
484
|
-
}
|
|
485
|
-
]
|
|
486
|
-
},
|
|
487
|
-
}
|
|
488
|
-
```
|
|
489
|
-
|
|
490
|
-
### ❌ Incorrect
|
|
491
|
-
|
|
492
|
-
```js
|
|
493
|
-
// @/crews/index/views/page.tsx
|
|
494
|
-
|
|
495
|
-
type CrewIndexPage = { hoge: string }
|
|
496
|
-
type CrewsView = { hoge: string }
|
|
497
|
-
```
|
|
498
|
-
```js
|
|
499
|
-
// @/crews/show/repositories/index.tsx
|
|
500
|
-
|
|
501
|
-
type CrewIndexRepository = { hoge: () => any }
|
|
502
|
-
```
|
|
503
|
-
|
|
504
|
-
### ✅ Correct
|
|
505
|
-
|
|
506
|
-
```js
|
|
507
|
-
// @/crews/index/views/page.tsx
|
|
508
|
-
|
|
509
|
-
type ItemProps = { hoge: string }
|
|
510
|
-
```
|
|
511
|
-
```js
|
|
512
|
-
// @/crews/show/repositories/index.tsx
|
|
513
|
-
|
|
514
|
-
type IndexProps = { hoge: () => any }
|
|
515
|
-
type ResponseType = { hoge: () => any }
|
|
516
|
-
``
|
|
517
|
-
|
|
518
|
-
## smarthr/format-translate-component
|
|
519
|
-
|
|
520
|
-
- 翻訳用コンポーネントを適用する際のルールを定めます
|
|
521
|
-
|
|
522
|
-
### rules
|
|
523
|
-
|
|
524
|
-
```js
|
|
525
|
-
{
|
|
526
|
-
rules: {
|
|
527
|
-
'smarthr/format-translate-component': [
|
|
528
|
-
'error', // 'warn', 'off'
|
|
529
|
-
{
|
|
530
|
-
componentName: 'Translate',
|
|
531
|
-
// componentPath: '@/any/path/Translate',
|
|
532
|
-
// prohibitAttributies: ['data-translate'],
|
|
533
|
-
}
|
|
534
|
-
]
|
|
535
|
-
},
|
|
536
|
-
}
|
|
537
|
-
```
|
|
538
|
-
|
|
539
|
-
### ❌ Incorrect
|
|
540
|
-
|
|
541
|
-
```jsx
|
|
542
|
-
<Translate><Any>ほげ</Any></Translate>
|
|
543
|
-
```
|
|
544
|
-
|
|
545
|
-
```jsx
|
|
546
|
-
<Translate><Any /></Translate>
|
|
547
|
-
```
|
|
548
|
-
|
|
549
|
-
```jsx
|
|
550
|
-
<Translate></Translate>
|
|
551
|
-
```
|
|
552
|
-
|
|
553
|
-
```jsx
|
|
554
|
-
// prohibitAttributies: ['data-translate'],
|
|
555
|
-
<Any data-translate="true">...</Any>
|
|
556
|
-
```
|
|
557
|
-
|
|
558
|
-
### ✅ Correct
|
|
559
|
-
|
|
560
|
-
```jsx
|
|
561
|
-
<Translate>ほげ</Translate>
|
|
562
|
-
```
|
|
563
|
-
```jsx
|
|
564
|
-
<Translate>ほげ<br />ふが</Translate>
|
|
565
|
-
```
|
|
566
|
-
```jsx
|
|
567
|
-
<Translate>{any}</Translate>
|
|
568
|
-
```
|
|
569
|
-
```jsx
|
|
570
|
-
<Translate dangerouslySetInnerHTML={{ __html: "ほげ" }} />
|
|
571
|
-
```
|
|
572
|
-
```jsx
|
|
573
|
-
// prohibitAttributies: ['data-translate'],
|
|
574
|
-
<Any data-hoge="true">...</Any>
|
|
575
|
-
```
|
|
576
|
-
|
|
3
|
+
- [a11y-clickable-element-has-text](https://github.com/kufu/eslint-plugin-smarthr/tree/main/rules/a11y-clickable-element-has-text)
|
|
4
|
+
- [a11y-image-has-alt-attribute](https://github.com/kufu/eslint-plugin-smarthr/tree/main/rules/a11y-image-has-alt-attribute)
|
|
5
|
+
- [a11y-trigger-has-button](https://github.com/kufu/eslint-plugin-smarthr/tree/main/rules/a11y-trigger-has-button)
|
|
6
|
+
- [best-practice-for-date](https://github.com/kufu/eslint-plugin-smarthr/tree/main/rules/best-practice-for-date)
|
|
7
|
+
- [format-import-path](https://github.com/kufu/eslint-plugin-smarthr/tree/main/rules/format-import-path)
|
|
8
|
+
- [format-translate-component](https://github.com/kufu/eslint-plugin-smarthr/tree/main/rules/format-translate-component)
|
|
9
|
+
- [jsx-start-with-spread-attributes](https://github.com/kufu/eslint-plugin-smarthr/tree/main/rules/jsx-start-with-spread-attributes)
|
|
10
|
+
- [no-import-other-domain](https://github.com/kufu/eslint-plugin-smarthr/tree/main/rules/no-import-other-domain)
|
|
11
|
+
- [prohibit-export-array-type](https://github.com/kufu/eslint-plugin-smarthr/tree/main/rules/prohibit-export-array-type)
|
|
12
|
+
- [prohibit-file-name](https://github.com/kufu/eslint-plugin-smarthr/tree/main/rules/prohibit-file-name)
|
|
13
|
+
- [prohibit-import](https://github.com/kufu/eslint-plugin-smarthr/tree/main/rules/prohibit-import)
|
|
14
|
+
- [redundant-name](https://github.com/kufu/eslint-plugin-smarthr/tree/main/rules/redundant-name)
|
|
15
|
+
- [require-barrel-import](https://github.com/kufu/eslint-plugin-smarthr/tree/main/rules/require-barrel-import)
|
|
16
|
+
- [require-export](https://github.com/kufu/eslint-plugin-smarthr/tree/main/rules/require-export)
|
|
17
|
+
- [require-import](https://github.com/kufu/eslint-plugin-smarthr/tree/main/rules/require-import)
|
package/index.js
CHANGED
|
@@ -14,14 +14,11 @@ module.exports = {
|
|
|
14
14
|
|
|
15
15
|
function generateRulesMap() {
|
|
16
16
|
let rulesPath = path.join(__dirname, 'rules');
|
|
17
|
-
let
|
|
17
|
+
let dirs = fs.readdirSync(rulesPath);
|
|
18
18
|
|
|
19
19
|
let rulesMap = {};
|
|
20
|
-
for (let
|
|
21
|
-
|
|
22
|
-
let ruleName = path.parse(file).name;
|
|
23
|
-
rulesMap[ruleName] = require(`./rules/${file}`);
|
|
24
|
-
}
|
|
20
|
+
for (let dir of dirs) {
|
|
21
|
+
rulesMap[path.parse(dir).name] = require(`./rules/${dir}`);
|
|
25
22
|
}
|
|
26
23
|
return rulesMap;
|
|
27
24
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# smarthr/a11y-clickable-element-has-text
|
|
2
|
+
|
|
3
|
+
- ButtonやAnchor,Link コンポーネントにテキスト要素が設定されていない場合、アクセシビリティの問題が発生する可能性を防ぐルールです
|
|
4
|
+
|
|
5
|
+
## rules
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
{
|
|
9
|
+
rules: {
|
|
10
|
+
'smarthr/a11y-clickable-element-has-text': 'error', // 'warn', 'off'
|
|
11
|
+
},
|
|
12
|
+
}
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## ❌ Incorrect
|
|
16
|
+
|
|
17
|
+
```jsx
|
|
18
|
+
<XxxAnchor>
|
|
19
|
+
<Xxx />
|
|
20
|
+
</XxxAnchor>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```jsx
|
|
24
|
+
<XxxLink>
|
|
25
|
+
<Yyy />
|
|
26
|
+
</XxxLink>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
```jsx
|
|
30
|
+
<XxxButton>
|
|
31
|
+
<Zzz />
|
|
32
|
+
</XxxButton>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## ✅ Correct
|
|
36
|
+
|
|
37
|
+
```jsx
|
|
38
|
+
<XxxAnchor>
|
|
39
|
+
Hoge
|
|
40
|
+
</XxxAnchor>
|
|
41
|
+
```
|
|
42
|
+
```jsx
|
|
43
|
+
<XxxLink>
|
|
44
|
+
<YyyIcon />
|
|
45
|
+
Fuga
|
|
46
|
+
</XxxLink>
|
|
47
|
+
```
|
|
48
|
+
```jsx
|
|
49
|
+
<XxxAnchor>>
|
|
50
|
+
<YyyIcon visuallyHiddenText="hoge" />
|
|
51
|
+
</XxxAnchor>
|
|
52
|
+
```
|
|
53
|
+
```jsx
|
|
54
|
+
<XxxButton>
|
|
55
|
+
<YyyImage alt="fuga" />
|
|
56
|
+
</XxxButton>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
```jsx
|
|
60
|
+
<YyyAnchoor />
|
|
61
|
+
```
|