Skip to content

Commit

Permalink
refactor(sort-maps): extracts types
Browse files Browse the repository at this point in the history
  • Loading branch information
hugop95 committed Jan 14, 2025
1 parent a6e1daf commit a2b8d79
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
21 changes: 1 addition & 20 deletions rules/sort-maps.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { TSESTree } from '@typescript-eslint/types'

import type { SortingNode } from '../types/sorting-node'
import type { Options } from './sort-maps/types'

import {
partitionByCommentJsonSchema,
Expand Down Expand Up @@ -30,26 +31,6 @@ import { sortNodes } from '../utils/sort-nodes'
import { complete } from '../utils/complete'
import { pairwise } from '../utils/pairwise'

type Options = [
Partial<{
partitionByComment:
| {
block?: string[] | boolean | string
line?: string[] | boolean | string
}
| string[]
| boolean
| string
type: 'alphabetical' | 'line-length' | 'natural' | 'custom'
specialCharacters: 'remove' | 'trim' | 'keep'
locales: NonNullable<Intl.LocalesArgument>
partitionByNewLine: boolean
order: 'desc' | 'asc'
ignoreCase: boolean
alphabet: string
}>,
]

type MESSAGE_ID = 'unexpectedMapElementsOrder'

let defaultOptions: Required<Options[0]> = {
Expand Down
17 changes: 17 additions & 0 deletions rules/sort-maps/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export type Options = Partial<{
partitionByComment:
| {
block?: string[] | boolean | string
line?: string[] | boolean | string
}
| string[]
| boolean
| string
type: 'alphabetical' | 'line-length' | 'natural' | 'custom'
specialCharacters: 'remove' | 'trim' | 'keep'
locales: NonNullable<Intl.LocalesArgument>
partitionByNewLine: boolean
order: 'desc' | 'asc'
ignoreCase: boolean
alphabet: string
}>[]

0 comments on commit a2b8d79

Please sign in to comment.