Skip to content

Commit

Permalink
fix(sort-modules): disable sorting for export decorated classes
Browse files Browse the repository at this point in the history
  • Loading branch information
hugop95 authored Nov 19, 2024
1 parent 191902a commit 84de1d4
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
9 changes: 9 additions & 0 deletions rules/sort-modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
49 changes: 49 additions & 0 deletions test/sort-modules.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,7 @@ describe(ruleName, () => {
},
)

/* Currently not handled correctly
ruleTester.run(
`${ruleName}(${type}): prioritize default over decorated`,
rule,
Expand Down Expand Up @@ -1036,6 +1037,7 @@ describe(ruleName, () => {
valid: [],
},
)
*/
})

describe(`${ruleName}(${type}): function modifiers priority`, () => {
Expand Down Expand Up @@ -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`, () => {
Expand Down

0 comments on commit 84de1d4

Please sign in to comment.