Skip to content

Commit 80a3173

Browse files
Fix import type * as ... in barrel import rules (#32)
1 parent 3cd6bc0 commit 80a3173

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

.changeset/great-beds-lick.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@effect/eslint-plugin": patch
3+
---
4+
5+
Fix import type \* as ... in barrel import rules

src/plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const meta = {
77

88
export const rules = {
99
dprint,
10-
noImportFromBarrelPackage,
10+
"no-import-from-barrel-package": noImportFromBarrelPackage,
1111
}
1212

1313
// NOTE: unfortunately plugins needs a self-reference inside configs,

src/rules/no-import-from-barrel-package.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ export const noImportFromBarrelPackage = createRule<[Options], MessageIds>({
4141
create: (context, options) => {
4242
return {
4343
ImportDeclaration: node => {
44+
// do not check for type imports
45+
if (node.importKind === "type") return
4446
// destruct options
4547
const [{ packageNames }] = options
4648
// first we check if the import is from one of the configured modules

test/no-import-from-barrel-package.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@ import { ruleTester } from "@effect/eslint-plugin/test/utils/index"
44

55
const options: [Options] = [{ packageNames: ["effect"] }]
66

7-
ruleTester.run("dprint", rule, {
7+
ruleTester.run("no-import-from-barrel-package", rule, {
88
valid: [
99
{
1010
code: `import * as T from "effect/Effect"`,
1111
options,
1212
},
1313
{
14-
code: `import { Effect as Eff} from "effect/Effect"
15-
`,
14+
code: `import { Effect as Eff} from "effect/Effect"`,
1615
options,
1716
},
1817
{
@@ -23,6 +22,10 @@ ruleTester.run("dprint", rule, {
2322
code: `import {type Effect } from "effect";`,
2423
options,
2524
},
25+
{
26+
code: `import type { Effect } from "effect"`,
27+
options,
28+
},
2629
{
2730
code: `import {test} from "lodash";`,
2831
options,

0 commit comments

Comments
 (0)