Skip to content

Commit

Permalink
fix: place static-block after static-property in default-options in s…
Browse files Browse the repository at this point in the history
…ort-classes
  • Loading branch information
hugop95 committed Sep 1, 2024
1 parent a6e8bdf commit 73b1b54
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
12 changes: 6 additions & 6 deletions docs/content/rules/sort-classes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ Allows you to use comments to separate the class members into logical groups. Th
default:
```
[
'static-block',
'index-signature',
'static-property',
'static-block',
['protected-property', 'protected-accessor-property'],
['private-property', 'private-accessor-property'],
['property', 'accessor-property'],
Expand Down Expand Up @@ -312,11 +312,6 @@ Example 2: (The most important group is written in the comments)
```ts
abstract class Example extends BaseExample {

// 'static-block'
static {
console.log("I am a static block");
}

// 'index-signature'
[key: string]: any;

Expand All @@ -326,6 +321,11 @@ abstract class Example extends BaseExample {
// 'declare-protected-static-readonly-property'
declare protected static readonly value: string;

// 'static-block'
static {
console.log("I am a static block");
}

// 'protected-abstract-override-readonly-decorated-property'
@SomeDecorator
protected abstract override readonly _value: number;
Expand Down
4 changes: 2 additions & 2 deletions rules/sort-classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,9 @@ export default createEslintRule<Options, MESSAGE_ID>({
ignoreCase: true,
partitionByComment: false,
groups: [
'static-block',
'index-signature',
'static-property',
'static-block',
['protected-property', 'protected-accessor-property'],
['private-property', 'private-accessor-property'],
['property', 'accessor-property'],
Expand All @@ -258,9 +258,9 @@ export default createEslintRule<Options, MESSAGE_ID>({

let options = complete(context.options.at(0), settings, {
groups: [
'static-block',
'index-signature',
'static-property',
'static-block',
['protected-property', 'protected-accessor-property'],
['private-property', 'private-accessor-property'],
['property', 'accessor-property'],
Expand Down
26 changes: 13 additions & 13 deletions test/sort-classes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5290,21 +5290,21 @@ describe(ruleName, () => {
protected protectedProperty
static {}
static staticProperty
[key: string]: string
static {}
}
`,
output: dedent`
class Class {
static {}
[key: string]: string
static staticProperty
static {}
protected accessor protectedAccessorProperty
protected protectedProperty
Expand Down Expand Up @@ -5417,6 +5417,15 @@ describe(ruleName, () => {
data: {
left: 'protectedProperty',
leftGroup: 'protected-property',
right: 'static',
rightGroup: 'static-block',
},
},
{
messageId: 'unexpectedClassesGroupOrder',
data: {
left: 'static',
leftGroup: 'static-block',
right: 'staticProperty',
rightGroup: 'static-property',
},
Expand All @@ -5430,15 +5439,6 @@ describe(ruleName, () => {
rightGroup: 'index-signature',
},
},
{
messageId: 'unexpectedClassesGroupOrder',
data: {
left: '[key: string]',
leftGroup: 'index-signature',
right: 'static',
rightGroup: 'static-block',
},
},
],
},
],
Expand Down

0 comments on commit 73b1b54

Please sign in to comment.