Skip to content

Commit

Permalink
feat(sort-named-imports): allow unsorted type
Browse files Browse the repository at this point in the history
  • Loading branch information
hugop95 committed Feb 13, 2025
1 parent 938e22a commit fc9679b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/content/rules/sort-named-imports.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ Specifies the sorting method.
- `'natural'` — Sort items in a [natural](https://github.com/yobacca/natural-orderby) order (e.g., “item2” < “item10”).
- `'line-length'` — Sort items by the length of the code line (shorter lines first).
- `'custom'` — Sort items using the alphabet entered in the [`alphabet`](#alphabet) option.
- `'unsorted'` — Do not sort items.

### order

Expand Down
2 changes: 0 additions & 2 deletions rules/sort-named-imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import type { SortingNode } from '../types/sorting-node'
import {
partitionByCommentJsonSchema,
partitionByNewLineJsonSchema,
buildTypeJsonSchema,
commonJsonSchemas,
} from '../utils/common-json-schemas'
import { validateCustomSortConfiguration } from '../utils/validate-custom-sort-configuration'
Expand Down Expand Up @@ -176,7 +175,6 @@ export default createEslintRule<Options, MESSAGE_ID>({
},
partitionByComment: partitionByCommentJsonSchema,
partitionByNewLine: partitionByNewLineJsonSchema,
type: buildTypeJsonSchema(),
},
additionalProperties: false,
type: 'object',
Expand Down
25 changes: 25 additions & 0 deletions test/rules/sort-named-imports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1799,6 +1799,31 @@ describe(ruleName, () => {
)
})

describe(`${ruleName}: unsorted type`, () => {
let type = 'unsorted'

let options = {
type: 'unsorted',
order: 'asc',
} as const

ruleTester.run(`${ruleName}(${type}): does not enforce sorting`, rule, {
valid: [
{
code: dedent`
import {
b,
c,
a,
} from 'module'
`,
options: [options],
},
],
invalid: [],
})
})

describe(`${ruleName}: misc`, () => {
ruleTester.run(
`${ruleName}: sets alphabetical asc sorting as default`,
Expand Down

0 comments on commit fc9679b

Please sign in to comment.