Skip to content

Commit

Permalink
fix(plugin-eslint): handle rules which emit column 0
Browse files Browse the repository at this point in the history
  • Loading branch information
matejchalk committed Feb 23, 2024
1 parent 1b71a3b commit de791e1
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/plugin-eslint/src/lib/runner/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,13 @@ function convertIssue(issue: LintIssue): Issue {
file: issue.filePath,
position: {
startLine: issue.line,
startColumn: issue.column,
endLine: issue.endLine,
endColumn: issue.endColumn,
...(issue.column > 0 && { startColumn: issue.column }),
...(issue.endLine &&
issue.endLine > 0 && {
endLine: issue.endLine,
}),
...(issue.endColumn &&
issue.endColumn > 0 && { endColumn: issue.endColumn }),
},
},
};
Expand Down
39 changes: 39 additions & 0 deletions packages/plugin-eslint/src/lib/runner/transform.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ describe('lintResultsToAudits', () => {
},
],
},
{
filePath: 'src/app/graphql/generated.ts',
messages: [
{
ruleId: 'unicorn/no-abusive-eslint-disable',
message: 'Specify the rules you want to disable',
severity: 1,
line: 1,
column: 0, // testing we omit non-positive columns
},
],
},
{
filePath: 'src/app/pages/settings.component.ts',
messages: [
Expand All @@ -78,13 +90,22 @@ describe('lintResultsToAudits', () => {
'src/app/app.component.ts': {
'max-lines': [500],
'@typescript-eslint/no-explicit-any': [],
'unicorn/no-abusive-eslint-disable': [],
},
'src/app/pages/settings.component.ts': {
'max-lines': [500],
'@typescript-eslint/no-explicit-any': [],
'unicorn/no-abusive-eslint-disable': [],
},
'src/app/graphql/generated.ts': {
'max-lines': [500],
'@typescript-eslint/no-explicit-any': [],
'unicorn/no-abusive-eslint-disable': [],
},
'src/app/app.component.spec.ts': {
'max-lines': [800],
'@typescript-eslint/no-explicit-any': [],
'unicorn/no-abusive-eslint-disable': [],
},
},
}),
Expand Down Expand Up @@ -182,6 +203,24 @@ describe('lintResultsToAudits', () => {
],
},
},
{
slug: 'unicorn-no-abusive-eslint-disable',
score: 0,
value: 1,
displayValue: '1 warning',
details: {
issues: [
{
message: 'Specify the rules you want to disable',
severity: 'warning',
source: {
file: 'src/app/graphql/generated.ts',
position: { startLine: 1 },
},
},
],
},
},
] satisfies AuditOutput[]);
});
});

0 comments on commit de791e1

Please sign in to comment.