Skip to content

Commit

Permalink
fix(eslint-plugin): [member-delimiter-style] autofixer result is not …
Browse files Browse the repository at this point in the history
…as expected with option `delimiter: 'none'` (#5023)
  • Loading branch information
holazz committed May 20, 2022
1 parent 7ee0bd0 commit 9e97a11
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/eslint-plugin/src/rules/member-delimiter-style.ts
Expand Up @@ -68,8 +68,8 @@ const definition = {
additionalProperties: false,
};

const isLastTokenEndOfLine = (token: string, line: string): boolean => {
const positionInLine = line.indexOf(token);
const isLastTokenEndOfLine = (token: LastTokenType, line: string): boolean => {
const positionInLine = token.loc.start.column;

return positionInLine === line.length - 1;
};
Expand All @@ -85,7 +85,7 @@ const makeFixFunction = ({
// if removing is the action but last token is not the end of the line
if (
optsNone &&
!isLastTokenEndOfLine(lastToken.value, lastTokenLine) &&
!isLastTokenEndOfLine(lastToken, lastTokenLine) &&
!isSingleLine
) {
return null;
Expand Down
38 changes: 38 additions & 0 deletions packages/eslint-plugin/tests/rules/member-delimiter-style.test.ts
Expand Up @@ -3548,5 +3548,43 @@ type Foo = {a: {
},
],
},
{
code: `
type Foo = {
a: {
b: true;
}; c: false;
}
`,
output: `
type Foo = {
a: {
b: true
}; c: false
}
`,
options: [
{
multiline: { delimiter: 'none' },
},
],
errors: [
{
messageId: 'unexpectedSemi',
line: 4,
column: 13,
},
{
messageId: 'unexpectedSemi',
line: 5,
column: 5,
},
{
messageId: 'unexpectedSemi',
line: 5,
column: 15,
},
],
},
],
});

0 comments on commit 9e97a11

Please sign in to comment.