Skip to content

Commit

Permalink
feat: Report ranges for diagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
adalinesimonian committed Dec 6, 2021
1 parent 9acd04a commit c798718
Show file tree
Hide file tree
Showing 3 changed files with 167 additions and 40 deletions.
200 changes: 162 additions & 38 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
"postcss-sass": "^0.5.0",
"postcss-scss": "^4.0.2",
"prettier": "^2.5.0",
"stylelint": "^14.1.0",
"stylelint": "git+https://[email protected]/stylelint/stylelint.git#warning-ranges",
"stylelint-processor-glamorous": "^0.3.0",
"stylelint-processor-styled-components": "^1.10.0",
"ts-jest": "^27.0.7",
Expand Down
5 changes: 4 additions & 1 deletion src/utils/stylelint/warning-to-diagnostic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ export function warningToDiagnostic(
rules?: { [name: string]: stylelint.Rule },
): Diagnostic {
const start = Position.create(warning.line - 1, warning.column - 1);
const end = Position.create(warning.line - 1, warning.column);
const end =
typeof warning.endLine === 'number' && typeof warning.endColumn === 'number'
? Position.create(warning.endLine - 1, warning.endColumn - 1)
: Position.create(warning.line - 1, warning.column);

const ruleDocUrl =
rules?.[warning.rule] && `https://stylelint.io/user-guide/rules/${warning.rule}`;
Expand Down

0 comments on commit c798718

Please sign in to comment.