Skip to content

Commit

Permalink
[Test] add tests for named aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
manuth committed Sep 1, 2024
1 parent f6e2d0d commit 529734c
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/src/rules/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,15 @@ ruleTester.run('order', rule, {
},
}],
}),
test({
code: `
import { A as A, A as B, A as C } from "./Z";
const { a, a: b, a: c } = require("./Z");
`,
options: [{
named: true,
}],
}),
],
invalid: [
// builtin before external module (require)
Expand Down Expand Up @@ -2847,6 +2856,29 @@ ruleTester.run('order', rule, {
message: '`A` export should occur before export of `B`',
}],
}),
test({
code: `
import { A as B, A as C, A } from "./Z";
export { A, A as D, A as B, A as C } from "./Z";
const { a: b, a: c, a } = require("./Z");
`,
output: `
import { A, A as B, A as C } from "./Z";
export { A, A as B, A as C, A as D } from "./Z";
const { a, a: b, a: c } = require("./Z");
`,
options: [{
named: true,
alphabetize: { order: 'asc' },
}],
errors: [{
message: '`A` import should occur before import of `A as B`',
}, {
message: '`A as D` export should occur after export of `A as C`',
}, {
message: '`a` import should occur before import of `a as b`',
}],
}),
// Alphabetize with require
...semver.satisfies(eslintPkg.version, '< 3.0.0') ? [] : [
test({
Expand Down

0 comments on commit 529734c

Please sign in to comment.