Skip to content

Commit

Permalink
fix: fix rule doc URL
Browse files Browse the repository at this point in the history
Since Stylelint 14.3.0, `meta.url` has been added:
<https://github.com/stylelint/stylelint/blob/14.3.0/CHANGELOG.md#1430>

Also, this change updates the `stylelint` package via `npm i stylelint`.
  • Loading branch information
ybiquitous committed Feb 9, 2022
1 parent 59be6cc commit 630dd96
Show file tree
Hide file tree
Showing 14 changed files with 228 additions and 150 deletions.
318 changes: 202 additions & 116 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@
"postcss-sass": "^0.5.0",
"postcss-scss": "^4.0.2",
"prettier": "^2.5.0",
"stylelint": "^14.1.0",
"stylelint": "^14.4.0",
"stylelint-processor-glamorous": "^0.3.0",
"stylelint-processor-styled-components": "^1.10.0",
"ts-jest": "^27.0.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ Object {
"diagnostics": Array [
Object {
"code": "unit-no-unknown",
"codeDescription": Object {
"href": "https://stylelint.io/user-guide/rules/unit-no-unknown",
},
"message": "unit-no-unknown",
"range": Object {
"end": Object {
Expand All @@ -24,9 +21,6 @@ Object {
},
Object {
"code": "at-rule-no-unknown",
"codeDescription": Object {
"href": "https://stylelint.io/user-guide/rules/at-rule-no-unknown",
},
"message": "at-rule-no-unknown",
"range": Object {
"end": Object {
Expand Down Expand Up @@ -66,9 +60,6 @@ Object {
"diagnostics": Array [
Object {
"code": "unit-no-unknown",
"codeDescription": Object {
"href": "https://stylelint.io/user-guide/rules/unit-no-unknown",
},
"message": "unit-no-unknown",
"range": Object {
"end": Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Object {
Object {
"code": "block-no-empty",
"codeDescription": Object {
"href": "https://stylelint.io/user-guide/rules/block-no-empty",
"href": "https://stylelint.io/user-guide/rules/list/block-no-empty",
},
"message": "Unexpected empty block (block-no-empty)",
"range": Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`warningToDiagnostic should add a rule documentation URL if a matching r
Object {
"code": "color-hex-case",
"codeDescription": Object {
"href": "https://stylelint.io/user-guide/rules/color-hex-case",
"href": "https://stylelint.io/rules/color-hex-case",
},
"message": "Expected \\"#AAA\\" to be \\"#aaa\\" (color-hex-case)",
"range": Object {
Expand Down
4 changes: 3 additions & 1 deletion src/utils/stylelint/__tests__/warning-to-diagnostic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ describe('warningToDiagnostic', () => {
},
});

const rules = { 'color-hex-case': {} } as unknown as {
const rules = {
'color-hex-case': { meta: { url: 'https://stylelint.io/rules/color-hex-case' } },
} as unknown as {
[name: string]: stylelint.Rule<unknown, unknown>;
};

Expand Down
3 changes: 1 addition & 2 deletions src/utils/stylelint/warning-to-diagnostic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ export function warningToDiagnostic(
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 ruleDocUrl = rules?.[warning.rule]?.meta?.url;

const diagnostic = Diagnostic.create(
Range.create(start, end),
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/__tests__/__snapshots__/code-actions.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Array [
"command": Object {
"arguments": Array [
Object {
"uri": "https://stylelint.io/user-guide/rules/indentation",
"uri": "https://stylelint.io/user-guide/rules/list/indentation",
},
],
"command": "stylelint.openRuleDoc",
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 @@ -5,7 +5,7 @@ Array [
Object {
"code": "color-hex-case",
"codeDescription": Object {
"href": "https://stylelint.io/user-guide/rules/color-hex-case",
"href": "https://stylelint.io/user-guide/rules/list/color-hex-case",
},
"message": "Expected \\"#fff\\" to be \\"#FFF\\" (color-hex-case)",
"range": Object {
Expand All @@ -24,7 +24,7 @@ Array [
Object {
"code": "indentation",
"codeDescription": Object {
"href": "https://stylelint.io/user-guide/rules/indentation",
"href": "https://stylelint.io/user-guide/rules/list/indentation",
},
"message": "Expected indentation of 8 spaces (indentation)",
"range": 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 @@ -5,7 +5,7 @@ Array [
Object {
"code": "block-no-empty",
"codeDescription": Object {
"href": "https://stylelint.io/user-guide/rules/block-no-empty",
"href": "https://stylelint.io/user-guide/rules/list/block-no-empty",
},
"message": "Unexpected empty block (block-no-empty)",
"range": 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 @@ -5,7 +5,7 @@ Array [
Object {
"code": "color-hex-case",
"codeDescription": Object {
"href": "https://stylelint.io/user-guide/rules/color-hex-case",
"href": "https://stylelint.io/user-guide/rules/list/color-hex-case",
},
"message": "Expected \\"#fff\\" to be \\"#FFF\\" (color-hex-case)",
"range": Object {
Expand All @@ -24,7 +24,7 @@ Array [
Object {
"code": "indentation",
"codeDescription": Object {
"href": "https://stylelint.io/user-guide/rules/indentation",
"href": "https://stylelint.io/user-guide/rules/list/indentation",
},
"message": "Expected indentation of 4 spaces (indentation)",
"range": Object {
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/__tests__/__snapshots__/lint.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Array [
Object {
"code": "color-no-invalid-hex",
"codeDescription": Object {
"href": "https://stylelint.io/user-guide/rules/color-no-invalid-hex",
"href": "https://stylelint.io/user-guide/rules/list/color-no-invalid-hex",
},
"message": "Unexpected invalid hex color \\"#y3\\" (color-no-invalid-hex)",
"range": Object {
Expand All @@ -40,7 +40,7 @@ Array [
Object {
"code": "indentation",
"codeDescription": Object {
"href": "https://stylelint.io/user-guide/rules/indentation",
"href": "https://stylelint.io/user-guide/rules/list/indentation",
},
"message": "Expected indentation of 4 spaces (indentation)",
"range": Object {
Expand All @@ -64,7 +64,7 @@ Array [
Object {
"code": "indentation",
"codeDescription": Object {
"href": "https://stylelint.io/user-guide/rules/indentation",
"href": "https://stylelint.io/user-guide/rules/list/indentation",
},
"message": "Expected indentation of 4 spaces (indentation)",
"range": 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 @@ -5,7 +5,7 @@ Array [
Object {
"code": "indentation",
"codeDescription": Object {
"href": "https://stylelint.io/user-guide/rules/indentation",
"href": "https://stylelint.io/user-guide/rules/list/indentation",
},
"message": "Expected indentation of 4 spaces (indentation)",
"range": Object {
Expand Down
18 changes: 9 additions & 9 deletions test/integration/stylelint-vscode/__snapshots__/test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Array [
Object {
"code": "string-quotes",
"codeDescription": Object {
"href": "https://stylelint.io/user-guide/rules/string-quotes",
"href": "https://stylelint.io/user-guide/rules/list/string-quotes",
},
"message": "Expected single quotes (string-quotes)",
"range": Object {
Expand All @@ -24,7 +24,7 @@ Array [
Object {
"code": "indentation",
"codeDescription": Object {
"href": "https://stylelint.io/user-guide/rules/indentation",
"href": "https://stylelint.io/user-guide/rules/list/indentation",
},
"message": "Expected indentation of 0 tabs (indentation)",
"range": Object {
Expand Down Expand Up @@ -174,7 +174,7 @@ Array [
Object {
"code": "font-weight-notation",
"codeDescription": Object {
"href": "https://stylelint.io/user-guide/rules/font-weight-notation",
"href": "https://stylelint.io/user-guide/rules/list/font-weight-notation",
},
"message": "Expected numeric font-weight notation (font-weight-notation)",
"range": Object {
Expand All @@ -193,7 +193,7 @@ Array [
Object {
"code": "font-weight-notation",
"codeDescription": Object {
"href": "https://stylelint.io/user-guide/rules/font-weight-notation",
"href": "https://stylelint.io/user-guide/rules/list/font-weight-notation",
},
"message": "Expected numeric font-weight notation (font-weight-notation)",
"range": Object {
Expand All @@ -217,7 +217,7 @@ Array [
Object {
"code": "length-zero-no-unit",
"codeDescription": Object {
"href": "https://stylelint.io/user-guide/rules/length-zero-no-unit",
"href": "https://stylelint.io/user-guide/rules/list/length-zero-no-unit",
},
"message": "Unexpected unit (length-zero-no-unit)",
"range": Object {
Expand All @@ -242,7 +242,7 @@ Object {
Object {
"code": "selector-type-no-unknown",
"codeDescription": Object {
"href": "https://stylelint.io/user-guide/rules/selector-type-no-unknown",
"href": "https://stylelint.io/user-guide/rules/list/selector-type-no-unknown",
},
"message": "Unexpected unknown type selector \\"unknown\\" (selector-type-no-unknown)",
"range": Object {
Expand Down Expand Up @@ -298,7 +298,7 @@ Object {
Object {
"code": "indentation",
"codeDescription": Object {
"href": "https://stylelint.io/user-guide/rules/indentation",
"href": "https://stylelint.io/user-guide/rules/list/indentation",
},
"message": "Expected indentation of 2 spaces (indentation)",
"range": Object {
Expand Down Expand Up @@ -379,7 +379,7 @@ Object {
Object {
"code": "indentation",
"codeDescription": Object {
"href": "https://stylelint.io/user-guide/rules/indentation",
"href": "https://stylelint.io/user-guide/rules/list/indentation",
},
"message": "Expected indentation of 4 spaces (indentation)",
"range": Object {
Expand Down Expand Up @@ -492,7 +492,7 @@ Object {
Object {
"code": "indentation",
"codeDescription": Object {
"href": "https://stylelint.io/user-guide/rules/indentation",
"href": "https://stylelint.io/user-guide/rules/list/indentation",
},
"message": "Expected indentation of 2 spaces (indentation)",
"range": Object {
Expand Down

0 comments on commit 630dd96

Please sign in to comment.