Skip to content

Commit

Permalink
refactor: moves options to types file
Browse files Browse the repository at this point in the history
  • Loading branch information
hugop95 committed Jan 3, 2025
1 parent 0df348f commit cfa2176
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 39 deletions.
40 changes: 1 addition & 39 deletions rules/sort-objects.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { TSESTree } from '@typescript-eslint/types'

import type { SortingNodeWithDependencies } from '../utils/sort-nodes-by-dependencies'
import type { Options } from './sort-objects/types'

import {
buildUseConfigurationIfJsonSchema,
Expand Down Expand Up @@ -47,52 +48,13 @@ import { complete } from '../utils/complete'
import { pairwise } from '../utils/pairwise'
import { matches } from '../utils/matches'

type Options = Partial<{
partitionByComment:
| {
block?: string[] | boolean | string
line?: string[] | boolean | string
}
| string[]
| boolean
| string
useConfigurationIf: {
callingFunctionNamePattern?: string
allNamesMatchPattern?: string
}
groups: (
| { newlinesBetween: 'ignore' | 'always' | 'never' }
| Group[]
| Group
)[]
type: 'alphabetical' | 'line-length' | 'unsorted' | 'natural' | 'custom'
destructuredObjects: { groups: boolean } | boolean
customGroups: Record<string, string[] | string>
newlinesBetween: 'ignore' | 'always' | 'never'
specialCharacters: 'remove' | 'trim' | 'keep'
locales: NonNullable<Intl.LocalesArgument>
partitionByNewLine: boolean
objectDeclarations: boolean
styledComponents: boolean
/**
* @deprecated for {@link `destructuredObjects`} and {@link `objectDeclarations`}
*/
destructureOnly: boolean
ignorePattern: string[]
order: 'desc' | 'asc'
ignoreCase: boolean
alphabet: string
}>[]

type MESSAGE_ID =
| 'missedSpacingBetweenObjectMembers'
| 'unexpectedObjectsDependencyOrder'
| 'extraSpacingBetweenObjectMembers'
| 'unexpectedObjectsGroupOrder'
| 'unexpectedObjectsOrder'

type Group = 'multiline' | 'unknown' | 'method' | string

let defaultOptions: Required<Options[0]> = {
partitionByNewLine: false,
partitionByComment: false,
Expand Down
38 changes: 38 additions & 0 deletions rules/sort-objects/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
export type Options = Partial<{
partitionByComment:
| {
block?: string[] | boolean | string
line?: string[] | boolean | string
}
| string[]
| boolean
| string
useConfigurationIf: {
callingFunctionNamePattern?: string
allNamesMatchPattern?: string
}
groups: (
| { newlinesBetween: 'ignore' | 'always' | 'never' }
| Group[]
| Group
)[]
type: 'alphabetical' | 'line-length' | 'unsorted' | 'natural' | 'custom'
destructuredObjects: { groups: boolean } | boolean
customGroups: Record<string, string[] | string>
newlinesBetween: 'ignore' | 'always' | 'never'
specialCharacters: 'remove' | 'trim' | 'keep'
locales: NonNullable<Intl.LocalesArgument>
partitionByNewLine: boolean
objectDeclarations: boolean
styledComponents: boolean
/**
* @deprecated for {@link `destructuredObjects`} and {@link `objectDeclarations`}
*/
destructureOnly: boolean
ignorePattern: string[]
order: 'desc' | 'asc'
ignoreCase: boolean
alphabet: string
}>[]

type Group = 'multiline' | 'unknown' | 'method' | string

0 comments on commit cfa2176

Please sign in to comment.