eslint-plugin-primer-react 8.5.1-rc.585f4b0 → 8.5.1-rc.7865cb9
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
CHANGED
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
- [#474](https://github.com/primer/eslint-plugin-primer-react/pull/474) [`1e0f943`](https://github.com/primer/eslint-plugin-primer-react/commit/1e0f943a264aaac2581b95916bd0cb8a66a41a17) Thanks [@liuliu-dev](https://github.com/liuliu-dev)! - Fix `no-unnecessary-components` rule to support `@primer/styled-react` imports.
|
|
8
|
-
|
|
9
7
|
- [#461](https://github.com/primer/eslint-plugin-primer-react/pull/461) [`75ae0a5`](https://github.com/primer/eslint-plugin-primer-react/commit/75ae0a5cb1d4587b5481c8a459033206aae8e5c3) Thanks [@joshfarrant](https://github.com/joshfarrant)! - Export `enforce-button-for-link-with-no-href` rule, which flags `Link` components which don't have a `href`.
|
|
10
8
|
|
|
11
9
|
## 8.5.0
|
package/package.json
CHANGED
|
@@ -7,7 +7,6 @@ const rule = require('../no-unnecessary-components')
|
|
|
7
7
|
const {components} = require('../no-unnecessary-components')
|
|
8
8
|
|
|
9
9
|
const prcImport = 'import React from "react"; import {Box, Text} from "@primer/react";'
|
|
10
|
-
const styledReactImport = 'import React from "react"; import {Box, Text} from "@primer/styled-react";'
|
|
11
10
|
const brandImport = 'import React from "react"; import {Box, Text} from "@primer/react-brand";'
|
|
12
11
|
|
|
13
12
|
/** @param {string} content */
|
|
@@ -67,26 +66,6 @@ ruleTester.run('unnecessary-components', rule, {
|
|
|
67
66
|
code: `${prcImport}${stringRecordDeclaration}${jsx(`<${component} {...props}>Hello World</${component}>`)}`,
|
|
68
67
|
filename,
|
|
69
68
|
},
|
|
70
|
-
{
|
|
71
|
-
name: `${component} from @primer/styled-react with sx prop`,
|
|
72
|
-
code: `${styledReactImport}${jsx(`<${component} sx={{color: "red"}}>Hello World</${component}>`)}`,
|
|
73
|
-
filename,
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
name: `${component} from @primer/styled-react with any styled-system prop`,
|
|
77
|
-
code: `${styledReactImport}${jsx(`<${component} flex="row">Hello World</${component}>`)}`,
|
|
78
|
-
filename,
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
name: `${component} from @primer/styled-react with spread sx prop`,
|
|
82
|
-
code: `${styledReactImport}${sxObjectDeclaration}${jsx(`<${component} {...props}>Hello World</${component}>`)}`,
|
|
83
|
-
filename,
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
name: `${component} from @primer/styled-react with string index spread props`,
|
|
87
|
-
code: `${styledReactImport}${stringRecordDeclaration}${jsx(`<${component} {...props}>Hello World</${component}>`)}`,
|
|
88
|
-
filename,
|
|
89
|
-
},
|
|
90
69
|
]),
|
|
91
70
|
{
|
|
92
71
|
name: `Text with weight prop`,
|
|
@@ -172,69 +151,5 @@ ruleTester.run('unnecessary-components', rule, {
|
|
|
172
151
|
errors: [{messageId}],
|
|
173
152
|
options: [{skipImportCheck: true}],
|
|
174
153
|
},
|
|
175
|
-
{
|
|
176
|
-
name: `${component} from @primer/styled-react without any styled-system props`,
|
|
177
|
-
code: `${styledReactImport}${jsx(`<${component}>Hello World</${component}>`)}`,
|
|
178
|
-
output: `${styledReactImport}${jsx(`<${replacement}>Hello World</${replacement}>`)}`,
|
|
179
|
-
errors: [{messageId}],
|
|
180
|
-
filename,
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
name: `Self-closing ${component} from @primer/styled-react without any styled-system props`,
|
|
184
|
-
code: `${styledReactImport}${jsx(`<${component} />`)}`,
|
|
185
|
-
output: `${styledReactImport}${jsx(`<${replacement} />`)}`,
|
|
186
|
-
errors: [{messageId}],
|
|
187
|
-
filename,
|
|
188
|
-
},
|
|
189
|
-
{
|
|
190
|
-
name: `${component} from @primer/styled-react with spread props without sx`,
|
|
191
|
-
code: `${styledReactImport}${testIdObjectDeclaration}${jsx(`<${component} {...props}>Hello World</${component}>`)}`,
|
|
192
|
-
output: `${styledReactImport}${testIdObjectDeclaration}${jsx(`<${replacement} {...props}>Hello World</${replacement}>`)}`,
|
|
193
|
-
errors: [{messageId}],
|
|
194
|
-
filename,
|
|
195
|
-
},
|
|
196
|
-
{
|
|
197
|
-
name: `${component} from @primer/styled-react with string element 'as' prop`,
|
|
198
|
-
code: `${styledReactImport}${jsx(`<${component} as="code">Hello world</${component}>`)}`,
|
|
199
|
-
// There is extra whitespace here we don't worry about since formatters would get rid of it
|
|
200
|
-
output: `${styledReactImport}${jsx(`<code >Hello world</code>`)}`,
|
|
201
|
-
errors: [{messageId}],
|
|
202
|
-
filename,
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
name: `${component} from @primer/styled-react with single-character 'as' prop`,
|
|
206
|
-
code: `${styledReactImport}${jsx(`<${component} as="p">Hello world</${component}>`)}`,
|
|
207
|
-
output: `${styledReactImport}${jsx(`<p >Hello world</p>`)}`,
|
|
208
|
-
errors: [{messageId}],
|
|
209
|
-
filename,
|
|
210
|
-
},
|
|
211
|
-
{
|
|
212
|
-
name: `${component} from @primer/styled-react with string element 'as' prop surrounded by unnecessary braces`,
|
|
213
|
-
code: `${styledReactImport}${jsx(`<${component} as={"code"}>Hello world</${component}>`)}`,
|
|
214
|
-
output: `${styledReactImport}${jsx(`<code >Hello world</code>`)}`,
|
|
215
|
-
errors: [{messageId}],
|
|
216
|
-
filename,
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
name: `${component} from @primer/styled-react with component reference 'as' prop`,
|
|
220
|
-
code: `${styledReactImport}${componentDeclaration}${jsx(`<${component} as={OtherComponent}>Hello world</${component}>`)}`,
|
|
221
|
-
output: `${styledReactImport}${componentDeclaration}${jsx(`<OtherComponent >Hello world</OtherComponent>`)}`,
|
|
222
|
-
errors: [{messageId}],
|
|
223
|
-
filename,
|
|
224
|
-
},
|
|
225
|
-
{
|
|
226
|
-
name: `${component} from @primer/styled-react with spread 'as' prop`,
|
|
227
|
-
code: `${styledReactImport}${asObjectDeclaration}${jsx(`<${component} {...props}>Hello world</${component}>`)}`,
|
|
228
|
-
output: null,
|
|
229
|
-
errors: [{messageId}],
|
|
230
|
-
filename,
|
|
231
|
-
},
|
|
232
|
-
{
|
|
233
|
-
name: `${component} from @primer/styled-react with unusable lowercase reference 'as' prop`,
|
|
234
|
-
code: `${styledReactImport}${asConstDeclaration}${jsx(`<${component} as={as}>Hello world</${component}>`)}`,
|
|
235
|
-
output: null,
|
|
236
|
-
errors: [{messageId}],
|
|
237
|
-
filename,
|
|
238
|
-
},
|
|
239
154
|
]),
|
|
240
155
|
})
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const {isImportedFrom} = require('./is-imported-from')
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Check if `name` is a JSX component that is imported from `@primer/react
|
|
5
|
-
* `@primer/
|
|
4
|
+
* Check if `name` is a JSX component that is imported from `@primer/react` or
|
|
5
|
+
* a subpath `@primer/react/*`.
|
|
6
6
|
* @returns {boolean}
|
|
7
7
|
*/
|
|
8
8
|
function isPrimerComponent(name, scope) {
|
|
@@ -18,6 +18,6 @@ function isPrimerComponent(name, scope) {
|
|
|
18
18
|
default:
|
|
19
19
|
return false
|
|
20
20
|
}
|
|
21
|
-
return isImportedFrom(/^@primer\/
|
|
21
|
+
return isImportedFrom(/^@primer\/react(?:$|\/)/, identifier, scope)
|
|
22
22
|
}
|
|
23
23
|
exports.isPrimerComponent = isPrimerComponent
|