From e2409716048cf0248914761ef1080c33f2403b70 Mon Sep 17 00:00:00 2001 From: "Azat S." Date: Fri, 1 Nov 2024 15:48:19 +0300 Subject: [PATCH] feat!: remove minimatch in favor of regexp --- docs/content/guide/getting-started.mdx | 3 +- docs/content/rules/sort-array-includes.mdx | 15 +- docs/content/rules/sort-classes.mdx | 16 +- docs/content/rules/sort-decorators.mdx | 19 +- docs/content/rules/sort-enums.mdx | 14 +- docs/content/rules/sort-exports.mdx | 15 +- docs/content/rules/sort-heritage-clauses.mdx | 17 +- docs/content/rules/sort-imports.mdx | 47 +-- docs/content/rules/sort-interfaces.mdx | 25 +- .../content/rules/sort-intersection-types.mdx | 15 +- docs/content/rules/sort-jsx-props.mdx | 25 +- docs/content/rules/sort-maps.mdx | 16 +- docs/content/rules/sort-named-exports.mdx | 15 +- docs/content/rules/sort-named-imports.mdx | 6 +- docs/content/rules/sort-object-types.mdx | 23 +- docs/content/rules/sort-objects.mdx | 25 +- docs/content/rules/sort-sets.mdx | 15 +- docs/content/rules/sort-switch-case.mdx | 2 - docs/content/rules/sort-union-types.mdx | 15 +- .../rules/sort-variable-declarations.mdx | 15 +- package.json | 1 - pnpm-lock.yaml | 3 - rules/sort-array-includes.ts | 5 - rules/sort-classes-utils.ts | 5 +- rules/sort-classes.ts | 10 +- rules/sort-classes.types.ts | 1 - rules/sort-decorators.ts | 5 - rules/sort-enums.ts | 5 - rules/sort-exports.ts | 5 - rules/sort-heritage-clauses.ts | 4 - rules/sort-imports.ts | 12 +- rules/sort-interfaces.ts | 9 +- rules/sort-intersection-types.ts | 5 - rules/sort-jsx-props.ts | 6 +- rules/sort-maps.ts | 5 - rules/sort-named-exports.ts | 5 - rules/sort-named-imports.ts | 5 - rules/sort-object-types.ts | 5 - rules/sort-objects.ts | 14 +- rules/sort-union-types.ts | 5 - rules/sort-variable-declarations.ts | 5 - test/get-settings.test.ts | 1 - test/sort-array-includes.test.ts | 7 +- test/sort-classes.test.ts | 12 +- test/sort-decorators.test.ts | 30 +- test/sort-enums.test.ts | 11 +- test/sort-exports.test.ts | 5 +- test/sort-heritage-clauses.test.ts | 9 +- test/sort-imports.test.ts | 329 ++++++------------ test/sort-interfaces.test.ts | 14 +- test/sort-intersection-types.test.ts | 7 +- test/sort-jsx-props.test.ts | 3 +- test/sort-maps.test.ts | 35 +- test/sort-named-exports.test.ts | 5 +- test/sort-named-imports.test.ts | 2 +- test/sort-object-types.test.ts | 8 +- test/sort-objects.test.ts | 16 +- test/sort-sets.test.ts | 35 +- test/sort-union-types.test.ts | 7 +- test/sort-variable-declarations.test.ts | 35 +- utils/common-json-schemas.ts | 6 - utils/get-node-range.ts | 10 +- utils/get-settings.ts | 2 - utils/is-partition-comment.ts | 12 +- utils/make-fixes.ts | 1 - utils/matches.ts | 19 +- utils/use-groups.ts | 7 +- 67 files changed, 294 insertions(+), 797 deletions(-) diff --git a/docs/content/guide/getting-started.mdx b/docs/content/guide/getting-started.mdx index b93942f90..1fd33aa95 100644 --- a/docs/content/guide/getting-started.mdx +++ b/docs/content/guide/getting-started.mdx @@ -145,9 +145,8 @@ In settings you can set the following options: - `ignoreCase` — Ignore case when sorting. - `ignorePattern` — Ignore sorting for elements that match the pattern. - `specialCharacters` — Control whether special characters should be kept, trimmed or removed before sorting. Values can be `'keep'`, `'trim'` or `'remove'`. -- `partitionByComment` — Partition the sorted elements by comments. Values can be `true`, `false` or glob pattern string. +- `partitionByComment` — Partition the sorted elements by comments. Values can be `true`, `false` or regexp pattern. - `partitionByNewLine` — Partition the sorted elements by new lines. Values can be `true` or `false`. -- `matcher` — Determine the matcher used for patterns in options such as `partitionByComment`. Values can be `minimatch` or `regex`. Example: diff --git a/docs/content/rules/sort-array-includes.mdx b/docs/content/rules/sort-array-includes.mdx index ebe45607c..8cd336137 100644 --- a/docs/content/rules/sort-array-includes.mdx +++ b/docs/content/rules/sort-array-includes.mdx @@ -176,8 +176,8 @@ Allows you to use comments to separate the members of arrays into logical groups - `true` — All comments will be treated as delimiters, creating partitions. - `false` — Comments will not be used as delimiters. -- `string` — A glob pattern to specify which comments should act as delimiters. -- `string[]` — A list of glob patterns to specify which comments should act as delimiters. +- `string` — A regexp pattern to specify which comments should act as delimiters. +- `string[]` — A list of regexp patterns to specify which comments should act as delimiters. ### partitionByNewLine @@ -209,15 +209,6 @@ if ([ Each group of elements (separated by empty lines) is treated independently, and the order within each group is preserved. -### matcher - -default: `'minimatch'` - -Determines the matcher used for patterns in the `partitionByComment` option. - -- `'minimatch'` — Use the [minimatch](https://github.com/isaacs/minimatch) library for pattern matching. -- `'regex'` — Use regular expressions for pattern matching. - ## Usage default: `[]` -You can define your own groups and use custom glob patterns or regex for matching very specific class members. - -Use the `matcher` option to specify the pattern matching method. +You can define your own groups and use regex for matching very specific class members. A custom group definition may follow one of the two following interfaces: @@ -616,14 +614,6 @@ Example: } ``` -### matcher - -default: `'minimatch'` - -Determines the matcher used for patterns in the `partitionByComment` and `customGroups` options. - -- `'minimatch'` — Use the [minimatch](https://github.com/isaacs/minimatch) library for pattern matching. -- `'regex'` — Use regular expressions for pattern matching. ## Usage @@ -648,7 +638,6 @@ Determines the matcher used for patterns in the `partitionByComment` and `custom ignoreCase: true, specialCharacters: 'keep', partitionByComment: false, - matcher: 'minimatch', groups: [ 'index-signature', ['static-property', 'static-accessor-property'], @@ -699,7 +688,6 @@ Determines the matcher used for patterns in the `partitionByComment` and `custom ignoreCase: true, specialCharacters: 'keep', partitionByComment: false, - matcher: 'minimatch', groups: [ 'index-signature', ['static-property', 'static-accessor-property'], diff --git a/docs/content/rules/sort-decorators.mdx b/docs/content/rules/sort-decorators.mdx index 0a4d82328..65e2b5c53 100644 --- a/docs/content/rules/sort-decorators.mdx +++ b/docs/content/rules/sort-decorators.mdx @@ -194,8 +194,8 @@ Allows you to use comments to separate class decorators into logical groups. - `true` — All comments will be treated as delimiters, creating partitions. - `false` — Comments will not be used as delimiters. -- `string` — A glob pattern to specify which comments should act as delimiters. -- `string[]` — An array of glob patterns to specify which comments should act as delimiters. +- `string` — A regexp pattern to specify which comments should act as delimiters. +- `string[]` — An array of regexp patterns to specify which comments should act as delimiters. ### groups @@ -227,9 +227,7 @@ All members of the groups in the array will be sorted together as if they were p default: `{}` -You can define your own groups and use custom glob patterns or regex to match specific decorators. - -Use the `matcher` option to specify the pattern matching method. +You can define your own groups and use regex to match specific decorators. Each key of `customGroups` represents a group name which you can then use in the `groups` option. The value for each key can either be of type: - `string` — A decorator's name matching the value will be marked as part of the group referenced by the key. @@ -267,15 +265,6 @@ class MyClass { } ``` -### matcher - -default: `'minimatch'` - -Determines the matcher used for patterns in the `partitionByComment` and `customGroups` options. - -- `'minimatch'` — Use the [minimatch](https://github.com/isaacs/minimatch) library for pattern matching. -- `'regex'` — Use regular expressions for pattern matching. - ## Usage default: `'minimatch'` - -Determines the matcher used for patterns in the `partitionByComment` option. - -- `'minimatch'` — Use the [minimatch](https://github.com/isaacs/minimatch) library for pattern matching. -- `'regex'` — Use regular expressions for pattern matching. - ## Usage default: `'minimatch'` - -Determines the matcher used for patterns in the `partitionByComment` option. - -- `'minimatch'` — Use the [minimatch](https://github.com/isaacs/minimatch) library for pattern matching. -- `'regex'` — Use regular expressions for pattern matching. - ## Usage default: `{}` -You can define your own groups and use custom glob patterns or regex to match specific heritage clauses. - -Use the `matcher` option to specify the pattern matching method. +You can define your own groups and use regex to match specific heritage clauses. Each key of `customGroups` represents a group name which you can then use in the `groups` option. The value for each key can either be of type: - `string` — A heritage clause's name matching the value will be marked as part of the group referenced by the key. @@ -159,20 +157,11 @@ interface Interface extends WithId, Logged, StartupService { 'unknown' ], + customGroups: { // [!code ++] -+ withIdInterface: 'WithId' // [!code ++] ++ withIdInterface: '^WithId' // [!code ++] + } // [!code ++] } ``` -### matcher - -default: `'minimatch'` - -Determines the matcher used for patterns in the `customGroups` option. - -- `'minimatch'` — Use the [minimatch](https://github.com/isaacs/minimatch) library for pattern matching. -- `'regex'` — Use regular expressions for pattern matching. - ## Usage default: `['~/**']` for `minimatch` matcher, `['^~/.*']` for `regex` matcher +default: `['^~/.*']` Allows you to specify a pattern for identifying internal imports. This is useful for distinguishing your own modules from external dependencies. -You can use glob patterns to define these internal imports. +You can use regexp patterns to define these internal imports. ### sortSideEffects @@ -293,9 +293,7 @@ import type { BaseOptions } from './index.d.ts' default: `{ value: {}, type: {} }` -You can define your own groups and use custom glob patterns or regex to match specific imports. - -Use the `matcher` option to specify the pattern matching method. +You can define your own groups and use regexp pattern to match specific imports. Each key of the `value` or `type` fields represents a group name which you can then use in the `groups` option. The value for each key can either be of type: - `string` — An import matching the value will be marked as part of the group referenced by the key. @@ -308,10 +306,10 @@ Custom group matching takes precedence over predefined group matching. ```js groups: [ -+ 'react', // [!code ++] ++ 'react', // [!code ++] 'type', ['builtin', 'external'], -+ 'lodash', // [!code ++] ++ 'lodash', // [!code ++] 'internal-type', 'internal', ['parent-type', 'sibling-type', 'index-type'], @@ -319,27 +317,18 @@ Custom group matching takes precedence over predefined group matching. 'object', 'unknown', ], -+ customGroups: { // [!code ++] -+ value: { // [!code ++] -+ react: ['react', 'react-*'], // [!code ++] -+ lodash: 'lodash', // [!code ++] -+ }, // [!code ++] -+ type: { // [!code ++] -+ react: ['react', 'react-*'], // [!code ++] -+ } // [!code ++] -+ }, // [!code ++] ++ customGroups: { // [!code ++] ++ value: { // [!code ++] ++ react: ['^react$', '^react-.+'], // [!code ++] ++ lodash: 'lodash', // [!code ++] ++ }, // [!code ++] ++ type: { // [!code ++] ++ react: ['^react$', '^react-.+'], // [!code ++] ++ } // [!code ++] ++ }, // [!code ++] } ``` -### matcher - -default: `'minimatch'` - -Determines the matcher used for patterns in the `internalPattern` and `customGroups` options. - -- `'minimatch'` — Use the [minimatch](https://github.com/isaacs/minimatch) library for pattern matching. -- `'regex'` — Use regular expressions for pattern matching. - ### environment default: `'node'` @@ -368,11 +357,9 @@ Specifies which environment’s built-in modules should be recognized. If you ar order: 'asc', ignoreCase: true, specialCharacters: 'keep', - matcher: 'minimatch', - internalPattern: ['~/**'], + internalPattern: ['^~/.+'], newlinesBetween: 'always', maxLineLength: undefined, - matcher: 'minimatch', groups: [ 'type', ['builtin', 'external'], @@ -409,11 +396,9 @@ Specifies which environment’s built-in modules should be recognized. If you ar order: 'asc', ignoreCase: true, specialCharacters: 'keep', - matcher: 'minimatch', - internalPattern: ['~/**'], + internalPattern: ['^~/.+'], newlinesBetween: 'always', maxLineLength: undefined, - matcher: 'minimatch', groups: [ 'type', ['builtin', 'external'], diff --git a/docs/content/rules/sort-interfaces.mdx b/docs/content/rules/sort-interfaces.mdx index bf334a445..b04e3490e 100644 --- a/docs/content/rules/sort-interfaces.mdx +++ b/docs/content/rules/sort-interfaces.mdx @@ -177,7 +177,7 @@ Controls whether special characters should be trimmed, removed or kept before so Allows you to specify names or patterns for interfaces that should be ignored by this rule. This can be useful if you have specific interfaces that you do not want to sort. -You can specify their names or a glob pattern to ignore, for example: `'Component*'` to ignore all interfaces whose names begin with the word “Component”. +You can specify their names or a regexp pattern to ignore, for example: `'^Component.+'` to ignore all interfaces whose names begin with the word “Component”. ### partitionByComment @@ -187,8 +187,8 @@ Allows you to use comments to separate the properties of interfaces into logical - `true` — All comments will be treated as delimiters, creating partitions. - `false` — Comments will not be used as delimiters. -- `string` — A glob pattern to specify which comments should act as delimiters. -- `string[]` — An array of glob patterns to specify which comments should act as delimiters. +- `string` — A regexp pattern to specify which comments should act as delimiters. +- `string[]` — An array of regexp patterns to specify which comments should act as delimiters. ### partitionByNewLine @@ -296,9 +296,7 @@ interface User { default: `{}` -You can define your own groups and use custom glob patterns or regex to match specific interface members. - -Use the `matcher` option to specify the pattern matching method. +You can define your own groups and use regexp patterns to match specific interface members. Each key of `customGroups` represents a group name which you can then use in the `groups` option. The value for each key can either be of type: - `string` — An interface member's name matching the value will be marked as part of the group referenced by the key. @@ -336,21 +334,12 @@ interface User { ['multiline', 'bottom'] // [!code ++] ], + customGroups: { // [!code ++] -+ top: ['id', 'name'] // [!code ++] -+ bottom: '*_metadata' // [!code ++] ++ top: ['^id$', '^name$'] // [!code ++] ++ bottom: '.+_metadata$' // [!code ++] + } // [!code ++] } ``` -### matcher - -default: `'minimatch'` - -Determines the matcher used for patterns in the `partitionByComment`, `ignorePattern` and `customGroups` options. - -- `'minimatch'` — Use the [minimatch](https://github.com/isaacs/minimatch) library for pattern matching. -- `'regex'` — Use regular expressions for pattern matching. - ## Usage default: `'minimatch'` - -Determines the matcher used for patterns in the `partitionByComment` option. - -- `'minimatch'` — Use the [minimatch](https://github.com/isaacs/minimatch) library for pattern matching. -- `'regex'` — Use regular expressions for pattern matching. - ## Usage default: `{}` -You can define your own groups and use custom glob patterns or regex to match specific JSX attributes. - -Use the `matcher` option to specify the pattern matching method. +You can define your own groups and use regexp pattern to match specific JSX attributes. Each key of `customGroups` represents a group name which you can then use in the `groups` option. The value for each key can either be of type: - `string` — A JSX prop's name matching the value will be marked as part of the group referenced by the key. @@ -231,23 +229,14 @@ Custom group matching takes precedence over predefined group matching. 'multiline', 'unknown', 'shorthand', -+ 'callback', // [!code ++] ++ 'callback', // [!code ++] ], -+ customGroups: { // [!code ++] -+ callback: 'on*' // [!code ++] -+ } // [!code ++] ++ customGroups: { // [!code ++] ++ callback: '^on.+' // [!code ++] ++ } // [!code ++] } ``` -### matcher - -default: `'minimatch'` - -Determines the matcher used for patterns in the `ignorePattern` and `customGroups` options. - -- `'minimatch'` — Use the [minimatch](https://github.com/isaacs/minimatch) library for pattern matching. -- `'regex'` — Use regular expressions for pattern matching. - ## Usage default: `'minimatch'` - -Determines the matcher used for patterns in the `partitionByComment` option. - -- `'minimatch'` — Use the [minimatch](https://github.com/isaacs/minimatch) library for pattern matching. -- `'regex'` — Use regular expressions for pattern matching. - ## Usage default: `'minimatch'` - -Determines the matcher used for patterns in the `partitionByComment` option. - -- `'minimatch'` — Use the [minimatch](https://github.com/isaacs/minimatch) library for pattern matching. -- `'regex'` — Use regular expressions for pattern matching. - ## Usage default: `{}` -You can define your own groups and use custom glob patterns or regex to match specific object type members. - -Use the `matcher` option to specify the pattern matching method. +You can define your own groups and use regexp pattern to match specific object type members. Each key of `customGroups` represents a group name which you can then use in the `groups` option. The value for each key can either be of type: - `string` — A type member's name matching the value will be marked as part of the group referenced by the key. @@ -293,21 +291,12 @@ type User = { ['multiline', 'bottom'] // [!code ++] ], + customGroups: { // [!code ++] -+ top: ['id', 'name'] // [!code ++] -+ bottom: '*_metadata' // [!code ++] ++ top: ['^id$', '^name$'] // [!code ++] ++ bottom: '.+_metadata$' // [!code ++] + } // [!code ++] } ``` -### matcher - -default: `'minimatch'` - -Determines the matcher used for patterns in the `partitionByComment` and `customGroups` options. - -- `'minimatch'` — Use the [minimatch](https://github.com/isaacs/minimatch) library for pattern matching. -- `'regex'` — Use regular expressions for pattern matching. - ## Usage default: `{}` -You can define your own groups and use custom glob patterns or regex to match specific object keys. - -Use the `matcher` option to specify the pattern matching method. +You can define your own groups and use regexp pattern to match specific object keys. Each key of `customGroups` represents a group name which you can then use in the `groups` option. The value for each key can either be of type: - `string` — An object attribute's name matching the value will be marked as part of the group referenced by the key. @@ -335,21 +333,12 @@ const user = { 'bottom' // [!code ++] ], + customGroups: { // [!code ++] -+ top: ['id', 'name'] // [!code ++] -+ bottom: '*_metadata' // [!code ++] ++ top: ['^id$', '^name$'] // [!code ++] ++ bottom: '.+_metadata$' // [!code ++] + } // [!code ++] } ``` -### matcher - -default: `'minimatch'` - -Determines the matcher used for patterns in the `partitionByComment`, `ignorePattern` and `customGroups` options. - -- `'minimatch'` — Use the [minimatch](https://github.com/isaacs/minimatch) library for pattern matching. -- `'regex'` — Use regular expressions for pattern matching. - ## Usage default: `'minimatch'` - -Determines the matcher used for patterns in the `partitionByComment` option. - -- `'minimatch'` — Use the [minimatch](https://github.com/isaacs/minimatch) library for pattern matching. -- `'regex'` — Use regular expressions for pattern matching. - ## Usage default: `'minimatch'` - -Determines the matcher used for patterns in the `partitionByComment` option. - -- `'minimatch'` — Use the [minimatch](https://github.com/isaacs/minimatch) library for pattern matching. -- `'regex'` — Use regular expressions for pattern matching. - ## Usage default: `'minimatch'` - -Determines the matcher used for patterns in the `partitionByComment` option. - -- `'minimatch'` — Use the [minimatch](https://github.com/isaacs/minimatch) library for pattern matching. -- `'regex'` — Use regular expressions for pattern matching. - ## Usage = { type: 'alphabetical', ignoreCase: true, specialCharacters: 'keep', - matcher: 'minimatch', order: 'asc', partitionByComment: false, partitionByNewLine: false, @@ -59,7 +56,6 @@ export let jsonSchema: JSONSchema4 = { properties: { type: typeJsonSchema, order: orderJsonSchema, - matcher: matcherJsonSchema, ignoreCase: ignoreCaseJsonSchema, specialCharacters: specialCharactersJsonSchema, groupKind: { @@ -153,7 +149,6 @@ export let sortArray = ( hasPartitionComment( partitionComment, getCommentsBefore(element, sourceCode), - options.matcher, )) || (options.partitionByNewLine && lastSortingNode && diff --git a/rules/sort-classes-utils.ts b/rules/sort-classes-utils.ts index 1eb10dafb..d94fe1111 100644 --- a/rules/sort-classes-utils.ts +++ b/rules/sort-classes-utils.ts @@ -16,7 +16,6 @@ import { matches } from '../utils/matches' interface CustomGroupMatchesProps { customGroup: SingleCustomGroup | CustomGroupBlock elementValue: undefined | string - matcher: 'minimatch' | 'regex' selectors: Selector[] modifiers: Modifier[] decorators: string[] @@ -191,7 +190,6 @@ export const customGroupMatches = (props: CustomGroupMatchesProps): boolean => { let matchesElementNamePattern: boolean = matches( props.elementName, props.customGroup.elementNamePattern, - props.matcher, ) if (!matchesElementNamePattern) { return false @@ -205,7 +203,6 @@ export const customGroupMatches = (props: CustomGroupMatchesProps): boolean => { let matchesElementValuePattern: boolean = matches( props.elementValue ?? '', props.customGroup.elementValuePattern, - props.matcher, ) if (!matchesElementValuePattern) { return false @@ -218,7 +215,7 @@ export const customGroupMatches = (props: CustomGroupMatchesProps): boolean => { ) { let decoratorPattern = props.customGroup.decoratorNamePattern let matchesDecoratorNamePattern: boolean = props.decorators.some( - decorator => matches(decorator, decoratorPattern, props.matcher), + decorator => matches(decorator, decoratorPattern), ) if (!matchesDecoratorNamePattern) { return false diff --git a/rules/sort-classes.ts b/rules/sort-classes.ts index b06b9aba1..0a5b06182 100644 --- a/rules/sort-classes.ts +++ b/rules/sort-classes.ts @@ -12,7 +12,6 @@ import { partitionByCommentJsonSchema, specialCharactersJsonSchema, ignoreCaseJsonSchema, - matcherJsonSchema, groupsJsonSchema, orderJsonSchema, typeJsonSchema, @@ -77,7 +76,6 @@ const defaultOptions: Required = { ['private-method', 'private-function-property'], 'unknown', ], - matcher: 'minimatch', partitionByComment: false, type: 'alphabetical', ignoreCase: true, @@ -100,7 +98,6 @@ export default createEslintRule({ properties: { type: typeJsonSchema, order: orderJsonSchema, - matcher: matcherJsonSchema, ignoreCase: ignoreCaseJsonSchema, specialCharacters: specialCharactersJsonSchema, partitionByComment: { @@ -308,11 +305,7 @@ export default createEslintRule({ if ( options.partitionByComment && - hasPartitionComment( - options.partitionByComment, - comments, - options.matcher, - ) + hasPartitionComment(options.partitionByComment, comments) ) { accumulator.push([]) } @@ -530,7 +523,6 @@ export default createEslintRule({ modifiers, selectors, decorators, - matcher: options.matcher, }) ) { defineGroup(customGroup.groupName, true) diff --git a/rules/sort-classes.types.ts b/rules/sort-classes.types.ts index 96f12f015..dd934c965 100644 --- a/rules/sort-classes.types.ts +++ b/rules/sort-classes.types.ts @@ -189,7 +189,6 @@ export type SortClassesOptions = [ type: 'alphabetical' | 'line-length' | 'natural' partitionByComment: string[] | boolean | string specialCharacters: 'remove' | 'trim' | 'keep' - matcher: 'minimatch' | 'regex' customGroups: CustomGroup[] groups: (Group[] | Group)[] order: 'desc' | 'asc' diff --git a/rules/sort-decorators.ts b/rules/sort-decorators.ts index bc5687be7..87b9cf94c 100644 --- a/rules/sort-decorators.ts +++ b/rules/sort-decorators.ts @@ -8,7 +8,6 @@ import { specialCharactersJsonSchema, customGroupsJsonSchema, ignoreCaseJsonSchema, - matcherJsonSchema, groupsJsonSchema, orderJsonSchema, typeJsonSchema, @@ -40,7 +39,6 @@ export type Options = [ partitionByComment: string[] | boolean | string specialCharacters: 'remove' | 'trim' | 'keep' groups: (Group[] | Group)[] - matcher: 'minimatch' | 'regex' sortOnParameters: boolean sortOnProperties: boolean sortOnAccessors: boolean @@ -55,7 +53,6 @@ type SortDecoratorsSortingNode = SortingNode const defaultOptions: Required[0]> = { type: 'alphabetical', - matcher: 'minimatch', ignoreCase: true, specialCharacters: 'keep', partitionByComment: false, @@ -83,7 +80,6 @@ export default createEslintRule, MESSAGE_ID>({ properties: { type: typeJsonSchema, order: orderJsonSchema, - matcher: matcherJsonSchema, ignoreCase: ignoreCaseJsonSchema, specialCharacters: specialCharactersJsonSchema, sortOnClasses: { @@ -196,7 +192,6 @@ let sortDecorators = ( hasPartitionComment( partitionComment, getCommentsBefore(decorator, sourceCode), - options.matcher, ) ) { accumulator.push([]) diff --git a/rules/sort-enums.ts b/rules/sort-enums.ts index a06562320..d9516f8bc 100644 --- a/rules/sort-enums.ts +++ b/rules/sort-enums.ts @@ -7,7 +7,6 @@ import { partitionByCommentJsonSchema, specialCharactersJsonSchema, ignoreCaseJsonSchema, - matcherJsonSchema, orderJsonSchema, typeJsonSchema, } from '../utils/common-json-schemas' @@ -35,7 +34,6 @@ export type Options = [ type: 'alphabetical' | 'line-length' | 'natural' partitionByComment: string[] | boolean | string specialCharacters: 'remove' | 'trim' | 'keep' - matcher: 'minimatch' | 'regex' partitionByNewLine: boolean forceNumericSort: boolean order: 'desc' | 'asc' @@ -48,7 +46,6 @@ const defaultOptions: Required = { partitionByComment: false, partitionByNewLine: false, type: 'alphabetical', - matcher: 'minimatch', ignoreCase: true, specialCharacters: 'keep', order: 'asc', @@ -70,7 +67,6 @@ export default createEslintRule({ properties: { type: typeJsonSchema, order: orderJsonSchema, - matcher: matcherJsonSchema, ignoreCase: ignoreCaseJsonSchema, specialCharacters: specialCharactersJsonSchema, sortByValue: { @@ -193,7 +189,6 @@ export default createEslintRule({ hasPartitionComment( partitionComment, getCommentsBefore(member, sourceCode), - options.matcher, )) || (options.partitionByNewLine && lastSortingNode && diff --git a/rules/sort-exports.ts b/rules/sort-exports.ts index db323a1e7..c32216fae 100644 --- a/rules/sort-exports.ts +++ b/rules/sort-exports.ts @@ -6,7 +6,6 @@ import { partitionByCommentJsonSchema, specialCharactersJsonSchema, ignoreCaseJsonSchema, - matcherJsonSchema, orderJsonSchema, typeJsonSchema, } from '../utils/common-json-schemas' @@ -30,7 +29,6 @@ type Options = [ type: 'alphabetical' | 'line-length' | 'natural' partitionByComment: string[] | boolean | string specialCharacters: 'remove' | 'trim' | 'keep' - matcher: 'minimatch' | 'regex' partitionByNewLine: boolean order: 'desc' | 'asc' ignoreCase: boolean @@ -46,7 +44,6 @@ const defaultOptions: Required = { ignoreCase: true, specialCharacters: 'keep', order: 'asc', - matcher: 'minimatch', partitionByComment: false, partitionByNewLine: false, groupKind: 'mixed', @@ -66,7 +63,6 @@ export default createEslintRule({ properties: { type: typeJsonSchema, order: orderJsonSchema, - matcher: matcherJsonSchema, ignoreCase: ignoreCaseJsonSchema, specialCharacters: specialCharactersJsonSchema, partitionByComment: { @@ -120,7 +116,6 @@ export default createEslintRule({ hasPartitionComment( partitionComment, getCommentsBefore(node, sourceCode), - options.matcher, )) || (options.partitionByNewLine && lastNode && diff --git a/rules/sort-heritage-clauses.ts b/rules/sort-heritage-clauses.ts index 55cf06a0b..7c32cb905 100644 --- a/rules/sort-heritage-clauses.ts +++ b/rules/sort-heritage-clauses.ts @@ -7,7 +7,6 @@ import { specialCharactersJsonSchema, customGroupsJsonSchema, ignoreCaseJsonSchema, - matcherJsonSchema, groupsJsonSchema, orderJsonSchema, typeJsonSchema, @@ -37,7 +36,6 @@ export type Options = [ type: 'alphabetical' | 'line-length' | 'natural' specialCharacters: 'remove' | 'trim' | 'keep' groups: (Group[] | Group)[] - matcher: 'minimatch' | 'regex' order: 'desc' | 'asc' ignoreCase: boolean }>, @@ -45,7 +43,6 @@ export type Options = [ const defaultOptions: Required[0]> = { type: 'alphabetical', - matcher: 'minimatch', ignoreCase: true, specialCharacters: 'keep', customGroups: {}, @@ -67,7 +64,6 @@ export default createEslintRule, MESSAGE_ID>({ properties: { type: typeJsonSchema, order: orderJsonSchema, - matcher: matcherJsonSchema, ignoreCase: ignoreCaseJsonSchema, specialCharacters: specialCharactersJsonSchema, groups: groupsJsonSchema, diff --git a/rules/sort-imports.ts b/rules/sort-imports.ts index f6cb9c70e..6f99331bd 100644 --- a/rules/sort-imports.ts +++ b/rules/sort-imports.ts @@ -7,7 +7,6 @@ import type { SortingNode } from '../typings' import { specialCharactersJsonSchema, ignoreCaseJsonSchema, - matcherJsonSchema, groupsJsonSchema, orderJsonSchema, typeJsonSchema, @@ -66,7 +65,6 @@ export type Options = [ newlinesBetween: 'ignore' | 'always' | 'never' specialCharacters: 'remove' | 'trim' | 'keep' groups: (Group[] | Group)[] - matcher: 'minimatch' | 'regex' environment: 'node' | 'bun' internalPattern: string[] sortSideEffects: boolean @@ -95,7 +93,6 @@ export default createEslintRule, MESSAGE_ID>({ properties: { type: typeJsonSchema, order: orderJsonSchema, - matcher: matcherJsonSchema, ignoreCase: ignoreCaseJsonSchema, specialCharacters: specialCharactersJsonSchema, internalPattern: { @@ -198,7 +195,6 @@ export default createEslintRule, MESSAGE_ID>({ sortSideEffects: false, newlinesBetween: 'always', maxLineLength: undefined, - matcher: 'minimatch', groups: [ 'type', ['builtin', 'external'], @@ -229,10 +225,8 @@ export default createEslintRule, MESSAGE_ID>({ 'object', 'unknown', ], - matcher: 'minimatch', customGroups: { type: {}, value: {} }, - internalPattern: - userOptions?.matcher === 'regex' ? ['^~/.*'] : ['~/**'], + internalPattern: ['^~/.*'], newlinesBetween: 'always', sortSideEffects: false, type: 'alphabetical', @@ -367,9 +361,7 @@ export default createEslintRule, MESSAGE_ID>({ let isInternal = (value: string) => options.internalPattern.length && - options.internalPattern.some(pattern => - matches(value, pattern, options.matcher), - ) + options.internalPattern.some(pattern => matches(value, pattern)) let isCoreModule = (value: string) => { let bunModules = [ diff --git a/rules/sort-interfaces.ts b/rules/sort-interfaces.ts index 490cb8a5c..9cb8500ec 100644 --- a/rules/sort-interfaces.ts +++ b/rules/sort-interfaces.ts @@ -5,7 +5,6 @@ import { specialCharactersJsonSchema, customGroupsJsonSchema, ignoreCaseJsonSchema, - matcherJsonSchema, groupsJsonSchema, orderJsonSchema, typeJsonSchema, @@ -47,7 +46,6 @@ export type Options = [ newlinesBetween: 'ignore' | 'always' | 'never' specialCharacters: 'remove' | 'trim' | 'keep' groups: (Group[] | Group)[] - matcher: 'minimatch' | 'regex' partitionByNewLine: boolean ignorePattern: string[] order: 'desc' | 'asc' @@ -60,7 +58,6 @@ const defaultOptions: Required[0]> = { partitionByNewLine: false, type: 'alphabetical', groupKind: 'mixed', - matcher: 'minimatch', newlinesBetween: 'ignore', ignorePattern: [], ignoreCase: true, @@ -84,7 +81,6 @@ export default createEslintRule, MESSAGE_ID>({ properties: { type: typeJsonSchema, order: orderJsonSchema, - matcher: matcherJsonSchema, ignoreCase: ignoreCaseJsonSchema, specialCharacters: specialCharactersJsonSchema, ignorePattern: { @@ -151,9 +147,7 @@ export default createEslintRule, MESSAGE_ID>({ let partitionComment = options.partitionByComment if ( - !options.ignorePattern.some(pattern => - matches(node.id.name, pattern, options.matcher), - ) + !options.ignorePattern.some(pattern => matches(node.id.name, pattern)) ) { let formattedMembers: SortingNode[][] = node.body.body.reduce( (accumulator: SortingNode[][], element) => { @@ -220,7 +214,6 @@ export default createEslintRule, MESSAGE_ID>({ hasPartitionComment( partitionComment, getCommentsBefore(element, sourceCode), - options.matcher, )) || (options.partitionByNewLine && lastElement && diff --git a/rules/sort-intersection-types.ts b/rules/sort-intersection-types.ts index 09d50a150..7c160d1cc 100644 --- a/rules/sort-intersection-types.ts +++ b/rules/sort-intersection-types.ts @@ -4,7 +4,6 @@ import { partitionByCommentJsonSchema, specialCharactersJsonSchema, ignoreCaseJsonSchema, - matcherJsonSchema, groupsJsonSchema, orderJsonSchema, typeJsonSchema, @@ -55,7 +54,6 @@ type Options = [ partitionByComment: string[] | boolean | string newlinesBetween: 'ignore' | 'always' | 'never' specialCharacters: 'remove' | 'trim' | 'keep' - matcher: 'minimatch' | 'regex' groups: (Group[] | Group)[] partitionByNewLine: boolean order: 'desc' | 'asc' @@ -68,7 +66,6 @@ const defaultOptions: Required = { ignoreCase: true, specialCharacters: 'keep', order: 'asc', - matcher: 'minimatch', newlinesBetween: 'ignore', partitionByComment: false, partitionByNewLine: false, @@ -89,7 +86,6 @@ export default createEslintRule({ properties: { type: typeJsonSchema, order: orderJsonSchema, - matcher: matcherJsonSchema, ignoreCase: ignoreCaseJsonSchema, specialCharacters: specialCharactersJsonSchema, groups: groupsJsonSchema, @@ -229,7 +225,6 @@ export default createEslintRule({ hasPartitionComment( partitionComment, getCommentsBefore(type, sourceCode, '&'), - options.matcher, )) || (options.partitionByNewLine && lastSortingNode && diff --git a/rules/sort-jsx-props.ts b/rules/sort-jsx-props.ts index 1906a6e3b..fbe359d0e 100644 --- a/rules/sort-jsx-props.ts +++ b/rules/sort-jsx-props.ts @@ -6,7 +6,6 @@ import { specialCharactersJsonSchema, customGroupsJsonSchema, ignoreCaseJsonSchema, - matcherJsonSchema, groupsJsonSchema, orderJsonSchema, typeJsonSchema, @@ -38,7 +37,6 @@ type Options = [ type: 'alphabetical' | 'line-length' | 'natural' specialCharacters: 'remove' | 'trim' | 'keep' groups: (Group[] | Group)[] - matcher: 'minimatch' | 'regex' ignorePattern: string[] order: 'desc' | 'asc' ignoreCase: boolean @@ -50,7 +48,6 @@ const defaultOptions: Required[0]> = { ignorePattern: [], ignoreCase: true, specialCharacters: 'keep', - matcher: 'minimatch', customGroups: {}, order: 'asc', groups: [], @@ -70,7 +67,6 @@ export default createEslintRule, MESSAGE_ID>({ properties: { type: typeJsonSchema, order: orderJsonSchema, - matcher: matcherJsonSchema, ignoreCase: ignoreCaseJsonSchema, specialCharacters: specialCharactersJsonSchema, ignorePattern: { @@ -114,7 +110,7 @@ export default createEslintRule, MESSAGE_ID>({ if (options.ignorePattern.length) { let tagName = sourceCode.getText(node.openingElement.name) shouldIgnore = options.ignorePattern.some(pattern => - matches(tagName, pattern, options.matcher), + matches(tagName, pattern), ) } diff --git a/rules/sort-maps.ts b/rules/sort-maps.ts index 0847652b4..6b413b304 100644 --- a/rules/sort-maps.ts +++ b/rules/sort-maps.ts @@ -6,7 +6,6 @@ import { partitionByCommentJsonSchema, specialCharactersJsonSchema, ignoreCaseJsonSchema, - matcherJsonSchema, orderJsonSchema, typeJsonSchema, } from '../utils/common-json-schemas' @@ -32,7 +31,6 @@ type Options = [ type: 'alphabetical' | 'line-length' | 'natural' partitionByComment: string[] | boolean | string specialCharacters: 'remove' | 'trim' | 'keep' - matcher: 'minimatch' | 'regex' partitionByNewLine: boolean order: 'desc' | 'asc' ignoreCase: boolean @@ -44,7 +42,6 @@ const defaultOptions: Required = { order: 'asc', ignoreCase: true, specialCharacters: 'keep', - matcher: 'minimatch', partitionByComment: false, partitionByNewLine: false, } @@ -63,7 +60,6 @@ export default createEslintRule({ properties: { type: typeJsonSchema, order: orderJsonSchema, - matcher: matcherJsonSchema, ignoreCase: ignoreCaseJsonSchema, specialCharacters: specialCharactersJsonSchema, partitionByComment: { @@ -154,7 +150,6 @@ export default createEslintRule({ hasPartitionComment( partitionComment, getCommentsBefore(element, sourceCode), - options.matcher, )) || (options.partitionByNewLine && lastSortingNode && diff --git a/rules/sort-named-exports.ts b/rules/sort-named-exports.ts index 85aeb21ab..664630b70 100644 --- a/rules/sort-named-exports.ts +++ b/rules/sort-named-exports.ts @@ -4,7 +4,6 @@ import { partitionByCommentJsonSchema, specialCharactersJsonSchema, ignoreCaseJsonSchema, - matcherJsonSchema, orderJsonSchema, typeJsonSchema, } from '../utils/common-json-schemas' @@ -31,7 +30,6 @@ type Options = [ type: 'alphabetical' | 'line-length' | 'natural' partitionByComment: string[] | boolean | string specialCharacters: 'remove' | 'trim' | 'keep' - matcher: 'minimatch' | 'regex' partitionByNewLine: boolean order: 'desc' | 'asc' ignoreCase: boolean @@ -43,7 +41,6 @@ const defaultOptions: Required = { order: 'asc', ignoreCase: true, specialCharacters: 'keep', - matcher: 'minimatch', partitionByNewLine: false, partitionByComment: false, groupKind: 'mixed', @@ -63,7 +60,6 @@ export default createEslintRule({ properties: { type: typeJsonSchema, order: orderJsonSchema, - matcher: matcherJsonSchema, ignoreCase: ignoreCaseJsonSchema, specialCharacters: specialCharactersJsonSchema, groupKind: { @@ -130,7 +126,6 @@ export default createEslintRule({ hasPartitionComment( partitionComment, getCommentsBefore(specifier, sourceCode), - options.matcher, )) || (options.partitionByNewLine && lastSortingNode && diff --git a/rules/sort-named-imports.ts b/rules/sort-named-imports.ts index 4dfd7b815..910d82132 100644 --- a/rules/sort-named-imports.ts +++ b/rules/sort-named-imports.ts @@ -4,7 +4,6 @@ import { partitionByCommentJsonSchema, specialCharactersJsonSchema, ignoreCaseJsonSchema, - matcherJsonSchema, orderJsonSchema, typeJsonSchema, } from '../utils/common-json-schemas' @@ -31,7 +30,6 @@ type Options = [ type: 'alphabetical' | 'line-length' | 'natural' partitionByComment: string[] | boolean | string specialCharacters: 'remove' | 'trim' | 'keep' - matcher: 'minimatch' | 'regex' partitionByNewLine: boolean order: 'desc' | 'asc' ignoreAlias: boolean @@ -45,7 +43,6 @@ const defaultOptions: Required = { groupKind: 'mixed', ignoreCase: true, specialCharacters: 'keep', - matcher: 'minimatch', partitionByNewLine: false, partitionByComment: false, order: 'asc', @@ -65,7 +62,6 @@ export default createEslintRule({ properties: { type: typeJsonSchema, order: orderJsonSchema, - matcher: matcherJsonSchema, ignoreCase: ignoreCaseJsonSchema, specialCharacters: specialCharactersJsonSchema, ignoreAlias: { @@ -146,7 +142,6 @@ export default createEslintRule({ hasPartitionComment( partitionComment, getCommentsBefore(specifier, sourceCode), - options.matcher, )) || (options.partitionByNewLine && lastSortingNode && diff --git a/rules/sort-object-types.ts b/rules/sort-object-types.ts index c8c6d6bf2..9f12cdf84 100644 --- a/rules/sort-object-types.ts +++ b/rules/sort-object-types.ts @@ -7,7 +7,6 @@ import { specialCharactersJsonSchema, customGroupsJsonSchema, ignoreCaseJsonSchema, - matcherJsonSchema, groupsJsonSchema, orderJsonSchema, typeJsonSchema, @@ -48,7 +47,6 @@ type Options = [ newlinesBetween: 'ignore' | 'always' | 'never' specialCharacters: 'remove' | 'trim' | 'keep' groups: (Group[] | Group)[] - matcher: 'minimatch' | 'regex' partitionByNewLine: boolean order: 'desc' | 'asc' ignoreCase: boolean @@ -62,7 +60,6 @@ const defaultOptions: Required[0]> = { partitionByNewLine: false, type: 'alphabetical', groupKind: 'mixed', - matcher: 'minimatch', newlinesBetween: 'ignore', ignoreCase: true, specialCharacters: 'keep', @@ -85,7 +82,6 @@ export default createEslintRule, MESSAGE_ID>({ properties: { type: typeJsonSchema, order: orderJsonSchema, - matcher: matcherJsonSchema, ignoreCase: ignoreCaseJsonSchema, specialCharacters: specialCharactersJsonSchema, partitionByComment: { @@ -208,7 +204,6 @@ export default createEslintRule, MESSAGE_ID>({ hasPartitionComment( partitionComment, getCommentsBefore(member, sourceCode), - options.matcher, )) || (options.partitionByNewLine && lastSortingNode && diff --git a/rules/sort-objects.ts b/rules/sort-objects.ts index 19b9c5b2a..dc68f5ad4 100644 --- a/rules/sort-objects.ts +++ b/rules/sort-objects.ts @@ -7,7 +7,6 @@ import { specialCharactersJsonSchema, customGroupsJsonSchema, ignoreCaseJsonSchema, - matcherJsonSchema, groupsJsonSchema, orderJsonSchema, typeJsonSchema, @@ -52,7 +51,6 @@ type Options = [ partitionByComment: string[] | boolean | string newlinesBetween: 'ignore' | 'always' | 'never' specialCharacters: 'remove' | 'trim' | 'keep' - matcher: 'minimatch' | 'regex' groups: (Group[] | Group)[] partitionByNewLine: boolean styledComponents: boolean @@ -70,7 +68,6 @@ const defaultOptions: Required = { destructureOnly: false, type: 'alphabetical', ignorePattern: [], - matcher: 'minimatch', newlinesBetween: 'ignore', ignoreCase: true, specialCharacters: 'keep', @@ -93,7 +90,6 @@ export default createEslintRule({ properties: { type: typeJsonSchema, order: orderJsonSchema, - matcher: matcherJsonSchema, ignoreCase: ignoreCaseJsonSchema, specialCharacters: specialCharactersJsonSchema, partitionByComment: { @@ -179,9 +175,7 @@ export default createEslintRule({ parentId?.type === 'Identifier' ? parentId.name : null let checkMatch = (identifier: string) => - options.ignorePattern.some(pattern => - matches(identifier, pattern, options.matcher), - ) + options.ignorePattern.some(pattern => matches(identifier, pattern)) if (typeof varIdentifier === 'string' && checkMatch(varIdentifier)) { shouldIgnore = true @@ -379,11 +373,7 @@ export default createEslintRule({ lastProp && getLinesBetween(sourceCode, lastProp, propSortingNode)) || (options.partitionByComment && - hasPartitionComment( - options.partitionByComment, - comments, - options.matcher, - )) + hasPartitionComment(options.partitionByComment, comments)) ) { accumulator.push([]) } diff --git a/rules/sort-union-types.ts b/rules/sort-union-types.ts index 93d55d965..78bdf1bc5 100644 --- a/rules/sort-union-types.ts +++ b/rules/sort-union-types.ts @@ -4,7 +4,6 @@ import { partitionByCommentJsonSchema, specialCharactersJsonSchema, ignoreCaseJsonSchema, - matcherJsonSchema, groupsJsonSchema, orderJsonSchema, typeJsonSchema, @@ -55,7 +54,6 @@ type Options = [ partitionByComment: string[] | boolean | string newlinesBetween: 'ignore' | 'always' | 'never' specialCharacters: 'remove' | 'trim' | 'keep' - matcher: 'minimatch' | 'regex' groups: (Group[] | Group)[] partitionByNewLine: boolean order: 'desc' | 'asc' @@ -69,7 +67,6 @@ const defaultOptions: Required = { specialCharacters: 'keep', order: 'asc', groups: [], - matcher: 'minimatch', newlinesBetween: 'ignore', partitionByNewLine: false, partitionByComment: false, @@ -89,7 +86,6 @@ export default createEslintRule({ properties: { type: typeJsonSchema, order: orderJsonSchema, - matcher: matcherJsonSchema, ignoreCase: ignoreCaseJsonSchema, specialCharacters: specialCharactersJsonSchema, groups: groupsJsonSchema, @@ -229,7 +225,6 @@ export default createEslintRule({ hasPartitionComment( partitionComment, getCommentsBefore(type, sourceCode, '|'), - options.matcher, )) || (options.partitionByNewLine && lastSortingNode && diff --git a/rules/sort-variable-declarations.ts b/rules/sort-variable-declarations.ts index b828a9f0f..b569a9dcb 100644 --- a/rules/sort-variable-declarations.ts +++ b/rules/sort-variable-declarations.ts @@ -6,7 +6,6 @@ import { partitionByCommentJsonSchema, specialCharactersJsonSchema, ignoreCaseJsonSchema, - matcherJsonSchema, orderJsonSchema, typeJsonSchema, } from '../utils/common-json-schemas' @@ -36,7 +35,6 @@ type Options = [ type: 'alphabetical' | 'line-length' | 'natural' partitionByComment: string[] | boolean | string specialCharacters: 'remove' | 'trim' | 'keep' - matcher: 'minimatch' | 'regex' partitionByNewLine: boolean order: 'desc' | 'asc' ignoreCase: boolean @@ -48,7 +46,6 @@ const defaultOptions: Required = { ignoreCase: true, specialCharacters: 'keep', partitionByNewLine: false, - matcher: 'minimatch', partitionByComment: false, order: 'asc', } @@ -67,7 +64,6 @@ export default createEslintRule({ properties: { type: typeJsonSchema, order: orderJsonSchema, - matcher: matcherJsonSchema, ignoreCase: ignoreCaseJsonSchema, specialCharacters: specialCharactersJsonSchema, partitionByComment: { @@ -215,7 +211,6 @@ export default createEslintRule({ hasPartitionComment( partitionComment, getCommentsBefore(declaration, sourceCode), - options.matcher, )) || (options.partitionByNewLine && lastSortingNode && diff --git a/test/get-settings.test.ts b/test/get-settings.test.ts index 9a9dbee10..a3c0ee70a 100644 --- a/test/get-settings.test.ts +++ b/test/get-settings.test.ts @@ -25,7 +25,6 @@ describe('get-settings', () => { specialCharacters: 'keep', ignorePattern: [], ignoreCase: true, - matcher: 'regex', order: 'asc', type: 'alphabetical', } diff --git a/test/sort-array-includes.test.ts b/test/sort-array-includes.test.ts index 83cec7126..2fae9a662 100644 --- a/test/sort-array-includes.test.ts +++ b/test/sort-array-includes.test.ts @@ -460,7 +460,7 @@ describe(ruleName, () => { options: [ { ...options, - partitionByComment: 'Part**', + partitionByComment: '^Part*', }, ], errors: [ @@ -591,7 +591,7 @@ describe(ruleName, () => { options: [ { ...options, - partitionByComment: 'Part: *', + partitionByComment: '^Part: *', groupKind: 'spreads-first', }, ], @@ -617,7 +617,7 @@ describe(ruleName, () => { ) }) - ruleTester.run(`${ruleName}(${type}): allows to use regex matcher`, rule, { + ruleTester.run(`${ruleName}(${type}): allows to use regex`, rule, { valid: [ { code: dedent` @@ -632,7 +632,6 @@ describe(ruleName, () => { options: [ { ...options, - matcher: 'regex', partitionByComment: ['^(?!.*foo).*$'], }, ], diff --git a/test/sort-classes.test.ts b/test/sort-classes.test.ts index c004a6dda..4c86b4cf8 100644 --- a/test/sort-classes.test.ts +++ b/test/sort-classes.test.ts @@ -7105,7 +7105,7 @@ describe(ruleName, () => { }) ruleTester.run( - `${ruleName}: allows to use regex matcher for element names in custom groups`, + `${ruleName}: allows to use regex for element names in custom groups`, rule, { valid: [ @@ -7121,7 +7121,6 @@ describe(ruleName, () => { options: [ { type: 'alphabetical', - matcher: 'regex', groups: ['unknown', 'elementsWithoutFoo'], customGroups: [ { @@ -7138,7 +7137,7 @@ describe(ruleName, () => { ) ruleTester.run( - `${ruleName}: allows to use regex matcher for element values in custom groups`, + `${ruleName}: allows to use regex for element values in custom groups`, rule, { valid: [ @@ -7154,7 +7153,6 @@ describe(ruleName, () => { options: [ { type: 'alphabetical', - matcher: 'regex', groups: ['unknown', 'elementsWithoutFoo'], customGroups: [ { @@ -7171,7 +7169,7 @@ describe(ruleName, () => { ) ruleTester.run( - `${ruleName}: allows to use regex matcher for decorator names in custom groups`, + `${ruleName}: allows to use regex for decorator names in custom groups`, rule, { valid: [ @@ -7189,7 +7187,6 @@ describe(ruleName, () => { options: [ { type: 'alphabetical', - matcher: 'regex', groups: ['decoratorsWithFoo', 'unknown'], customGroups: [ { @@ -7677,7 +7674,7 @@ describe(ruleName, () => { }) ruleTester.run( - `${ruleName}: allows to use regex matcher for partition comments`, + `${ruleName}: allows to use regex for partition comments`, rule, { valid: [ @@ -7694,7 +7691,6 @@ describe(ruleName, () => { options: [ { type: 'alphabetical', - matcher: 'regex', partitionByComment: ['^(?!.*foo).*$'], }, ], diff --git a/test/sort-decorators.test.ts b/test/sort-decorators.test.ts index b952c37d9..606dfd99b 100644 --- a/test/sort-decorators.test.ts +++ b/test/sort-decorators.test.ts @@ -431,7 +431,7 @@ describe(ruleName, () => { ...options, groups: ['unknown', 'error'], customGroups: { - error: '*Error', + error: 'Error$', }, }, ], @@ -452,7 +452,7 @@ describe(ruleName, () => { ) ruleTester.run( - `${ruleName}(${type}): allows to use regex matcher for custom groups`, + `${ruleName}(${type}): allows to use regex for custom groups`, rule, { valid: [ @@ -492,7 +492,6 @@ describe(ruleName, () => { options: [ { ...options, - matcher: 'regex', groups: ['unknown', 'elementsWithoutFoo'], customGroups: { elementsWithoutFoo: '^(?!.*Foo).*$', @@ -659,7 +658,7 @@ describe(ruleName, () => { options: [ { ...options, - partitionByComment: 'Part**', + partitionByComment: '^Part*', }, ], errors: duplicate5Times([ @@ -875,7 +874,7 @@ describe(ruleName, () => { ) ruleTester.run( - `${ruleName}(${type}): allows to use regex matcher for partition comments`, + `${ruleName}(${type}): allows to use regex for partition comments`, rule, { valid: [ @@ -920,7 +919,6 @@ describe(ruleName, () => { options: [ { ...options, - matcher: 'regex', partitionByComment: ['^(?!.*foo).*$'], }, ], @@ -1431,7 +1429,7 @@ describe(ruleName, () => { ...options, groups: ['unknown', 'error'], customGroups: { - error: '*Error', + error: 'Error$', }, }, ], @@ -1452,7 +1450,7 @@ describe(ruleName, () => { ) ruleTester.run( - `${ruleName}(${type}): allows to use regex matcher for custom groups`, + `${ruleName}(${type}): allows to use regex for custom groups`, rule, { valid: [ @@ -1492,7 +1490,6 @@ describe(ruleName, () => { options: [ { ...options, - matcher: 'regex', groups: ['unknown', 'elementsWithoutFoo'], customGroups: { elementsWithoutFoo: '^(?!.*Foo).*$', @@ -1659,7 +1656,7 @@ describe(ruleName, () => { options: [ { ...options, - partitionByComment: 'Part**', + partitionByComment: '^Part*', }, ], errors: duplicate5Times([ @@ -1875,7 +1872,7 @@ describe(ruleName, () => { ) ruleTester.run( - `${ruleName}(${type}): allows to use regex matcher for partition comments`, + `${ruleName}(${type}): allows to use regex for partition comments`, rule, { valid: [ @@ -1920,7 +1917,6 @@ describe(ruleName, () => { options: [ { ...options, - matcher: 'regex', partitionByComment: ['^(?!.*foo).*$'], }, ], @@ -2425,7 +2421,7 @@ describe(ruleName, () => { ...options, groups: ['unknown', 'error'], customGroups: { - error: '*Error', + error: 'Error$', }, }, ], @@ -2446,7 +2442,7 @@ describe(ruleName, () => { ) ruleTester.run( - `${ruleName}(${type}): allows to use regex matcher for custom groups`, + `${ruleName}(${type}): allows to use regex for custom groups`, rule, { valid: [ @@ -2486,7 +2482,6 @@ describe(ruleName, () => { options: [ { ...options, - matcher: 'regex', groups: ['unknown', 'elementsWithoutFoo'], customGroups: { elementsWithoutFoo: '^(?!.*Foo).*$', @@ -2653,7 +2648,7 @@ describe(ruleName, () => { options: [ { ...options, - partitionByComment: 'Part**', + partitionByComment: '^Part*', }, ], errors: duplicate5Times([ @@ -2876,7 +2871,7 @@ describe(ruleName, () => { ) ruleTester.run( - `${ruleName}(${type}): allows to use regex matcher for partition comments`, + `${ruleName}(${type}): allows to use regex for partition comments`, rule, { valid: [ @@ -2921,7 +2916,6 @@ describe(ruleName, () => { options: [ { ...options, - matcher: 'regex', partitionByComment: ['^(?!.*foo).*$'], }, ], diff --git a/test/sort-enums.test.ts b/test/sort-enums.test.ts index e90c12695..2d3765095 100644 --- a/test/sort-enums.test.ts +++ b/test/sort-enums.test.ts @@ -296,7 +296,7 @@ describe(ruleName, () => { options: [ { ...options, - partitionByComment: 'Part**', + partitionByComment: '^Part*', }, ], errors: [ @@ -400,7 +400,7 @@ describe(ruleName, () => { ) ruleTester.run( - `${ruleName}(${type}): allows to use regex matcher for partition comments`, + `${ruleName}(${type}): allows to use regex for partition comments`, rule, { valid: [ @@ -417,7 +417,6 @@ describe(ruleName, () => { options: [ { ...options, - matcher: 'regex', partitionByComment: ['^(?!.*foo).*$'], }, ], @@ -918,7 +917,7 @@ describe(ruleName, () => { options: [ { ...options, - partitionByComment: 'Part**', + partitionByComment: '^Part*', }, ], errors: [ @@ -1401,7 +1400,7 @@ describe(ruleName, () => { options: [ { ...options, - partitionByComment: 'Part**', + partitionByComment: '^Part*', }, ], errors: [ @@ -2090,7 +2089,7 @@ describe(ruleName, () => { options: [ { type: 'alphabetical', - partitionByComment: 'Part**', + partitionByComment: '^Part*', }, ], errors: [ diff --git a/test/sort-exports.test.ts b/test/sort-exports.test.ts index 3d50f6e52..2ff4d1c56 100644 --- a/test/sort-exports.test.ts +++ b/test/sort-exports.test.ts @@ -248,7 +248,7 @@ describe(ruleName, () => { options: [ { ...options, - partitionByComment: 'Part**', + partitionByComment: '^Part*', }, ], errors: [ @@ -347,7 +347,7 @@ describe(ruleName, () => { }) ruleTester.run( - `${ruleName}(${type}): allows to use regex matcher for partition comments`, + `${ruleName}(${type}): allows to use regex for partition comments`, rule, { valid: [ @@ -362,7 +362,6 @@ describe(ruleName, () => { options: [ { ...options, - matcher: 'regex', partitionByComment: ['^(?!.*foo).*$'], }, ], diff --git a/test/sort-heritage-clauses.test.ts b/test/sort-heritage-clauses.test.ts index 1f4ebf1f4..df73775a4 100644 --- a/test/sort-heritage-clauses.test.ts +++ b/test/sort-heritage-clauses.test.ts @@ -258,7 +258,7 @@ describe(ruleName, () => { ) ruleTester.run( - `${ruleName}(${type}): allows to use regex matcher for custom groups`, + `${ruleName}(${type}): allows to use regex for custom groups`, rule, { valid: [ @@ -274,7 +274,6 @@ describe(ruleName, () => { options: [ { ...options, - matcher: 'regex', groups: ['unknown', 'elementsWithoutFoo'], customGroups: { elementsWithoutFoo: '^(?!.*Foo).*$', @@ -599,7 +598,7 @@ describe(ruleName, () => { ) ruleTester.run( - `${ruleName}(${type}): allows to use regex matcher for custom groups`, + `${ruleName}(${type}): allows to use regex for custom groups`, rule, { valid: [ @@ -615,7 +614,6 @@ describe(ruleName, () => { options: [ { ...options, - matcher: 'regex', groups: ['unknown', 'elementsWithoutFoo'], customGroups: { elementsWithoutFoo: '^(?!.*Foo).*$', @@ -922,7 +920,7 @@ describe(ruleName, () => { ) ruleTester.run( - `${ruleName}(${type}): allows to use regex matcher for custom groups`, + `${ruleName}(${type}): allows to use regex for custom groups`, rule, { valid: [ @@ -938,7 +936,6 @@ describe(ruleName, () => { options: [ { ...options, - matcher: 'regex', groups: ['unknown', 'elementsWithoutFoo'], customGroups: { elementsWithoutFoo: '^(?!.*Foo).*$', diff --git a/test/sort-imports.test.ts b/test/sort-imports.test.ts index 98a7a83b6..67435dc6a 100644 --- a/test/sort-imports.test.ts +++ b/test/sort-imports.test.ts @@ -96,7 +96,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -167,7 +167,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -272,7 +272,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'never', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -311,7 +311,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'never', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -385,7 +385,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -422,7 +422,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -475,7 +475,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -515,7 +515,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -564,7 +564,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -593,7 +593,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -640,7 +640,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -670,7 +670,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -704,7 +704,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -740,7 +740,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -775,7 +775,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -812,7 +812,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -847,7 +847,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: ['builtin-type', 'type'], }, ], @@ -877,7 +877,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -1000,11 +1000,11 @@ describe(ruleName, () => { ...options, customGroups: { type: { - primary: ['t', '@a/**'], + primary: ['t', '@a/.+'], }, value: { - primary: ['t', '@a/**'], - secondary: '@b/**', + primary: ['t', '@a/.+'], + secondary: '@b/.+', }, }, groups: [ @@ -1119,7 +1119,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['#**'], + internalPattern: ['#.+'], groups: [ 'type', ['builtin', 'external'], @@ -1163,7 +1163,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['#**'], + internalPattern: ['#.+'], groups: [ 'type', ['builtin', 'external'], @@ -1307,7 +1307,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -1361,7 +1361,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -1435,7 +1435,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: ['external', 'side-effect', 'unknown'], sortSideEffects: false, }, @@ -1451,7 +1451,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: ['external', 'side-effect', 'unknown'], sortSideEffects: false, }, @@ -1479,7 +1479,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: ['external', 'side-effect', 'unknown'], sortSideEffects: false, }, @@ -1525,7 +1525,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: ['external', 'side-effect', 'unknown'], sortSideEffects: true, }, @@ -2184,7 +2184,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -2255,7 +2255,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -2360,7 +2360,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'never', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -2399,7 +2399,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'never', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -2473,7 +2473,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -2510,7 +2510,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -2563,7 +2563,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -2603,7 +2603,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -2652,7 +2652,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -2681,7 +2681,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -2728,7 +2728,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -2758,7 +2758,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -2792,7 +2792,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -2828,7 +2828,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -2863,7 +2863,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -2900,7 +2900,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -2935,7 +2935,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: ['builtin-type', 'type'], }, ], @@ -2965,7 +2965,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -3088,11 +3088,11 @@ describe(ruleName, () => { ...options, customGroups: { type: { - primary: ['t', '@a/**'], + primary: ['t', '@a/.+'], }, value: { - primary: ['t', '@a/**'], - secondary: '@b/**', + primary: ['t', '@a/.+'], + secondary: '@b/.+', }, }, groups: [ @@ -3207,7 +3207,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['#**'], + internalPattern: ['#.+'], groups: [ 'type', ['builtin', 'external'], @@ -3251,7 +3251,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['#**'], + internalPattern: ['#.+'], groups: [ 'type', ['builtin', 'external'], @@ -3395,7 +3395,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -3449,7 +3449,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -3523,7 +3523,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: ['external', 'side-effect', 'unknown'], sortSideEffects: false, }, @@ -3539,7 +3539,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: ['external', 'side-effect', 'unknown'], sortSideEffects: false, }, @@ -3567,7 +3567,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: ['external', 'side-effect', 'unknown'], sortSideEffects: false, }, @@ -3613,7 +3613,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: ['external', 'side-effect', 'unknown'], sortSideEffects: true, }, @@ -3715,7 +3715,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -3786,7 +3786,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -3912,7 +3912,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'never', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -3951,7 +3951,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'never', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -4025,7 +4025,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -4062,7 +4062,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -4115,7 +4115,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -4155,7 +4155,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -4204,7 +4204,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -4233,7 +4233,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -4280,7 +4280,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -4314,7 +4314,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -4350,7 +4350,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -4385,7 +4385,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -4422,7 +4422,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -4457,7 +4457,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: ['builtin-type', 'type'], }, ], @@ -4487,7 +4487,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -4610,11 +4610,11 @@ describe(ruleName, () => { ...options, customGroups: { type: { - primary: ['t', '@a/**'], + primary: ['t', '@a/.+'], }, value: { - primary: ['t', '@a/**'], - secondary: '@b/**', + primary: ['t', '@a/.+'], + secondary: '@b/.+', }, }, groups: [ @@ -4722,7 +4722,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['#**'], + internalPattern: ['#.+'], groups: [ 'type', ['builtin', 'external'], @@ -4766,7 +4766,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['#**'], + internalPattern: ['#.+'], groups: [ 'type', ['builtin', 'external'], @@ -4992,7 +4992,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -5046,7 +5046,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: [ 'type', ['builtin', 'external'], @@ -5127,7 +5127,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: ['external', 'side-effect', 'unknown'], sortSideEffects: false, }, @@ -5143,7 +5143,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: ['external', 'side-effect', 'unknown'], sortSideEffects: false, }, @@ -5171,7 +5171,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: ['external', 'side-effect', 'unknown'], sortSideEffects: false, }, @@ -5217,7 +5217,7 @@ describe(ruleName, () => { { ...options, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], groups: ['external', 'side-effect', 'unknown'], sortSideEffects: true, }, @@ -5522,21 +5522,21 @@ describe(ruleName, () => { ], customGroups: { value: { - stores: ['~/stores/**'], - services: ['~/services/**'], - validators: ['~/validators/**'], - utils: ['~/utils/**'], - logics: ['~/logics/**'], - composable: ['~/composable/**'], - ui: ['~/ui/**'], - components: ['~/components/**'], - pages: ['~/pages/**'], - widgets: ['~/widgets/**'], - assets: ['~/assets/**'], + stores: ['^~/stores/.+'], + services: ['^~/services/.+'], + validators: ['^~/validators/.+'], + utils: ['^~/utils/.+'], + logics: ['^~/logics/.+'], + composable: ['^~/composable/.+'], + ui: ['^~/ui/.+'], + components: ['^~/components/.+'], + pages: ['^~/pages/.+'], + widgets: ['^~/widgets/.+'], + assets: ['^~/assets/.+'], }, }, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], }, ], }, @@ -5609,21 +5609,21 @@ describe(ruleName, () => { ], customGroups: { value: { - stores: ['~/stores/**'], - services: ['~/services/**'], - validators: ['~/validators/**'], - utils: ['~/utils/**'], - logics: ['~/logics/**'], - composable: ['~/composable/**'], - ui: ['~/ui/**'], - components: ['~/components/**'], - pages: ['~/pages/**'], - widgets: ['~/widgets/**'], - assets: ['~/assets/**'], + stores: ['~/stores/.+'], + services: ['~/services/.+'], + validators: ['~/validators/.+'], + utils: ['~/utils/.+'], + logics: ['~/logics/.+'], + composable: ['~/composable/.+'], + ui: ['~/ui/.+'], + components: ['~/components/.+'], + pages: ['~/pages/.+'], + widgets: ['~/widgets/.+'], + assets: ['~/assets/.+'], }, }, newlinesBetween: 'always', - internalPattern: ['~/**'], + internalPattern: ['^~/.*'], }, ], errors: [ @@ -5780,114 +5780,5 @@ describe(ruleName, () => { ).not.toThrow(expectedThrownError) }) }) - - describe(`${ruleName}: allows to use regex matcher`, () => { - let options = { - type: 'alphabetical', - ignoreCase: true, - order: 'asc', - matcher: 'regex', - } as const - - ruleTester.run( - `${ruleName}: uses default internalPattern for regex`, - rule, - { - valid: [ - { - code: dedent` - import type { T } from 't' - - import { a1, a2, a3 } from 'a' - - import { b1, b2 } from '~/b' - import { c1, c2, c3 } from '~/c' - - import { e1, e2, e3 } from '../../e' - `, - options: [ - { - ...options, - groups: ['type', 'external', 'internal', 'parent'], - }, - ], - }, - ], - invalid: [], - }, - ) - - ruleTester.run( - `${ruleName}: allows to use regex matcher for custom groups`, - rule, - { - valid: [ - { - code: dedent` - import type { T } from 't' - - import { i18n } from "../../../../../Basics/Language"; - import { i18n } from "../../../Basics/Language"; - - import { b1, b2 } from '~/b' - import { c1, c2, c3 } from '~/c' - `, - options: [ - { - ...options, - customGroups: { - value: { - primary: '^(?:\\.\\.\\/)+Basics\\/Language$', - }, - }, - groups: ['type', 'primary', 'unknown'], - }, - ], - }, - ], - invalid: [], - }, - ) - - ruleTester.run( - `${ruleName}: allows hash symbol in internal pattern`, - rule, - { - valid: [ - { - code: dedent` - import type { T } from 'a' - - import { a } from 'a' - - import type { S } from '#b' - - import { b1, b2 } from '#b' - import c from '#c' - - import { d } from '../d' - `, - options: [ - { - ...options, - internalPattern: ['^#.*$'], - groups: [ - 'type', - ['builtin', 'external'], - 'internal-type', - 'internal', - ['parent-type', 'sibling-type', 'index-type'], - ['parent', 'sibling', 'index'], - 'object', - 'unknown', - ], - }, - ], - }, - ], - invalid: [], - }, - ) - }) }) }) diff --git a/test/sort-interfaces.test.ts b/test/sort-interfaces.test.ts index 4681be688..ca1777e54 100644 --- a/test/sort-interfaces.test.ts +++ b/test/sort-interfaces.test.ts @@ -581,7 +581,7 @@ describe(ruleName, () => { ) ruleTester.run( - `${ruleName}(${type}): allows to use regex matcher for custom groups`, + `${ruleName}(${type}): allows to use regex for custom groups`, rule, { valid: [ @@ -597,7 +597,6 @@ describe(ruleName, () => { options: [ { ...options, - matcher: 'regex', groups: ['unknown', 'elementsWithoutFoo'], customGroups: { elementsWithoutFoo: '^(?!.*Foo).*$', @@ -848,7 +847,7 @@ describe(ruleName, () => { options: [ { ...options, - partitionByComment: 'Part**', + partitionByComment: '^Part*', }, ], errors: [ @@ -952,7 +951,7 @@ describe(ruleName, () => { ) ruleTester.run( - `${ruleName}(${type}): allows to use regex matcher for partition comments`, + `${ruleName}(${type}): allows to use regex for partition comments`, rule, { valid: [ @@ -969,7 +968,6 @@ describe(ruleName, () => { options: [ { ...options, - matcher: 'regex', partitionByComment: ['^(?!.*foo).*$'], }, ], @@ -1909,7 +1907,7 @@ describe(ruleName, () => { options: [ { ...options, - partitionByComment: 'Part**', + partitionByComment: '^Part*', }, ], errors: [ @@ -2761,7 +2759,7 @@ describe(ruleName, () => { { ...options, customGroups: { - callback: 'on*', + callback: '^on.+', }, groups: ['unknown', 'callback'], groupKind: 'required-first', @@ -2902,7 +2900,7 @@ describe(ruleName, () => { options: [ { ...options, - partitionByComment: 'Part**', + partitionByComment: '^Part*', }, ], errors: [ diff --git a/test/sort-intersection-types.test.ts b/test/sort-intersection-types.test.ts index 5799c1ac5..19a714666 100644 --- a/test/sort-intersection-types.test.ts +++ b/test/sort-intersection-types.test.ts @@ -517,7 +517,7 @@ describe(ruleName, () => { options: [ { ...options, - partitionByComment: 'Part**', + partitionByComment: '^Part*', }, ], errors: [ @@ -571,7 +571,7 @@ describe(ruleName, () => { options: [ { ...options, - partitionByComment: 'Part**', + partitionByComment: '^Part*', }, ], errors: [ @@ -672,7 +672,7 @@ describe(ruleName, () => { ) ruleTester.run( - `${ruleName}(${type}): allows to use regex matcher for partition comments`, + `${ruleName}(${type}): allows to use regex for partition comments`, rule, { valid: [ @@ -688,7 +688,6 @@ describe(ruleName, () => { options: [ { ...options, - matcher: 'regex', partitionByComment: ['^(?!.*foo).*$'], }, ], diff --git a/test/sort-jsx-props.test.ts b/test/sort-jsx-props.test.ts index 119ce6afc..cfeb037ff 100644 --- a/test/sort-jsx-props.test.ts +++ b/test/sort-jsx-props.test.ts @@ -495,7 +495,7 @@ describe(ruleName, () => { }) ruleTester.run( - `${ruleName}(${type}): allows to use regex matcher for custom groups`, + `${ruleName}(${type}): allows to use regex for custom groups`, rule, { valid: [ @@ -511,7 +511,6 @@ describe(ruleName, () => { options: [ { ...options, - matcher: 'regex', groups: ['unknown', 'elementsWithoutFoo'], customGroups: { elementsWithoutFoo: '^(?!.*Foo).*$', diff --git a/test/sort-maps.test.ts b/test/sort-maps.test.ts index 5ccacd739..b95efaec8 100644 --- a/test/sort-maps.test.ts +++ b/test/sort-maps.test.ts @@ -337,7 +337,7 @@ describe(ruleName, () => { options: [ { ...options, - partitionByComment: 'Part**', + partitionByComment: '^Part*', }, ], errors: [ @@ -440,13 +440,10 @@ describe(ruleName, () => { }, ) - ruleTester.run( - `${ruleName}(${type}): allows to use regex matcher`, - rule, - { - valid: [ - { - code: dedent` + ruleTester.run(`${ruleName}(${type}): allows to use regex`, rule, { + valid: [ + { + code: dedent` new Map([ ['e', 'e'], ['f', 'f'], @@ -455,18 +452,16 @@ describe(ruleName, () => { ['b', 'b'], ]) `, - options: [ - { - ...options, - matcher: 'regex', - partitionByComment: ['^(?!.*foo).*$'], - }, - ], - }, - ], - invalid: [], - }, - ) + options: [ + { + ...options, + partitionByComment: ['^(?!.*foo).*$'], + }, + ], + }, + ], + invalid: [], + }) }) ruleTester.run( diff --git a/test/sort-named-exports.test.ts b/test/sort-named-exports.test.ts index d8b4d681d..4393de745 100644 --- a/test/sort-named-exports.test.ts +++ b/test/sort-named-exports.test.ts @@ -251,7 +251,7 @@ describe(ruleName, () => { options: [ { ...options, - partitionByComment: 'Part**', + partitionByComment: '^Part*', groupKind: 'types-first', }, ], @@ -356,7 +356,7 @@ describe(ruleName, () => { ) ruleTester.run( - `${ruleName}(${type}): allows to use regex matcher for partition comments`, + `${ruleName}(${type}): allows to use regex for partition comments`, rule, { valid: [ @@ -373,7 +373,6 @@ describe(ruleName, () => { options: [ { ...options, - matcher: 'regex', partitionByComment: ['^(?!.*foo).*$'], }, ], diff --git a/test/sort-named-imports.test.ts b/test/sort-named-imports.test.ts index 6cdde8a3c..f66132d1e 100644 --- a/test/sort-named-imports.test.ts +++ b/test/sort-named-imports.test.ts @@ -500,7 +500,7 @@ describe(ruleName, () => { options: [ { ...options, - partitionByComment: 'Part**', + partitionByComment: '^Part*', groupKind: 'types-first', }, ], diff --git a/test/sort-object-types.test.ts b/test/sort-object-types.test.ts index 68e488e29..8a8210480 100644 --- a/test/sort-object-types.test.ts +++ b/test/sort-object-types.test.ts @@ -355,7 +355,7 @@ describe(ruleName, () => { ) ruleTester.run( - `${ruleName}(${type}): allows to use regex matcher for custom groups`, + `${ruleName}(${type}): allows to use regex for custom groups`, rule, { valid: [ @@ -371,7 +371,6 @@ describe(ruleName, () => { options: [ { ...options, - matcher: 'regex', groups: ['unknown', 'elementsWithoutFoo'], customGroups: { elementsWithoutFoo: '^(?!.*Foo).*$', @@ -543,7 +542,7 @@ describe(ruleName, () => { options: [ { ...options, - partitionByComment: 'Part**', + partitionByComment: '^Part*', }, ], errors: [ @@ -647,7 +646,7 @@ describe(ruleName, () => { ) ruleTester.run( - `${ruleName}(${type}): allows to use regex matcher for partition comments`, + `${ruleName}(${type}): allows to use regex for partition comments`, rule, { valid: [ @@ -664,7 +663,6 @@ describe(ruleName, () => { options: [ { ...options, - matcher: 'regex', partitionByComment: ['^(?!.*foo).*$'], }, ], diff --git a/test/sort-objects.test.ts b/test/sort-objects.test.ts index b89b7ad66..a6b557d7f 100644 --- a/test/sort-objects.test.ts +++ b/test/sort-objects.test.ts @@ -322,7 +322,7 @@ describe(ruleName, () => { }) ruleTester.run( - `${ruleName}(${type}): allows to use regex matcher for custom groups`, + `${ruleName}(${type}): allows to use regex for custom groups`, rule, { valid: [ @@ -338,7 +338,6 @@ describe(ruleName, () => { options: [ { ...options, - matcher: 'regex', groups: ['unknown', 'elementsWithoutFoo'], customGroups: { elementsWithoutFoo: '^(?!.*Foo).*$', @@ -1261,7 +1260,7 @@ describe(ruleName, () => { options: [ { ...options, - partitionByComment: 'Part**', + partitionByComment: '^Part*', }, ], errors: [ @@ -1362,7 +1361,7 @@ describe(ruleName, () => { options: [ { ...options, - partitionByComment: 'Part**', + partitionByComment: '^Part*', }, ], errors: [ @@ -1466,7 +1465,7 @@ describe(ruleName, () => { ) ruleTester.run( - `${ruleName}(${type}): allows to use regex matcher for partition comments`, + `${ruleName}(${type}): allows to use regex for partition comments`, rule, { valid: [ @@ -1483,7 +1482,6 @@ describe(ruleName, () => { options: [ { ...options, - matcher: 'regex', partitionByComment: ['^(?!.*foo).*$'], }, ], @@ -2508,7 +2506,7 @@ describe(ruleName, () => { options: [ { ...options, - partitionByComment: 'Part**', + partitionByComment: '^Part*', }, ], errors: [ @@ -3311,7 +3309,7 @@ describe(ruleName, () => { options: [ { ...options, - partitionByComment: 'Part**', + partitionByComment: '^Part*', }, ], errors: [ @@ -3695,7 +3693,7 @@ describe(ruleName, () => { `, options: [ { - ignorePattern: ['*Styles'], + ignorePattern: ['Styles$'], }, ], }, diff --git a/test/sort-sets.test.ts b/test/sort-sets.test.ts index 9e54f2ffd..ff401762f 100644 --- a/test/sort-sets.test.ts +++ b/test/sort-sets.test.ts @@ -460,7 +460,7 @@ describe(ruleName, () => { options: [ { ...options, - partitionByComment: 'Part**', + partitionByComment: '^Part*', }, ], errors: [ @@ -563,13 +563,10 @@ describe(ruleName, () => { }, ) - ruleTester.run( - `${ruleName}(${type}): allows to use regex matcher`, - rule, - { - valid: [ - { - code: dedent` + ruleTester.run(`${ruleName}(${type}): allows to use regex`, rule, { + valid: [ + { + code: dedent` new Set([ 'e', 'f', @@ -578,18 +575,16 @@ describe(ruleName, () => { 'b', ]) `, - options: [ - { - ...options, - matcher: 'regex', - partitionByComment: ['^(?!.*foo).*$'], - }, - ], - }, - ], - invalid: [], - }, - ) + options: [ + { + ...options, + partitionByComment: ['^(?!.*foo).*$'], + }, + ], + }, + ], + invalid: [], + }) }) ruleTester.run( diff --git a/test/sort-union-types.test.ts b/test/sort-union-types.test.ts index 0266b86fb..f9743b365 100644 --- a/test/sort-union-types.test.ts +++ b/test/sort-union-types.test.ts @@ -520,7 +520,7 @@ describe(ruleName, () => { options: [ { ...options, - partitionByComment: 'Part**', + partitionByComment: '^Part*', }, ], errors: [ @@ -574,7 +574,7 @@ describe(ruleName, () => { options: [ { ...options, - partitionByComment: 'Part**', + partitionByComment: '^Part*', }, ], errors: [ @@ -675,7 +675,7 @@ describe(ruleName, () => { ) ruleTester.run( - `${ruleName}(${type}): allows to use regex matcher for partition comments`, + `${ruleName}(${type}): allows to use regex for partition comments`, rule, { valid: [ @@ -691,7 +691,6 @@ describe(ruleName, () => { options: [ { ...options, - matcher: 'regex', partitionByComment: ['^(?!.*foo).*$'], }, ], diff --git a/test/sort-variable-declarations.test.ts b/test/sort-variable-declarations.test.ts index 845f2e1b9..fe27f09a1 100644 --- a/test/sort-variable-declarations.test.ts +++ b/test/sort-variable-declarations.test.ts @@ -745,7 +745,7 @@ describe(ruleName, () => { options: [ { ...options, - partitionByComment: 'Part**', + partitionByComment: '^Part*', }, ], errors: [ @@ -845,13 +845,10 @@ describe(ruleName, () => { }, ) - ruleTester.run( - `${ruleName}(${type}): allows to use regex matcher`, - rule, - { - valid: [ - { - code: dedent` + ruleTester.run(`${ruleName}(${type}): allows to use regex`, rule, { + valid: [ + { + code: dedent` const e = 'e', f = 'f', @@ -859,18 +856,16 @@ describe(ruleName, () => { a = 'a', b = 'b' `, - options: [ - { - ...options, - matcher: 'regex', - partitionByComment: ['^(?!.*foo).*$'], - }, - ], - }, - ], - invalid: [], - }, - ) + options: [ + { + ...options, + partitionByComment: ['^(?!.*foo).*$'], + }, + ], + }, + ], + invalid: [], + }) }) ruleTester.run( diff --git a/utils/common-json-schemas.ts b/utils/common-json-schemas.ts index 007f6664c..cdd0780e1 100644 --- a/utils/common-json-schemas.ts +++ b/utils/common-json-schemas.ts @@ -13,12 +13,6 @@ export let orderJsonSchema: JSONSchema4 = { type: 'string', } -export let matcherJsonSchema: JSONSchema4 = { - description: 'Specifies the string matcher.', - enum: ['minimatch', 'regex'], - type: 'string', -} - export let ignoreCaseJsonSchema: JSONSchema4 = { description: 'Controls whether sorting should be case-sensitive or not.', type: 'boolean', diff --git a/utils/get-node-range.ts b/utils/get-node-range.ts index a4e85a6eb..0f31a818d 100644 --- a/utils/get-node-range.ts +++ b/utils/get-node-range.ts @@ -11,7 +11,6 @@ export let getNodeRange = ( sourceCode: TSESLint.SourceCode, additionalOptions?: { partitionByComment?: string[] | boolean | string - matcher?: 'minimatch' | 'regex' }, ): TSESTree.Range => { let start = node.range.at(0)! @@ -34,20 +33,13 @@ export let getNodeRange = ( let comments = getCommentsBefore(node, sourceCode) let partitionComment = additionalOptions?.partitionByComment ?? false - let partitionCommentMatcher = additionalOptions?.matcher ?? 'minimatch' // Iterate on all comments starting from the bottom until we reach the last // of the comments, a newline between comments, or a partition comment let relevantTopComment: TSESTree.Comment | undefined for (let i = comments.length - 1; i >= 0; i--) { let comment = comments[i] - if ( - isPartitionComment( - partitionComment, - comment.value, - partitionCommentMatcher, - ) - ) { + if (isPartitionComment(partitionComment, comment.value)) { break } // Check for newlines between comments or between the first comment and diff --git a/utils/get-settings.ts b/utils/get-settings.ts index bd3f04ee9..8b461ddc9 100644 --- a/utils/get-settings.ts +++ b/utils/get-settings.ts @@ -4,7 +4,6 @@ export type Settings = Partial<{ type: 'alphabetical' | 'line-length' | 'natural' partitionByComment: string[] | boolean | string specialCharacters: 'remove' | 'trim' | 'keep' - matcher: 'minimatch' | 'regex' partitionByNewLine: boolean ignorePattern: string[] order: 'desc' | 'asc' @@ -25,7 +24,6 @@ export let getSettings = ( 'specialCharacters', 'ignorePattern', 'ignoreCase', - 'matcher', 'order', 'type', ] diff --git a/utils/is-partition-comment.ts b/utils/is-partition-comment.ts index 50993c4d9..45bf8694c 100644 --- a/utils/is-partition-comment.ts +++ b/utils/is-partition-comment.ts @@ -5,21 +5,15 @@ import { matches } from './matches' export let isPartitionComment = ( partitionComment: string[] | boolean | string, comment: string, - matcher: 'minimatch' | 'regex', ) => (Array.isArray(partitionComment) && - partitionComment.some(pattern => - matches(comment.trim(), pattern, matcher), - )) || + partitionComment.some(pattern => matches(comment.trim(), pattern))) || (typeof partitionComment === 'string' && - matches(comment.trim(), partitionComment, matcher)) || + matches(comment.trim(), partitionComment)) || partitionComment === true export let hasPartitionComment = ( partitionComment: string[] | boolean | string, comments: TSESTree.Comment[], - matcher: 'minimatch' | 'regex', ): boolean => - comments.some(comment => - isPartitionComment(partitionComment, comment.value, matcher), - ) + comments.some(comment => isPartitionComment(partitionComment, comment.value)) diff --git a/utils/make-fixes.ts b/utils/make-fixes.ts index 02702f004..606a35908 100644 --- a/utils/make-fixes.ts +++ b/utils/make-fixes.ts @@ -12,7 +12,6 @@ export const makeFixes = ( sourceCode: TSESLint.SourceCode, additionalOptions?: { partitionByComment: string[] | boolean | string - matcher: 'minimatch' | 'regex' }, ) => { let fixes: TSESLint.RuleFix[] = [] diff --git a/utils/matches.ts b/utils/matches.ts index 4fab95370..221bc87cb 100644 --- a/utils/matches.ts +++ b/utils/matches.ts @@ -1,17 +1,2 @@ -import { minimatch } from 'minimatch' - -export let matches = ( - value: string, - pattern: string, - type: 'minimatch' | 'regex', -) => { - switch (type) { - case 'regex': - return new RegExp(pattern).test(value) - case 'minimatch': - default: - return minimatch(value, pattern, { - nocomment: true, - }) - } -} +export let matches = (value: string, pattern: string) => + new RegExp(pattern).test(value) diff --git a/utils/use-groups.ts b/utils/use-groups.ts index 62f574bc0..0d39d6f9a 100644 --- a/utils/use-groups.ts +++ b/utils/use-groups.ts @@ -1,11 +1,10 @@ import { matches } from './matches' interface UseGroupProps { - matcher: 'minimatch' | 'regex' groups: (string[] | string)[] } -export let useGroups = ({ matcher, groups }: UseGroupProps) => { +export let useGroups = ({ groups }: UseGroupProps) => { let group: undefined | string // For lookup performance let groupsSet = new Set(groups.flat()) @@ -29,12 +28,12 @@ export let useGroups = ({ matcher, groups }: UseGroupProps) => { for (let [key, pattern] of Object.entries(customGroups)) { if ( Array.isArray(pattern) && - pattern.some(patternValue => matches(name, patternValue, matcher)) + pattern.some(patternValue => matches(name, patternValue)) ) { defineGroup(key, params.override) } - if (typeof pattern === 'string' && matches(name, pattern, matcher)) { + if (typeof pattern === 'string' && matches(name, pattern)) { defineGroup(key, params.override) } }