diff --git a/rules/sort-objects.ts b/rules/sort-objects.ts index 7544603d4..910adf55b 100644 --- a/rules/sort-objects.ts +++ b/rules/sort-objects.ts @@ -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, @@ -47,43 +48,6 @@ 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 - newlinesBetween: 'ignore' | 'always' | 'never' - specialCharacters: 'remove' | 'trim' | 'keep' - locales: NonNullable - 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' @@ -91,8 +55,6 @@ type MESSAGE_ID = | 'unexpectedObjectsGroupOrder' | 'unexpectedObjectsOrder' -type Group = 'multiline' | 'unknown' | 'method' | string - let defaultOptions: Required = { partitionByNewLine: false, partitionByComment: false, diff --git a/rules/sort-objects/types.ts b/rules/sort-objects/types.ts new file mode 100644 index 000000000..b5172d2af --- /dev/null +++ b/rules/sort-objects/types.ts @@ -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 + newlinesBetween: 'ignore' | 'always' | 'never' + specialCharacters: 'remove' | 'trim' | 'keep' + locales: NonNullable + 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