Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make hovering over problems more reliable #325

Merged
merged 1 commit into from
Nov 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Object {
"message": "unit-no-unknown",
"range": Object {
"end": Object {
"character": 0,
"character": 1,
"line": 0,
},
"start": Object {
Expand All @@ -30,7 +30,7 @@ Object {
"message": "at-rule-no-unknown",
"range": Object {
"end": Object {
"character": 0,
"character": 1,
"line": 0,
},
"start": Object {
Expand All @@ -46,7 +46,7 @@ Object {
"message": "alpha-value-notation",
"range": Object {
"end": Object {
"character": 0,
"character": 1,
"line": 0,
},
"start": Object {
Expand All @@ -72,7 +72,7 @@ Object {
"message": "unit-no-unknown",
"range": Object {
"end": Object {
"character": 0,
"character": 1,
"line": 0,
},
"start": Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Object {
"message": "Unexpected empty block (block-no-empty)",
"range": Object {
"end": Object {
"character": 2,
"character": 3,
"line": 0,
},
"start": Object {
Expand All @@ -53,7 +53,7 @@ Object {
"message": "Unclosed block (CssSyntaxError)",
"range": Object {
"end": Object {
"character": 0,
"character": 1,
"line": 0,
},
"start": Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Object {
"message": "Expected \\"#AAA\\" to be \\"#aaa\\" (color-hex-case)",
"range": Object {
"end": Object {
"character": 11,
"character": 12,
"line": 1,
},
"start": Object {
Expand All @@ -28,7 +28,7 @@ Object {
"message": "Expected \\"#AAA\\" to be \\"#aaa\\" (color-hex-case)",
"range": Object {
"end": Object {
"character": 11,
"character": 12,
"line": 1,
},
"start": Object {
Expand All @@ -47,7 +47,7 @@ Object {
"message": "Expected \\"#bbbbbb\\" to be \\"#bbb\\" (color-hex-length)",
"range": Object {
"end": Object {
"character": 18,
"character": 19,
"line": 2,
},
"start": Object {
Expand Down
5 changes: 3 additions & 2 deletions src/utils/stylelint/warning-to-diagnostic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,14 @@ export function warningToDiagnostic(
warning: stylelint.Warning,
rules?: { [name: string]: stylelint.Rule },
): Diagnostic {
const position = Position.create(warning.line - 1, warning.column - 1);
const start = Position.create(warning.line - 1, warning.column - 1);
const end = Position.create(warning.line - 1, warning.column);

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

const diagnostic = Diagnostic.create(
Range.create(position, position),
Range.create(start, end),
warning.text,
DiagnosticSeverity[warning.severity === 'warning' ? 'Warning' : 'Error'],
warning.rule,
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/__tests__/__snapshots__/config-basedir.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Array [
"message": "Expected \\"#fff\\" to be \\"#FFF\\" (color-hex-case)",
"range": Object {
"end": Object {
"character": 9,
"character": 10,
"line": 1,
},
"start": Object {
Expand All @@ -29,7 +29,7 @@ Array [
"message": "Expected indentation of 8 spaces (indentation)",
"range": Object {
"end": Object {
"character": 2,
"character": 3,
"line": 1,
},
"start": Object {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/__tests__/__snapshots__/config-file.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Array [
"message": "Unexpected empty block (block-no-empty)",
"range": Object {
"end": Object {
"character": 2,
"character": 3,
"line": 0,
},
"start": Object {
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/__tests__/__snapshots__/ignore-disables.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Array [
"message": "Expected \\"#fff\\" to be \\"#FFF\\" (color-hex-case)",
"range": Object {
"end": Object {
"character": 9,
"character": 10,
"line": 3,
},
"start": Object {
Expand All @@ -29,7 +29,7 @@ Array [
"message": "Expected indentation of 4 spaces (indentation)",
"range": Object {
"end": Object {
"character": 2,
"character": 3,
"line": 3,
},
"start": Object {
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/__tests__/__snapshots__/lint.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Array [
"message": "Bar (plugin/foo-bar)",
"range": Object {
"end": Object {
"character": 5,
"character": 6,
"line": 0,
},
"start": Object {
Expand All @@ -26,7 +26,7 @@ Array [
"message": "Unexpected invalid hex color \\"#y3\\" (color-no-invalid-hex)",
"range": Object {
"end": Object {
"character": 11,
"character": 12,
"line": 6,
},
"start": Object {
Expand All @@ -45,7 +45,7 @@ Array [
"message": "Expected indentation of 4 spaces (indentation)",
"range": Object {
"end": Object {
"character": 2,
"character": 3,
"line": 2,
},
"start": Object {
Expand All @@ -69,7 +69,7 @@ Array [
"message": "Expected indentation of 4 spaces (indentation)",
"range": Object {
"end": Object {
"character": 2,
"character": 3,
"line": 2,
},
"start": Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Array [
"message": "Rule \\"foo\\" isn't enabled",
"range": Object {
"end": Object {
"character": 0,
"character": 1,
"line": 0,
},
"start": Object {
Expand All @@ -23,7 +23,7 @@ Array [
"message": "Rule \\"foo\\" isn't enabled",
"range": Object {
"end": Object {
"character": 0,
"character": 1,
"line": 2,
},
"start": Object {
Expand All @@ -39,7 +39,7 @@ Array [
"message": "Rule \\"foo\\" isn't enabled",
"range": Object {
"end": Object {
"character": 0,
"character": 1,
"line": 4,
},
"start": Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Array [
"message": "Needless disable for \\"indentation\\"",
"range": Object {
"end": Object {
"character": 2,
"character": 3,
"line": 2,
},
"start": Object {
Expand All @@ -23,7 +23,7 @@ Array [
"message": "Needless disable for \\"indentation\\"",
"range": Object {
"end": Object {
"character": 0,
"character": 1,
"line": 6,
},
"start": Object {
Expand All @@ -39,7 +39,7 @@ Array [
"message": "Needless disable for \\"indentation\\"",
"range": Object {
"end": Object {
"character": 16,
"character": 17,
"line": 14,
},
"start": Object {
Expand All @@ -55,7 +55,7 @@ Array [
"message": "Needless disable for \\"indentation\\"",
"range": Object {
"end": Object {
"character": 0,
"character": 1,
"line": 17,
},
"start": Object {
Expand All @@ -71,7 +71,7 @@ Array [
"message": "Needless disable for \\"unknown\\"",
"range": Object {
"end": Object {
"character": 2,
"character": 3,
"line": 2,
},
"start": Object {
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/__tests__/__snapshots__/stylelint-resolution.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Array [
"message": "Fake result",
"range": Object {
"end": Object {
"character": 0,
"character": 1,
"line": 0,
},
"start": Object {
Expand All @@ -28,7 +28,7 @@ Array [
"message": "Fake result from yarn-pnp",
"range": Object {
"end": Object {
"character": 0,
"character": 1,
"line": 0,
},
"start": Object {
Expand All @@ -49,7 +49,7 @@ Array [
"message": "Fake result from yarn-2-pnp",
"range": Object {
"end": Object {
"character": 0,
"character": 1,
"line": 0,
},
"start": Object {
Expand All @@ -70,7 +70,7 @@ Array [
"message": "Fake result from resolve-local",
"range": Object {
"end": Object {
"character": 0,
"character": 1,
"line": 0,
},
"start": Object {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/__tests__/__snapshots__/validate.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Array [
"message": "Expected indentation of 4 spaces (indentation)",
"range": Object {
"end": Object {
"character": 2,
"character": 3,
"line": 2,
},
"start": Object {
Expand Down