Skip to content

Commit b4698df

Browse files
authored
feat: add no-wildcard-imports rule (#225)
* feat: add no-wildcard-imports rule * chore: add changeset * chore: fix eslint * refactor: update wildcard imports errors, update tests * chore(eslint): remove unused console * chore: add eslintignore for local npm lint perf
1 parent 99ff734 commit b4698df

File tree

6 files changed

+764
-0
lines changed

6 files changed

+764
-0
lines changed

.changeset/breezy-insects-scream.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'eslint-plugin-primer-react': minor
3+
---
4+
5+
Add eslint rule for discouraging use of wildcard imports from @primer/react

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
**/dist/**
2+
**/node_modules/**

docs/rules/no-wildcard-imports.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# No Wildcard Imports
2+
3+
## Rule Details
4+
5+
This rule enforces that no wildcard imports are used from `@primer/react`.
6+
7+
👎 Examples of **incorrect** code for this rule
8+
9+
```jsx
10+
import {Dialog} from '@primer/react/lib-esm/Dialog/Dialog'
11+
12+
function ExampleComponent() {
13+
return <Dialog>{/* ... */}</Dialog>
14+
}
15+
```
16+
17+
👍 Examples of **correct** code for this rule:
18+
19+
```jsx
20+
import {Dialog} from '@primer/react/experimental'
21+
22+
function ExampleComponent() {
23+
return <Dialog>{/* ... */}</Dialog>
24+
}
25+
```

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module.exports = {
1111
'a11y-remove-disable-tooltip': require('./rules/a11y-remove-disable-tooltip'),
1212
'a11y-use-next-tooltip': require('./rules/a11y-use-next-tooltip'),
1313
'use-deprecated-from-deprecated': require('./rules/use-deprecated-from-deprecated'),
14+
'no-wildcard-imports': require('./rules/no-wildcard-imports'),
1415
'no-unnecessary-components': require('./rules/no-unnecessary-components'),
1516
'prefer-action-list-item-onselect': require('./rules/prefer-action-list-item-onselect'),
1617
},

0 commit comments

Comments
 (0)