eslint-plugin-primer-react 4.0.3 → 4.0.4-rc.5058fcb

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.
Files changed (46) hide show
  1. package/.changeset/README.md +3 -3
  2. package/.eslintrc.js +39 -0
  3. package/.github/dependabot.yml +11 -5
  4. package/.github/workflows/add-to-inbox.yml +33 -0
  5. package/.github/workflows/ci.yml +34 -18
  6. package/.github/workflows/release.yml +2 -2
  7. package/.github/workflows/release_canary.yml +8 -5
  8. package/.github/workflows/release_candidate.yml +4 -4
  9. package/.markdownlint-cli2.cjs +26 -0
  10. package/.nvmrc +1 -0
  11. package/.prettierignore +3 -0
  12. package/CHANGELOG.md +7 -1
  13. package/README.md +4 -2
  14. package/docs/rules/a11y-explicit-heading.md +17 -7
  15. package/docs/rules/a11y-tooltip-interactive-trigger.md +6 -2
  16. package/docs/rules/direct-slot-children.md +49 -46
  17. package/docs/rules/new-color-css-vars-have-fallback.md +25 -0
  18. package/docs/rules/new-css-color-vars.md +19 -14
  19. package/docs/rules/no-deprecated-colors.md +91 -82
  20. package/docs/rules/no-system-props.md +12 -5
  21. package/package-lock.json +15583 -0
  22. package/package.json +22 -14
  23. package/src/configs/components.js +19 -19
  24. package/src/configs/recommended.js +9 -8
  25. package/src/index.js +4 -3
  26. package/src/rules/__tests__/a11y-explicit-heading.test.js +22 -25
  27. package/src/rules/__tests__/a11y-tooltip-interactive-trigger.test.js +43 -43
  28. package/src/rules/__tests__/direct-slot-children.test.js +36 -36
  29. package/src/rules/__tests__/new-color-css-vars.test.js +612 -44
  30. package/src/rules/__tests__/new-css-vars-have-fallback.test.js +31 -0
  31. package/src/rules/__tests__/no-deprecated-colors.test.js +66 -66
  32. package/src/rules/__tests__/no-system-props.test.js +51 -51
  33. package/src/rules/a11y-explicit-heading.js +16 -13
  34. package/src/rules/a11y-tooltip-interactive-trigger.js +21 -22
  35. package/src/rules/direct-slot-children.js +11 -11
  36. package/src/rules/new-color-css-vars-have-fallback.js +87 -0
  37. package/src/rules/new-color-css-vars.js +97 -83
  38. package/src/rules/no-deprecated-colors.js +15 -15
  39. package/src/rules/no-system-props.js +21 -21
  40. package/src/url.js +1 -1
  41. package/src/utils/__tests__/flatten-components.test.js +13 -13
  42. package/src/utils/css-variable-map.json +538 -184
  43. package/src/utils/flatten-components.js +11 -11
  44. package/src/utils/is-imported-from.js +1 -1
  45. package/src/utils/new-color-css-vars-map.json +326 -0
  46. /package/.github/{workflows/CODEOWNERS → CODEOWNERS} +0 -0
@@ -0,0 +1,31 @@
1
+ const rule = require('../new-color-css-vars-have-fallback')
2
+ const {RuleTester} = require('eslint')
3
+
4
+ const ruleTester = new RuleTester({
5
+ parserOptions: {
6
+ ecmaVersion: 'latest',
7
+ sourceType: 'module',
8
+ ecmaFeatures: {
9
+ jsx: true,
10
+ },
11
+ },
12
+ })
13
+
14
+ ruleTester.run('new-color-css-vars-have-fallback', rule, {
15
+ valid: [
16
+ {
17
+ code: `<circle stroke="var(--fgColor-muted, var(--color-fg-muted))" strokeWidth="2" />`,
18
+ },
19
+ ],
20
+ invalid: [
21
+ {
22
+ code: `<circle stroke="var(--fgColor-muted)" strokeWidth="2" />`,
23
+ errors: [
24
+ {
25
+ message:
26
+ 'Expected a fallback value for CSS variable --fgColor-muted. New color variables fallbacks, check primer.style/primitives to find the correct value.',
27
+ },
28
+ ],
29
+ },
30
+ ],
31
+ })
@@ -4,12 +4,12 @@ const {RuleTester} = require('eslint')
4
4
  const deprecatedVars = {
5
5
  'text.primary': 'fg.default',
6
6
  'bg.primary': 'canvas.default',
7
- 'auto.green.5': ['success.fg', 'success.emphasis']
7
+ 'auto.green.5': ['success.fg', 'success.emphasis'],
8
8
  }
9
9
 
10
10
  const removedVars = {
11
11
  'fade.fg10': null,
12
- 'autocomplete.shadow': 'shadow.medium'
12
+ 'autocomplete.shadow': 'shadow.medium',
13
13
  }
14
14
 
15
15
  jest.mock('@primer/primitives/dist/deprecated/colors', () => deprecatedVars)
@@ -20,9 +20,9 @@ const ruleTester = new RuleTester({
20
20
  ecmaVersion: 'latest',
21
21
  sourceType: 'module',
22
22
  ecmaFeatures: {
23
- jsx: true
24
- }
25
- }
23
+ jsx: true,
24
+ },
25
+ },
26
26
  })
27
27
 
28
28
  ruleTester.run('no-deprecated-colors', rule, {
@@ -38,7 +38,7 @@ ruleTester.run('no-deprecated-colors', rule, {
38
38
  `import {Box} from '@primer/react'; <Box sx={styles}>Hello</Box>`,
39
39
  `import {Box} from '@primer/react'; <Box sx={{color: text.primary}}>Hello</Box>`,
40
40
  `import {Box} from '@primer/react'; <Box sx={{color: "fg.default"}}>Hello</Box>`,
41
- `{color: 'text.primary'}`
41
+ `{color: 'text.primary'}`,
42
42
  ],
43
43
  invalid: [
44
44
  {
@@ -47,18 +47,18 @@ ruleTester.run('no-deprecated-colors', rule, {
47
47
  options: [{checkAllStrings: true}],
48
48
  errors: [
49
49
  {
50
- message: '"text.primary" is deprecated. Use "fg.default" instead.'
51
- }
52
- ]
50
+ message: '"text.primary" is deprecated. Use "fg.default" instead.',
51
+ },
52
+ ],
53
53
  },
54
54
  {
55
55
  code: `import {Box} from "@primer/react"; function Example() { return <Box color="text.primary">Hello</Box> }`,
56
56
  output: `import {Box} from "@primer/react"; function Example() { return <Box color="fg.default">Hello</Box> }`,
57
57
  errors: [
58
58
  {
59
- message: '"text.primary" is deprecated. Use "fg.default" instead.'
60
- }
61
- ]
59
+ message: '"text.primary" is deprecated. Use "fg.default" instead.',
60
+ },
61
+ ],
62
62
  },
63
63
  {
64
64
  code: `import {Box} from "../components"; function Example() { return <Box color="text.primary">Hello</Box> }`,
@@ -66,81 +66,81 @@ ruleTester.run('no-deprecated-colors', rule, {
66
66
  options: [{skipImportCheck: true}],
67
67
  errors: [
68
68
  {
69
- message: '"text.primary" is deprecated. Use "fg.default" instead.'
70
- }
71
- ]
69
+ message: '"text.primary" is deprecated. Use "fg.default" instead.',
70
+ },
71
+ ],
72
72
  },
73
73
  {
74
74
  code: `import Box from '@primer/react/lib-esm/Box'; function Example() { return <Box color="text.primary">Hello</Box> }`,
75
75
  output: `import Box from '@primer/react/lib-esm/Box'; function Example() { return <Box color="fg.default">Hello</Box> }`,
76
76
  errors: [
77
77
  {
78
- message: '"text.primary" is deprecated. Use "fg.default" instead.'
79
- }
80
- ]
78
+ message: '"text.primary" is deprecated. Use "fg.default" instead.',
79
+ },
80
+ ],
81
81
  },
82
82
  {
83
83
  code: `import {Box} from "@primer/react"; const Example = () => <Box color="text.primary">Hello</Box>`,
84
84
  output: `import {Box} from "@primer/react"; const Example = () => <Box color="fg.default">Hello</Box>`,
85
85
  errors: [
86
86
  {
87
- message: '"text.primary" is deprecated. Use "fg.default" instead.'
88
- }
89
- ]
87
+ message: '"text.primary" is deprecated. Use "fg.default" instead.',
88
+ },
89
+ ],
90
90
  },
91
91
  {
92
92
  code: `import {Box} from "@primer/react"; <Box bg="bg.primary" m={1} />`,
93
93
  output: `import {Box} from "@primer/react"; <Box bg="canvas.default" m={1} />`,
94
94
  errors: [
95
95
  {
96
- message: '"bg.primary" is deprecated. Use "canvas.default" instead.'
97
- }
98
- ]
96
+ message: '"bg.primary" is deprecated. Use "canvas.default" instead.',
97
+ },
98
+ ],
99
99
  },
100
100
  {
101
101
  code: `import {Box} from "@primer/react"; <Box sx={{bg: "bg.primary", m: 1, ...rest}} />`,
102
102
  output: `import {Box} from "@primer/react"; <Box sx={{bg: "canvas.default", m: 1, ...rest}} />`,
103
103
  errors: [
104
104
  {
105
- message: '"bg.primary" is deprecated. Use "canvas.default" instead.'
106
- }
107
- ]
105
+ message: '"bg.primary" is deprecated. Use "canvas.default" instead.',
106
+ },
107
+ ],
108
108
  },
109
109
  {
110
110
  code: `import {Box} from "@primer/react"; <Box sx={{boxShadow: theme => theme.shadows.autocomplete.shadow}} />`,
111
111
  output: `import {Box} from "@primer/react"; <Box sx={{boxShadow: theme => theme.shadows.shadow.medium}} />`,
112
112
  errors: [
113
113
  {
114
- message: '"theme.shadows.autocomplete.shadow" is deprecated. Use "theme.shadows.shadow.medium" instead.'
115
- }
116
- ]
114
+ message: '"theme.shadows.autocomplete.shadow" is deprecated. Use "theme.shadows.shadow.medium" instead.',
115
+ },
116
+ ],
117
117
  },
118
118
  {
119
119
  code: `import {Box} from "@primer/react"; <Box sx={{boxShadow: theme => \`0 1px 2px \${theme.colors.text.primary}\`}} />`,
120
120
  output: `import {Box} from "@primer/react"; <Box sx={{boxShadow: theme => \`0 1px 2px \${theme.colors.fg.default}\`}} />`,
121
121
  errors: [
122
122
  {
123
- message: '"theme.colors.text.primary" is deprecated. Use "theme.colors.fg.default" instead.'
124
- }
125
- ]
123
+ message: '"theme.colors.text.primary" is deprecated. Use "theme.colors.fg.default" instead.',
124
+ },
125
+ ],
126
126
  },
127
127
  {
128
128
  code: `import {Box} from "@primer/react"; <Box sx={{boxShadow: t => \`0 1px 2px \${t.colors.text.primary}\`}} />`,
129
129
  output: `import {Box} from "@primer/react"; <Box sx={{boxShadow: t => \`0 1px 2px \${t.colors.fg.default}\`}} />`,
130
130
  errors: [
131
131
  {
132
- message: '"t.colors.text.primary" is deprecated. Use "t.colors.fg.default" instead.'
133
- }
134
- ]
132
+ message: '"t.colors.text.primary" is deprecated. Use "t.colors.fg.default" instead.',
133
+ },
134
+ ],
135
135
  },
136
136
  {
137
137
  code: `import {Box} from "@primer/react"; <Box sx={{"&:hover": {bg: "bg.primary"}}} />`,
138
138
  output: `import {Box} from "@primer/react"; <Box sx={{"&:hover": {bg: "canvas.default"}}} />`,
139
139
  errors: [
140
140
  {
141
- message: '"bg.primary" is deprecated. Use "canvas.default" instead.'
142
- }
143
- ]
141
+ message: '"bg.primary" is deprecated. Use "canvas.default" instead.',
142
+ },
143
+ ],
144
144
  },
145
145
  {
146
146
  code: `import {Box} from "@primer/react"; <Box color="auto.green.5" />`,
@@ -150,72 +150,72 @@ ruleTester.run('no-deprecated-colors', rule, {
150
150
  suggestions: [
151
151
  {
152
152
  desc: 'Use "success.fg" instead.',
153
- output: `import {Box} from "@primer/react"; <Box color="success.fg" />`
153
+ output: `import {Box} from "@primer/react"; <Box color="success.fg" />`,
154
154
  },
155
155
  {
156
156
  desc: 'Use "success.emphasis" instead.',
157
- output: `import {Box} from "@primer/react"; <Box color="success.emphasis" />`
158
- }
159
- ]
160
- }
161
- ]
157
+ output: `import {Box} from "@primer/react"; <Box color="success.emphasis" />`,
158
+ },
159
+ ],
160
+ },
161
+ ],
162
162
  },
163
163
  {
164
164
  code: `import {Box} from "@primer/react"; <Box color="fade.fg10" />`,
165
165
  errors: [
166
166
  {
167
167
  message:
168
- '"fade.fg10" is deprecated. Go to https://primer.style/primitives or reach out in the #primer channel on Slack to find a suitable replacement.'
169
- }
170
- ]
168
+ '"fade.fg10" is deprecated. Go to https://primer.style/primitives or reach out in the #primer channel on Slack to find a suitable replacement.',
169
+ },
170
+ ],
171
171
  },
172
172
  {
173
173
  code: `import {Box, Text} from "@primer/react"; <Box bg="bg.primary"><Text color="text.primary">Hello</Text></Box>`,
174
174
  output: `import {Box, Text} from "@primer/react"; <Box bg="canvas.default"><Text color="fg.default">Hello</Text></Box>`,
175
175
  errors: [
176
176
  {
177
- message: '"bg.primary" is deprecated. Use "canvas.default" instead.'
177
+ message: '"bg.primary" is deprecated. Use "canvas.default" instead.',
178
178
  },
179
179
  {
180
- message: '"text.primary" is deprecated. Use "fg.default" instead.'
181
- }
182
- ]
180
+ message: '"text.primary" is deprecated. Use "fg.default" instead.',
181
+ },
182
+ ],
183
183
  },
184
184
  {
185
185
  code: `import {themeGet} from "@primer/react"; themeGet("colors.text.primary")`,
186
186
  output: `import {themeGet} from "@primer/react"; themeGet("colors.fg.default")`,
187
187
  errors: [
188
188
  {
189
- message: '"colors.text.primary" is deprecated. Use "colors.fg.default" instead.'
190
- }
191
- ]
189
+ message: '"colors.text.primary" is deprecated. Use "colors.fg.default" instead.',
190
+ },
191
+ ],
192
192
  },
193
193
  {
194
194
  code: `import {themeGet} from "@primer/react"; themeGet("shadows.autocomplete.shadow")`,
195
195
  output: `import {themeGet} from "@primer/react"; themeGet("shadows.shadow.medium")`,
196
196
  errors: [
197
197
  {
198
- message: '"shadows.autocomplete.shadow" is deprecated. Use "shadows.shadow.medium" instead.'
199
- }
200
- ]
198
+ message: '"shadows.autocomplete.shadow" is deprecated. Use "shadows.shadow.medium" instead.',
199
+ },
200
+ ],
201
201
  },
202
202
  {
203
203
  code: `import {get} from "./constants"; get("colors.text.primary")`,
204
204
  output: `import {get} from "./constants"; get("colors.fg.default")`,
205
205
  errors: [
206
206
  {
207
- message: '"colors.text.primary" is deprecated. Use "colors.fg.default" instead.'
208
- }
209
- ]
207
+ message: '"colors.text.primary" is deprecated. Use "colors.fg.default" instead.',
208
+ },
209
+ ],
210
210
  },
211
211
  {
212
212
  code: `import {get} from "../constants"; get("colors.text.primary")`,
213
213
  output: `import {get} from "../constants"; get("colors.fg.default")`,
214
214
  errors: [
215
215
  {
216
- message: '"colors.text.primary" is deprecated. Use "colors.fg.default" instead.'
217
- }
218
- ]
219
- }
220
- ]
216
+ message: '"colors.text.primary" is deprecated. Use "colors.fg.default" instead.',
217
+ },
218
+ ],
219
+ },
220
+ ],
221
221
  })
@@ -6,9 +6,9 @@ const ruleTester = new RuleTester({
6
6
  ecmaVersion: 'latest',
7
7
  sourceType: 'module',
8
8
  ecmaFeatures: {
9
- jsx: true
10
- }
11
- }
9
+ jsx: true,
10
+ },
11
+ },
12
12
  })
13
13
 
14
14
  ruleTester.run('no-system-props', rule, {
@@ -21,7 +21,7 @@ ruleTester.run('no-system-props', rule, {
21
21
  `import {Button} from '@primer/react'; <Button {...someExpression()} />`,
22
22
  `import {Button} from '@primer/react'; <Button variant="large" />`,
23
23
  `import {Button} from '@primer/react'; <Button size="large" />`,
24
- `import {ActionMenu} from '@primer/react'; <ActionMenu.Overlay width="large" />`
24
+ `import {ActionMenu} from '@primer/react'; <ActionMenu.Overlay width="large" />`,
25
25
  ],
26
26
  invalid: [
27
27
  {
@@ -30,9 +30,9 @@ ruleTester.run('no-system-props', rule, {
30
30
  errors: [
31
31
  {
32
32
  messageId: 'noSystemProps',
33
- data: {propNames: 'width', componentName: 'Button'}
34
- }
35
- ]
33
+ data: {propNames: 'width', componentName: 'Button'},
34
+ },
35
+ ],
36
36
  },
37
37
  {
38
38
  code: `import {Button} from '@primer/react'; <Button width="200" />`,
@@ -40,9 +40,9 @@ ruleTester.run('no-system-props', rule, {
40
40
  errors: [
41
41
  {
42
42
  messageId: 'noSystemProps',
43
- data: {propNames: 'width', componentName: 'Button'}
44
- }
45
- ]
43
+ data: {propNames: 'width', componentName: 'Button'},
44
+ },
45
+ ],
46
46
  },
47
47
  {
48
48
  code: `import {Button} from '@primer/react'; <Button width={"200"} />`,
@@ -50,9 +50,9 @@ ruleTester.run('no-system-props', rule, {
50
50
  errors: [
51
51
  {
52
52
  messageId: 'noSystemProps',
53
- data: {propNames: 'width', componentName: 'Button'}
54
- }
55
- ]
53
+ data: {propNames: 'width', componentName: 'Button'},
54
+ },
55
+ ],
56
56
  },
57
57
  {
58
58
  code: `import {Button} from '@primer/react'; <Button width={myWidth} />`,
@@ -60,9 +60,9 @@ ruleTester.run('no-system-props', rule, {
60
60
  errors: [
61
61
  {
62
62
  messageId: 'noSystemProps',
63
- data: {propNames: 'width', componentName: 'Button'}
64
- }
65
- ]
63
+ data: {propNames: 'width', componentName: 'Button'},
64
+ },
65
+ ],
66
66
  },
67
67
  {
68
68
  code: `import {Button} from '@primer/react'; <Button width={200} height={100} />`,
@@ -70,9 +70,9 @@ ruleTester.run('no-system-props', rule, {
70
70
  errors: [
71
71
  {
72
72
  messageId: 'noSystemProps',
73
- data: {propNames: 'width, height', componentName: 'Button'}
74
- }
75
- ]
73
+ data: {propNames: 'width, height', componentName: 'Button'},
74
+ },
75
+ ],
76
76
  },
77
77
  {
78
78
  code: `import {Button} from '@primer/react'; <Button width={200} sx={{height: 200}} />`,
@@ -80,9 +80,9 @@ ruleTester.run('no-system-props', rule, {
80
80
  errors: [
81
81
  {
82
82
  messageId: 'noSystemProps',
83
- data: {propNames: 'width', componentName: 'Button'}
84
- }
85
- ]
83
+ data: {propNames: 'width', componentName: 'Button'},
84
+ },
85
+ ],
86
86
  },
87
87
  {
88
88
  code: `import {Button} from '@primer/react'; <Button width={200} sx={{width: 300}} />`,
@@ -90,9 +90,9 @@ ruleTester.run('no-system-props', rule, {
90
90
  errors: [
91
91
  {
92
92
  messageId: 'noSystemProps',
93
- data: {propNames: 'width', componentName: 'Button'}
94
- }
95
- ]
93
+ data: {propNames: 'width', componentName: 'Button'},
94
+ },
95
+ ],
96
96
  },
97
97
  {
98
98
  code: `import {Button} from '@primer/react'; <Button width={200} sx={myStylez} />`,
@@ -100,9 +100,9 @@ ruleTester.run('no-system-props', rule, {
100
100
  errors: [
101
101
  {
102
102
  messageId: 'noSystemProps',
103
- data: {propNames: 'width', componentName: 'Button'}
104
- }
105
- ]
103
+ data: {propNames: 'width', componentName: 'Button'},
104
+ },
105
+ ],
106
106
  },
107
107
  {
108
108
  code: `import {Button} from '@primer/react'; <Button width={200} sx={{...partialStyles, width: 100}} />`,
@@ -110,9 +110,9 @@ ruleTester.run('no-system-props', rule, {
110
110
  errors: [
111
111
  {
112
112
  messageId: 'noSystemProps',
113
- data: {propNames: 'width', componentName: 'Button'}
114
- }
115
- ]
113
+ data: {propNames: 'width', componentName: 'Button'},
114
+ },
115
+ ],
116
116
  },
117
117
  {
118
118
  code: `import {Label} from '@primer/react'; <Label width={200} outline />`,
@@ -120,9 +120,9 @@ ruleTester.run('no-system-props', rule, {
120
120
  errors: [
121
121
  {
122
122
  messageId: 'noSystemProps',
123
- data: {propNames: 'width', componentName: 'Label'}
124
- }
125
- ]
123
+ data: {propNames: 'width', componentName: 'Label'},
124
+ },
125
+ ],
126
126
  },
127
127
  {
128
128
  code: `import {Box} from '@primer/react'; <Box width={200} />`,
@@ -131,9 +131,9 @@ ruleTester.run('no-system-props', rule, {
131
131
  errors: [
132
132
  {
133
133
  messageId: 'noSystemProps',
134
- data: {propNames: 'width', componentName: 'Box'}
135
- }
136
- ]
134
+ data: {propNames: 'width', componentName: 'Box'},
135
+ },
136
+ ],
137
137
  },
138
138
  {
139
139
  code: `import {Text} from '@primer/react'; <Text width={200} />`,
@@ -142,9 +142,9 @@ ruleTester.run('no-system-props', rule, {
142
142
  errors: [
143
143
  {
144
144
  messageId: 'noSystemProps',
145
- data: {propNames: 'width', componentName: 'Text'}
146
- }
147
- ]
145
+ data: {propNames: 'width', componentName: 'Text'},
146
+ },
147
+ ],
148
148
  },
149
149
  {
150
150
  code: `import {Button} from '../Button'; <Button width={200} />`,
@@ -153,9 +153,9 @@ ruleTester.run('no-system-props', rule, {
153
153
  errors: [
154
154
  {
155
155
  messageId: 'noSystemProps',
156
- data: {propNames: 'width', componentName: 'Button'}
157
- }
158
- ]
156
+ data: {propNames: 'width', componentName: 'Button'},
157
+ },
158
+ ],
159
159
  },
160
160
  {
161
161
  code: `import {Foo} from '../Foo'; <Foo width={200} />`,
@@ -164,9 +164,9 @@ ruleTester.run('no-system-props', rule, {
164
164
  errors: [
165
165
  {
166
166
  messageId: 'noSystemProps',
167
- data: {propNames: 'width', componentName: 'Foo'}
168
- }
169
- ]
167
+ data: {propNames: 'width', componentName: 'Foo'},
168
+ },
169
+ ],
170
170
  },
171
171
  {
172
172
  code: `import {Button} from '@primer/react'; <Button.Counter width={200} />`,
@@ -174,9 +174,9 @@ ruleTester.run('no-system-props', rule, {
174
174
  errors: [
175
175
  {
176
176
  messageId: 'noSystemProps',
177
- data: {propNames: 'width', componentName: 'Button.Counter'}
178
- }
179
- ]
180
- }
181
- ]
177
+ data: {propNames: 'width', componentName: 'Button.Counter'},
178
+ },
179
+ ],
180
+ },
181
+ ],
182
182
  })
@@ -15,7 +15,7 @@ const isUsingAsProp = elem => {
15
15
 
16
16
  const isValidAsUsage = value => validHeadings.includes(value.toLowerCase())
17
17
  const isInvalid = elem => {
18
- if (elem.attributes.length === 1 && elem.attributes[0].type === 'JSXSpreadAttribute') return;
18
+ if (elem.attributes.length === 1 && elem.attributes[0].type === 'JSXSpreadAttribute') return
19
19
 
20
20
  const elemAs = isUsingAsProp(elem)
21
21
 
@@ -35,32 +35,35 @@ module.exports = {
35
35
  {
36
36
  properties: {
37
37
  skipImportCheck: {
38
- type: 'boolean'
39
- }
40
- }
41
- }
38
+ type: 'boolean',
39
+ },
40
+ },
41
+ },
42
42
  ],
43
43
  messages: {
44
44
  nonExplicitHeadingLevel: 'Heading must have an explicit heading level applied through the `as` prop.',
45
- invalidAsValue: 'Usage of `as` must only be used for heading elements (h1-h6).'
46
- }
45
+ invalidAsValue: 'Usage of `as` must only be used for heading elements (h1-h6).',
46
+ },
47
47
  },
48
- create: function(context) {
48
+ create(context) {
49
49
  return {
50
50
  JSXOpeningElement(jsxNode) {
51
51
  const skipImportCheck = context.options[0] ? context.options[0].skipImportCheck : false
52
52
 
53
- if ((skipImportCheck || isPrimerComponent(jsxNode.name, context.getScope(jsxNode))) && isHeadingComponent(jsxNode)) {
53
+ if (
54
+ (skipImportCheck || isPrimerComponent(jsxNode.name, context.getScope(jsxNode))) &&
55
+ isHeadingComponent(jsxNode)
56
+ ) {
54
57
  const error = isInvalid(jsxNode)
55
58
 
56
59
  if (error) {
57
60
  context.report({
58
61
  node: jsxNode,
59
- messageId: error
62
+ messageId: error,
60
63
  })
61
64
  }
62
65
  }
63
- }
66
+ },
64
67
  }
65
- }
66
- }
68
+ },
69
+ }