diff --git a/rules/sort-modules.ts b/rules/sort-modules.ts index 350b713a6..dcbdf8f1c 100644 --- a/rules/sort-modules.ts +++ b/rules/sort-modules.ts @@ -325,6 +325,15 @@ let analyzeModule = ({ continue } + if ( + selector === 'class' && + modifiers.includes('export') && + modifiers.includes('decorated') + ) { + // Not always handled correctly at the moment + continue + } + let { defineGroup, getGroup } = useGroups(options) for (let officialGroup of generatePredefinedGroups({ cache: cachedGroupsByModifiersAndSelectors, diff --git a/test/sort-modules.test.ts b/test/sort-modules.test.ts index d20726a3c..e0916cdde 100644 --- a/test/sort-modules.test.ts +++ b/test/sort-modules.test.ts @@ -959,6 +959,7 @@ describe(ruleName, () => { }, ) + /* Currently not handled correctly ruleTester.run( `${ruleName}(${type}): prioritize default over decorated`, rule, @@ -1036,6 +1037,7 @@ describe(ruleName, () => { valid: [], }, ) + */ }) describe(`${ruleName}(${type}): function modifiers priority`, () => { @@ -2375,6 +2377,53 @@ describe(ruleName, () => { }, ) }) + + ruleTester.run( + `${ruleName}(${type}): ignores exported decorated classes`, + rule, + { + invalid: [ + { + errors: [ + { + data: { + right: 'B', + left: 'C', + }, + messageId: 'unexpectedModulesOrder', + }, + ], + output: dedent` + @B + class B {} + + @A + export class A {} + + @C + class C {} + `, + code: dedent` + @C + class C {} + + @A + export class A {} + + @B + class B {} + `, + options: [ + { + ...options, + groups: ['unknown'], + }, + ], + }, + ], + valid: [], + }, + ) }) describe(`${ruleName}: sorting by natural order`, () => {