eslint-plugin-smarthr 1.4.2 → 1.5.0
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/libs/common_domain.js +5 -8
- package/libs/util.js +4 -0
- package/package.json +4 -4
- package/rules/a11y-anchor-has-href-attribute/index.js +31 -20
- package/rules/a11y-clickable-element-has-text/index.js +4 -25
- package/rules/a11y-delegate-element-has-role-presentation/index.js +34 -55
- package/rules/a11y-form-control-in-form/index.js +5 -31
- package/rules/a11y-heading-in-sectioning-content/index.js +7 -63
- package/rules/a11y-image-has-alt-attribute/index.js +0 -16
- package/rules/a11y-input-has-name-attribute/index.js +15 -33
- package/rules/a11y-input-in-form-control/index.js +28 -74
- package/rules/a11y-numbered-text-within-ol/index.js +2 -11
- package/rules/a11y-prohibit-input-maxlength-attribute/index.js +8 -20
- package/rules/a11y-prohibit-input-placeholder/index.js +2 -14
- package/rules/a11y-prohibit-sectioning-content-in-form/index.js +5 -37
- package/rules/a11y-prohibit-useless-sectioning-fragment/index.js +5 -23
- package/rules/a11y-required-layout-as-attribute/index.js +0 -25
- package/rules/a11y-trigger-has-button/index.js +10 -18
- package/rules/best-practice-for-data-test-attribute/index.js +3 -6
- package/rules/best-practice-for-layouts/index.js +2 -16
- package/rules/best-practice-for-remote-trigger-dialog/index.js +3 -11
- package/rules/best-practice-for-tailwind-prohibit-root-margin/index.js +38 -30
- package/rules/best-practice-for-tailwind-variants/index.js +10 -18
- package/rules/component-name/README.md +44 -0
- package/rules/component-name/index.js +139 -0
- package/rules/design-system-guideline-prohibit-double-icons/index.js +1 -11
- package/rules/format-import-path/index.js +14 -6
- package/rules/format-translate-component/index.js +3 -1
- package/rules/no-import-other-domain/index.js +8 -8
- package/rules/prohibit-file-name/index.js +1 -1
- package/rules/prohibit-import/index.js +21 -23
- package/rules/prohibit-path-within-template-literal/index.js +1 -1
- package/rules/require-barrel-import/index.js +6 -8
- package/rules/require-declaration/index.js +5 -3
- package/rules/require-export/index.js +34 -30
- package/rules/require-import/index.js +10 -10
- package/rules/trim-props/index.js +9 -8
- package/test/a11y-anchor-has-href-attribute.js +0 -29
- package/test/a11y-clickable-element-has-text.js +0 -66
- package/test/{a11y-delegate-element-has-role-presantation.js → a11y-delegate-element-has-role-presentation.js} +3 -2
- package/test/a11y-form-control-in-form.js +1 -1
- package/test/a11y-heading-in-sectioning-content.js +0 -82
- package/test/a11y-image-has-alt-attribute.js +0 -45
- package/test/a11y-input-has-name-attribute.js +0 -44
- package/test/a11y-input-in-form-control.js +9 -33
- package/test/a11y-prohhibit-input-placeholder.js +0 -45
- package/test/a11y-trigger-has-button.js +0 -42
- package/test/best-practice-for-remote-trigger-dialog.js +0 -6
- package/test/component-name.js +247 -0
- package/test/prohibit-import.js +13 -13
|
@@ -12,14 +12,14 @@ const ruleTester = new RuleTester({
|
|
|
12
12
|
})
|
|
13
13
|
const noLabeledInput = (name) => `${name} を、smarthr-ui/FormControl もしくはそれを拡張したコンポーネントが囲むようマークアップを変更してください。
|
|
14
14
|
- FormControlで入力要素を囲むことでラベルと入力要素が適切に紐づき、操作性が高まります
|
|
15
|
-
- ${name}が入力要素とラベル・タイトル・説明など含む概念を表示するコンポーネントの場合、コンポーネント名を/((
|
|
16
|
-
- ${name}が入力要素自体を表現するコンポーネントの一部である場合、ルートとなるコンポーネントの名称を/((I|^i)nput
|
|
15
|
+
- ${name}が入力要素とラベル・タイトル・説明など含む概念を表示するコンポーネントの場合、コンポーネント名を/(Form(Control|Group)|(F|^f)ieldset)$/とマッチするように修正してください
|
|
16
|
+
- ${name}が入力要素自体を表現するコンポーネントの一部である場合、ルートとなるコンポーネントの名称を/(RadioButton(Panel)?(s)?|Check(B|b)ox(es|s)?|(Search)?(I|^i)nput(File)?|(T|^t)extarea|(S|^s)elect|Combo(B|b)ox|(Date|Wareki|Time)Picker)$/とマッチするように修正してください
|
|
17
17
|
- 上記のいずれの方法も適切ではない場合、${name}のtitle属性に "どんな値を入力すれば良いのか" の説明を設定してください
|
|
18
18
|
- 例: <${name} title="姓を全角カタカナのみで入力してください" />`
|
|
19
19
|
const noLabeledSelect = (name) => `${name} を、smarthr-ui/FormControl もしくはそれを拡張したコンポーネントが囲むようマークアップを変更してください。
|
|
20
20
|
- FormControlで入力要素を囲むことでラベルと入力要素が適切に紐づき、操作性が高まります
|
|
21
|
-
- ${name}が入力要素とラベル・タイトル・説明など含む概念を表示するコンポーネントの場合、コンポーネント名を/((
|
|
22
|
-
- ${name}が入力要素自体を表現するコンポーネントの一部である場合、ルートとなるコンポーネントの名称を/((I|^i)nput
|
|
21
|
+
- ${name}が入力要素とラベル・タイトル・説明など含む概念を表示するコンポーネントの場合、コンポーネント名を/(Form(Control|Group)|(F|^f)ieldset)$/とマッチするように修正してください
|
|
22
|
+
- ${name}が入力要素自体を表現するコンポーネントの一部である場合、ルートとなるコンポーネントの名称を/(RadioButton(Panel)?(s)?|Check(B|b)ox(es|s)?|(Search)?(I|^i)nput(File)?|(T|^t)extarea|(S|^s)elect|Combo(B|b)ox|(Date|Wareki|Time)Picker)$/とマッチするように修正してください
|
|
23
23
|
- 上記のいずれの方法も適切ではない場合、${name}のtitle属性に "どんな値を選択すれば良いのか" の説明を設定してください
|
|
24
24
|
- 例: <${name} title="検索対象を選択してください" />`
|
|
25
25
|
const invalidPureCheckboxInFormControl = (name) => `HogeFormControl が ${name} を含んでいます。smarthr-ui/FormControl を smarthr-ui/Fieldset に変更し、正しくグルーピングされるように修正してください。
|
|
@@ -34,13 +34,13 @@ const invalidMultiInputsInFormControl = () => `HogeFormControl が複数の入
|
|
|
34
34
|
- 方法1: 入力要素ごとにラベルを設定できる場合、HogeFormControlをsmarthr-ui/Fieldset、もしくはそれを拡張したコンポーネントに変更した上で、入力要素を一つずつsmarthr-ui/FormControlで囲むようにマークアップを変更してください
|
|
35
35
|
- 方法2: 郵便番号や電話番号など、本来一つの概念の入力要素を分割して複数の入力要素にしている場合、一つの入力要素にまとめることを検討してください
|
|
36
36
|
- コピーアンドペーストがしやすくなる、ブラウザの自動補完などがより適切に反映されるなど多大なメリットがあります
|
|
37
|
-
- 方法3: HogeFormControl が smarthr-ui/FormControl、もしくはそれを拡張しているコンポーネントではない場合、名称を /((
|
|
37
|
+
- 方法3: HogeFormControl が smarthr-ui/FormControl、もしくはそれを拡張しているコンポーネントではない場合、名称を /(Form(Control|Group)|(F|^f)ieldset)$/ にマッチしないものに変更してください
|
|
38
38
|
- 方法4: 上記方法のいずれも対応出来ない場合、HogeFormControl に 'role="group"' 属性を設定してください`
|
|
39
39
|
const noLabeledInputInFieldset = (name) => `HogeFieldset が ラベルを持たない入力要素(${name})を含んでいます。入力要素が何であるかを正しく伝えるため、以下の方法のいずれかで修正してください。
|
|
40
40
|
- 方法1: HogeFieldset を smarthr-ui/FormControl、もしくはそれを拡張したコンポーネントに変更してください
|
|
41
41
|
- 方法2: ${name} がlabel要素を含むコンポーネントである場合、名称を/(Form(Control|Group))$/にマッチするものに変更してください
|
|
42
42
|
- smarthr-ui/FormControl、smarthr-ui/FormGroup はlabel要素を内包しています
|
|
43
|
-
- 方法3: ${name} がRadioButton、もしくはCheckboxを表すコンポーネントの場合、名称を/(RadioButton
|
|
43
|
+
- 方法3: ${name} がRadioButton、もしくはCheckboxを表すコンポーネントの場合、名称を/(RadioButton(Panel)?(s)?|Check(B|b)ox(es|s)?)$/にマッチするものに変更してください
|
|
44
44
|
- smarthr-ui/RadioButton、smarthr-ui/RadioButtonPanel、smarthr-ui/Checkbox はlabel要素を内包しています
|
|
45
45
|
- 方法4: HogeFieldset が smarthr-ui/Fieldset、もしくはそれを拡張しているコンポーネントではない場合、名称を /Fieldset$/ にマッチしないものに変更してください
|
|
46
46
|
- 方法5: 別途label要素が存在し、それらと紐づけたい場合はlabel要素のhtmlFor属性、${name}のid属性に同じ文字列を指定してください。この文字列はhtml内で一意である必要があります
|
|
@@ -50,7 +50,7 @@ const noLabeledInputInFieldsetWithSelect = (name) => `HogeFieldset が ラベル
|
|
|
50
50
|
- 方法1: HogeFieldset を smarthr-ui/FormControl、もしくはそれを拡張したコンポーネントに変更してください
|
|
51
51
|
- 方法2: ${name} がlabel要素を含むコンポーネントである場合、名称を/(Form(Control|Group))$/にマッチするものに変更してください
|
|
52
52
|
- smarthr-ui/FormControl、smarthr-ui/FormGroup はlabel要素を内包しています
|
|
53
|
-
- 方法3: ${name} がRadioButton、もしくはCheckboxを表すコンポーネントの場合、名称を/(RadioButton
|
|
53
|
+
- 方法3: ${name} がRadioButton、もしくはCheckboxを表すコンポーネントの場合、名称を/(RadioButton(Panel)?(s)?|Check(B|b)ox(es|s)?)$/にマッチするものに変更してください
|
|
54
54
|
- smarthr-ui/RadioButton、smarthr-ui/RadioButtonPanel、smarthr-ui/Checkbox はlabel要素を内包しています
|
|
55
55
|
- 方法4: HogeFieldset が smarthr-ui/Fieldset、もしくはそれを拡張しているコンポーネントではない場合、名称を /Fieldset$/ にマッチしないものに変更してください
|
|
56
56
|
- 方法5: 別途label要素が存在し、それらと紐づけたい場合はlabel要素のhtmlFor属性、${name}のid属性に同じ文字列を指定してください。この文字列はhtml内で一意である必要があります
|
|
@@ -68,29 +68,16 @@ const useFormControlInsteadOfSectionInRadio = (name, section) => `${name}は${se
|
|
|
68
68
|
- ${section} 内のHeading要素はFieldsetのtitle属性に変更してください
|
|
69
69
|
- 方法2: ${section} と ${name} の間に Fieldset が存在するようにマークアップを変更してください`
|
|
70
70
|
const invalidFieldsetHasRoleGroup = (fieldset, base) => `${fieldset}に 'role="group" が設定されています。${base} をつかってマークアップする場合、'role="group"' は不要です
|
|
71
|
-
- ${fieldset} が ${base}、もしくはそれを拡張しているコンポーネントではない場合、名称を /((
|
|
71
|
+
- ${fieldset} が ${base}、もしくはそれを拡張しているコンポーネントではない場合、名称を /(Form(Control|Group)|(F|^f)ieldset)$/ にマッチしないものに変更してください`
|
|
72
72
|
const invalidChildreninFormControl = (children) => `FormControl が、${children} を子要素として持っており、マークアップとして正しくない状態になっています。以下のいずれかの方法で修正を試みてください。
|
|
73
73
|
- 方法1: 親要素であるFormControlをsmarthr-ui/FormControl、もしくはそれを拡張していないコンポーネントでマークアップしてください
|
|
74
74
|
- FormControlではなく、smarthr-ui/Fieldset、もしくはsmarthr-ui/Section + smarthr-ui/Heading などでのマークアップを検討してください
|
|
75
75
|
- 方法2: 親要素であるFormControlがsmarthr-ui/FormControlを拡張したコンポーネントではない場合、コンポーネント名を/(Form(Control|Group))$/と一致しない名称に変更してください`
|
|
76
76
|
const requireMultiInputInFormControlWithRoleGroup = () => `HogeFormControl内に入力要素が2個以上存在しないため、'role=\"group\"'を削除してください。'role=\"group\"'は複数の入力要素を一つのグループとして扱うための属性です。
|
|
77
|
-
- HogeFormControl内に2つ以上の入力要素が存在する場合、入力要素を含むコンポーネント名全てを/((I|^i)nput
|
|
77
|
+
- HogeFormControl内に2つ以上の入力要素が存在する場合、入力要素を含むコンポーネント名全てを/(RadioButton(Panel)?(s)?|Check(B|b)ox(es|s)?|(Search)?(I|^i)nput(File)?|(T|^t)extarea|(S|^s)elect|Combo(B|b)ox|(Date|Wareki|Time)Picker)$/、もしくは/(Form(Control|Group)|(F|^f)ieldset)$/にマッチする名称に変更してください`
|
|
78
78
|
|
|
79
79
|
ruleTester.run('a11y-input-in-form-control', rule, {
|
|
80
80
|
valid: [
|
|
81
|
-
{ code: `import styled from 'styled-components'` },
|
|
82
|
-
{ code: `import styled, { css } from 'styled-components'` },
|
|
83
|
-
{ code: `import { css } from 'styled-components'` },
|
|
84
|
-
{ code: `import { HogeAInput as FugaInput } from './hoge'` },
|
|
85
|
-
{ code: `import { Textarea as HogeTextarea } from './hoge'` },
|
|
86
|
-
{ code: 'const HogeInput = styled.input``' },
|
|
87
|
-
{ code: 'const HogeTextarea = styled.textarea``' },
|
|
88
|
-
{ code: 'const HogeSelect = styled(Select)``' },
|
|
89
|
-
{ code: 'const HogeRadioButton = styled(FugaRadioButton)``' },
|
|
90
|
-
{ code: 'const HogeRadioButtonPanel = styled(FugaRadioButtonPanel)``' },
|
|
91
|
-
{ code: 'const HogeCheckbox = styled(FugaCheckBox)``' },
|
|
92
|
-
{ code: 'const DatePicker = styled(AnyDatePicker)``' },
|
|
93
|
-
{ code: 'const WarekiPicker = styled(AnyWarekiPicker)``' },
|
|
94
81
|
{ code: '<input type="hidden" />' },
|
|
95
82
|
{ code: '<input title="any"/>' },
|
|
96
83
|
{ code: '<HogeInput title="any"/>' },
|
|
@@ -139,17 +126,6 @@ ruleTester.run('a11y-input-in-form-control', rule, {
|
|
|
139
126
|
{ code: '<HogeFormControl>{ dateInput ? <DateInput /> : <Input /> }</HogeFormControl>'},
|
|
140
127
|
],
|
|
141
128
|
invalid: [
|
|
142
|
-
{ code: `import hoge from 'styled-components'`, errors: [ { message: `styled-components をimportする際は、名称が"styled" となるようにしてください。例: "import styled from 'styled-components'"` } ] },
|
|
143
|
-
{ code: `import { ComboBox as ComboBoxHoge } from './hoge'`, errors: [ { message: `ComboBoxHogeを正規表現 "/(Combobox)$/" がmatchする名称に変更してください。
|
|
144
|
-
- ComboBoxが型の場合、'import type { ComboBox as ComboBoxHoge }' もしくは 'import { type ComboBox as ComboBoxHoge }' のように明示的に型であることを宣言してください。名称変更が不要になります` } ] },
|
|
145
|
-
{ code: 'const RadioButton = styled(FugaRadioButtonPanel)``', errors: [
|
|
146
|
-
{ message: `RadioButtonを正規表現 "/(RadioButtonPanel)$/" がmatchする名称に変更してください。` },
|
|
147
|
-
{ message: `RadioButton は /RadioButton$/ にmatchする名前のコンポーネントを拡張することを期待している名称になっています
|
|
148
|
-
- RadioButton の名称の末尾が"RadioButton" という文字列ではない状態にしつつ、"FugaRadioButtonPanel"を継承していることをわかる名称に変更してください
|
|
149
|
-
- もしくは"FugaRadioButtonPanel"を"RadioButton"の継承元であることがわかるような名称に変更するか、適切な別コンポーネントに差し替えてください
|
|
150
|
-
- 修正例1: const Xxxx = styled(FugaRadioButtonPanel)
|
|
151
|
-
- 修正例2: const RadioButtonXxxx = styled(FugaRadioButtonPanel)
|
|
152
|
-
- 修正例3: const RadioButton = styled(XxxxRadioButton)` } ] },
|
|
153
129
|
{ code: `<input />`, errors: [ { message: noLabeledInput('input') } ] },
|
|
154
130
|
{ code: `<HogeInput />`, errors: [ { message: noLabeledInput('HogeInput') } ] },
|
|
155
131
|
{ code: '<textarea />', errors: [ { message: noLabeledInput('textarea') } ] },
|
|
@@ -12,24 +12,6 @@ const ruleTester = new RuleTester({
|
|
|
12
12
|
})
|
|
13
13
|
ruleTester.run('a11y-prohibit-input-placeholder', rule, {
|
|
14
14
|
valid: [
|
|
15
|
-
{ code: `import styled from 'styled-components'` },
|
|
16
|
-
{ code: `import styled, { css } from 'styled-components'` },
|
|
17
|
-
{ code: `import { css } from 'styled-components'` },
|
|
18
|
-
{ code: `import { Input as HogeInput } from './hoge'` },
|
|
19
|
-
{ code: `import { HogeSearchInput as FugaSearchInput } from './hoge'` },
|
|
20
|
-
{ code: `import { HogeTextarea as FugaHogeTextarea } from './hoge'` },
|
|
21
|
-
{ code: `import { Combobox as FugaHogeCombobox } from './hoge'` },
|
|
22
|
-
{ code: `import { AbcDatePicker as StyledDatePicker } from './hoge'` },
|
|
23
|
-
{ code: `import { AbcWarekiPicker as StyledWarekiPicker } from './hoge'` },
|
|
24
|
-
{ code: 'const HogeInput = styled.input``' },
|
|
25
|
-
{ code: 'const HogeTextarea = styled.textarea``' },
|
|
26
|
-
{ code: 'const HogeInput = styled(Input)``' },
|
|
27
|
-
{ code: 'const HogeInput = styled(StyledInput)``' },
|
|
28
|
-
{ code: 'const HogeTextarea = styled(Textarea)``' },
|
|
29
|
-
{ code: 'const hoge = styled.fieldset``' },
|
|
30
|
-
{ code: 'const HogeFieldSet = styled(FieldSet)``' },
|
|
31
|
-
{ code: 'const HogeCombobox = styled(ComboBox)``' },
|
|
32
|
-
{ code: 'const HogeSearchInput = styled(SearchInput)``' },
|
|
33
15
|
{ code: `<input />` },
|
|
34
16
|
{ code: `<textarea />` },
|
|
35
17
|
{ code: `<FieldSet />` },
|
|
@@ -49,33 +31,6 @@ ruleTester.run('a11y-prohibit-input-placeholder', rule, {
|
|
|
49
31
|
{ code: `<ComboBox placeholder="hoge" dropdownHelpMessage="fuga" />` },
|
|
50
32
|
],
|
|
51
33
|
invalid: [
|
|
52
|
-
{ code: `import hoge from 'styled-components'`, errors: [ { message: `styled-components をimportする際は、名称が"styled" となるようにしてください。例: "import styled from 'styled-components'"` } ] },
|
|
53
|
-
{ code: `import { Input as InputHoge } from './hoge'`, errors: [ { message: `InputHogeを正規表現 "/Input$/" がmatchする名称に変更してください。
|
|
54
|
-
- Inputが型の場合、'import type { Input as InputHoge }' もしくは 'import { type Input as InputHoge }' のように明示的に型であることを宣言してください。名称変更が不要になります` } ] },
|
|
55
|
-
{ code: `import { SearchInput as Hoge } from './hoge'`, errors: [ { message: `Hogeを正規表現 "/Input$/" がmatchする名称に変更してください。
|
|
56
|
-
- SearchInputが型の場合、'import type { SearchInput as Hoge }' もしくは 'import { type SearchInput as Hoge }' のように明示的に型であることを宣言してください。名称変更が不要になります` }, { message: `Hogeを正規表現 "/SearchInput$/" がmatchする名称に変更してください。
|
|
57
|
-
- SearchInputが型の場合、'import type { SearchInput as Hoge }' もしくは 'import { type SearchInput as Hoge }' のように明示的に型であることを宣言してください。名称変更が不要になります` } ] },
|
|
58
|
-
{ code: `import { HogeTextarea as HogeTextareaFuga } from './hoge'`, errors: [ { message: `HogeTextareaFugaを正規表現 "/Textarea$/" がmatchする名称に変更してください。
|
|
59
|
-
- HogeTextareaが型の場合、'import type { HogeTextarea as HogeTextareaFuga }' もしくは 'import { type HogeTextarea as HogeTextareaFuga }' のように明示的に型であることを宣言してください。名称変更が不要になります` } ] },
|
|
60
|
-
{ code: `import { HogeCombobox as ComboboxFuga } from './hoge'`, errors: [ { message: `ComboboxFugaを正規表現 "/Combobox$/" がmatchする名称に変更してください。
|
|
61
|
-
- HogeComboboxが型の場合、'import type { HogeCombobox as ComboboxFuga }' もしくは 'import { type HogeCombobox as ComboboxFuga }' のように明示的に型であることを宣言してください。名称変更が不要になります` } ] },
|
|
62
|
-
{ code: `import { DatePicker as HogeDatePickerFuga } from './hoge'`, errors: [ { message: `HogeDatePickerFugaを正規表現 "/(Date|Wareki)Picker$/" がmatchする名称に変更してください。
|
|
63
|
-
- DatePickerが型の場合、'import type { DatePicker as HogeDatePickerFuga }' もしくは 'import { type DatePicker as HogeDatePickerFuga }' のように明示的に型であることを宣言してください。名称変更が不要になります` } ] },
|
|
64
|
-
{ code: `import { WarekiPicker as HogeWarekiPickerFuga } from './hoge'`, errors: [ { message: `HogeWarekiPickerFugaを正規表現 "/(Date|Wareki)Picker$/" がmatchする名称に変更してください。
|
|
65
|
-
- WarekiPickerが型の場合、'import type { WarekiPicker as HogeWarekiPickerFuga }' もしくは 'import { type WarekiPicker as HogeWarekiPickerFuga }' のように明示的に型であることを宣言してください。名称変更が不要になります` } ] },
|
|
66
|
-
{ code: 'const Hoge = styled.input``', errors: [ { message: `Hogeを正規表現 "/Input$/" がmatchする名称に変更してください。` } ] },
|
|
67
|
-
{ code: 'const Hoge = styled(StyledInput)``', errors: [ { message: `Hogeを正規表現 "/Input$/" がmatchする名称に変更してください。` } ] },
|
|
68
|
-
{ code: 'const Hoge = styled.textarea``', errors: [ { message: `Hogeを正規表現 "/Textarea$/" がmatchする名称に変更してください。` } ] },
|
|
69
|
-
{ code: 'const Hoge = styled(StyledTextarea)``', errors: [ { message: `Hogeを正規表現 "/Textarea$/" がmatchする名称に変更してください。` } ] },
|
|
70
|
-
{ code: 'const Hoge = styled(FieldSet)``', errors: [ { message: `Hogeを正規表現 "/FieldSet$/" がmatchする名称に変更してください。` } ] },
|
|
71
|
-
{ code: 'const Hoge = styled(Combobox)``', errors: [ { message: `Hogeを正規表現 "/Combobox$/" がmatchする名称に変更してください。` } ] },
|
|
72
|
-
{
|
|
73
|
-
code: 'const Hoge = styled(SearchInput)``',
|
|
74
|
-
errors: [
|
|
75
|
-
{ message: `Hogeを正規表現 "/Input$/" がmatchする名称に変更してください。` },
|
|
76
|
-
{ message: `Hogeを正規表現 "/SearchInput$/" がmatchする名称に変更してください。` },
|
|
77
|
-
],
|
|
78
|
-
},
|
|
79
34
|
{ code: `<input placeholder />`, errors: [ { message: `input にはplaceholder属性は設定せず、別途ヒント用要素の利用を検討してください。(例: '<div><input /><Hint>ヒント</Hint></div>')` } ] },
|
|
80
35
|
{ code: `<textarea placeholder="hoge" />`, errors: [ { message: `textarea にはplaceholder属性は設定せず、別途ヒント用要素の利用を検討してください。(例: '<div><textarea /><Hint>ヒント</Hint></div>')` } ] },
|
|
81
36
|
{ code: `<StyledInput placeholder={any} />`, errors: [ { message: `StyledInput にはplaceholder属性は設定せず、別途ヒント用要素の利用を検討してください。(例: '<div><StyledInput /><Hint>ヒント</Hint></div>')` } ] },
|
|
@@ -12,53 +12,11 @@ const ruleTester = new RuleTester({
|
|
|
12
12
|
})
|
|
13
13
|
ruleTester.run('a11y-trigger-has-button', rule, {
|
|
14
14
|
valid: [
|
|
15
|
-
{ code: `import styled from 'styled-components'` },
|
|
16
|
-
{ code: `import styled, { css } from 'styled-components'` },
|
|
17
|
-
{ code: `import { css } from 'styled-components'` },
|
|
18
|
-
{ code: `import { DropdownTrigger as HogeDropdownTrigger } from './hoge'` },
|
|
19
|
-
{ code: `import { FugaDialogTrigger as HogeDialogTrigger } from './hoge'` },
|
|
20
|
-
{ code: `import { AbcButton as HogeAbcButton } from './hoge'` },
|
|
21
|
-
{ code: `import { AnchorButton as FugaAnchorButton } from './hoge'` },
|
|
22
|
-
{ code: `import { HogeAnchor as HogeFugaAnchor } from './hoge'` },
|
|
23
|
-
{ code: `import { FugaLink as HogeLink } from './hoge'` },
|
|
24
|
-
{ code: 'const HogeButton = styled.button``' },
|
|
25
|
-
{ code: 'const HogeAnchor = styled.a``' },
|
|
26
|
-
{ code: 'const HogeLink = styled.a``' },
|
|
27
|
-
{ code: 'const HogeButton = styled(Button)``' },
|
|
28
|
-
{ code: 'const HogeButtonAnchor = styled(ButtonAnchor)``' },
|
|
29
|
-
{ code: 'const HogeAnchorButton = styled(AnchorButton)``' },
|
|
30
|
-
{ code: 'const HogeLink = styled(FugaLink)``' },
|
|
31
|
-
{ code: 'const HogeAnchor = styled(FugaAnchor)``' },
|
|
32
|
-
{ code: 'const HogeDialogTrigger = styled(DialogTrigger)``' },
|
|
33
|
-
{ code: 'const HogeDropdownTrigger = styled(DropdownTrigger)``' },
|
|
34
15
|
{ code: '<DropdownTrigger><button>hoge</button></DropdownTrigger>' },
|
|
35
16
|
{ code: '<DialogTrigger><button>{hoge}</button></DialogTrigger>' },
|
|
36
17
|
{ code: '<DropdownTrigger>{hoge}</DropdownTrigger>' },
|
|
37
18
|
],
|
|
38
19
|
invalid: [
|
|
39
|
-
{ code: `import hoge from 'styled-components'`, errors: [ { message: `styled-components をimportする際は、名称が"styled" となるようにしてください。例: "import styled from 'styled-components'"` } ] },
|
|
40
|
-
{ code: `import { DropdownTrigger as Hoge } from './hoge'`, errors: [ { message: `Hogeを正規表現 "/DropdownTrigger$/" がmatchする名称に変更してください。
|
|
41
|
-
- DropdownTriggerが型の場合、'import type { DropdownTrigger as Hoge }' もしくは 'import { type DropdownTrigger as Hoge }' のように明示的に型であることを宣言してください。名称変更が不要になります` } ] },
|
|
42
|
-
{ code: `import { DialogTrigger as Hoge } from './hoge'`, errors: [ { message: `Hogeを正規表現 "/DialogTrigger$/" がmatchする名称に変更してください。
|
|
43
|
-
- DialogTriggerが型の場合、'import type { DialogTrigger as Hoge }' もしくは 'import { type DialogTrigger as Hoge }' のように明示的に型であることを宣言してください。名称変更が不要になります` } ] },
|
|
44
|
-
{ code: `import { Button as Hoge } from './hoge'`, errors: [ { message: `Hogeを正規表現 "/Button$/" がmatchする名称に変更してください。
|
|
45
|
-
- Buttonが型の場合、'import type { Button as Hoge }' もしくは 'import { type Button as Hoge }' のように明示的に型であることを宣言してください。名称変更が不要になります` } ] },
|
|
46
|
-
{ code: `import { AbcAnchorButton as Hoge } from './hoge'`, errors: [ { message: `Hogeを正規表現 "/Button$/" がmatchする名称に変更してください。
|
|
47
|
-
- AbcAnchorButtonが型の場合、'import type { AbcAnchorButton as Hoge }' もしくは 'import { type AbcAnchorButton as Hoge }' のように明示的に型であることを宣言してください。名称変更が不要になります` }, { message: `Hogeを正規表現 "/AnchorButton$/" がmatchする名称に変更してください。
|
|
48
|
-
- AbcAnchorButtonが型の場合、'import type { AbcAnchorButton as Hoge }' もしくは 'import { type AbcAnchorButton as Hoge }' のように明示的に型であることを宣言してください。名称変更が不要になります` } ] },
|
|
49
|
-
{ code: `import { Anchor as Hoge } from './hoge'`, errors: [ { message: `Hogeを正規表現 "/Anchor$/" がmatchする名称に変更してください。
|
|
50
|
-
- Anchorが型の場合、'import type { Anchor as Hoge }' もしくは 'import { type Anchor as Hoge }' のように明示的に型であることを宣言してください。名称変更が不要になります` } ] },
|
|
51
|
-
{ code: `import { Link as Hoge } from './hoge'`, errors: [ { message: `Hogeを正規表現 "/Link$/" がmatchする名称に変更してください。
|
|
52
|
-
- Linkが型の場合、'import type { Link as Hoge }' もしくは 'import { type Link as Hoge }' のように明示的に型であることを宣言してください。名称変更が不要になります` } ] },
|
|
53
|
-
{ code: 'const Hoge = styled.button``', errors: [ { message: `Hogeを正規表現 "/Button$/" がmatchする名称に変更してください。` } ] },
|
|
54
|
-
{ code: 'const Hoge = styled.a``', errors: [ { message: `Hogeを正規表現 "/(Anchor|Link)$/" がmatchする名称に変更してください。` } ] },
|
|
55
|
-
{ code: 'const Hoge = styled(Button)``', errors: [ { message: `Hogeを正規表現 "/Button$/" がmatchする名称に変更してください。` } ] },
|
|
56
|
-
{ code: 'const Hoge = styled(AnchorButton)``', errors: [ { message: `Hogeを正規表現 "/Button$/" がmatchする名称に変更してください。` },{ message: `Hogeを正規表現 "/AnchorButton$/" がmatchする名称に変更してください。` } ] },
|
|
57
|
-
{ code: 'const Hoge = styled(ButtonAnchor)``', errors: [ { message: `Hogeを正規表現 "/ButtonAnchor$/" がmatchする名称に変更してください。` }, { message: `Hogeを正規表現 "/Anchor$/" がmatchする名称に変更してください。` } ] },
|
|
58
|
-
{ code: 'const Hoge = styled(Anchor)``', errors: [ { message: `Hogeを正規表現 "/Anchor$/" がmatchする名称に変更してください。` } ] },
|
|
59
|
-
{ code: 'const Hoge = styled(Link)``', errors: [ { message: `Hogeを正規表現 "/Link$/" がmatchする名称に変更してください。` } ] },
|
|
60
|
-
{ code: 'const Hoge = styled(DropdownTrigger)``', errors: [ { message: `Hogeを正規表現 "/DropdownTrigger$/" がmatchする名称に変更してください。` } ] },
|
|
61
|
-
{ code: 'const Hoge = styled(DialogTrigger)``', errors: [ { message: `Hogeを正規表現 "/DialogTrigger$/" がmatchする名称に変更してください。` } ] },
|
|
62
20
|
{ code: '<DropdownTrigger>ほげ</DropdownTrigger>', errors: [ { message: 'DropdownTrigger の直下にはbuttonコンポーネントのみ設置してください' } ] },
|
|
63
21
|
{ code: '<DialogTrigger><span><Button>ほげ</Button></span></DialogTrigger>', errors: [ { message: 'DialogTrigger の直下にはbuttonコンポーネントのみ設置してください' } ] },
|
|
64
22
|
{ code: '<DropdownTrigger><AnchorButton>ほげ</AnchorButton></DropdownTrigger>', errors: [ { message: 'DropdownTrigger の直下にはbuttonコンポーネントのみ設置してください' } ] },
|
|
@@ -12,18 +12,12 @@ const ruleTester = new RuleTester({
|
|
|
12
12
|
})
|
|
13
13
|
ruleTester.run('best-practice-for-remote-trigger-dialog', rule, {
|
|
14
14
|
valid: [
|
|
15
|
-
{ code: `import styled from 'styled-components'` },
|
|
16
|
-
{ code: 'const HogeRemoteDialogTrigger = styled(RemoteDialogTrigger)``' },
|
|
17
|
-
{ code: 'const RemoteTriggerHogeDialog = styled(RemoteTriggerActionDialog)``' },
|
|
18
15
|
{ code: '<RemoteDialogTrigger targetId="hoge">open.</RemoteDialogTrigger>' },
|
|
19
16
|
{ code: '<StyledRemoteDialogTrigger targetId="fuga">open.</StyledRemoteDialogTrigger>' },
|
|
20
17
|
{ code: '<RemoteTriggerActionDialog {...args} id="hoge">content.</RemoteTriggerActionDialog>' },
|
|
21
18
|
{ code: '<RemoteTriggerHogeDialog {...args} id="hoge">content.</RemoteTriggerHogeDialog>' },
|
|
22
19
|
],
|
|
23
20
|
invalid: [
|
|
24
|
-
{ code: `import hoge from 'styled-components'`, errors: [ { message: `styled-components をimportする際は、名称が"styled" となるようにしてください。例: "import styled from 'styled-components'"` } ] },
|
|
25
|
-
{ code: 'const Hoge = styled(RemoteDialogTrigger)``', errors: [ { message: 'Hogeを正規表現 "/RemoteDialogTrigger$/" がmatchする名称に変更してください。' } ] },
|
|
26
|
-
{ code: 'const Fuga = styled(RemoteTriggerActionDialog)``', errors: [ { message: 'Fugaを正規表現 "/RemoteTrigger(.+)Dialog$/" がmatchする名称に変更してください。' } ] },
|
|
27
21
|
{ code: '<RemoteDialogTrigger targetId={hoge}>open.</RemoteDialogTrigger>', errors: [ { message: `RemoteDialogTriggerのtargetId属性には直接文字列を指定してください。
|
|
28
22
|
- 変数などは利用できません(これは関連するTriggerとDialogを検索しやすくするためです)
|
|
29
23
|
- RemoteTriggerActionDialogはループやDropdown内にTriggerが存在する場合に利用してください
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
const rule = require('../rules/component-name')
|
|
2
|
+
const RuleTester = require('eslint').RuleTester
|
|
3
|
+
|
|
4
|
+
const ruleTester = new RuleTester({
|
|
5
|
+
languageOptions: {
|
|
6
|
+
parserOptions: {
|
|
7
|
+
ecmaFeatures: {
|
|
8
|
+
jsx: true,
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
const messageProperName = ({ extended, matcher, sampleMatcher, suffix, base }) => {
|
|
15
|
+
const isComponent = base[0].toUpperCase() === base[0]
|
|
16
|
+
const sampleSuffix = `styled${isComponent ? `(${base})` : `.${base}`}`
|
|
17
|
+
const actualPrefix = sampleMatcher ? extended.replace(sampleMatcher, '') : (base[0] === base[0].toUpperCase() ? base.replace(matcher, '') : 'Hoge')
|
|
18
|
+
|
|
19
|
+
return `${extended} は ${matcher} にmatchする名前のコンポーネントを拡張することを期待している名称になっています
|
|
20
|
+
- ${extended} の名称の末尾が"${suffix}" という文字列ではない状態にしつつ、"${base}"を継承していることをわかる名称に変更してください
|
|
21
|
+
- もしくは"${base}"を"${extended}"の継承元であることがわかるような${isComponent ? '名称に変更するか、適切な別コンポーネントに差し替えてください' : '適切なタグや別コンポーネントに差し替えてください'}
|
|
22
|
+
- 修正例1: const ${actualPrefix}Xxxx = ${sampleSuffix}
|
|
23
|
+
- 修正例2: const ${actualPrefix}${suffix}Xxxx = ${sampleSuffix}
|
|
24
|
+
- 修正例3: const ${actualPrefix}${suffix} = styled(Xxxx${suffix})`
|
|
25
|
+
}
|
|
26
|
+
const messageInheritance = ({ extended, matcher }) => `${extended}を正規表現 "${matcher}" がmatchする名称に変更してください。`
|
|
27
|
+
const messageImportAs = ({ extended, matcher, base }) => `${messageInheritance({ extended, matcher })}
|
|
28
|
+
- ${base}が型の場合、'import type { ${base} as ${extended} }' もしくは 'import { type ${base} as ${extended} }' のように明示的に型であることを宣言してください。名称変更が不要になります`
|
|
29
|
+
const messageExtendSectioningContent = ({ extended, expected }) => `${extended} は smarthr-ui/${expected} をextendすることを期待する名称になっています
|
|
30
|
+
- childrenにHeadingを含まない場合、コンポーネントの名称から"${expected}"を取り除いてください
|
|
31
|
+
- childrenにHeadingを含み、アウトラインの範囲を指定するためのコンポーネントならば、smarthr-ui/${expected}をexendしてください
|
|
32
|
+
- "styled(Xxxx)" 形式の場合、拡張元であるXxxxコンポーネントの名称の末尾に"${expected}"を設定し、そのコンポーネント内でsmarthr-ui/${expected}を利用してください`
|
|
33
|
+
|
|
34
|
+
ruleTester.run('component-name', rule, {
|
|
35
|
+
valid: [
|
|
36
|
+
{ code: `import styled from 'styled-components'` },
|
|
37
|
+
{ code: `import styled, { css } from 'styled-components'` },
|
|
38
|
+
{ code: `import { css } from 'styled-components'` },
|
|
39
|
+
|
|
40
|
+
{ code: `const HogeOrderedFugaList = styled.ol` },
|
|
41
|
+
{ code: `const HogeOrderedFugaList = styled(HogeOrderedList)` },
|
|
42
|
+
{ code: `import { HogeOrderedFugaList } from 'hoge'` },
|
|
43
|
+
{ code: `import { OrderedFugaList as HogeOrderedPiyoList } from 'hoge'` },
|
|
44
|
+
|
|
45
|
+
{ code: `const HogeSelect = styled(FugaSelect)` },
|
|
46
|
+
|
|
47
|
+
{ code: `const HogeAnchor = styled.a` },
|
|
48
|
+
{ code: `const HogeLink = styled.a` },
|
|
49
|
+
|
|
50
|
+
{ code: 'const HogeButton = styled.button``' },
|
|
51
|
+
{ code: 'const HogeButton = styled(Button)``' },
|
|
52
|
+
{ code: 'const FugaSmartHRLogo = styled(SmartHRLogo)``' },
|
|
53
|
+
{ code: 'const FugaText = styled(HogeText)(() => ``)' },
|
|
54
|
+
{ code: 'const FugaMessage = styled(HogeMessage)(() => ``)' },
|
|
55
|
+
|
|
56
|
+
{ code: `const HogeInput = styled.input` },
|
|
57
|
+
{ code: `const HogeTextarea = styled(Textarea)` },
|
|
58
|
+
{ code: `import { InputFile as HogeInputFile } from 'hoge'` },
|
|
59
|
+
{ code: `const HogeRadioButton = styled(RadioButton)` },
|
|
60
|
+
{ code: `import { HogeRadioButtonPanel } from 'hoge'` },
|
|
61
|
+
{ code: `const HogeCheckbox = styled(Checkbox)` },
|
|
62
|
+
{ code: `import { HogeCombobox as FugaCombobox } from 'hoge'` },
|
|
63
|
+
|
|
64
|
+
{ code: `const FugaRightFixedNote = styled(HogeRightFixedNote)` },
|
|
65
|
+
{ code: `import { HogeFieldset as FugaFieldset } from 'hoge'` },
|
|
66
|
+
{ code: `const FugaFormControl = styled(HogeFormControl)` },
|
|
67
|
+
{ code: `import { HogeTabItem as TabItem } from 'hoge'` },
|
|
68
|
+
{ code: `const Form = styled(HogeForm)` },
|
|
69
|
+
{ code: `import { ActionDialogWithTrigger as FugaActionDialogWithTrigger } from 'hoge'` },
|
|
70
|
+
{ code: `const FugaRemoteDialogTrigger = styled(RemoteDialogTrigger)` },
|
|
71
|
+
{ code: `import { HogeRemoteTriggerActionDialog as FugaRemoteTriggerAnyDialog } from 'hoge'` },
|
|
72
|
+
|
|
73
|
+
{ code: `const HogeFieldset = styled.fieldset` },
|
|
74
|
+
{ code: `const HogeFieldsets = styled(FugaFieldsets)` },
|
|
75
|
+
{ code: `import { HogeFormControls as FugaFormControls } from 'hoge'` },
|
|
76
|
+
{ code: `const RemoteTriggerFormDialog = styled(RemoteTriggerAnyFormDialog)` },
|
|
77
|
+
|
|
78
|
+
{ code: `import { PageHeading as HogePageHeading } from './hoge'` },
|
|
79
|
+
{ code: `import { HogeHeading as FugaHeading } from './hoge'` },
|
|
80
|
+
{ code: `import { HogeArticle as FugaArticle } from './hoge'` },
|
|
81
|
+
{ code: `import { HogeAside as FugaAside } from './hoge'` },
|
|
82
|
+
{ code: `import { HogeNav as FugaNav } from './hoge'` },
|
|
83
|
+
{ code: `import { HogeSection as FugaSection } from './hoge'` },
|
|
84
|
+
{ code: `import { ModelessDialog as FugaModelessDialog } from './hoge'` },
|
|
85
|
+
{ code: 'const HogePageHeading = styled.h1``' },
|
|
86
|
+
{ code: 'const HogeHeading = styled.h2``' },
|
|
87
|
+
{ code: 'const HogeHeading = styled.h3``' },
|
|
88
|
+
{ code: 'const HogeHeading = styled.h4``' },
|
|
89
|
+
{ code: 'const HogeHeading = styled.h5``' },
|
|
90
|
+
{ code: 'const HogeHeading = styled.h6``' },
|
|
91
|
+
{ code: 'const FugaHeading = styled(Heading)``' },
|
|
92
|
+
{ code: 'const FugaHeading = styled(HogeHeading)``' },
|
|
93
|
+
{ code: 'const FugaArticle = styled(HogeArticle)``' },
|
|
94
|
+
{ code: 'const FugaAside = styled(HogeAside)``' },
|
|
95
|
+
{ code: 'const FugaNav = styled(HogeNav)``' },
|
|
96
|
+
{ code: 'const FugaSection = styled(HogeSection)``' },
|
|
97
|
+
{ code: "const FugaHeading = styled(Heading).attrs(() => ({ type: 'blockTitle' }))``" },
|
|
98
|
+
{ code: 'const FugaCenter = styled(HogeCenter)``' },
|
|
99
|
+
{ code: 'const FugaReel = styled(HogeReel)``' },
|
|
100
|
+
{ code: 'const FugaSidebar = styled(HogeSidebar)``' },
|
|
101
|
+
{ code: 'const FugaStack = styled(HogeStack)``' },
|
|
102
|
+
|
|
103
|
+
{ code: `import { HogeImg as FugaImg } from './hoge'` },
|
|
104
|
+
{ code: `import { HogeImage as FugaImage } from './hoge'` },
|
|
105
|
+
{ code: `import { HogeIcon as FugaIcon } from './hoge'` },
|
|
106
|
+
{ code: 'const HogeImg = styled.img``' },
|
|
107
|
+
{ code: 'const HogeImage = styled.img``' },
|
|
108
|
+
{ code: 'const HogeIcon = styled.img``' },
|
|
109
|
+
{ code: 'const HogeImg = styled.svg``' },
|
|
110
|
+
{ code: 'const HogeImage = styled.svg``' },
|
|
111
|
+
{ code: 'const HogeIcon = styled.svg``' },
|
|
112
|
+
{ code: 'const HogeImg = styled(Img)``' },
|
|
113
|
+
{ code: 'const HogeImage = styled(Image)``' },
|
|
114
|
+
{ code: 'const HogeIcon = styled(Icon)``' },
|
|
115
|
+
|
|
116
|
+
{ code: 'const HogeRadioButton = styled(FugaRadioButton)``' },
|
|
117
|
+
{ code: 'const HogeRadioButtonPanel = styled(FugaRadioButtonPanel)``' },
|
|
118
|
+
{ code: 'const HogeCheckbox = styled(FugaCheckBox)``' },
|
|
119
|
+
|
|
120
|
+
{ code: `import { HogeSearchInput as FugaSearchInput } from './hoge'` },
|
|
121
|
+
|
|
122
|
+
{ code: 'const IndexNav = styled(HogeIndexNav)``' },
|
|
123
|
+
|
|
124
|
+
{ code: `import { DropdownTrigger as HogeDropdownTrigger } from './hoge'` },
|
|
125
|
+
{ code: `import { FugaDialogTrigger as HogeDialogTrigger } from './hoge'` },
|
|
126
|
+
{ code: `import { AbcButton as HogeAbcButton } from './hoge'` },
|
|
127
|
+
{ code: `import { AnchorButton as FugaAnchorButton } from './hoge'` },
|
|
128
|
+
{ code: `import { HogeAnchor as HogeFugaAnchor } from './hoge'` },
|
|
129
|
+
{ code: `import { FugaLink as HogeLink } from './hoge'` },
|
|
130
|
+
{ code: 'const HogeAnchor = styled.a``' },
|
|
131
|
+
{ code: 'const HogeLink = styled.a``' },
|
|
132
|
+
{ code: 'const HogeButtonAnchor = styled(ButtonAnchor)``' },
|
|
133
|
+
{ code: 'const HogeAnchorButton = styled(AnchorButton)``' },
|
|
134
|
+
{ code: 'const HogeLink = styled(FugaLink)``' },
|
|
135
|
+
{ code: 'const HogeAnchor = styled(FugaAnchor)``' },
|
|
136
|
+
{ code: 'const HogeDialogTrigger = styled(DialogTrigger)``' },
|
|
137
|
+
{ code: 'const HogeDropdownTrigger = styled(DropdownTrigger)``' },
|
|
138
|
+
|
|
139
|
+
{ code: 'const RemoteTriggerHogeDialog = styled(RemoteTriggerActionDialog)``' },
|
|
140
|
+
],
|
|
141
|
+
invalid: [
|
|
142
|
+
{ code: `import hoge from 'styled-components'`, errors: [ { message: `styled-components をimportする際は、名称が"styled" となるようにしてください。例: "import styled from 'styled-components'"` } ] },
|
|
143
|
+
|
|
144
|
+
{ code: `const HogeOrderedFugaList = styled.ul`, errors: [ { message: messageProperName({ extended: 'HogeOrderedFugaList', matcher: /(Ordered(.*)List|^ol)$/, suffix: 'OrderedFugaList', base: 'ul' }) } ] },
|
|
145
|
+
{ code: `const HogeOrderedFugaList = styled(Hoge)`, errors: [ { message: messageProperName({ extended: 'HogeOrderedFugaList', matcher: /(Ordered(.*)List|^ol)$/, suffix: 'OrderedFugaList', base: 'Hoge' }) } ] },
|
|
146
|
+
{ code: `const Hoge = styled.ol`, errors: [ { message: messageInheritance({ extended: 'Hoge', matcher: /Ordered(.*)List$/ }) } ] },
|
|
147
|
+
{ code: `import { HogeOrderedFugaList as Fuga } from 'hoge'`, errors: [ { message: messageImportAs({ extended: 'Fuga', matcher: /Ordered(.*)List$/, base: 'HogeOrderedFugaList' }) } ] },
|
|
148
|
+
|
|
149
|
+
{ code: `const HogeSelect = styled.div`, errors: [ { message: messageProperName({ extended: 'HogeSelect', matcher: /(S|^s)elect$/, suffix: 'Select', base: 'div' }) } ] },
|
|
150
|
+
|
|
151
|
+
{ code: `const HogeAnchor = styled.div`, errors: [ { message: messageProperName({ extended: 'HogeAnchor', matcher: /(Anchor|^a)$/, suffix: 'Anchor', base: 'div' }) } ] },
|
|
152
|
+
{ code: `const HogeLink = styled.div`, errors: [ { message: messageProperName({ extended: 'HogeLink', matcher: /(Link|^a)$/, suffix: 'Link', base: 'div' }) } ] },
|
|
153
|
+
{ code: `const HogeAnchor = styled(Hoge)`, errors: [ { message: messageProperName({ extended: 'HogeAnchor', matcher: /(Anchor|^a)$/, suffix: 'Anchor', base: 'Hoge' }) } ] },
|
|
154
|
+
{ code: `const HogeLink = styled(Hoge)`, errors: [ { message: messageProperName({ extended: 'HogeLink', matcher: /(Link|^a)$/, suffix: 'Link', base: 'Hoge' }) } ] },
|
|
155
|
+
{ code: `const Hoge = styled.a`, errors: [ { message: messageInheritance({ extended: 'Hoge', matcher: /(Anchor|Link)$/ }) } ] },
|
|
156
|
+
{ code: `import { HogeAnchor as Fuga } from 'hoge'`, errors: [ { message: messageImportAs({ extended: 'Fuga', matcher: /Anchor$/, base: 'HogeAnchor' }) } ] },
|
|
157
|
+
{ code: `import { HogeLink as Fuga } from 'hoge'`, errors: [ { message: messageImportAs({ extended: 'Fuga', matcher: /Link$/, base: 'HogeLink' }) } ] },
|
|
158
|
+
|
|
159
|
+
{ code: `import { SmartHRLogo as SmartHRLogoHoge } from './hoge'`, errors: [ { message: messageImportAs({ extended: 'SmartHRLogoHoge', matcher: /SmartHRLogo$/, base: 'SmartHRLogo' }) } ] },
|
|
160
|
+
{ code: `import { FugaMessage as FugaMessageFuga } from './hoge'`, errors: [ { message: messageImportAs({ extended: 'FugaMessageFuga', matcher: /Message$/, base: 'FugaMessage' }) } ] },
|
|
161
|
+
{ code: 'const Hoge = styled.button``', errors: [ { message: messageInheritance({ extended: 'Hoge', matcher: /Button$/ }) } ] },
|
|
162
|
+
{ code: 'const Fuga = styled(SmartHRLogo)``', errors: [ { message: messageInheritance({ extended: 'Fuga', matcher: /SmartHRLogo$/ }) } ] },
|
|
163
|
+
{ code: 'const Hoge = styled(HogeMessage)``', errors: [ { message: messageInheritance({ extended: 'Hoge', matcher: /Message$/ }) } ] },
|
|
164
|
+
{ code: 'const HogeButton = styled.div``', errors: [ { message: messageProperName({ extended: 'HogeButton', matcher: /(B|^b)utton$/, suffix: 'Button', base: 'div' }) } ] },
|
|
165
|
+
|
|
166
|
+
{ code: `import { DatePicker as DatePickerHoge } from './hoge'`, errors: [ { message: messageImportAs({ extended: 'DatePickerHoge', matcher: /(Date|Wareki)Picker$/, base: 'DatePicker' }) } ] },
|
|
167
|
+
{ code: 'const Fuga = styled(WarekiPicker)``', errors: [ { message: messageInheritance({ extended: 'Fuga', matcher: /(Date|Wareki)Picker$/ }) } ] },
|
|
168
|
+
{ code: `import { TimePicker as Hoge } from './hoge'`, errors: [ { message: messageImportAs({ extended: 'Hoge', matcher: /TimePicker$/, base: 'TimePicker' }) } ] },
|
|
169
|
+
{ code: 'const Hoge = styled(DropZone)``', errors: [ { message: messageInheritance({ extended: 'Hoge', matcher: /DropZone$/ }) } ] },
|
|
170
|
+
{ code: `import { Switch as Hoge } from './hoge'`, errors: [ { message: messageImportAs({ extended: 'Hoge', matcher: /Switch$/, base: 'Switch' }) } ] },
|
|
171
|
+
{ code: 'const SegmentedControlHoge = styled(FugaSegmentedControl)``', errors: [ { message: messageInheritance({ extended: 'SegmentedControlHoge', matcher: '/SegmentedControl$/' }) } ] },
|
|
172
|
+
{ code: `import { FormDialog as HogeDialog } from './hoge'`, errors: [ { message: messageImportAs({ extended: 'HogeDialog', matcher: /FormDialog$/, base: 'FormDialog' }) } ] },
|
|
173
|
+
{ code: 'const PaginationFuga = styled(FugaPagination)``', errors: [ { message: messageInheritance({ extended: 'PaginationFuga', matcher: /Pagination$/ }) } ] },
|
|
174
|
+
{ code: `import { HogeSideNav as Hoge } from './hoge'`, errors: [ { message: messageImportAs({ extended: 'Hoge', matcher: /Nav$/, base: 'HogeSideNav' }) }, { message: messageImportAs({ extended: 'Hoge', matcher: /SideNav$/, base: 'HogeSideNav' }) } ] },
|
|
175
|
+
{ code: 'const AccordionPanelAny = styled(FugaAccordionPanel)``', errors: [ { message: messageInheritance({ extended: 'AccordionPanelAny', matcher: /AccordionPanel$/ }) } ] },
|
|
176
|
+
{ code: `import { HogeFilterDropdown as Hoge } from './hoge'`, errors: [ { message: messageImportAs({ extended: 'Hoge', matcher: /FilterDropdown$/, base: 'HogeFilterDropdown' }) } ] },
|
|
177
|
+
{ code: `const Hoge = styled.fieldset`, errors: [ { message: messageInheritance({ extended: 'Hoge', matcher: /Fieldset$/ }) } ] },
|
|
178
|
+
{ code: `const Hoge = styled(Fieldsets)`, errors: [ { message: messageInheritance({ extended: 'Hoge', matcher: /Fieldsets$/ }) } ] },
|
|
179
|
+
{ code: `const Hoge = styled(FormControls)`, errors: [ { message: messageInheritance({ extended: 'Hoge', matcher: /FormControls$/ }) } ] },
|
|
180
|
+
{ code: `const Hoge = styled(FilterDropdown)`, errors: [ { message: messageInheritance({ extended: 'Hoge', matcher: /FilterDropdown$/ }) } ] },
|
|
181
|
+
|
|
182
|
+
{ code: `import { HogePageHeading as PageHeadingAbc } from './hoge'`, errors: [ { message: messageImportAs({ extended: 'PageHeadingAbc', matcher: /Heading$/, base: 'HogePageHeading' }) }, { message: messageImportAs({ extended: 'PageHeadingAbc', matcher: /PageHeading$/, base: 'HogePageHeading' }) } ] },
|
|
183
|
+
{ code: `import { Heading as HeadingHoge } from './hoge'`, errors: [ { message: messageImportAs({ extended: 'HeadingHoge', matcher: /Heading$/, base: 'Heading' }) } ] },
|
|
184
|
+
{ code: `import { HogeArticle as HogeArticleFuga } from './hoge'`, errors: [ { message: messageImportAs({ extended: 'HogeArticleFuga', matcher: /Article$/, base: 'HogeArticle' }) } ] },
|
|
185
|
+
{ code: `import { HogeAside as HogeAsideFuga } from './hoge'`, errors: [ { message: messageImportAs({ extended: 'HogeAsideFuga', matcher: /Aside$/, base: 'HogeAside' }) } ] },
|
|
186
|
+
{ code: `import { HogeNav as HogeNavFuga } from './hoge'`, errors: [ { message: messageImportAs({ extended: 'HogeNavFuga', matcher: /Nav$/, base: 'HogeNav' }) } ] },
|
|
187
|
+
{ code: `import { HogeSection as HogeSectionFuga } from './hoge'`, errors: [ { message: messageImportAs({ extended: 'HogeSectionFuga', matcher: /Section$/, base: 'HogeSection' }) } ] },
|
|
188
|
+
{ code: `import { HogeModelessDialog as HogeModelessDialogFuga } from './hoge'`, errors: [ { message: messageImportAs({ extended: 'HogeModelessDialogFuga', matcher: /ModelessDialog$/, base: 'HogeModelessDialog' }) } ] },
|
|
189
|
+
{ code: 'const Hoge = styled.h1``', errors: [ { message: messageInheritance({ extended: 'Hoge', matcher: /PageHeading$/ }) } ] },
|
|
190
|
+
{ code: 'const Hoge = styled.h2``', errors: [ { message: messageInheritance({ extended: 'Hoge', matcher: /Heading$/ }) } ] },
|
|
191
|
+
{ code: 'const Hoge = styled.h3``', errors: [ { message: messageInheritance({ extended: 'Hoge', matcher: /Heading$/ }) } ] },
|
|
192
|
+
{ code: 'const Hoge = styled.h4``', errors: [ { message: messageInheritance({ extended: 'Hoge', matcher: /Heading$/ }) } ] },
|
|
193
|
+
{ code: 'const Hoge = styled.h5``', errors: [ { message: messageInheritance({ extended: 'Hoge', matcher: /Heading$/ }) } ] },
|
|
194
|
+
{ code: 'const Hoge = styled.h6``', errors: [ { message: messageInheritance({ extended: 'Hoge', matcher: /Heading$/ }) } ] },
|
|
195
|
+
{ code: 'const Fuga = styled(Heading)``', errors: [ { message: messageInheritance({ extended: 'Fuga', matcher: /Heading$/ }) } ] },
|
|
196
|
+
{ code: 'const Fuga = styled(HogeHeading)``', errors: [ { message: messageInheritance({ extended: 'Fuga', matcher: /Heading$/ }) } ] },
|
|
197
|
+
{ code: 'const Fuga = styled(HogeHeading).attrs(() => ({ type: "blockTitle" }))``', errors: [ { message: messageInheritance({ extended: 'Fuga', matcher: /Heading$/ }) } ] },
|
|
198
|
+
{ code: 'const Fuga = styled(HogeArticle)``', errors: [ { message: messageInheritance({ extended: 'Fuga', matcher: /Article$/ }) } ] },
|
|
199
|
+
{ code: 'const Fuga = styled(HogeAside)``', errors: [ { message: messageInheritance({ extended: 'Fuga', matcher: /Aside$/ }) } ] },
|
|
200
|
+
{ code: 'const Fuga = styled(HogeNav)``', errors: [ { message: messageInheritance({ extended: 'Fuga', matcher: /Nav$/ }) } ] },
|
|
201
|
+
{ code: 'const Fuga = styled(HogeSection)``', errors: [ { message: messageInheritance({ extended: 'Fuga', matcher: /Section$/ }) } ] },
|
|
202
|
+
{ code: 'const Fuga = styled(HogeCenter)``', errors: [ { message: messageInheritance({ extended: 'Fuga', matcher: /Center$/ }) } ] },
|
|
203
|
+
{ code: 'const Fuga = styled(HogeReel)``', errors: [ { message: messageInheritance({ extended: 'Fuga', matcher: /Reel$/ }) } ] },
|
|
204
|
+
{ code: 'const Fuga = styled(HogeSidebar)``', errors: [ { message: messageInheritance({ extended: 'Fuga', matcher: /Sidebar$/ }) } ] },
|
|
205
|
+
{ code: 'const Fuga = styled(HogeStack)``', errors: [ { message: messageInheritance({ extended: 'Fuga', matcher: /Stack$/ }) } ] },
|
|
206
|
+
{ code: 'const StyledSection = styled.div``', errors: [ { message: messageExtendSectioningContent({ extended: 'StyledSection', expected: 'Section' }) } ] },
|
|
207
|
+
{ code: 'const StyledArticle = styled(Hoge)``', errors: [ { message:messageExtendSectioningContent({ extended: 'StyledArticle', expected: 'Article' }) } ] },
|
|
208
|
+
{ code: 'const StyledAside = styled(AsideXxxx)``', errors: [ { message: messageExtendSectioningContent({ extended: 'StyledAside', expected: 'Aside' }) } ] },
|
|
209
|
+
{ code: 'const HogeHeading = styled(Hoge)``', errors: [ { message: messageProperName({ extended: 'HogeHeading', matcher: /(Heading|^h(1|2|3|4|5|6))$/, suffix: 'Heading', base: 'Hoge' }) } ] },
|
|
210
|
+
{ code: 'const HogeHeading = styled.div``', errors: [ { message: messageProperName({ extended: 'HogeHeading', matcher: /(Heading|^h(1|2|3|4|5|6))$/, suffix: 'Heading', base: 'div' }) } ] },
|
|
211
|
+
{ code: `import { HogeImg as ImgFuga } from './hoge'`, errors: [ { message: messageImportAs({ extended: 'ImgFuga', matcher: /Img$/, base: 'HogeImg' }) } ] },
|
|
212
|
+
{ code: `import { HogeImage as HogeImageFuga } from './hoge'`, errors: [ { message: messageImportAs({ extended: 'HogeImageFuga', matcher: /Image$/, base: 'HogeImage' }) } ] },
|
|
213
|
+
{ code: `import { Icon as Hoge } from './hoge'`, errors: [ { message: messageImportAs({ extended: 'Hoge', matcher: /Icon$/, base: 'Icon' }) } ] },
|
|
214
|
+
{ code: 'const Hoge = styled.img``', errors: [ { message: messageInheritance({ extended: 'Hoge', matcher: /(Img|Image|Icon)$/ }) } ] },
|
|
215
|
+
{ code: 'const Hoge = styled.svg``', errors: [ { message: messageInheritance({ extended: 'Hoge', matcher: /(Img|Image|Icon)$/ }) } ] },
|
|
216
|
+
{ code: 'const Hoge = styled(Icon)``', errors: [ { message: messageInheritance({ extended: 'Hoge', matcher: /Icon$/ }) } ] },
|
|
217
|
+
{ code: 'const Hoge = styled(Img)``', errors: [ { message: messageInheritance({ extended: 'Hoge', matcher: /Img$/ }) } ] },
|
|
218
|
+
{ code: 'const Hoge = styled(Image)``', errors: [ { message: messageInheritance({ extended: 'Hoge', matcher: /Image$/ }) } ] },
|
|
219
|
+
{ code: 'const HogeImage = styled.span``', errors: [ { message: messageProperName({ extended: 'HogeImage', matcher: /(Image|^(img|svg))$/, suffix: 'Image', base: 'span' }) } ] },
|
|
220
|
+
{ code: 'const HogeImg = styled(Hoge)``', errors: [ { message: messageProperName({ extended: 'HogeImg', matcher: /(Img|^(img|svg))$/, suffix: 'Img', base: 'Hoge' }) } ] },
|
|
221
|
+
{ code: 'const HogeIcon = styled(Hoge)``', errors: [ { message: messageProperName({ extended: 'HogeIcon', matcher: /(Icon|^(img|svg))$/, suffix: 'Icon', base: 'Hoge' }) } ] },
|
|
222
|
+
{ code: `import { ComboBox as ComboBoxHoge } from './hoge'`, errors: [ { message: messageImportAs({ extended: 'ComboBoxHoge', matcher: /Combobox$/, base: 'ComboBox' }) } ] },
|
|
223
|
+
{ code: 'const RadioButton = styled(FugaRadioButtonPanel)``', errors: [
|
|
224
|
+
{ message: messageInheritance({ extended: 'RadioButton', matcher: /RadioButtonPanel$/ }) },
|
|
225
|
+
{ message: messageProperName({ extended: 'RadioButton', matcher: /(B|^b)utton$/, sampleMatcher: /(Button)$/, suffix: 'Button', base: 'FugaRadioButtonPanel' }) },
|
|
226
|
+
{ message: messageProperName({ extended: 'RadioButton', matcher: /RadioButton$/, sampleMatcher: /(RadioButton)$/, suffix: 'RadioButton', base: 'FugaRadioButtonPanel' }) }] },
|
|
227
|
+
{ code: 'const SideNav = styled(Hoge)``', errors: [ { message: messageExtendSectioningContent({ extended: 'SideNav', expected: 'Nav' }) }, { message: messageProperName({ extended: 'SideNav', matcher: /SideNav$/, sampleMatcher: /(SideNav)$/, suffix: 'SideNav', base: 'Hoge' }) } ] },
|
|
228
|
+
|
|
229
|
+
{ code: `import { DropdownTrigger as Hoge } from './hoge'`, errors: [ { message: messageImportAs({ extended: 'Hoge', matcher: /DropdownTrigger$/, base: 'DropdownTrigger' }) } ] },
|
|
230
|
+
{ code: `import { DialogTrigger as Hoge } from './hoge'`, errors: [ { message: messageImportAs({ extended: 'Hoge', matcher: /DialogTrigger$/, base: 'DialogTrigger' }) } ] },
|
|
231
|
+
{ code: `import { Button as Hoge } from './hoge'`, errors: [ { message: messageImportAs({ extended: 'Hoge', matcher: /Button$/, base: 'Button' }) } ] },
|
|
232
|
+
{ code: `import { AbcAnchorButton as Hoge } from './hoge'`, errors: [ { message: messageImportAs({ extended: 'Hoge', matcher: /Button$/, base: 'AbcAnchorButton' }) }, messageImportAs({ extended: 'Hoge', matcher: /AnchorButton$/, base: 'AbcAnchorButton' }) ] },
|
|
233
|
+
{ code: `import { Anchor as Hoge } from './hoge'`, errors: [ { message: messageImportAs({ extended: 'Hoge', matcher: /Anchor$/, base: 'Anchor' }) } ] },
|
|
234
|
+
{ code: `import { Link as Hoge } from './hoge'`, errors: [ { message: messageImportAs({ extended: 'Hoge', matcher: /Link$/, base: 'Link' }) } ] },
|
|
235
|
+
{ code: 'const Hoge = styled.a``', errors: [ { message: messageInheritance({ extended: 'Hoge', matcher: /(Anchor|Link)$/ }) } ] },
|
|
236
|
+
{ code: 'const Hoge = styled(Button)``', errors: [ { message: messageInheritance({ extended: 'Hoge', matcher: /Button$/ }) } ] },
|
|
237
|
+
{ code: 'const Hoge = styled(AnchorButton)``', errors: [ { message: messageInheritance({ extended: 'Hoge', matcher: /Button$/ }) }, { message: messageInheritance({ extended: 'Hoge', matcher: /AnchorButton$/ }) } ] },
|
|
238
|
+
{ code: 'const Hoge = styled(ButtonAnchor)``', errors: [ { message: messageInheritance({ extended: 'Hoge', matcher: /Anchor$/ }) } ] },
|
|
239
|
+
{ code: 'const Hoge = styled(Anchor)``', errors: [ { message: messageInheritance({ extended: 'Hoge', matcher: /Anchor$/ }) } ] },
|
|
240
|
+
{ code: 'const Hoge = styled(Link)``', errors: [ { message: messageInheritance({ extended: 'Hoge', matcher: /Link$/ }) } ] },
|
|
241
|
+
{ code: 'const Hoge = styled(DropdownTrigger)``', errors: [ { message: messageInheritance({ extended: 'Hoge', matcher: /DropdownTrigger$/ }) } ] },
|
|
242
|
+
{ code: 'const Hoge = styled(DialogTrigger)``', errors: [ { message: messageInheritance({ extended: 'Hoge', matcher: /DialogTrigger$/ }) } ] },
|
|
243
|
+
|
|
244
|
+
{ code: 'const Hoge = styled(RemoteDialogTrigger)``', errors: [ { message: messageInheritance({ extended: 'Hoge', matcher: /DialogTrigger$/ }) }, { message: messageInheritance({ extended: 'Hoge', matcher: /RemoteDialogTrigger$/ }) } ] },
|
|
245
|
+
{ code: 'const Fuga = styled(RemoteTriggerActionDialog)``', errors: [ { message: messageInheritance({ extended: 'Fuga', matcher: /RemoteTrigger(.+)Dialog$/ }) } ] },
|
|
246
|
+
]
|
|
247
|
+
})
|