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 (typescript-eslint#6619)

fix: check order when optionalityOrder present with no optional members
  • Loading branch information
kxrt authored and hasparus committed Mar 22, 2023
1 parent 989aa57 commit 16523e5
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 16523e5

Please sign in to comment.