-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheslint.config.js
More file actions
80 lines (78 loc) · 2.29 KB
/
Copy patheslint.config.js
File metadata and controls
80 lines (78 loc) · 2.29 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
import dz from '@d-zero/eslint-config';
import reactHooks from 'eslint-plugin-react-hooks';
// @d-zero/eslint-config/base の no-restricted-syntax セレクタを複製せず継承する
const baseNoRestrictedSyntax =
dz.configs.frontend
.map((config) => config.rules?.['no-restricted-syntax'])
.find(Boolean)
?.slice(1) ?? [];
/**
* @type {import('eslint').Linter.Config[]}
*/
export default [
{
ignores: [
'**/.*/**/*',
'**/dist/**',
'**/server/**/*',
'**/node_modules/**',
'**/*.d.ts',
'**/storybook-static/**',
],
},
...dz.configs.frontend,
{
files: ['**/*.{jsx,tsx}', '**/use-*.{ts,tsx}'],
...reactHooks.configs.flat.recommended,
},
{
rules: {
'@typescript-eslint/no-empty-object-type': 0,
'@typescript-eslint/no-unused-vars': [
2,
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
],
// @d-zero/eslint-config/base の no-restricted-syntax を維持しつつ
// clickイベント禁止(Invoker Commands API に統一する)を追加。
// ボタン起点のアクションは command/commandfor で宣言し、
// 受け手が command イベントを処理する
'no-restricted-syntax': [
2,
...baseNoRestrictedSyntax,
{
selector: "JSXAttribute[name.name='onClick']",
message:
'onClickは禁止です。Invoker Commands API(command/commandfor属性 + commandイベント)を使ってください。',
},
{
selector:
"CallExpression[callee.property.name='addEventListener'][arguments.0.value='click']",
message:
"addEventListener('click')は禁止です。Invoker Commands API(command/commandfor属性 + commandイベント)を使ってください。",
},
{
selector: "CallExpression[callee.property.name='click']",
message:
'プログラムによるclick()呼び出しは禁止です。ファイル選択はshowPicker()を使ってください。',
},
],
},
},
{
files: ['*.mjs', '**/*.spec.{js,mjs,ts,tsx}', '**/*.config.ts'],
rules: {
'import-x/no-extraneous-dependencies': 0,
},
},
{
// テストはユーザー操作の再現としてclickを発火してよい
files: ['**/*.spec.{js,mjs,ts,tsx}', '**/__tests__/**/*'],
rules: {
'no-restricted-syntax': 0,
},
},
{
files: ['.textlintrc.js'],
...dz.configs.commonjs,
},
];