Skip to content

Commit

Permalink
fix(eslint-plugin): [member-ordering] check order when optionalityOrd…
Browse files Browse the repository at this point in the history
…er is present with no optional members (#6619)

fix: check order when optionalityOrder present with no optional members
  • Loading branch information
kxrt committed Mar 18, 2023
1 parent 0d0639f commit 6aff431
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/eslint-plugin/src/rules/member-ordering.ts
Expand Up @@ -952,6 +952,8 @@ export default util.createRule<Options, MessageIds>({
}
checkOrder(members.slice(0, switchIndex));
checkOrder(members.slice(switchIndex));
} else {
checkOrder(members);
}
}

Expand Down
Expand Up @@ -105,8 +105,8 @@ class X {
code: `
class X {
a: string;
static {}
b: string;
static {}
}
`,
options: [
Expand Down Expand Up @@ -337,6 +337,35 @@ class X {
},
],
},
{
code: `
class X {
b: string;
a: string;
}
`,
options: [
{
default: {
memberTypes: 'never',
order: 'natural-case-insensitive',
optionalityOrder: 'required-first',
},
},
],
errors: [
{
messageId: 'incorrectOrder',
line: 4,
column: 3,
data: {
member: 'a',
beforeMember: 'b',
optionalOrRequired: 'required',
},
},
],
},
// optionalityOrder - optional-first
{
code: `
Expand Down

0 comments on commit 6aff431

Please sign in to comment.