eslint-plugin-smarthr 0.3.14 → 0.3.15
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/format_styled_components.js +33 -18
- package/package.json +1 -1
- package/test/a11y-anchor-has-href-attribute.js +4 -0
- package/test/a11y-clickable-element-has-text.js +12 -0
- package/test/a11y-heading-in-sectioning-content.js +14 -0
- package/test/a11y-image-has-alt-attribute.js +6 -0
- package/test/a11y-input-has-name-attribute.js +18 -0
- package/test/a11y-prohhibit-input-placeholder.js +10 -0
- package/test/a11y-trigger-has-button.js +12 -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.3.15](https://github.com/kufu/eslint-plugin-smarthr/compare/v0.3.14...v0.3.15) (2023-11-29)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* a11y系ruleに "import時のasでのrename内容をチェックする" 処理を追加 ([#90](https://github.com/kufu/eslint-plugin-smarthr/issues/90)) ([2eab779](https://github.com/kufu/eslint-plugin-smarthr/commit/2eab77960985e7c52bd262ff674ae31cb2c6008e))
|
|
11
|
+
|
|
5
12
|
### [0.3.14](https://github.com/kufu/eslint-plugin-smarthr/compare/v0.3.13...v0.3.14) (2023-11-05)
|
|
6
13
|
|
|
7
14
|
|
|
@@ -3,6 +3,21 @@ const STYLED_COMPONENTS = `${STYLED_COMPONENTS_METHOD}-components`
|
|
|
3
3
|
|
|
4
4
|
const findInvalidImportNameNode = (s) => s.type === 'ImportDefaultSpecifier' && s.local.name !== STYLED_COMPONENTS_METHOD
|
|
5
5
|
|
|
6
|
+
const checkImportStyledComponents = (node, context) => {
|
|
7
|
+
if (node.source.value !== STYLED_COMPONENTS) {
|
|
8
|
+
return
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const invalidNameNode = node.specifiers.find(findInvalidImportNameNode)
|
|
12
|
+
|
|
13
|
+
if (invalidNameNode) {
|
|
14
|
+
context.report({
|
|
15
|
+
node: invalidNameNode,
|
|
16
|
+
message: `${STYLED_COMPONENTS} をimportする際は、名称が"${STYLED_COMPONENTS_METHOD}" となるようにしてください。例: "import ${STYLED_COMPONENTS_METHOD} from '${STYLED_COMPONENTS}'"`,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
6
21
|
const generateTagFormatter = ({ context, EXPECTED_NAMES, UNEXPECTED_NAMES }) => {
|
|
7
22
|
const entriesesTagNames = Object.entries(EXPECTED_NAMES).map(([b, e]) => [ new RegExp(b), new RegExp(e) ])
|
|
8
23
|
const entriesesUnTagNames = UNEXPECTED_NAMES ? Object.entries(UNEXPECTED_NAMES).map(([b, e]) => {
|
|
@@ -11,20 +26,27 @@ const generateTagFormatter = ({ context, EXPECTED_NAMES, UNEXPECTED_NAMES }) =>
|
|
|
11
26
|
return [ new RegExp(b), new RegExp(auctualE), messageTemplate ]
|
|
12
27
|
}) : []
|
|
13
28
|
|
|
14
|
-
return {
|
|
15
|
-
ImportDeclaration: (node) => {
|
|
16
|
-
if (node.source.value !== STYLED_COMPONENTS) {
|
|
17
|
-
return
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const invalidNameNode = node.specifiers.find(findInvalidImportNameNode)
|
|
21
29
|
|
|
22
|
-
|
|
30
|
+
const checkImportedNameToLocalName = (node, base, extended) => {
|
|
31
|
+
entriesesTagNames.forEach(([b, e]) => {
|
|
32
|
+
if (base.match(b) && !extended.match(e)) {
|
|
23
33
|
context.report({
|
|
24
|
-
node
|
|
25
|
-
message: `${
|
|
34
|
+
node,
|
|
35
|
+
message: `${extended}を正規表現 "${e.toString()}" がmatchする名称に変更してください`,
|
|
26
36
|
});
|
|
27
37
|
}
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
ImportDeclaration: (node) => {
|
|
43
|
+
checkImportStyledComponents(node, context)
|
|
44
|
+
|
|
45
|
+
node.specifiers.forEach((s) => {
|
|
46
|
+
if (s.imported && s.imported.name !== s.local.name) {
|
|
47
|
+
checkImportedNameToLocalName(node, s.imported.name, s.local.name)
|
|
48
|
+
}
|
|
49
|
+
})
|
|
28
50
|
},
|
|
29
51
|
VariableDeclarator: (node) => {
|
|
30
52
|
if (!node.init) {
|
|
@@ -64,14 +86,7 @@ const generateTagFormatter = ({ context, EXPECTED_NAMES, UNEXPECTED_NAMES }) =>
|
|
|
64
86
|
if (base) {
|
|
65
87
|
const extended = node.id.name
|
|
66
88
|
|
|
67
|
-
|
|
68
|
-
if (base.match(b) && !extended.match(e)) {
|
|
69
|
-
context.report({
|
|
70
|
-
node,
|
|
71
|
-
message: `${extended}を正規表現 "${e.toString()}" がmatchする名称に変更してください`,
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
})
|
|
89
|
+
checkImportedNameToLocalName(node, base, extended)
|
|
75
90
|
|
|
76
91
|
entriesesUnTagNames.forEach(([b, e, m]) => {
|
|
77
92
|
const matcher = extended.match(e)
|
package/package.json
CHANGED
|
@@ -25,6 +25,8 @@ ruleTester.run('a11y-anchor-has-href-attribute', rule, {
|
|
|
25
25
|
{ code: `import styled from 'styled-components'` },
|
|
26
26
|
{ code: `import styled, { css } from 'styled-components'` },
|
|
27
27
|
{ code: `import { css } from 'styled-components'` },
|
|
28
|
+
{ code: `import { HogeAnchor as FugaAnchor } from './hoge'` },
|
|
29
|
+
{ code: `import { Link as FugaLink } from './hoge'` },
|
|
28
30
|
{ code: 'const HogeAnchor = styled.a``' },
|
|
29
31
|
{ code: 'const HogeLink = styled.a``' },
|
|
30
32
|
{ code: 'const HogeAnchor = styled(Anchor)``' },
|
|
@@ -39,6 +41,8 @@ ruleTester.run('a11y-anchor-has-href-attribute', rule, {
|
|
|
39
41
|
],
|
|
40
42
|
invalid: [
|
|
41
43
|
{ code: `import hoge from 'styled-components'`, errors: [ { message: `styled-components をimportする際は、名称が"styled" となるようにしてください。例: "import styled from 'styled-components'"` } ] },
|
|
44
|
+
{ code: `import { Anchor as AnchorHoge } from './hoge'`, errors: [ { message: `AnchorHogeを正規表現 "/Anchor$/" がmatchする名称に変更してください` } ] },
|
|
45
|
+
{ code: `import { HogeLink as HogeLinkFuga } from './hoge'`, errors: [ { message: `HogeLinkFugaを正規表現 "/Link$/" がmatchする名称に変更してください` } ] },
|
|
42
46
|
{ code: 'const Hoge = styled.a``', errors: [ { message: `Hogeを正規表現 "/(Anchor|Link)$/" がmatchする名称に変更してください` } ] },
|
|
43
47
|
{ code: 'const Hoge = styled(Anchor)``', errors: [ { message: `Hogeを正規表現 "/Anchor$/" がmatchする名称に変更してください` } ] },
|
|
44
48
|
{ code: 'const Hoge = styled(Link)``', errors: [ { message: `Hogeを正規表現 "/Link$/" がmatchする名称に変更してください` } ] },
|
|
@@ -22,6 +22,12 @@ ruleTester.run('a11y-clickable-element-has-text', rule, {
|
|
|
22
22
|
{ code: `import styled from 'styled-components'` },
|
|
23
23
|
{ code: `import styled, { css } from 'styled-components'` },
|
|
24
24
|
{ code: `import { css } from 'styled-components'` },
|
|
25
|
+
{ code: `import { SmartHRLogo as HogeSmartHRLogo } from './hoge'` },
|
|
26
|
+
{ code: `import { AbcButton as StyledAbcButton } from './hoge'` },
|
|
27
|
+
{ code: `import { HogeAnchor as FugaAnchor } from './hoge'` },
|
|
28
|
+
{ code: `import { Link as FugaLink } from './hoge'` },
|
|
29
|
+
{ code: `import { FugaText as HogeFugaText } from './hoge'` },
|
|
30
|
+
{ code: `import { FugaMessage as HogeFugaMessage } from './hoge'` },
|
|
25
31
|
{ code: 'const HogeAnchor = styled.a``' },
|
|
26
32
|
{ code: 'const HogeLink = styled.a``' },
|
|
27
33
|
{ code: 'const HogeButton = styled.button``' },
|
|
@@ -128,6 +134,12 @@ ruleTester.run('a11y-clickable-element-has-text', rule, {
|
|
|
128
134
|
],
|
|
129
135
|
invalid: [
|
|
130
136
|
{ code: `import hoge from 'styled-components'`, errors: [ { message: `styled-components をimportする際は、名称が"styled" となるようにしてください。例: "import styled from 'styled-components'"` } ] },
|
|
137
|
+
{ code: `import { SmartHRLogo as SmartHRLogoHoge } from './hoge'`, errors: [ { message: `SmartHRLogoHogeを正規表現 "/SmartHRLogo$/" がmatchする名称に変更してください` } ] },
|
|
138
|
+
{ code: `import { AbcButton as AbcButtonFuga } from './hoge'`, errors: [ { message: `AbcButtonFugaを正規表現 "/Button$/" がmatchする名称に変更してください` } ] },
|
|
139
|
+
{ code: `import { Anchor as AnchorHoge } from './hoge'`, errors: [ { message: `AnchorHogeを正規表現 "/Anchor$/" がmatchする名称に変更してください` } ] },
|
|
140
|
+
{ code: `import { HogeLink as HogeLinkFuga } from './hoge'`, errors: [ { message: `HogeLinkFugaを正規表現 "/Link$/" がmatchする名称に変更してください` } ] },
|
|
141
|
+
{ code: `import { FugaText as FugaTextFuga } from './hoge'`, errors: [ { message: `FugaTextFugaを正規表現 "/Text$/" がmatchする名称に変更してください` } ] },
|
|
142
|
+
{ code: `import { FugaMessage as FugaMessageFuga } from './hoge'`, errors: [ { message: `FugaMessageFugaを正規表現 "/Message$/" がmatchする名称に変更してください` } ] },
|
|
131
143
|
{ code: 'const Hoge = styled.a``', errors: [ { message: `Hogeを正規表現 "/(Anchor|Link)$/" がmatchする名称に変更してください` } ] },
|
|
132
144
|
{ code: 'const Hoge = styled.button``', errors: [ { message: `Hogeを正規表現 "/Button$/" がmatchする名称に変更してください` } ] },
|
|
133
145
|
{ code: 'const Hoge = styled(Anchor)``', errors: [ { message: `Hogeを正規表現 "/Anchor$/" がmatchする名称に変更してください` } ] },
|
|
@@ -26,6 +26,13 @@ const noTagAttrMessage = `tag属性を指定せず、smarthr-uiのArticle, Aside
|
|
|
26
26
|
ruleTester.run('a11y-heading-in-sectioning-content', rule, {
|
|
27
27
|
valid: [
|
|
28
28
|
{ code: `import styled from 'styled-components'` },
|
|
29
|
+
{ code: `import { PageHeading as HogePageHeading } from './hoge'` },
|
|
30
|
+
{ code: `import { HogeHeading as FugaHeading } from './hoge'` },
|
|
31
|
+
{ code: `import { HogeArticle as FugaArticle } from './hoge'` },
|
|
32
|
+
{ code: `import { HogeAside as FugaAside } from './hoge'` },
|
|
33
|
+
{ code: `import { HogeNav as FugaNav } from './hoge'` },
|
|
34
|
+
{ code: `import { HogeSection as FugaSection } from './hoge'` },
|
|
35
|
+
{ code: `import { ModelessDialog as FugaModelessDialog } from './hoge'` },
|
|
29
36
|
{ code: 'const HogePageHeading = styled.h1``' },
|
|
30
37
|
{ code: 'const HogeHeading = styled.h2``' },
|
|
31
38
|
{ code: 'const HogeHeading = styled.h3``' },
|
|
@@ -47,6 +54,13 @@ ruleTester.run('a11y-heading-in-sectioning-content', rule, {
|
|
|
47
54
|
],
|
|
48
55
|
invalid: [
|
|
49
56
|
{ code: `import hoge from 'styled-components'`, errors: [ { message: `styled-components をimportする際は、名称が"styled" となるようにしてください。例: "import styled from 'styled-components'"` } ] },
|
|
57
|
+
{ code: `import { HogePageHeading as PageHeadingAbc } from './hoge'`, errors: [ { message: `PageHeadingAbcを正規表現 "/PageHeading$/" がmatchする名称に変更してください` }, { message: `PageHeadingAbcを正規表現 "/Heading$/" がmatchする名称に変更してください` } ] },
|
|
58
|
+
{ code: `import { Heading as HeadingHoge } from './hoge'`, errors: [ { message: `HeadingHogeを正規表現 "/Heading$/" がmatchする名称に変更してください` } ] },
|
|
59
|
+
{ code: `import { HogeArticle as HogeArticleFuga } from './hoge'`, errors: [ { message: `HogeArticleFugaを正規表現 "/Article$/" がmatchする名称に変更してください` } ] },
|
|
60
|
+
{ code: `import { HogeAside as HogeAsideFuga } from './hoge'`, errors: [ { message: `HogeAsideFugaを正規表現 "/Aside$/" がmatchする名称に変更してください` } ] },
|
|
61
|
+
{ code: `import { HogeNav as HogeNavFuga } from './hoge'`, errors: [ { message: `HogeNavFugaを正規表現 "/Nav$/" がmatchする名称に変更してください` } ] },
|
|
62
|
+
{ code: `import { HogeSection as HogeSectionFuga } from './hoge'`, errors: [ { message: `HogeSectionFugaを正規表現 "/Section$/" がmatchする名称に変更してください` } ] },
|
|
63
|
+
{ code: `import { HogeModelessDialog as HogeModelessDialogFuga } from './hoge'`, errors: [ { message: `HogeModelessDialogFugaを正規表現 "/ModelessDialog$/" がmatchする名称に変更してください` } ] },
|
|
50
64
|
{ code: 'const Hoge = styled.h1``', errors: [ { message: `Hogeを正規表現 "/PageHeading$/" がmatchする名称に変更してください` } ] },
|
|
51
65
|
{ code: 'const Hoge = styled.h2``', errors: [ { message: `Hogeを正規表現 "/Heading$/" がmatchする名称に変更してください` } ] },
|
|
52
66
|
{ code: 'const Hoge = styled.h3``', errors: [ { message: `Hogeを正規表現 "/Heading$/" がmatchする名称に変更してください` } ] },
|
|
@@ -26,6 +26,9 @@ ruleTester.run('a11y-image-has-alt-attribute', rule, {
|
|
|
26
26
|
{ code: `import styled from 'styled-components'` },
|
|
27
27
|
{ code: `import styled, { css } from 'styled-components'` },
|
|
28
28
|
{ code: `import { css } from 'styled-components'` },
|
|
29
|
+
{ code: `import { HogeImg as FugaImg } from './hoge'` },
|
|
30
|
+
{ code: `import { HogeImage as FugaImage } from './hoge'` },
|
|
31
|
+
{ code: `import { HogeIcon as FugaIcon } from './hoge'` },
|
|
29
32
|
{ code: 'const HogeImg = styled.img``' },
|
|
30
33
|
{ code: 'const HogeImage = styled.img``' },
|
|
31
34
|
{ code: 'const HogeIcon = styled.img``' },
|
|
@@ -46,6 +49,9 @@ ruleTester.run('a11y-image-has-alt-attribute', rule, {
|
|
|
46
49
|
],
|
|
47
50
|
invalid: [
|
|
48
51
|
{ code: `import hoge from 'styled-components'`, errors: [ { message: `styled-components をimportする際は、名称が"styled" となるようにしてください。例: "import styled from 'styled-components'"` } ] },
|
|
52
|
+
{ code: `import { HogeImg as ImgFuga } from './hoge'`, errors: [ { message: `ImgFugaを正規表現 "/Img$/" がmatchする名称に変更してください` } ] },
|
|
53
|
+
{ code: `import { HogeImage as HogeImageFuga } from './hoge'`, errors: [ { message: `HogeImageFugaを正規表現 "/Image$/" がmatchする名称に変更してください` } ] },
|
|
54
|
+
{ code: `import { Icon as Hoge } from './hoge'`, errors: [ { message: `Hogeを正規表現 "/Icon$/" がmatchする名称に変更してください` } ] },
|
|
49
55
|
{ code: 'const Hoge = styled.img``', errors: [ { message: `Hogeを正規表現 "/(Img|Image|Icon)$/" がmatchする名称に変更してください` } ] },
|
|
50
56
|
{ code: 'const Hoge = styled.svg``', errors: [ { message: `Hogeを正規表現 "/(Img|Image|Icon)$/" がmatchする名称に変更してください` } ] },
|
|
51
57
|
{ code: 'const Hoge = styled(Icon)``', errors: [ { message: `Hogeを正規表現 "/Icon$/" がmatchする名称に変更してください` } ] },
|
|
@@ -23,6 +23,15 @@ ruleTester.run('a11y-input-has-name-attribute', rule, {
|
|
|
23
23
|
{ code: `import styled from 'styled-components'` },
|
|
24
24
|
{ code: `import styled, { css } from 'styled-components'` },
|
|
25
25
|
{ code: `import { css } from 'styled-components'` },
|
|
26
|
+
{ code: `import { Input as HogeInput } from './hoge'` },
|
|
27
|
+
{ code: `import { HogeTextarea as FugaTextarea } from './hoge'` },
|
|
28
|
+
{ code: `import { Select as HogeSelect } from './hoge'` },
|
|
29
|
+
{ code: `import { InputFile as HogeInputFile } from './hoge'` },
|
|
30
|
+
{ code: `import { HogeRadioButton as FugaRadioButton } from './hoge'` },
|
|
31
|
+
{ code: `import { CheckBox as FugaCheckBox } from './hoge'` },
|
|
32
|
+
{ code: `import { HogeComboBox as FugaComboBox } from './hoge'` },
|
|
33
|
+
{ code: `import { DatePicker as HogeDatePicker } from './hoge'` },
|
|
34
|
+
{ code: `import { HogeDropZone as HogeFugaDropZone } from './hoge'` },
|
|
26
35
|
{ code: 'const HogeInput = styled.input``' },
|
|
27
36
|
{ code: 'const HogeInput = styled(Input)``' },
|
|
28
37
|
{ code: 'const HogeRadioButton = styled(RadioButton)``' },
|
|
@@ -43,6 +52,15 @@ ruleTester.run('a11y-input-has-name-attribute', rule, {
|
|
|
43
52
|
],
|
|
44
53
|
invalid: [
|
|
45
54
|
{ code: `import hoge from 'styled-components'`, errors: [ { message: `styled-components をimportする際は、名称が"styled" となるようにしてください。例: "import styled from 'styled-components'"` } ] },
|
|
55
|
+
{ code: `import { Input as InputHoge } from './hoge'`, errors: [ { message: `InputHogeを正規表現 "/Input$/" がmatchする名称に変更してください` } ] },
|
|
56
|
+
{ code: `import { HogeTextarea as HogeTextareaFuga } from './hoge'`, errors: [ { message: `HogeTextareaFugaを正規表現 "/Textarea$/" がmatchする名称に変更してください` } ] },
|
|
57
|
+
{ code: `import { HogeSelect as SelectFuga } from './hoge'`, errors: [ { message: `SelectFugaを正規表現 "/Select$/" がmatchする名称に変更してください` } ] },
|
|
58
|
+
{ code: `import { InputFile as HogeInputFileFuga } from './hoge'`, errors: [ { message: `HogeInputFileFugaを正規表現 "/InputFile$/" がmatchする名称に変更してください` } ] },
|
|
59
|
+
{ code: `import { HogeRadioButton as FugaRadioButtonAbc } from './hoge'`, errors: [ { message: `FugaRadioButtonAbcを正規表現 "/RadioButton$/" がmatchする名称に変更してください` } ] },
|
|
60
|
+
{ code: `import { CheckBox as FugaCheckBoxHoge } from './hoge'`, errors: [ { message: `FugaCheckBoxHogeを正規表現 "/CheckBox$/" がmatchする名称に変更してください` } ] },
|
|
61
|
+
{ code: `import { HogeComboBox as ComboBoxFuga } from './hoge'`, errors: [ { message: `ComboBoxFugaを正規表現 "/ComboBox$/" がmatchする名称に変更してください` } ] },
|
|
62
|
+
{ code: `import { DatePicker as HogeDatePickerFuga } from './hoge'`, errors: [ { message: `HogeDatePickerFugaを正規表現 "/DatePicker$/" がmatchする名称に変更してください` } ] },
|
|
63
|
+
{ code: `import { HogeDropZone as HogeFugaDropZoneAbc } from './hoge'`, errors: [ { message: `HogeFugaDropZoneAbcを正規表現 "/DropZone$/" がmatchする名称に変更してください` } ] },
|
|
46
64
|
{ code: 'const Hoge = styled.input``', errors: [ { message: `Hogeを正規表現 "/Input$/" がmatchする名称に変更してください` } ] },
|
|
47
65
|
{ code: 'const Hoge = styled.Input``', errors: [ { message: `Hogeを正規表現 "/Input$/" がmatchする名称に変更してください` } ] },
|
|
48
66
|
{ code: 'const Hoge = styled(RadioButton)``', errors: [ { message: `Hogeを正規表現 "/RadioButton$/" がmatchする名称に変更してください` } ] },
|
|
@@ -17,6 +17,11 @@ ruleTester.run('a11y-prohibit-input-placeholder', rule, {
|
|
|
17
17
|
{ code: `import styled from 'styled-components'` },
|
|
18
18
|
{ code: `import styled, { css } from 'styled-components'` },
|
|
19
19
|
{ code: `import { css } from 'styled-components'` },
|
|
20
|
+
{ code: `import { Input as HogeInput } from './hoge'` },
|
|
21
|
+
{ code: `import { HogeSearchInput as FugaSearchInput } from './hoge'` },
|
|
22
|
+
{ code: `import { HogeTextarea as FugaHogeTextarea } from './hoge'` },
|
|
23
|
+
{ code: `import { ComboBox as FugaHogeComboBox } from './hoge'` },
|
|
24
|
+
{ code: `import { AbcDatePicker as StyledDatePicker } from './hoge'` },
|
|
20
25
|
{ code: 'const HogeInput = styled.input``' },
|
|
21
26
|
{ code: 'const HogeTextarea = styled.textarea``' },
|
|
22
27
|
{ code: 'const HogeInput = styled(Input)``' },
|
|
@@ -44,6 +49,11 @@ ruleTester.run('a11y-prohibit-input-placeholder', rule, {
|
|
|
44
49
|
],
|
|
45
50
|
invalid: [
|
|
46
51
|
{ code: `import hoge from 'styled-components'`, errors: [ { message: `styled-components をimportする際は、名称が"styled" となるようにしてください。例: "import styled from 'styled-components'"` } ] },
|
|
52
|
+
{ code: `import { Input as InputHoge } from './hoge'`, errors: [ { message: `InputHogeを正規表現 "/Input$/" がmatchする名称に変更してください` } ] },
|
|
53
|
+
{ code: `import { SearchInput as Hoge } from './hoge'`, errors: [ { message: `Hogeを正規表現 "/Input$/" がmatchする名称に変更してください` }, { message: `Hogeを正規表現 "/SearchInput$/" がmatchする名称に変更してください` } ] },
|
|
54
|
+
{ code: `import { HogeTextarea as HogeTextareaFuga } from './hoge'`, errors: [ { message: `HogeTextareaFugaを正規表現 "/Textarea$/" がmatchする名称に変更してください` } ] },
|
|
55
|
+
{ code: `import { HogeComboBox as ComboBoxFuga } from './hoge'`, errors: [ { message: `ComboBoxFugaを正規表現 "/ComboBox$/" がmatchする名称に変更してください` } ] },
|
|
56
|
+
{ code: `import { DatePicker as HogeDatePickerFuga } from './hoge'`, errors: [ { message: `HogeDatePickerFugaを正規表現 "/DatePicker$/" がmatchする名称に変更してください` } ] },
|
|
47
57
|
{ code: 'const Hoge = styled.input``', errors: [ { message: `Hogeを正規表現 "/Input$/" がmatchする名称に変更してください` } ] },
|
|
48
58
|
{ code: 'const Hoge = styled(StyledInput)``', errors: [ { message: `Hogeを正規表現 "/Input$/" がmatchする名称に変更してください` } ] },
|
|
49
59
|
{ code: 'const Hoge = styled.textarea``', errors: [ { message: `Hogeを正規表現 "/Textarea$/" がmatchする名称に変更してください` } ] },
|
|
@@ -17,6 +17,12 @@ ruleTester.run('a11y-trigger-has-button', rule, {
|
|
|
17
17
|
{ code: `import styled from 'styled-components'` },
|
|
18
18
|
{ code: `import styled, { css } from 'styled-components'` },
|
|
19
19
|
{ code: `import { css } from 'styled-components'` },
|
|
20
|
+
{ code: `import { DropdownTrigger as HogeDropdownTrigger } from './hoge'` },
|
|
21
|
+
{ code: `import { FugaDialogTrigger as HogeDialogTrigger } from './hoge'` },
|
|
22
|
+
{ code: `import { AbcButton as HogeAbcButton } from './hoge'` },
|
|
23
|
+
{ code: `import { AnchorButton as FugaAnchorButton } from './hoge'` },
|
|
24
|
+
{ code: `import { HogeAnchor as HogeFugaAnchor } from './hoge'` },
|
|
25
|
+
{ code: `import { FugaLink as HogeLink } from './hoge'` },
|
|
20
26
|
{ code: 'const HogeButton = styled.button``' },
|
|
21
27
|
{ code: 'const HogeAnchor = styled.a``' },
|
|
22
28
|
{ code: 'const HogeLink = styled.a``' },
|
|
@@ -33,6 +39,12 @@ ruleTester.run('a11y-trigger-has-button', rule, {
|
|
|
33
39
|
],
|
|
34
40
|
invalid: [
|
|
35
41
|
{ code: `import hoge from 'styled-components'`, errors: [ { message: `styled-components をimportする際は、名称が"styled" となるようにしてください。例: "import styled from 'styled-components'"` } ] },
|
|
42
|
+
{ code: `import { DropdownTrigger as Hoge } from './hoge'`, errors: [ { message: `Hogeを正規表現 "/DropdownTrigger$/" がmatchする名称に変更してください` } ] },
|
|
43
|
+
{ code: `import { DialogTrigger as Hoge } from './hoge'`, errors: [ { message: `Hogeを正規表現 "/DialogTrigger$/" がmatchする名称に変更してください` } ] },
|
|
44
|
+
{ code: `import { Button as Hoge } from './hoge'`, errors: [ { message: `Hogeを正規表現 "/Button$/" がmatchする名称に変更してください` } ] },
|
|
45
|
+
{ code: `import { AbcAnchorButton as Hoge } from './hoge'`, errors: [ { message: `Hogeを正規表現 "/Button$/" がmatchする名称に変更してください` }, { message: `Hogeを正規表現 "/AnchorButton$/" がmatchする名称に変更してください` } ] },
|
|
46
|
+
{ code: `import { Anchor as Hoge } from './hoge'`, errors: [ { message: `Hogeを正規表現 "/Anchor$/" がmatchする名称に変更してください` } ] },
|
|
47
|
+
{ code: `import { Link as Hoge } from './hoge'`, errors: [ { message: `Hogeを正規表現 "/Link$/" がmatchする名称に変更してください` } ] },
|
|
36
48
|
{ code: 'const Hoge = styled.button``', errors: [ { message: `Hogeを正規表現 "/Button$/" がmatchする名称に変更してください` } ] },
|
|
37
49
|
{ code: 'const Hoge = styled.a``', errors: [ { message: `Hogeを正規表現 "/(Anchor|Link)$/" がmatchする名称に変更してください` } ] },
|
|
38
50
|
{ code: 'const Hoge = styled(Button)``', errors: [ { message: `Hogeを正規表現 "/Button$/" がmatchする名称に変更してください` } ] },
|