diff --git a/rules/sort-array-includes.ts b/rules/sort-array-includes.ts index eb9ec70ac..ae2ee042b 100644 --- a/rules/sort-array-includes.ts +++ b/rules/sort-array-includes.ts @@ -3,8 +3,8 @@ import type { RuleContext } from '@typescript-eslint/utils/ts-eslint' import type { TSESTree } from '@typescript-eslint/types' import type { TSESLint } from '@typescript-eslint/utils' -import type { Selector, Options } from './sort-array-includes.types' -import type { SortingNode } from '../typings' +import type { Selector, Options } from './sort-array-includes/types' +import type { SortingNode } from '../types/sorting-node' import { buildUseConfigurationIfJsonSchema, @@ -20,20 +20,22 @@ import { orderJsonSchema, } from '../utils/common-json-schemas' import { validateGeneratedGroupsConfiguration } from '../utils/validate-generated-groups-configuration' +import { + singleCustomGroupJsonSchema, + allSelectors, +} from './sort-array-includes/types' import { getCustomGroupsCompareOptions } from '../utils/get-custom-groups-compare-options' +import { doesCustomGroupMatch } from './sort-array-includes/does-custom-group-match' import { getMatchingContextOptions } from '../utils/get-matching-context-options' import { generatePredefinedGroups } from '../utils/generate-predefined-groups' import { getEslintDisabledLines } from '../utils/get-eslint-disabled-lines' -import { singleCustomGroupJsonSchema } from './sort-array-includes.types' import { isNodeEslintDisabled } from '../utils/is-node-eslint-disabled' import { hasPartitionComment } from '../utils/is-partition-comment' import { createNodeIndexMap } from '../utils/create-node-index-map' import { sortNodesByGroups } from '../utils/sort-nodes-by-groups' import { getCommentsBefore } from '../utils/get-comments-before' -import { customGroupMatches } from './sort-array-includes-utils' import { createEslintRule } from '../utils/create-eslint-rule' import { getLinesBetween } from '../utils/get-lines-between' -import { allSelectors } from './sort-array-includes.types' import { getGroupNumber } from '../utils/get-group-number' import { getSourceCode } from '../utils/get-source-code' import { toSingleLine } from '../utils/to-single-line' @@ -235,7 +237,7 @@ export let sortArray = ({ let name = getNodeName({ sourceCode, element }) for (let customGroup of options.customGroups) { if ( - customGroupMatches({ + doesCustomGroupMatch({ selectors: [selector], elementName: name, customGroup, diff --git a/rules/sort-array-includes-utils.ts b/rules/sort-array-includes/does-custom-group-match.ts similarity index 69% rename from rules/sort-array-includes-utils.ts rename to rules/sort-array-includes/does-custom-group-match.ts index 349e517de..801df37bc 100644 --- a/rules/sort-array-includes-utils.ts +++ b/rules/sort-array-includes/does-custom-group-match.ts @@ -1,12 +1,8 @@ -import type { - SingleCustomGroup, - AnyOfCustomGroup, - Selector, -} from './sort-array-includes.types' +import type { SingleCustomGroup, AnyOfCustomGroup, Selector } from './types' -import { matches } from '../utils/matches' +import { matches } from '../../utils/matches' -interface CustomGroupMatchesProps { +interface DoesCustomGroupMatchProps { customGroup: SingleCustomGroup | AnyOfCustomGroup selectors: Selector[] elementName: string @@ -14,16 +10,18 @@ interface CustomGroupMatchesProps { /** * Determines whether a custom group matches the given properties. - * @param {CustomGroupMatchesProps} props - The properties to compare with the + * @param {DoesCustomGroupMatchProps} props - The properties to compare with the * custom group, including selectors, modifiers, and element name. * @returns {boolean} `true` if the custom group matches the properties; * otherwise, `false`. */ -export let customGroupMatches = (props: CustomGroupMatchesProps): boolean => { +export let doesCustomGroupMatch = ( + props: DoesCustomGroupMatchProps, +): boolean => { if ('anyOf' in props.customGroup) { // At least one subgroup must match return props.customGroup.anyOf.some(subgroup => - customGroupMatches({ ...props, customGroup: subgroup }), + doesCustomGroupMatch({ ...props, customGroup: subgroup }), ) } if ( diff --git a/rules/sort-array-includes.types.ts b/rules/sort-array-includes/types.ts similarity index 97% rename from rules/sort-array-includes.types.ts rename to rules/sort-array-includes/types.ts index 4ffd62cd5..05f60ac94 100644 --- a/rules/sort-array-includes.types.ts +++ b/rules/sort-array-includes/types.ts @@ -3,7 +3,7 @@ import type { JSONSchema4 } from '@typescript-eslint/utils/json-schema' import { buildCustomGroupSelectorJsonSchema, elementNamePatternJsonSchema, -} from '../utils/common-json-schemas' +} from '../../utils/common-json-schemas' export type Options = Partial<{ type: 'alphabetical' | 'line-length' | 'unsorted' | 'natural' | 'custom' diff --git a/rules/sort-classes-utils.ts b/rules/sort-classes-utils.ts deleted file mode 100644 index 58010cb05..000000000 --- a/rules/sort-classes-utils.ts +++ /dev/null @@ -1,135 +0,0 @@ -import type { TSESTree } from '@typescript-eslint/utils' - -import type { - SingleCustomGroup, - AnyOfCustomGroup, - Modifier, - Selector, -} from './sort-classes.types' - -import { isSortable } from '../utils/is-sortable' -import { matches } from '../utils/matches' - -interface CustomGroupMatchesProps { - customGroup: SingleCustomGroup | AnyOfCustomGroup - elementValue: undefined | string - selectors: Selector[] - modifiers: Modifier[] - decorators: string[] - elementName: string -} - -/** - * Returns a list of groups of overload signatures. - * @param {TSESTree.ClassElement[]} members - The class elements to process. - * @returns {TSESTree.ClassElement[][]} An array of groups of overload - * signatures. - */ -export let getOverloadSignatureGroups = ( - members: TSESTree.ClassElement[], -): TSESTree.ClassElement[][] => { - let methods = members - .filter( - member => - member.type === 'MethodDefinition' || - member.type === 'TSAbstractMethodDefinition', - ) - .filter(member => member.kind === 'method') - // Static and non-static overload signatures can coexist with the same name - let staticOverloadSignaturesByName = new Map< - string, - TSESTree.ClassElement[] - >() - let overloadSignaturesByName = new Map() - for (let method of methods) { - if (method.key.type !== 'Identifier') { - continue - } - let { name } = method.key - let mapToUse = method.static - ? staticOverloadSignaturesByName - : overloadSignaturesByName - let signatureOverloadsGroup = mapToUse.get(name) - if (!signatureOverloadsGroup) { - signatureOverloadsGroup = [] - mapToUse.set(name, signatureOverloadsGroup) - } - signatureOverloadsGroup.push(method) - } - // Ignore groups that only have one method - return [ - ...overloadSignaturesByName.values(), - ...staticOverloadSignaturesByName.values(), - ].filter(isSortable) -} - -/** - * Determines whether a custom group matches the given properties. - * @param {CustomGroupMatchesProps} props - The properties to match against the - * custom group, including selectors, modifiers, decorators, and element names. - * @returns {boolean} `true` if the custom group matches the properties; - * otherwise, `false`. - */ -export let customGroupMatches = (props: CustomGroupMatchesProps): boolean => { - if ('anyOf' in props.customGroup) { - // At least one subgroup must match - return props.customGroup.anyOf.some(subgroup => - customGroupMatches({ ...props, customGroup: subgroup }), - ) - } - if ( - props.customGroup.selector && - !props.selectors.includes(props.customGroup.selector) - ) { - return false - } - - if (props.customGroup.modifiers) { - for (let modifier of props.customGroup.modifiers) { - if (!props.modifiers.includes(modifier)) { - return false - } - } - } - - if ( - 'elementNamePattern' in props.customGroup && - props.customGroup.elementNamePattern - ) { - let matchesElementNamePattern: boolean = matches( - props.elementName, - props.customGroup.elementNamePattern, - ) - if (!matchesElementNamePattern) { - return false - } - } - - if ( - 'elementValuePattern' in props.customGroup && - props.customGroup.elementValuePattern - ) { - let matchesElementValuePattern: boolean = matches( - props.elementValue ?? '', - props.customGroup.elementValuePattern, - ) - if (!matchesElementValuePattern) { - return false - } - } - - if ( - 'decoratorNamePattern' in props.customGroup && - props.customGroup.decoratorNamePattern - ) { - let decoratorPattern = props.customGroup.decoratorNamePattern - let matchesDecoratorNamePattern: boolean = props.decorators.some( - decorator => matches(decorator, decoratorPattern), - ) - if (!matchesDecoratorNamePattern) { - return false - } - } - - return true -} diff --git a/rules/sort-classes.ts b/rules/sort-classes.ts index 663b279f6..fd51eea4f 100644 --- a/rules/sort-classes.ts +++ b/rules/sort-classes.ts @@ -5,7 +5,7 @@ import type { SortClassesOptions, Modifier, Selector, -} from './sort-classes.types' +} from './sort-classes/types' import type { SortingNodeWithDependencies } from '../utils/sort-nodes-by-dependencies' import { @@ -31,14 +31,12 @@ import { singleCustomGroupJsonSchema, allModifiers, allSelectors, -} from './sort-classes.types' +} from './sort-classes/types' import { validateCustomSortConfiguration } from '../utils/validate-custom-sort-configuration' -import { - getOverloadSignatureGroups, - customGroupMatches, -} from './sort-classes-utils' import { getCustomGroupsCompareOptions } from '../utils/get-custom-groups-compare-options' +import { getOverloadSignatureGroups } from './sort-classes/get-overload-signature-groups' import { generatePredefinedGroups } from '../utils/generate-predefined-groups' +import { doesCustomGroupMatch } from './sort-classes/does-custom-group-match' import { getEslintDisabledLines } from '../utils/get-eslint-disabled-lines' import { isNodeEslintDisabled } from '../utils/is-node-eslint-disabled' import { hasPartitionComment } from '../utils/is-partition-comment' @@ -506,7 +504,7 @@ export default createEslintRule({ for (let customGroup of options.customGroups) { if ( - customGroupMatches({ + doesCustomGroupMatch({ elementValue: memberValue, elementName: name, customGroup, diff --git a/rules/sort-classes/does-custom-group-match.ts b/rules/sort-classes/does-custom-group-match.ts new file mode 100644 index 000000000..11a576a77 --- /dev/null +++ b/rules/sort-classes/does-custom-group-match.ts @@ -0,0 +1,91 @@ +import type { + SingleCustomGroup, + AnyOfCustomGroup, + Modifier, + Selector, +} from './types' + +import { matches } from '../../utils/matches' + +interface DoesCustomGroupMatchProps { + customGroup: SingleCustomGroup | AnyOfCustomGroup + elementValue: undefined | string + selectors: Selector[] + modifiers: Modifier[] + decorators: string[] + elementName: string +} + +/** + * Determines whether a custom group matches the given properties. + * @param {DoesCustomGroupMatchProps} props - The properties to match against + * the custom group, including selectors, modifiers, decorators, and element + * names. + * @returns {boolean} `true` if the custom group matches the properties; + * otherwise, `false`. + */ +export let doesCustomGroupMatch = ( + props: DoesCustomGroupMatchProps, +): boolean => { + if ('anyOf' in props.customGroup) { + // At least one subgroup must match + return props.customGroup.anyOf.some(subgroup => + doesCustomGroupMatch({ ...props, customGroup: subgroup }), + ) + } + if ( + props.customGroup.selector && + !props.selectors.includes(props.customGroup.selector) + ) { + return false + } + + if (props.customGroup.modifiers) { + for (let modifier of props.customGroup.modifiers) { + if (!props.modifiers.includes(modifier)) { + return false + } + } + } + + if ( + 'elementNamePattern' in props.customGroup && + props.customGroup.elementNamePattern + ) { + let matchesElementNamePattern: boolean = matches( + props.elementName, + props.customGroup.elementNamePattern, + ) + if (!matchesElementNamePattern) { + return false + } + } + + if ( + 'elementValuePattern' in props.customGroup && + props.customGroup.elementValuePattern + ) { + let matchesElementValuePattern: boolean = matches( + props.elementValue ?? '', + props.customGroup.elementValuePattern, + ) + if (!matchesElementValuePattern) { + return false + } + } + + if ( + 'decoratorNamePattern' in props.customGroup && + props.customGroup.decoratorNamePattern + ) { + let decoratorPattern = props.customGroup.decoratorNamePattern + let matchesDecoratorNamePattern: boolean = props.decorators.some( + decorator => matches(decorator, decoratorPattern), + ) + if (!matchesDecoratorNamePattern) { + return false + } + } + + return true +} diff --git a/rules/sort-classes/get-overload-signature-groups.ts b/rules/sort-classes/get-overload-signature-groups.ts new file mode 100644 index 000000000..0a559bc24 --- /dev/null +++ b/rules/sort-classes/get-overload-signature-groups.ts @@ -0,0 +1,47 @@ +import type { TSESTree } from '@typescript-eslint/utils' + +import { isSortable } from '../../utils/is-sortable' + +/** + * Returns a list of groups of overload signatures. + * @param {TSESTree.ClassElement[]} members - The class elements to process. + * @returns {TSESTree.ClassElement[][]} An array of groups of overload + * signatures. + */ +export let getOverloadSignatureGroups = ( + members: TSESTree.ClassElement[], +): TSESTree.ClassElement[][] => { + let methods = members + .filter( + member => + member.type === 'MethodDefinition' || + member.type === 'TSAbstractMethodDefinition', + ) + .filter(member => member.kind === 'method') + // Static and non-static overload signatures can coexist with the same name + let staticOverloadSignaturesByName = new Map< + string, + TSESTree.ClassElement[] + >() + let overloadSignaturesByName = new Map() + for (let method of methods) { + if (method.key.type !== 'Identifier') { + continue + } + let { name } = method.key + let mapToUse = method.static + ? staticOverloadSignaturesByName + : overloadSignaturesByName + let signatureOverloadsGroup = mapToUse.get(name) + if (!signatureOverloadsGroup) { + signatureOverloadsGroup = [] + mapToUse.set(name, signatureOverloadsGroup) + } + signatureOverloadsGroup.push(method) + } + // Ignore groups that only have one method + return [ + ...overloadSignaturesByName.values(), + ...staticOverloadSignaturesByName.values(), + ].filter(isSortable) +} diff --git a/rules/sort-classes.types.ts b/rules/sort-classes/types.ts similarity index 98% rename from rules/sort-classes.types.ts rename to rules/sort-classes/types.ts index 78839c14a..624e07cdc 100644 --- a/rules/sort-classes.types.ts +++ b/rules/sort-classes/types.ts @@ -1,12 +1,12 @@ import type { JSONSchema4 } from '@typescript-eslint/utils/json-schema' -import type { JoinWithDash } from '../typings' +import type { JoinWithDash } from '../../types/join-with-dash' import { buildCustomGroupModifiersJsonSchema, buildCustomGroupSelectorJsonSchema, elementNamePatternJsonSchema, -} from '../utils/common-json-schemas' +} from '../../utils/common-json-schemas' export type SortClassesOptions = [ Partial<{ diff --git a/rules/sort-decorators.ts b/rules/sort-decorators.ts index b55e9e418..a78919c0b 100644 --- a/rules/sort-decorators.ts +++ b/rules/sort-decorators.ts @@ -1,7 +1,7 @@ import type { RuleContext } from '@typescript-eslint/utils/ts-eslint' import type { TSESTree } from '@typescript-eslint/types' -import type { SortingNode } from '../typings' +import type { SortingNode } from '../types/sorting-node' import { partitionByCommentJsonSchema, @@ -18,13 +18,13 @@ import { validateCustomSortConfiguration } from '../utils/validate-custom-sort-c import { validateGroupsConfiguration } from '../utils/validate-groups-configuration' import { getEslintDisabledLines } from '../utils/get-eslint-disabled-lines' import { isNodeEslintDisabled } from '../utils/is-node-eslint-disabled' +import { getDecoratorName } from './sort-decorators/get-decorator-name' import { hasPartitionComment } from '../utils/is-partition-comment' import { createNodeIndexMap } from '../utils/create-node-index-map' import { sortNodesByGroups } from '../utils/sort-nodes-by-groups' import { getCommentsBefore } from '../utils/get-comments-before' import { getNodeDecorators } from '../utils/get-node-decorators' import { createEslintRule } from '../utils/create-eslint-rule' -import { getDecoratorName } from '../utils/get-decorator-name' import { getGroupNumber } from '../utils/get-group-number' import { getSourceCode } from '../utils/get-source-code' import { toSingleLine } from '../utils/to-single-line' diff --git a/utils/get-decorator-name.ts b/rules/sort-decorators/get-decorator-name.ts similarity index 100% rename from utils/get-decorator-name.ts rename to rules/sort-decorators/get-decorator-name.ts diff --git a/rules/sort-exports.ts b/rules/sort-exports.ts index ca5325aff..d4128614d 100644 --- a/rules/sort-exports.ts +++ b/rules/sort-exports.ts @@ -1,6 +1,6 @@ import type { TSESTree } from '@typescript-eslint/types' -import type { SortingNode } from '../typings' +import type { SortingNode } from '../types/sorting-node' import { partitionByCommentJsonSchema, diff --git a/rules/sort-heritage-clauses.ts b/rules/sort-heritage-clauses.ts index 2cf18a71d..0ab620028 100644 --- a/rules/sort-heritage-clauses.ts +++ b/rules/sort-heritage-clauses.ts @@ -1,7 +1,7 @@ import type { RuleContext } from '@typescript-eslint/utils/ts-eslint' import type { TSESTree } from '@typescript-eslint/types' -import type { SortingNode } from '../typings' +import type { SortingNode } from '../types/sorting-node' import { specialCharactersJsonSchema, diff --git a/rules/sort-imports.ts b/rules/sort-imports.ts index 4513c8827..513cf09a6 100644 --- a/rules/sort-imports.ts +++ b/rules/sort-imports.ts @@ -2,7 +2,7 @@ import type { TSESTree } from '@typescript-eslint/types' import { builtinModules } from 'node:module' -import type { SortingNode } from '../typings' +import type { SortingNode } from '../types/sorting-node' import { partitionByCommentJsonSchema, @@ -18,12 +18,12 @@ import { } from '../utils/common-json-schemas' import { validateNewlinesAndPartitionConfiguration } from '../utils/validate-newlines-and-partition-configuration' import { validateCustomSortConfiguration } from '../utils/validate-custom-sort-configuration' +import { readClosestTsConfigByPath } from './sort-imports/read-closest-ts-config-by-path' import { validateGroupsConfiguration } from '../utils/validate-groups-configuration' -import { readClosestTsConfigByPath } from '../utils/read-closest-ts-config-by-path' import { getOptionsWithCleanGroups } from '../utils/get-options-with-clean-groups' import { getEslintDisabledLines } from '../utils/get-eslint-disabled-lines' +import { getTypescriptImport } from './sort-imports/get-typescript-import' import { isNodeEslintDisabled } from '../utils/is-node-eslint-disabled' -import { getTypescriptImport } from '../utils/get-typescript-import' import { createNodeIndexMap } from '../utils/create-node-index-map' import { hasPartitionComment } from '../utils/is-partition-comment' import { sortNodesByGroups } from '../utils/sort-nodes-by-groups' diff --git a/utils/get-typescript-import.ts b/rules/sort-imports/get-typescript-import.ts similarity index 100% rename from utils/get-typescript-import.ts rename to rules/sort-imports/get-typescript-import.ts diff --git a/utils/read-closest-ts-config-by-path.ts b/rules/sort-imports/read-closest-ts-config-by-path.ts similarity index 100% rename from utils/read-closest-ts-config-by-path.ts rename to rules/sort-imports/read-closest-ts-config-by-path.ts diff --git a/rules/sort-interfaces.ts b/rules/sort-interfaces.ts index 9a33ea44f..1aba4c438 100644 --- a/rules/sort-interfaces.ts +++ b/rules/sort-interfaces.ts @@ -1,4 +1,4 @@ -import type { Options as SortObjectTypesOptions } from './sort-object-types.types' +import type { Options as SortObjectTypesOptions } from './sort-object-types/types' import { sortObjectTypeElements, jsonSchema } from './sort-object-types' import { createEslintRule } from '../utils/create-eslint-rule' diff --git a/rules/sort-intersection-types.ts b/rules/sort-intersection-types.ts index 068618db7..547d637a3 100644 --- a/rules/sort-intersection-types.ts +++ b/rules/sort-intersection-types.ts @@ -1,4 +1,4 @@ -import type { SortingNode } from '../typings' +import type { SortingNode } from '../types/sorting-node' import { partitionByCommentJsonSchema, diff --git a/rules/sort-jsx-props.ts b/rules/sort-jsx-props.ts index e71351b75..63dae549d 100644 --- a/rules/sort-jsx-props.ts +++ b/rules/sort-jsx-props.ts @@ -1,6 +1,6 @@ import type { TSESTree } from '@typescript-eslint/types' -import type { SortingNode } from '../typings' +import type { SortingNode } from '../types/sorting-node' import { specialCharactersJsonSchema, diff --git a/rules/sort-maps.ts b/rules/sort-maps.ts index bff24e9e2..bb6996e34 100644 --- a/rules/sort-maps.ts +++ b/rules/sort-maps.ts @@ -1,6 +1,6 @@ import type { TSESTree } from '@typescript-eslint/types' -import type { SortingNode } from '../typings' +import type { SortingNode } from '../types/sorting-node' import { partitionByCommentJsonSchema, diff --git a/rules/sort-modules.ts b/rules/sort-modules.ts index 867c0a3fc..c5aa1a72f 100644 --- a/rules/sort-modules.ts +++ b/rules/sort-modules.ts @@ -7,7 +7,7 @@ import type { SortModulesOptions, Modifier, Selector, -} from './sort-modules.types' +} from './sort-modules/types' import type { SortingNodeWithDependencies } from '../utils/sort-nodes-by-dependencies' import { @@ -33,10 +33,11 @@ import { singleCustomGroupJsonSchema, allModifiers, allSelectors, -} from './sort-modules.types' +} from './sort-modules/types' import { validateCustomSortConfiguration } from '../utils/validate-custom-sort-configuration' import { getCustomGroupsCompareOptions } from '../utils/get-custom-groups-compare-options' import { generatePredefinedGroups } from '../utils/generate-predefined-groups' +import { doesCustomGroupMatch } from './sort-modules/does-custom-group-match' import { getEslintDisabledLines } from '../utils/get-eslint-disabled-lines' import { isNodeEslintDisabled } from '../utils/is-node-eslint-disabled' import { createNodeIndexMap } from '../utils/create-node-index-map' @@ -50,7 +51,6 @@ import { createEslintRule } from '../utils/create-eslint-rule' import { getLinesBetween } from '../utils/get-lines-between' import { getGroupNumber } from '../utils/get-group-number' import { getEnumMembers } from '../utils/get-enum-members' -import { customGroupMatches } from './sort-modules-utils' import { getSourceCode } from '../utils/get-source-code' import { toSingleLine } from '../utils/to-single-line' import { rangeToDiff } from '../utils/range-to-diff' @@ -324,7 +324,7 @@ let analyzeModule = ({ } for (let customGroup of options.customGroups) { if ( - customGroupMatches({ + doesCustomGroupMatch({ selectors: [selector], elementName: name, customGroup, diff --git a/rules/sort-modules-utils.ts b/rules/sort-modules/does-custom-group-match.ts similarity index 82% rename from rules/sort-modules-utils.ts rename to rules/sort-modules/does-custom-group-match.ts index ed45f4a00..05506f148 100644 --- a/rules/sort-modules-utils.ts +++ b/rules/sort-modules/does-custom-group-match.ts @@ -3,11 +3,11 @@ import type { AnyOfCustomGroup, Modifier, Selector, -} from './sort-modules.types' +} from './types' -import { matches } from '../utils/matches' +import { matches } from '../../utils/matches' -interface CustomGroupMatchesProps { +interface DoesCustomGroupMatchProps { customGroup: SingleCustomGroup | AnyOfCustomGroup selectors: Selector[] modifiers: Modifier[] @@ -17,16 +17,18 @@ interface CustomGroupMatchesProps { /** * Determines whether a custom group matches the given properties. - * @param {CustomGroupMatchesProps} props - The properties to compare with the + * @param {DoesCustomGroupMatchProps} props - The properties to compare with the * custom group, including selectors, modifiers, decorators, and element name. * @returns {boolean} `true` if the custom group matches the properties; * otherwise, `false`. */ -export let customGroupMatches = (props: CustomGroupMatchesProps): boolean => { +export let doesCustomGroupMatch = ( + props: DoesCustomGroupMatchProps, +): boolean => { if ('anyOf' in props.customGroup) { // At least one subgroup must match return props.customGroup.anyOf.some(subgroup => - customGroupMatches({ ...props, customGroup: subgroup }), + doesCustomGroupMatch({ ...props, customGroup: subgroup }), ) } if ( diff --git a/rules/sort-modules.types.ts b/rules/sort-modules/types.ts similarity index 97% rename from rules/sort-modules.types.ts rename to rules/sort-modules/types.ts index fa1af6bb5..d4872fc38 100644 --- a/rules/sort-modules.types.ts +++ b/rules/sort-modules/types.ts @@ -1,12 +1,12 @@ import type { JSONSchema4 } from '@typescript-eslint/utils/json-schema' -import type { JoinWithDash } from '../typings' +import type { JoinWithDash } from '../../types/join-with-dash' import { buildCustomGroupModifiersJsonSchema, buildCustomGroupSelectorJsonSchema, elementNamePatternJsonSchema, -} from '../utils/common-json-schemas' +} from '../../utils/common-json-schemas' export type SortModulesOptions = [ Partial<{ diff --git a/rules/sort-named-exports.ts b/rules/sort-named-exports.ts index f8a20b3cc..0f459c719 100644 --- a/rules/sort-named-exports.ts +++ b/rules/sort-named-exports.ts @@ -1,6 +1,6 @@ import type { TSESTree } from '@typescript-eslint/types' -import type { SortingNode } from '../typings' +import type { SortingNode } from '../types/sorting-node' import { partitionByCommentJsonSchema, diff --git a/rules/sort-named-imports.ts b/rules/sort-named-imports.ts index 2aaa68bc6..fa765c62b 100644 --- a/rules/sort-named-imports.ts +++ b/rules/sort-named-imports.ts @@ -1,6 +1,6 @@ import type { TSESTree } from '@typescript-eslint/types' -import type { SortingNode } from '../typings' +import type { SortingNode } from '../types/sorting-node' import { partitionByCommentJsonSchema, diff --git a/rules/sort-object-types.ts b/rules/sort-object-types.ts index 199ae0e92..c04d95044 100644 --- a/rules/sort-object-types.ts +++ b/rules/sort-object-types.ts @@ -3,8 +3,8 @@ import type { RuleContext } from '@typescript-eslint/utils/ts-eslint' import type { TSESTree } from '@typescript-eslint/types' import type { TSESLint } from '@typescript-eslint/utils' -import type { Modifier, Selector, Options } from './sort-object-types.types' -import type { SortingNode } from '../typings' +import type { Modifier, Selector, Options } from './sort-object-types/types' +import type { SortingNode } from '../types/sorting-node' import { buildUseConfigurationIfJsonSchema, @@ -22,15 +22,20 @@ import { orderJsonSchema, } from '../utils/common-json-schemas' import { validateNewlinesAndPartitionConfiguration } from '../utils/validate-newlines-and-partition-configuration' +import { + singleCustomGroupJsonSchema, + allModifiers, + allSelectors, +} from './sort-object-types/types' import { validateGeneratedGroupsConfiguration } from '../utils/validate-generated-groups-configuration' import { validateCustomSortConfiguration } from '../utils/validate-custom-sort-configuration' import { getCustomGroupsCompareOptions } from '../utils/get-custom-groups-compare-options' +import { doesCustomGroupMatch } from './sort-object-types/does-custom-group-match' import { getMatchingContextOptions } from '../utils/get-matching-context-options' import { generatePredefinedGroups } from '../utils/generate-predefined-groups' import { getEslintDisabledLines } from '../utils/get-eslint-disabled-lines' -import { singleCustomGroupJsonSchema } from './sort-object-types.types' +import { isMemberOptional } from './sort-object-types/is-member-optional' import { isNodeEslintDisabled } from '../utils/is-node-eslint-disabled' -import { allModifiers, allSelectors } from './sort-object-types.types' import { hasPartitionComment } from '../utils/is-partition-comment' import { isNodeFunctionType } from '../utils/is-node-function-type' import { createNodeIndexMap } from '../utils/create-node-index-map' @@ -39,8 +44,6 @@ import { getCommentsBefore } from '../utils/get-comments-before' import { makeNewlinesFixes } from '../utils/make-newlines-fixes' import { getNewlinesErrors } from '../utils/get-newlines-errors' import { createEslintRule } from '../utils/create-eslint-rule' -import { isMemberOptional } from '../utils/is-member-optional' -import { customGroupMatches } from './sort-object-types-utils' import { getLinesBetween } from '../utils/get-lines-between' import { getGroupNumber } from '../utils/get-group-number' import { getSourceCode } from '../utils/get-source-code' @@ -314,7 +317,7 @@ export let sortObjectTypeElements = ({ if (Array.isArray(options.customGroups)) { for (let customGroup of options.customGroups) { if ( - customGroupMatches({ + doesCustomGroupMatch({ elementName: name, customGroup, selectors, diff --git a/rules/sort-object-types-utils.ts b/rules/sort-object-types/does-custom-group-match.ts similarity index 78% rename from rules/sort-object-types-utils.ts rename to rules/sort-object-types/does-custom-group-match.ts index 0dd7bd114..dc45207e0 100644 --- a/rules/sort-object-types-utils.ts +++ b/rules/sort-object-types/does-custom-group-match.ts @@ -3,11 +3,11 @@ import type { AnyOfCustomGroup, Modifier, Selector, -} from './sort-object-types.types' +} from './types' -import { matches } from '../utils/matches' +import { matches } from '../../utils/matches' -interface CustomGroupMatchesProps { +interface DoesCustomGroupMatchProps { customGroup: SingleCustomGroup | AnyOfCustomGroup selectors: Selector[] modifiers: Modifier[] @@ -16,16 +16,18 @@ interface CustomGroupMatchesProps { /** * Determines whether a custom group matches the given properties. - * @param {CustomGroupMatchesProps} props - The properties to compare with the + * @param {DoesCustomGroupMatchProps} props - The properties to compare with the * custom group, including selectors, modifiers, and element name. * @returns {boolean} `true` if the custom group matches the properties; * otherwise, `false`. */ -export let customGroupMatches = (props: CustomGroupMatchesProps): boolean => { +export let doesCustomGroupMatch = ( + props: DoesCustomGroupMatchProps, +): boolean => { if ('anyOf' in props.customGroup) { // At least one subgroup must match return props.customGroup.anyOf.some(subgroup => - customGroupMatches({ ...props, customGroup: subgroup }), + doesCustomGroupMatch({ ...props, customGroup: subgroup }), ) } if ( diff --git a/utils/is-member-optional.ts b/rules/sort-object-types/is-member-optional.ts similarity index 100% rename from utils/is-member-optional.ts rename to rules/sort-object-types/is-member-optional.ts diff --git a/rules/sort-object-types.types.ts b/rules/sort-object-types/types.ts similarity index 97% rename from rules/sort-object-types.types.ts rename to rules/sort-object-types/types.ts index ed61ad027..3d0b2c6bd 100644 --- a/rules/sort-object-types.types.ts +++ b/rules/sort-object-types/types.ts @@ -1,12 +1,12 @@ import type { JSONSchema4 } from '@typescript-eslint/utils/json-schema' -import type { JoinWithDash } from '../typings' +import type { JoinWithDash } from '../../types/join-with-dash' import { buildCustomGroupModifiersJsonSchema, buildCustomGroupSelectorJsonSchema, elementNamePatternJsonSchema, -} from '../utils/common-json-schemas' +} from '../../utils/common-json-schemas' export type Options = Partial<{ useConfigurationIf: { diff --git a/rules/sort-objects.ts b/rules/sort-objects.ts index ebe0d0479..ee75d30cc 100644 --- a/rules/sort-objects.ts +++ b/rules/sort-objects.ts @@ -22,7 +22,7 @@ import { } from '../utils/sort-nodes-by-dependencies' import { validateNewlinesAndPartitionConfiguration } from '../utils/validate-newlines-and-partition-configuration' import { validateCustomSortConfiguration } from '../utils/validate-custom-sort-configuration' -import { getFirstNodeParentWithType } from '../utils/get-first-node-parent-with-type' +import { getFirstNodeParentWithType } from './sort-objects/get-first-node-parent-with-type' import { validateGroupsConfiguration } from '../utils/validate-groups-configuration' import { getMatchingContextOptions } from '../utils/get-matching-context-options' import { getEslintDisabledLines } from '../utils/get-eslint-disabled-lines' diff --git a/utils/get-first-node-parent-with-type.ts b/rules/sort-objects/get-first-node-parent-with-type.ts similarity index 100% rename from utils/get-first-node-parent-with-type.ts rename to rules/sort-objects/get-first-node-parent-with-type.ts diff --git a/rules/sort-sets.ts b/rules/sort-sets.ts index cdfcd18e4..531f2e729 100644 --- a/rules/sort-sets.ts +++ b/rules/sort-sets.ts @@ -1,4 +1,4 @@ -import type { Options } from './sort-array-includes.types' +import type { Options } from './sort-array-includes/types' import { defaultOptions, jsonSchema, sortArray } from './sort-array-includes' import { createEslintRule } from '../utils/create-eslint-rule' diff --git a/rules/sort-switch-case.ts b/rules/sort-switch-case.ts index 69fd50d46..7f166d411 100644 --- a/rules/sort-switch-case.ts +++ b/rules/sort-switch-case.ts @@ -1,7 +1,7 @@ import type { TSESTree } from '@typescript-eslint/types' import type { TSESLint } from '@typescript-eslint/utils' -import type { SortingNode } from '../typings' +import type { SortingNode } from '../types/sorting-node' import { specialCharactersJsonSchema, diff --git a/rules/sort-union-types.ts b/rules/sort-union-types.ts index d7521faed..8e66902f3 100644 --- a/rules/sort-union-types.ts +++ b/rules/sort-union-types.ts @@ -1,4 +1,4 @@ -import type { SortingNode } from '../typings' +import type { SortingNode } from '../types/sorting-node' import { partitionByCommentJsonSchema, diff --git a/test/fixtures/tsconfig.json b/test/fixtures/tsconfig.json index cb938d776..fe8f1d646 100644 --- a/test/fixtures/tsconfig.json +++ b/test/fixtures/tsconfig.json @@ -8,5 +8,11 @@ "target": "es5", "strict": true }, - "include": ["file.svelte", "file.astro", "react.tsx", "file.vue", "file.ts"] + "include": [ + "../fixtures/file.svelte", + "../fixtures/file.astro", + "../fixtures/react.tsx", + "../fixtures/file.vue", + "../fixtures/file.ts" + ] } diff --git a/test/sort-array-includes.test.ts b/test/rules/sort-array-includes.test.ts similarity index 99% rename from test/sort-array-includes.test.ts rename to test/rules/sort-array-includes.test.ts index b90c4308c..1a341ced7 100644 --- a/test/sort-array-includes.test.ts +++ b/test/rules/sort-array-includes.test.ts @@ -5,8 +5,8 @@ import { RuleTester as EslintRuleTester } from 'eslint' import { afterAll, describe, it } from 'vitest' import { dedent } from 'ts-dedent' -import rule from '../rules/sort-array-includes' -import { Alphabet } from '../utils/alphabet' +import rule from '../../rules/sort-array-includes' +import { Alphabet } from '../../utils/alphabet' let ruleName = 'sort-array-includes' diff --git a/test/sort-classes.test.ts b/test/rules/sort-classes.test.ts similarity index 98% rename from test/sort-classes.test.ts rename to test/rules/sort-classes.test.ts index 2f7e7ede5..2b97c94a0 100644 --- a/test/sort-classes.test.ts +++ b/test/rules/sort-classes.test.ts @@ -1,23 +1,12 @@ import type { Rule } from 'eslint' -import { expectTypeOf, afterAll, describe, it } from 'vitest' import { RuleTester } from '@typescript-eslint/rule-tester' import { RuleTester as EslintRuleTester } from 'eslint' +import { afterAll, describe, it } from 'vitest' import { dedent } from 'ts-dedent' -import type { - GetMethodOrSetMethodGroup, - NonDeclarePropertyGroup, - FunctionPropertyGroup, - AccessorPropertyGroup, - DeclarePropertyGroup, - IndexSignatureGroup, - ConstructorGroup, - MethodGroup, -} from '../rules/sort-classes.types' - -import { Alphabet } from '../utils/alphabet' -import rule from '../rules/sort-classes' +import { Alphabet } from '../../utils/alphabet' +import rule from '../../rules/sort-classes' let ruleName = 'sort-classes' @@ -8759,78 +8748,4 @@ describe(ruleName, () => { }, ) }) - - describe(`${ruleName}: test types`, () => { - it('test get method or set method group type', () => { - expectTypeOf( - 'get-method' as const, - ).toMatchTypeOf() - - expectTypeOf( - 'set-method' as const, - ).toMatchTypeOf() - - expectTypeOf( - 'protected-get-method' as const, - ).toMatchTypeOf() - - expectTypeOf( - 'public-decorated-get-method' as const, - ).toMatchTypeOf() - }) - - it('test non declare property group type', () => { - expectTypeOf( - 'public-static-override-property' as const, - ).toMatchTypeOf() - }) - - it('test function property group type', () => { - expectTypeOf( - 'private-static-function-property' as const, - ).toMatchTypeOf() - }) - - it('test accessor property group type', () => { - expectTypeOf( - 'static-accessor-property' as const, - ).toMatchTypeOf() - - expectTypeOf( - 'protected-static-accessor-property' as const, - ).toMatchTypeOf() - - expectTypeOf( - 'accessor-property' as const, - ).toMatchTypeOf() - - expectTypeOf( - 'protected-accessor-property' as const, - ).toMatchTypeOf() - }) - - it('test declare property group type', () => { - expectTypeOf( - 'declare-protected-static-readonly-property' as const, - ).toMatchTypeOf() - }) - - it('test declare method group type', () => { - expectTypeOf('public-method' as const).toMatchTypeOf() - - expectTypeOf('protected-method' as const).toMatchTypeOf() - - expectTypeOf('private-method' as const).toMatchTypeOf() - }) - - it('test constructor group type', () => { - expectTypeOf('constructor' as const).toMatchTypeOf() - }) - - it('test index signature group type', () => { - expectTypeOf( - 'index-signature' as const, - ).toMatchTypeOf() - }) - }) }) diff --git a/test/rules/sort-classes/type.test.ts b/test/rules/sort-classes/type.test.ts new file mode 100644 index 000000000..cf40dba7f --- /dev/null +++ b/test/rules/sort-classes/type.test.ts @@ -0,0 +1,88 @@ +import { expectTypeOf, describe, it } from 'vitest' + +import type { + GetMethodOrSetMethodGroup, + NonDeclarePropertyGroup, + FunctionPropertyGroup, + AccessorPropertyGroup, + DeclarePropertyGroup, + IndexSignatureGroup, + ConstructorGroup, + MethodGroup, +} from '../../../rules/sort-classes/types' + +let ruleName = 'sort-classes' + +describe(`${ruleName}: test types`, () => { + it('test get method or set method group type', () => { + expectTypeOf( + 'get-method' as const, + ).toMatchTypeOf() + + expectTypeOf( + 'set-method' as const, + ).toMatchTypeOf() + + expectTypeOf( + 'protected-get-method' as const, + ).toMatchTypeOf() + + expectTypeOf( + 'public-decorated-get-method' as const, + ).toMatchTypeOf() + }) + + it('test non declare property group type', () => { + expectTypeOf( + 'public-static-override-property' as const, + ).toMatchTypeOf() + }) + + it('test function property group type', () => { + expectTypeOf( + 'private-static-function-property' as const, + ).toMatchTypeOf() + }) + + it('test accessor property group type', () => { + expectTypeOf( + 'static-accessor-property' as const, + ).toMatchTypeOf() + + expectTypeOf( + 'protected-static-accessor-property' as const, + ).toMatchTypeOf() + + expectTypeOf( + 'accessor-property' as const, + ).toMatchTypeOf() + + expectTypeOf( + 'protected-accessor-property' as const, + ).toMatchTypeOf() + }) + + it('test declare property group type', () => { + expectTypeOf( + 'declare-protected-static-readonly-property' as const, + ).toMatchTypeOf() + }) + + it('test declare method group type', () => { + expectTypeOf('public-method' as const).toMatchTypeOf() + + expectTypeOf('protected-method' as const).toMatchTypeOf() + + expectTypeOf('private-method' as const).toMatchTypeOf() + }) + + it('test constructor group type', () => { + expectTypeOf('constructor' as const).toMatchTypeOf() + }) + + it('test index signature group type', () => { + expectTypeOf( + 'index-signature' as const, + ).toMatchTypeOf() + }) +}) diff --git a/test/sort-decorators.test.ts b/test/rules/sort-decorators.test.ts similarity index 99% rename from test/sort-decorators.test.ts rename to test/rules/sort-decorators.test.ts index 2d66c1793..54ab7e905 100644 --- a/test/sort-decorators.test.ts +++ b/test/rules/sort-decorators.test.ts @@ -6,8 +6,8 @@ import { RuleTester as EslintRuleTester } from 'eslint' import { afterAll, describe, it } from 'vitest' import { dedent } from 'ts-dedent' -import { Alphabet } from '../utils/alphabet' -import rule from '../rules/sort-decorators' +import { Alphabet } from '../../utils/alphabet' +import rule from '../../rules/sort-decorators' let ruleName = 'sort-decorators' diff --git a/test/get-decorator-name.test.ts b/test/rules/sort-decorators/get-decorator-name.test.ts similarity index 95% rename from test/get-decorator-name.test.ts rename to test/rules/sort-decorators/get-decorator-name.test.ts index 8ff6a177e..9cabc7c7d 100644 --- a/test/get-decorator-name.test.ts +++ b/test/rules/sort-decorators/get-decorator-name.test.ts @@ -3,7 +3,7 @@ import type { TSESTree } from '@typescript-eslint/types' import { AST_NODE_TYPES } from '@typescript-eslint/types' import { describe, expect, it } from 'vitest' -import { getDecoratorName } from '../utils/get-decorator-name' +import { getDecoratorName } from '../../../rules/sort-decorators/get-decorator-name' describe('get-decorator-name', () => { describe('call expressions', () => { diff --git a/test/sort-enums.test.ts b/test/rules/sort-enums.test.ts similarity index 99% rename from test/sort-enums.test.ts rename to test/rules/sort-enums.test.ts index ca7ffc1fb..13a18de81 100644 --- a/test/sort-enums.test.ts +++ b/test/rules/sort-enums.test.ts @@ -2,10 +2,10 @@ import { RuleTester } from '@typescript-eslint/rule-tester' import { afterAll, describe, it } from 'vitest' import { dedent } from 'ts-dedent' -import type { Options } from '../rules/sort-enums' +import type { Options } from '../../rules/sort-enums' -import { Alphabet } from '../utils/alphabet' -import rule from '../rules/sort-enums' +import { Alphabet } from '../../utils/alphabet' +import rule from '../../rules/sort-enums' let ruleName = 'sort-enums' diff --git a/test/sort-exports.test.ts b/test/rules/sort-exports.test.ts similarity index 99% rename from test/sort-exports.test.ts rename to test/rules/sort-exports.test.ts index 004600b35..b23fb93dd 100644 --- a/test/sort-exports.test.ts +++ b/test/rules/sort-exports.test.ts @@ -5,8 +5,8 @@ import { RuleTester as EslintRuleTester } from 'eslint' import { afterAll, describe, it } from 'vitest' import { dedent } from 'ts-dedent' -import { Alphabet } from '../utils/alphabet' -import rule from '../rules/sort-exports' +import { Alphabet } from '../../utils/alphabet' +import rule from '../../rules/sort-exports' let ruleName = 'sort-exports' diff --git a/test/sort-heritage-clauses.test.ts b/test/rules/sort-heritage-clauses.test.ts similarity index 99% rename from test/sort-heritage-clauses.test.ts rename to test/rules/sort-heritage-clauses.test.ts index 32659ca1e..b752fcfb6 100644 --- a/test/sort-heritage-clauses.test.ts +++ b/test/rules/sort-heritage-clauses.test.ts @@ -5,8 +5,8 @@ import { RuleTester as EslintRuleTester } from 'eslint' import { afterAll, describe, it } from 'vitest' import { dedent } from 'ts-dedent' -import rule from '../rules/sort-heritage-clauses' -import { Alphabet } from '../utils/alphabet' +import rule from '../../rules/sort-heritage-clauses' +import { Alphabet } from '../../utils/alphabet' let ruleName = 'sort-heritage-clauses' diff --git a/test/sort-imports.test.ts b/test/rules/sort-imports.test.ts similarity index 99% rename from test/sort-imports.test.ts rename to test/rules/sort-imports.test.ts index e2f672ab2..e24640fb7 100644 --- a/test/sort-imports.test.ts +++ b/test/rules/sort-imports.test.ts @@ -11,12 +11,12 @@ import { createModuleResolutionCache } from 'typescript' import { RuleTester as EslintRuleTester } from 'eslint' import { dedent } from 'ts-dedent' -import type { MESSAGE_ID, Options } from '../rules/sort-imports' +import type { MESSAGE_ID, Options } from '../../rules/sort-imports' -import * as readClosestTsConfigUtils from '../utils/read-closest-ts-config-by-path' -import * as getTypescriptImportUtils from '../utils/get-typescript-import' -import { Alphabet } from '../utils/alphabet' -import rule from '../rules/sort-imports' +import * as readClosestTsConfigUtils from '../../rules/sort-imports/read-closest-ts-config-by-path' +import * as getTypescriptImportUtils from '../../rules/sort-imports/get-typescript-import' +import { Alphabet } from '../../utils/alphabet' +import rule from '../../rules/sort-imports' let ruleName = 'sort-imports' diff --git a/test/get-typescript-import.test.ts b/test/rules/sort-imports/get-typescript-import.test.ts similarity index 85% rename from test/get-typescript-import.test.ts rename to test/rules/sort-imports/get-typescript-import.test.ts index 089e69833..5d38e14a7 100644 --- a/test/get-typescript-import.test.ts +++ b/test/rules/sort-imports/get-typescript-import.test.ts @@ -3,7 +3,7 @@ import type { Mock } from 'vitest' import { beforeEach, describe, expect, it, vi } from 'vitest' import * as ts from 'typescript' -import type { getTypescriptImport as testedFunction } from '../utils/get-typescript-import' +import type { getTypescriptImport as testedFunction } from '../../../rules/sort-imports/get-typescript-import' let mockCreateRequire: Mock<() => typeof ts> = vi.fn() @@ -15,7 +15,9 @@ describe('getTypescriptImport', () => { let getTypescriptImport: typeof testedFunction beforeEach(async () => { - ;({ getTypescriptImport } = await import('../utils/get-typescript-import')) + ;({ getTypescriptImport } = await import( + '../../../rules/sort-imports/get-typescript-import' + )) vi.clearAllMocks() vi.resetModules() }) diff --git a/test/read-closest-ts-config-by-path.test.ts b/test/rules/sort-imports/read-closest-ts-config-by-path.test.ts similarity index 88% rename from test/read-closest-ts-config-by-path.test.ts rename to test/rules/sort-imports/read-closest-ts-config-by-path.test.ts index f03622229..d3ed590a2 100644 --- a/test/read-closest-ts-config-by-path.test.ts +++ b/test/rules/sort-imports/read-closest-ts-config-by-path.test.ts @@ -7,9 +7,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest' import path from 'node:path' import ts from 'typescript' -import type { readClosestTsConfigByPath as testedFunction } from '../utils/read-closest-ts-config-by-path' - -// Heavily inspired from https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/typescript-estree/tests/lib/getProjectConfigFiles.test.ts +import type { readClosestTsConfigByPath as testedFunction } from '../../../rules/sort-imports/read-closest-ts-config-by-path' let mockExistsSync: Mock<(filePath: string) => boolean> = vi.fn() @@ -42,14 +40,14 @@ vi.mock('node:module', _ => ({ let mockGetTypescriptImport: Mock<() => null> = vi.fn() -vi.mock('../utils/get-typescript-import', () => ({ +vi.mock('../../../rules/sort-imports/get-typescript-import', () => ({ getTypescriptImport: () => mockGetTypescriptImport(), })) let testInput = { - filePath: './repos/repo/packages/package/file.ts', - tsconfigRootDir: './repos/repo', - contextCwd: './', + filePath: '../../repos/repo/packages/package/file.ts', + tsconfigRootDir: '../../repos/repo', + contextCwd: '../../../', } let tsConfigContent = { @@ -67,7 +65,7 @@ describe('readClosestTsConfigByPath', () => { beforeEach(async () => { ;({ readClosestTsConfigByPath } = await import( - '../utils/read-closest-ts-config-by-path' + '../../../rules/sort-imports/read-closest-ts-config-by-path' )) vi.clearAllMocks() vi.resetModules() @@ -85,7 +83,7 @@ describe('readClosestTsConfigByPath', () => { describe('with typescript present', () => { beforeEach(async () => { let actualGetTypescriptImport = await vi.importActual( - '../utils/get-typescript-import', + '../../../rules/sort-imports/get-typescript-import', ) mockGetTypescriptImport.mockImplementation( actualGetTypescriptImport.getTypescriptImport as never, @@ -150,11 +148,13 @@ describe('readClosestTsConfigByPath', () => { readClosestTsConfigByPath({ filePath: './a/b/c/d.ts', tsconfigRootDir: './a', - contextCwd: './', + contextCwd: '../../', }) - // This should call to fs.existsSync once: e - // Then it should retrieve c from cache, pointing to a + /** + * This should call to fs.existsSync once: e + * Then it should retrieve c from cache, pointing to a + */ let actual = readClosestTsConfigByPath({ filePath: './a/b/c/e/f.ts', tsconfigRootDir: './a', @@ -175,19 +175,23 @@ describe('readClosestTsConfigByPath', () => { mockParseJsonConfigFileContentReturnValue() mockConvertCompilerOptionsFromJsonReturnValue() - // This should call to fs.existsSync 4 times: d, c, b, a + /** + * This should call to fs.existsSync 4 times: d, c, b, a + */ readClosestTsConfigByPath({ filePath: './a/b/c/d/e.ts', tsconfigRootDir: './a', - contextCwd: './', + contextCwd: '../../', }) - // This should call to fs.existsSync 2: g, f - // Then it should retrieve b from cache, pointing to a + /** + * This should call to fs.existsSync 2: g, f + * Then it should retrieve b from cache, pointing to a + */ let actual = readClosestTsConfigByPath({ filePath: './a/b/f/g/h.ts', tsconfigRootDir: './a', - contextCwd: './', + contextCwd: '../../', }) expect(actual?.compilerOptions).toEqual( @@ -213,7 +217,8 @@ describe('readClosestTsConfigByPath', () => { it('returns a parent tsconfig.json when matched', () => { mockExistsSync.mockImplementation( - filePath => filePath === path.normalize('repos/repo/tsconfig.json'), + filePath => + filePath === path.normalize('../../repos/repo/tsconfig.json'), ) mockReadConfigFileReturnValue() mockParseJsonConfigFileContentReturnValue() @@ -234,7 +239,7 @@ describe('readClosestTsConfigByPath', () => { expect(() => readClosestTsConfigByPath(testInput), ).toThrowErrorMatchingInlineSnapshot( - `[Error: Couldn't find any tsconfig.json relative to './repos/repo/packages/package/file.ts' within './repos/repo'.]`, + `[Error: Couldn't find any tsconfig.json relative to '../../repos/repo/packages/package/file.ts' within '../../repos/repo'.]`, ) }) @@ -246,7 +251,7 @@ describe('readClosestTsConfigByPath', () => { expect(() => readClosestTsConfigByPath({ ...testInput, tsconfigRootDir: '/' }), ).toThrowErrorMatchingInlineSnapshot( - `[Error: Couldn't find any tsconfig.json relative to './repos/repo/packages/package/file.ts' within '/'.]`, + `[Error: Couldn't find any tsconfig.json relative to '../../repos/repo/packages/package/file.ts' within '/'.]`, ) }) }) diff --git a/test/sort-interfaces.test.ts b/test/rules/sort-interfaces.test.ts similarity index 99% rename from test/sort-interfaces.test.ts rename to test/rules/sort-interfaces.test.ts index 34f82a5bb..a983f47a6 100644 --- a/test/sort-interfaces.test.ts +++ b/test/rules/sort-interfaces.test.ts @@ -2,10 +2,10 @@ import { RuleTester } from '@typescript-eslint/rule-tester' import { afterAll, describe, it } from 'vitest' import { dedent } from 'ts-dedent' -import type { Options } from '../rules/sort-interfaces' +import type { Options } from '../../rules/sort-interfaces' -import { Alphabet } from '../utils/alphabet' -import rule from '../rules/sort-interfaces' +import { Alphabet } from '../../utils/alphabet' +import rule from '../../rules/sort-interfaces' let ruleName = 'sort-interfaces' diff --git a/test/sort-intersection-types.test.ts b/test/rules/sort-intersection-types.test.ts similarity index 99% rename from test/sort-intersection-types.test.ts rename to test/rules/sort-intersection-types.test.ts index d1cadbb6b..7c6a16eda 100644 --- a/test/sort-intersection-types.test.ts +++ b/test/rules/sort-intersection-types.test.ts @@ -2,8 +2,8 @@ import { RuleTester } from '@typescript-eslint/rule-tester' import { afterAll, describe, it } from 'vitest' import { dedent } from 'ts-dedent' -import rule from '../rules/sort-intersection-types' -import { Alphabet } from '../utils/alphabet' +import rule from '../../rules/sort-intersection-types' +import { Alphabet } from '../../utils/alphabet' let ruleName = 'sort-intersection-types' diff --git a/test/sort-jsx-props.test.ts b/test/rules/sort-jsx-props.test.ts similarity index 99% rename from test/sort-jsx-props.test.ts rename to test/rules/sort-jsx-props.test.ts index 675d994be..85a6ff838 100644 --- a/test/sort-jsx-props.test.ts +++ b/test/rules/sort-jsx-props.test.ts @@ -4,8 +4,8 @@ import { afterAll, describe, it } from 'vitest' import { dedent } from 'ts-dedent' import path from 'node:path' -import { Alphabet } from '../utils/alphabet' -import rule from '../rules/sort-jsx-props' +import { Alphabet } from '../../utils/alphabet' +import rule from '../../rules/sort-jsx-props' let ruleName = 'sort-jsx-props' @@ -20,7 +20,7 @@ describe(ruleName, () => { let ruleTester = new RuleTester({ languageOptions: { parserOptions: { - tsconfigRootDir: path.join(__dirname, './fixtures'), + tsconfigRootDir: path.join(__dirname, '../fixtures'), extraFileExtensions: ['.svelte', '.astro', '.vue'], ecmaFeatures: { jsx: true, diff --git a/test/sort-maps.test.ts b/test/rules/sort-maps.test.ts similarity index 99% rename from test/sort-maps.test.ts rename to test/rules/sort-maps.test.ts index 5d2ef7515..821fb3432 100644 --- a/test/sort-maps.test.ts +++ b/test/rules/sort-maps.test.ts @@ -5,8 +5,8 @@ import { RuleTester as EslintRuleTester } from 'eslint' import { afterAll, describe, it } from 'vitest' import { dedent } from 'ts-dedent' -import { Alphabet } from '../utils/alphabet' -import rule from '../rules/sort-maps' +import { Alphabet } from '../../utils/alphabet' +import rule from '../../rules/sort-maps' let ruleName = 'sort-maps' diff --git a/test/sort-modules.test.ts b/test/rules/sort-modules.test.ts similarity index 99% rename from test/sort-modules.test.ts rename to test/rules/sort-modules.test.ts index caaf58045..ef2698f20 100644 --- a/test/sort-modules.test.ts +++ b/test/rules/sort-modules.test.ts @@ -5,8 +5,8 @@ import { RuleTester as EslintRuleTester } from 'eslint' import { afterAll, describe, it } from 'vitest' import { dedent } from 'ts-dedent' -import { Alphabet } from '../utils/alphabet' -import rule from '../rules/sort-modules' +import { Alphabet } from '../../utils/alphabet' +import rule from '../../rules/sort-modules' let ruleName = 'sort-modules' diff --git a/test/sort-named-exports.test.ts b/test/rules/sort-named-exports.test.ts similarity index 99% rename from test/sort-named-exports.test.ts rename to test/rules/sort-named-exports.test.ts index a80e60946..85acd2345 100644 --- a/test/sort-named-exports.test.ts +++ b/test/rules/sort-named-exports.test.ts @@ -5,8 +5,8 @@ import { RuleTester as EslintRuleTester } from 'eslint' import { afterAll, describe, it } from 'vitest' import { dedent } from 'ts-dedent' -import rule from '../rules/sort-named-exports' -import { Alphabet } from '../utils/alphabet' +import rule from '../../rules/sort-named-exports' +import { Alphabet } from '../../utils/alphabet' let ruleName = 'sort-named-exports' diff --git a/test/sort-named-imports.test.ts b/test/rules/sort-named-imports.test.ts similarity index 99% rename from test/sort-named-imports.test.ts rename to test/rules/sort-named-imports.test.ts index a54c28123..6f83ec111 100644 --- a/test/sort-named-imports.test.ts +++ b/test/rules/sort-named-imports.test.ts @@ -5,8 +5,8 @@ import { RuleTester as EslintRuleTester } from 'eslint' import { afterAll, describe, it } from 'vitest' import { dedent } from 'ts-dedent' -import rule from '../rules/sort-named-imports' -import { Alphabet } from '../utils/alphabet' +import rule from '../../rules/sort-named-imports' +import { Alphabet } from '../../utils/alphabet' let ruleName = 'sort-named-imports' diff --git a/test/sort-object-types.test.ts b/test/rules/sort-object-types.test.ts similarity index 99% rename from test/sort-object-types.test.ts rename to test/rules/sort-object-types.test.ts index 3f9ded11a..d05124c85 100644 --- a/test/sort-object-types.test.ts +++ b/test/rules/sort-object-types.test.ts @@ -2,8 +2,8 @@ import { RuleTester } from '@typescript-eslint/rule-tester' import { afterAll, describe, it } from 'vitest' import { dedent } from 'ts-dedent' -import rule from '../rules/sort-object-types' -import { Alphabet } from '../utils/alphabet' +import rule from '../../rules/sort-object-types' +import { Alphabet } from '../../utils/alphabet' let ruleName = 'sort-object-types' diff --git a/test/sort-objects.test.ts b/test/rules/sort-objects.test.ts similarity index 99% rename from test/sort-objects.test.ts rename to test/rules/sort-objects.test.ts index 4b6d8df52..d9fb440f7 100644 --- a/test/sort-objects.test.ts +++ b/test/rules/sort-objects.test.ts @@ -5,8 +5,8 @@ import { RuleTester as EslintRuleTester } from 'eslint' import { afterAll, describe, it } from 'vitest' import { dedent } from 'ts-dedent' -import { Alphabet } from '../utils/alphabet' -import rule from '../rules/sort-objects' +import { Alphabet } from '../../utils/alphabet' +import rule from '../../rules/sort-objects' let ruleName = 'sort-objects' diff --git a/test/sort-sets.test.ts b/test/rules/sort-sets.test.ts similarity index 99% rename from test/sort-sets.test.ts rename to test/rules/sort-sets.test.ts index 6d9f66d36..9560a1b60 100644 --- a/test/sort-sets.test.ts +++ b/test/rules/sort-sets.test.ts @@ -5,8 +5,8 @@ import { RuleTester as EslintRuleTester } from 'eslint' import { afterAll, describe, it } from 'vitest' import { dedent } from 'ts-dedent' -import { Alphabet } from '../utils/alphabet' -import rule from '../rules/sort-sets' +import { Alphabet } from '../../utils/alphabet' +import rule from '../../rules/sort-sets' let ruleName = 'sort-sets' diff --git a/test/sort-switch-case.test.ts b/test/rules/sort-switch-case.test.ts similarity index 99% rename from test/sort-switch-case.test.ts rename to test/rules/sort-switch-case.test.ts index 61d6343e8..dbffee145 100644 --- a/test/sort-switch-case.test.ts +++ b/test/rules/sort-switch-case.test.ts @@ -5,8 +5,8 @@ import { RuleTester as EslintRuleTester } from 'eslint' import { afterAll, describe, it } from 'vitest' import { dedent } from 'ts-dedent' -import rule from '../rules/sort-switch-case' -import { Alphabet } from '../utils/alphabet' +import rule from '../../rules/sort-switch-case' +import { Alphabet } from '../../utils/alphabet' let ruleName = 'sort-switch-case' diff --git a/test/sort-union-types.test.ts b/test/rules/sort-union-types.test.ts similarity index 99% rename from test/sort-union-types.test.ts rename to test/rules/sort-union-types.test.ts index 49129ade9..671d3bf9b 100644 --- a/test/sort-union-types.test.ts +++ b/test/rules/sort-union-types.test.ts @@ -2,8 +2,8 @@ import { RuleTester } from '@typescript-eslint/rule-tester' import { afterAll, describe, it } from 'vitest' import { dedent } from 'ts-dedent' -import rule from '../rules/sort-union-types' -import { Alphabet } from '../utils/alphabet' +import rule from '../../rules/sort-union-types' +import { Alphabet } from '../../utils/alphabet' let ruleName = 'sort-union-types' diff --git a/test/sort-variable-declarations.test.ts b/test/rules/sort-variable-declarations.test.ts similarity index 99% rename from test/sort-variable-declarations.test.ts rename to test/rules/sort-variable-declarations.test.ts index 686726d5d..ec43356c4 100644 --- a/test/sort-variable-declarations.test.ts +++ b/test/rules/sort-variable-declarations.test.ts @@ -5,8 +5,8 @@ import { RuleTester as EslintRuleTester } from 'eslint' import { afterAll, describe, it } from 'vitest' import { dedent } from 'ts-dedent' -import rule from '../rules/sort-variable-declarations' -import { Alphabet } from '../utils/alphabet' +import rule from '../../rules/sort-variable-declarations' +import { Alphabet } from '../../utils/alphabet' let ruleName = 'sort-variable-declarations' diff --git a/test/alphabet.test.ts b/test/utils/alphabet.test.ts similarity index 99% rename from test/alphabet.test.ts rename to test/utils/alphabet.test.ts index ecc1846e2..86f5c24e3 100644 --- a/test/alphabet.test.ts +++ b/test/utils/alphabet.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest' -import { Alphabet } from '../utils/alphabet' +import { Alphabet } from '../../utils/alphabet' describe('alphabet', () => { describe('generators', () => { diff --git a/test/compare.test.ts b/test/utils/compare.test.ts similarity index 97% rename from test/compare.test.ts rename to test/utils/compare.test.ts index f34d74b54..1384f1531 100644 --- a/test/compare.test.ts +++ b/test/utils/compare.test.ts @@ -1,9 +1,9 @@ import { describe, expect, it } from 'vitest' -import type { SortingNode } from '../typings' +import type { SortingNode } from '../../types/sorting-node' -import { Alphabet } from '../utils/alphabet' -import { compare } from '../utils/compare' +import { Alphabet } from '../../utils/alphabet' +import { compare } from '../../utils/compare' describe('compare', () => { describe('alphabetical', () => { diff --git a/test/generate-predefined-groups.test.ts b/test/utils/generate-predefined-groups.test.ts similarity index 94% rename from test/generate-predefined-groups.test.ts rename to test/utils/generate-predefined-groups.test.ts index 9f5290144..d20ae74fb 100644 --- a/test/generate-predefined-groups.test.ts +++ b/test/utils/generate-predefined-groups.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest' -import { generatePredefinedGroups } from '../utils/generate-predefined-groups' +import { generatePredefinedGroups } from '../../utils/generate-predefined-groups' describe('generate-predefined-groups', () => { it('should generate official groups', () => { diff --git a/test/get-array-combinations.test.ts b/test/utils/get-array-combinations.test.ts similarity index 80% rename from test/get-array-combinations.test.ts rename to test/utils/get-array-combinations.test.ts index b3e74b65c..22fd52fb9 100644 --- a/test/get-array-combinations.test.ts +++ b/test/utils/get-array-combinations.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest' -import { getArrayCombinations } from '../utils/get-array-combinations' +import { getArrayCombinations } from '../../utils/get-array-combinations' describe('get-array-combinations', () => { it('gets array combinations', () => { diff --git a/test/get-eslint-disabled-rules.test.ts b/test/utils/get-eslint-disabled-rules.test.ts similarity index 92% rename from test/get-eslint-disabled-rules.test.ts rename to test/utils/get-eslint-disabled-rules.test.ts index 815e6795a..9a1c8aba2 100644 --- a/test/get-eslint-disabled-rules.test.ts +++ b/test/utils/get-eslint-disabled-rules.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest' -import { getEslintDisabledRules } from '../utils/get-eslint-disabled-rules' +import { getEslintDisabledRules } from '../../utils/get-eslint-disabled-rules' let eslintDisableDirectives = [ 'eslint-disable', diff --git a/test/get-matching-context-options.test.ts b/test/utils/get-matching-context-options.test.ts similarity index 94% rename from test/get-matching-context-options.test.ts rename to test/utils/get-matching-context-options.test.ts index e6ea0506d..70fb3e76d 100644 --- a/test/get-matching-context-options.test.ts +++ b/test/utils/get-matching-context-options.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest' -import { getMatchingContextOptions } from '../utils/get-matching-context-options' +import { getMatchingContextOptions } from '../../utils/get-matching-context-options' describe('get-matching-context-options', () => { describe('`allNamesMatchPattern`', () => { diff --git a/test/clean-groups-option.test.ts b/test/utils/get-options-with-clean-groups.test.ts similarity index 85% rename from test/clean-groups-option.test.ts rename to test/utils/get-options-with-clean-groups.test.ts index 9da819c22..a0bc86b53 100644 --- a/test/clean-groups-option.test.ts +++ b/test/utils/get-options-with-clean-groups.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest' -import { getOptionsWithCleanGroups } from '../utils/get-options-with-clean-groups' +import { getOptionsWithCleanGroups } from '../../utils/get-options-with-clean-groups' describe('get-options-with-cleaned-groups', () => { it('get options with cleaned groups', () => { diff --git a/test/get-settings.test.ts b/test/utils/get-settings.test.ts similarity index 88% rename from test/get-settings.test.ts rename to test/utils/get-settings.test.ts index 98a7a6530..f3f899fde 100644 --- a/test/get-settings.test.ts +++ b/test/utils/get-settings.test.ts @@ -1,8 +1,8 @@ import { describe, expect, it } from 'vitest' -import type { Settings } from '../utils/get-settings' +import type { Settings } from '../../utils/get-settings' -import { getSettings } from '../utils/get-settings' +import { getSettings } from '../../utils/get-settings' describe('get-settings', () => { it('throws an error when an invalid setting is provided', () => { diff --git a/test/validate-custom-sort-configuration.test.ts b/test/utils/validate-custom-sort-configuration.test.ts similarity index 86% rename from test/validate-custom-sort-configuration.test.ts rename to test/utils/validate-custom-sort-configuration.test.ts index aa2587c40..9efb5b7ea 100644 --- a/test/validate-custom-sort-configuration.test.ts +++ b/test/utils/validate-custom-sort-configuration.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest' -import { validateCustomSortConfiguration } from '../utils/validate-custom-sort-configuration' +import { validateCustomSortConfiguration } from '../../utils/validate-custom-sort-configuration' describe('validate-custom-sort-configuration', () => { it('accepts empty alphabet when type is not `custom`', () => { diff --git a/test/validate-generated-groups-configuration.test.ts b/test/utils/validate-generated-groups-configuration.test.ts similarity index 90% rename from test/validate-generated-groups-configuration.test.ts rename to test/utils/validate-generated-groups-configuration.test.ts index e4d38c2a4..2266263d0 100644 --- a/test/validate-generated-groups-configuration.test.ts +++ b/test/utils/validate-generated-groups-configuration.test.ts @@ -1,8 +1,8 @@ import { describe, expect, it } from 'vitest' -import { validateGeneratedGroupsConfiguration } from '../utils/validate-generated-groups-configuration' -import { allModifiers, allSelectors } from '../rules/sort-classes.types' -import { getArrayCombinations } from '../utils/get-array-combinations' +import { validateGeneratedGroupsConfiguration } from '../../utils/validate-generated-groups-configuration' +import { allModifiers, allSelectors } from '../../rules/sort-classes/types' +import { getArrayCombinations } from '../../utils/get-array-combinations' describe('validate-generated-groups-configuration', () => { it('allows predefined groups', () => { diff --git a/test/validate-groups-configuration.test.ts b/test/utils/validate-groups-configuration.test.ts similarity index 92% rename from test/validate-groups-configuration.test.ts rename to test/utils/validate-groups-configuration.test.ts index 7456e713a..404a23ef2 100644 --- a/test/validate-groups-configuration.test.ts +++ b/test/utils/validate-groups-configuration.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest' -import { validateGroupsConfiguration } from '../utils/validate-groups-configuration' +import { validateGroupsConfiguration } from '../../utils/validate-groups-configuration' /** * It is currently not possible to test rules that throw errors diff --git a/test/validate-newlines-and-partition-configuration.test.ts b/test/utils/validate-newlines-and-partition-configuration.test.ts similarity index 93% rename from test/validate-newlines-and-partition-configuration.test.ts rename to test/utils/validate-newlines-and-partition-configuration.test.ts index fd85098d7..e760d678e 100644 --- a/test/validate-newlines-and-partition-configuration.test.ts +++ b/test/utils/validate-newlines-and-partition-configuration.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest' -import { validateNewlinesAndPartitionConfiguration } from '../utils/validate-newlines-and-partition-configuration' +import { validateNewlinesAndPartitionConfiguration } from '../../utils/validate-newlines-and-partition-configuration' describe('validate-newlines-and-partition-configuration', () => { let partitionByCommentValues: (string[] | boolean | string)[] = [ diff --git a/typings/eslint-plugin-eslint-plugin.d.ts b/types/eslint-plugin-eslint-plugin.d.ts similarity index 100% rename from typings/eslint-plugin-eslint-plugin.d.ts rename to types/eslint-plugin-eslint-plugin.d.ts diff --git a/typings/join-with-dash.ts b/types/join-with-dash.ts similarity index 100% rename from typings/join-with-dash.ts rename to types/join-with-dash.ts diff --git a/typings/join.ts b/types/join.ts similarity index 100% rename from typings/join.ts rename to types/join.ts diff --git a/typings/sorting-node.ts b/types/sorting-node.ts similarity index 100% rename from typings/sorting-node.ts rename to types/sorting-node.ts diff --git a/typings/index.ts b/typings/index.ts deleted file mode 100644 index 6beb32cd7..000000000 --- a/typings/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export type { JoinWithDash } from './join-with-dash' -export type { SortingNode } from './sorting-node' diff --git a/utils/compare.ts b/utils/compare.ts index ed43d9e2a..a32b6db85 100644 --- a/utils/compare.ts +++ b/utils/compare.ts @@ -1,6 +1,6 @@ import { compare as createNaturalCompare } from 'natural-orderby' -import type { SortingNode } from '../typings' +import type { SortingNode } from '../types/sorting-node' import { convertBooleanToSign } from './convert-boolean-to-sign' diff --git a/utils/create-node-index-map.ts b/utils/create-node-index-map.ts index f606f57a4..3b5ec1ed8 100644 --- a/utils/create-node-index-map.ts +++ b/utils/create-node-index-map.ts @@ -1,6 +1,6 @@ import type { TSESTree } from '@typescript-eslint/types' -import type { SortingNode } from '../typings' +import type { SortingNode } from '../types/sorting-node' export let createNodeIndexMap = ( nodes: SortingNode[], diff --git a/utils/get-custom-groups-compare-options.ts b/utils/get-custom-groups-compare-options.ts index ad765ca34..1b7244b03 100644 --- a/utils/get-custom-groups-compare-options.ts +++ b/utils/get-custom-groups-compare-options.ts @@ -1,5 +1,5 @@ +import type { SortingNode } from '../types/sorting-node' import type { CompareOptions } from './compare' -import type { SortingNode } from '../typings' interface Options { customGroups: Record | CustomGroup[] diff --git a/utils/get-group-number.ts b/utils/get-group-number.ts index e3ac7284c..d5b2f544d 100644 --- a/utils/get-group-number.ts +++ b/utils/get-group-number.ts @@ -1,4 +1,4 @@ -import type { SortingNode } from '../typings' +import type { SortingNode } from '../types/sorting-node' export let getGroupNumber = ( groups: (string[] | string)[], diff --git a/utils/get-lines-between.ts b/utils/get-lines-between.ts index 744b2c984..0052f9809 100644 --- a/utils/get-lines-between.ts +++ b/utils/get-lines-between.ts @@ -1,6 +1,6 @@ import type { TSESLint } from '@typescript-eslint/utils' -import type { SortingNode } from '../typings' +import type { SortingNode } from '../types/sorting-node' export let getLinesBetween = ( source: TSESLint.SourceCode, diff --git a/utils/get-newlines-errors.ts b/utils/get-newlines-errors.ts index 35a3f0b77..17bfea2be 100644 --- a/utils/get-newlines-errors.ts +++ b/utils/get-newlines-errors.ts @@ -1,6 +1,6 @@ import type { TSESLint } from '@typescript-eslint/utils' -import type { SortingNode } from '../typings' +import type { SortingNode } from '../types/sorting-node' import { getLinesBetween } from './get-lines-between' diff --git a/utils/make-fixes.ts b/utils/make-fixes.ts index 113690757..61c1dfea7 100644 --- a/utils/make-fixes.ts +++ b/utils/make-fixes.ts @@ -1,6 +1,6 @@ import type { TSESLint } from '@typescript-eslint/utils' -import type { SortingNode } from '../typings' +import type { SortingNode } from '../types/sorting-node' import { makeCommentAfterFixes } from './make-comment-after-fixes' import { getNodeRange } from './get-node-range' diff --git a/utils/make-newlines-fixes.ts b/utils/make-newlines-fixes.ts index 95af5de0f..2a7f08f8e 100644 --- a/utils/make-newlines-fixes.ts +++ b/utils/make-newlines-fixes.ts @@ -1,6 +1,6 @@ import type { TSESLint } from '@typescript-eslint/utils' -import type { SortingNode } from '../typings' +import type { SortingNode } from '../types/sorting-node' import { getLinesBetween } from './get-lines-between' import { getGroupNumber } from './get-group-number' diff --git a/utils/sort-nodes-by-dependencies.ts b/utils/sort-nodes-by-dependencies.ts index 59154546e..b6cdb0b83 100644 --- a/utils/sort-nodes-by-dependencies.ts +++ b/utils/sort-nodes-by-dependencies.ts @@ -1,6 +1,6 @@ import type { TSESTree } from '@typescript-eslint/types' -import type { SortingNode } from '../typings' +import type { SortingNode } from '../types/sorting-node' export interface SortingNodeWithDependencies< Node extends TSESTree.Node = TSESTree.Node, diff --git a/utils/sort-nodes-by-groups.ts b/utils/sort-nodes-by-groups.ts index 72ce9e76d..c32dcd87d 100644 --- a/utils/sort-nodes-by-groups.ts +++ b/utils/sort-nodes-by-groups.ts @@ -1,5 +1,5 @@ +import type { SortingNode } from '../types/sorting-node' import type { CompareOptions } from './compare' -import type { SortingNode } from '../typings' import { getGroupNumber } from './get-group-number' import { sortNodes } from './sort-nodes' diff --git a/utils/sort-nodes.ts b/utils/sort-nodes.ts index 9d591dd88..655cda8b2 100644 --- a/utils/sort-nodes.ts +++ b/utils/sort-nodes.ts @@ -1,5 +1,5 @@ +import type { SortingNode } from '../types/sorting-node' import type { CompareOptions } from './compare' -import type { SortingNode } from '../typings' import { compare } from './compare' diff --git a/vite.config.ts b/vite.config.ts index 040661be8..9d93819eb 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -98,7 +98,7 @@ export default defineConfig({ }, include: [ path.join(__dirname, 'index.ts'), - path.join(__dirname, 'typings'), + path.join(__dirname, 'types'), path.join(__dirname, 'rules'), path.join(__dirname, 'utils'), ],