Skip to content

Commit

Permalink
added tests with default and named in the same moment
Browse files Browse the repository at this point in the history
  • Loading branch information
XantreDev committed Jan 11, 2024
1 parent 3f554d3 commit 708a1fa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
3 changes: 3 additions & 0 deletions crates/oxc_linter/fixtures/import/named-and-default-export.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {};

export const foo = 10
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,16 @@ fn test() {
r#"import baz, {a} from "./named-exports""#,
r#"import baz from "./named-exports"; const jjj = bar.jjj"#,
r#"import {a} from "./named-exports"; const baz = a.baz"#,
r#"import baz from "./default_export_default_property"; const d = baz.default;"#,
r#"import baz, {foo} from "./named-and-default-export"; const d = baz.default;"#,
];

let fail = vec![
r#"import baz from "./named-exports"; const a = baz.a;"#,
r#"import baz from "./named-exports"; const a = baz["a"];"#,
r#"import baz from "./named-exports"; baz.a();"#,
r#"import baz, { bar } from "./named-exports"; const {a} = baz"#,
r#"import baz from "./named-and-default-export"; const {foo: _foo} = baz"#,
];

Tester::new_without_config(NoNamedAsDefaultMember::NAME, pass, fail)
Expand Down
15 changes: 11 additions & 4 deletions crates/oxc_linter/src/snapshots/no_named_as_default_member.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,39 @@ source: crates/oxc_linter/src/tester.rs
assertion_line: 154
expression: no_named_as_default_member
---
eslint-plugin-import(no-named-as-default-member): `"baz"` also has a named export `"a"`
eslint-plugin-import(no-named-as-default-member): "baz" also has a named export "a"
╭─[index.js:1:1]
1import baz from "./named-exports"; const a = baz.a;
· ─────
╰────
help: Check if you meant to write `import {a} from "./named-exports"`

eslint-plugin-import(no-named-as-default-member): `"baz"` also has a named export `"a"`
eslint-plugin-import(no-named-as-default-member): "baz" also has a named export "a"
╭─[index.js:1:1]
1import baz from "./named-exports"; const a = baz["a"];
· ────────
╰────
help: Check if you meant to write `import {a} from "./named-exports"`

eslint-plugin-import(no-named-as-default-member): `"baz"` also has a named export `"a"`
eslint-plugin-import(no-named-as-default-member): "baz" also has a named export "a"
╭─[index.js:1:1]
1import baz from "./named-exports"; baz.a();
· ─────
╰────
help: Check if you meant to write `import {a} from "./named-exports"`

eslint-plugin-import(no-named-as-default-member): `"baz"` also has a named export `"a"`
eslint-plugin-import(no-named-as-default-member): "baz" also has a named export "a"
╭─[index.js:1:1]
1import baz, { bar } from "./named-exports"; const {a} = baz
· ─────────
╰────
help: Check if you meant to write `import {a} from "./named-exports"`

eslint-plugin-import(no-named-as-default-member): "baz" also has a named export "foo"
╭─[index.js:1:1]
1import baz from "./named-and-default-export"; const {foo: _foo} = baz
· ─────────────────
╰────
help: Check if you meant to write `import {foo} from "./named-and-default-export"`


0 comments on commit 708a1fa

Please sign in to comment.