From 860facb0acba36f98106e0b6cbdd8c89b8beea18 Mon Sep 17 00:00:00 2001 From: Adaline Valentina Simonian Date: Mon, 6 Dec 2021 14:02:49 -0800 Subject: [PATCH 1/9] feat: Report ranges for diagnostics --- src/utils/stylelint/warning-to-diagnostic.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/utils/stylelint/warning-to-diagnostic.ts b/src/utils/stylelint/warning-to-diagnostic.ts index 22b39104..7d773e51 100644 --- a/src/utils/stylelint/warning-to-diagnostic.ts +++ b/src/utils/stylelint/warning-to-diagnostic.ts @@ -46,7 +46,10 @@ export function warningToDiagnostic( ruleMetadata?: stylelint.LinterResult['ruleMetadata'], ): 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 = ruleMetadata?.[warning.rule]?.url; From 5cef2348e89ce377a9a4e49279f75288d6013afd Mon Sep 17 00:00:00 2001 From: yosuke ota Date: Wed, 17 Aug 2022 11:05:34 +0900 Subject: [PATCH 2/9] update snap --- .../__snapshots__/stylelint-runner.ts.snap | 2 +- .../warning-to-diagnostic.ts.snap | 2 +- .../__snapshots__/config-basedir.ts.snap | 2 +- .../__snapshots__/config-file.ts.snap | 2 +- .../__snapshots__/ignore-disables.ts.snap | 2 +- test/e2e/__tests__/__snapshots__/lint.ts.snap | 6 ++-- .../report-invalid-scope-disables.ts.snap | 6 ++-- .../report-needless-disables.ts.snap | 10 +++--- .../__tests__/__snapshots__/validate.ts.snap | 2 +- .../__snapshots__/test.ts.snap | 34 +++++++++---------- 10 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/utils/stylelint/__tests__/__snapshots__/stylelint-runner.ts.snap b/src/utils/stylelint/__tests__/__snapshots__/stylelint-runner.ts.snap index 7fb422c4..bce03ce2 100644 --- a/src/utils/stylelint/__tests__/__snapshots__/stylelint-runner.ts.snap +++ b/src/utils/stylelint/__tests__/__snapshots__/stylelint-runner.ts.snap @@ -30,7 +30,7 @@ Object { "message": "Unexpected empty block (block-no-empty)", "range": Object { "end": Object { - "character": 3, + "character": 4, "line": 0, }, "start": Object { diff --git a/src/utils/stylelint/__tests__/__snapshots__/warning-to-diagnostic.ts.snap b/src/utils/stylelint/__tests__/__snapshots__/warning-to-diagnostic.ts.snap index 0d9a8b2e..3bd2e790 100644 --- a/src/utils/stylelint/__tests__/__snapshots__/warning-to-diagnostic.ts.snap +++ b/src/utils/stylelint/__tests__/__snapshots__/warning-to-diagnostic.ts.snap @@ -47,7 +47,7 @@ Object { "message": "Expected \\"#bbbbbb\\" to be \\"#bbb\\" (color-hex-length)", "range": Object { "end": Object { - "character": 19, + "character": 25, "line": 2, }, "start": Object { diff --git a/test/e2e/__tests__/__snapshots__/config-basedir.ts.snap b/test/e2e/__tests__/__snapshots__/config-basedir.ts.snap index da50444a..f705dc7c 100644 --- a/test/e2e/__tests__/__snapshots__/config-basedir.ts.snap +++ b/test/e2e/__tests__/__snapshots__/config-basedir.ts.snap @@ -29,7 +29,7 @@ Array [ "message": "Expected indentation of 8 spaces (indentation)", "range": Object { "end": Object { - "character": 3, + "character": 14, "line": 1, }, "start": Object { diff --git a/test/e2e/__tests__/__snapshots__/config-file.ts.snap b/test/e2e/__tests__/__snapshots__/config-file.ts.snap index 23d6f863..2d704bf8 100644 --- a/test/e2e/__tests__/__snapshots__/config-file.ts.snap +++ b/test/e2e/__tests__/__snapshots__/config-file.ts.snap @@ -10,7 +10,7 @@ Array [ "message": "Unexpected empty block (block-no-empty)", "range": Object { "end": Object { - "character": 3, + "character": 4, "line": 0, }, "start": Object { diff --git a/test/e2e/__tests__/__snapshots__/ignore-disables.ts.snap b/test/e2e/__tests__/__snapshots__/ignore-disables.ts.snap index 8f321f0a..e4abfc5b 100644 --- a/test/e2e/__tests__/__snapshots__/ignore-disables.ts.snap +++ b/test/e2e/__tests__/__snapshots__/ignore-disables.ts.snap @@ -29,7 +29,7 @@ Array [ "message": "Expected indentation of 4 spaces (indentation)", "range": Object { "end": Object { - "character": 3, + "character": 14, "line": 3, }, "start": Object { diff --git a/test/e2e/__tests__/__snapshots__/lint.ts.snap b/test/e2e/__tests__/__snapshots__/lint.ts.snap index aae09884..4fd8dfcf 100644 --- a/test/e2e/__tests__/__snapshots__/lint.ts.snap +++ b/test/e2e/__tests__/__snapshots__/lint.ts.snap @@ -26,7 +26,7 @@ Array [ "message": "Unexpected invalid hex color \\"#y3\\" (color-no-invalid-hex)", "range": Object { "end": Object { - "character": 12, + "character": 14, "line": 6, }, "start": Object { @@ -45,7 +45,7 @@ Array [ "message": "Expected indentation of 4 spaces (indentation)", "range": Object { "end": Object { - "character": 3, + "character": 13, "line": 2, }, "start": Object { @@ -69,7 +69,7 @@ Array [ "message": "Expected indentation of 4 spaces (indentation)", "range": Object { "end": Object { - "character": 3, + "character": 13, "line": 2, }, "start": Object { diff --git a/test/e2e/__tests__/__snapshots__/report-invalid-scope-disables.ts.snap b/test/e2e/__tests__/__snapshots__/report-invalid-scope-disables.ts.snap index e2b55eef..326ae8ed 100644 --- a/test/e2e/__tests__/__snapshots__/report-invalid-scope-disables.ts.snap +++ b/test/e2e/__tests__/__snapshots__/report-invalid-scope-disables.ts.snap @@ -7,7 +7,7 @@ Array [ "message": "Rule \\"foo\\" isn't enabled", "range": Object { "end": Object { - "character": 1, + "character": 36, "line": 0, }, "start": Object { @@ -23,7 +23,7 @@ Array [ "message": "Rule \\"foo\\" isn't enabled", "range": Object { "end": Object { - "character": 1, + "character": 31, "line": 2, }, "start": Object { @@ -39,7 +39,7 @@ Array [ "message": "Rule \\"foo\\" isn't enabled", "range": Object { "end": Object { - "character": 1, + "character": 26, "line": 4, }, "start": Object { diff --git a/test/e2e/__tests__/__snapshots__/report-needless-disables.ts.snap b/test/e2e/__tests__/__snapshots__/report-needless-disables.ts.snap index 5bf7aa0e..65f56e01 100644 --- a/test/e2e/__tests__/__snapshots__/report-needless-disables.ts.snap +++ b/test/e2e/__tests__/__snapshots__/report-needless-disables.ts.snap @@ -7,7 +7,7 @@ Array [ "message": "Needless disable for \\"indentation\\"", "range": Object { "end": Object { - "character": 3, + "character": 55, "line": 2, }, "start": Object { @@ -23,7 +23,7 @@ Array [ "message": "Needless disable for \\"indentation\\"", "range": Object { "end": Object { - "character": 1, + "character": 34, "line": 6, }, "start": Object { @@ -39,7 +39,7 @@ Array [ "message": "Needless disable for \\"indentation\\"", "range": Object { "end": Object { - "character": 17, + "character": 55, "line": 14, }, "start": Object { @@ -55,7 +55,7 @@ Array [ "message": "Needless disable for \\"indentation\\"", "range": Object { "end": Object { - "character": 1, + "character": 34, "line": 17, }, "start": Object { @@ -71,7 +71,7 @@ Array [ "message": "Needless disable for \\"unknown\\"", "range": Object { "end": Object { - "character": 3, + "character": 55, "line": 2, }, "start": Object { diff --git a/test/e2e/__tests__/__snapshots__/validate.ts.snap b/test/e2e/__tests__/__snapshots__/validate.ts.snap index dbc211b3..93696ff0 100644 --- a/test/e2e/__tests__/__snapshots__/validate.ts.snap +++ b/test/e2e/__tests__/__snapshots__/validate.ts.snap @@ -10,7 +10,7 @@ Array [ "message": "Expected indentation of 4 spaces (indentation)", "range": Object { "end": Object { - "character": 3, + "character": 13, "line": 2, }, "start": Object { diff --git a/test/integration/stylelint-vscode/__snapshots__/test.ts.snap b/test/integration/stylelint-vscode/__snapshots__/test.ts.snap index 92bb4216..6557be56 100644 --- a/test/integration/stylelint-vscode/__snapshots__/test.ts.snap +++ b/test/integration/stylelint-vscode/__snapshots__/test.ts.snap @@ -10,7 +10,7 @@ Array [ "message": "Unexpected unknown at-rule \\"@unknown\\" (scss/at-rule-no-unknown)", "range": Object { "end": Object { - "character": 1, + "character": 30, "line": 0, }, "start": Object { @@ -53,7 +53,7 @@ Array [ "message": "Expected indentation of 0 tabs (indentation)", "range": Object { "end": Object { - "character": 3, + "character": 14, "line": 0, }, "start": Object { @@ -203,7 +203,7 @@ Array [ "message": "Expected numeric font-weight notation (font-weight-notation)", "range": Object { "end": Object { - "character": 30, + "character": 33, "line": 2, }, "start": Object { @@ -222,7 +222,7 @@ Array [ "message": "Expected numeric font-weight notation (font-weight-notation)", "range": Object { "end": Object { - "character": 7, + "character": 12, "line": 4, }, "start": Object { @@ -246,8 +246,8 @@ Array [ "message": "Unexpected unit (length-zero-no-unit)", "range": Object { "end": Object { - "character": 11, - "line": 3, + "character": 10, + "line": 1, }, "start": Object { "character": 10, @@ -271,7 +271,7 @@ Object { "message": "Unexpected unknown type selector \\"unknown\\" (selector-type-no-unknown)", "range": Object { "end": Object { - "character": 1, + "character": 7, "line": 1, }, "start": Object { @@ -327,7 +327,7 @@ Object { "message": "Expected indentation of 2 spaces (indentation)", "range": Object { "end": Object { - "character": 4, + "character": 12, "line": 1, }, "start": Object { @@ -350,7 +350,7 @@ Object { "message": "Rule \\"foo\\" isn't enabled", "range": Object { "end": Object { - "character": 1, + "character": 36, "line": 1, }, "start": Object { @@ -366,7 +366,7 @@ Object { "message": "Rule \\"foo\\" isn't enabled", "range": Object { "end": Object { - "character": 1, + "character": 31, "line": 3, }, "start": Object { @@ -382,7 +382,7 @@ Object { "message": "Rule \\"foo\\" isn't enabled", "range": Object { "end": Object { - "character": 1, + "character": 26, "line": 5, }, "start": Object { @@ -408,7 +408,7 @@ Object { "message": "Expected indentation of 4 spaces (indentation)", "range": Object { "end": Object { - "character": 3, + "character": 47, "line": 2, }, "start": Object { @@ -424,7 +424,7 @@ Object { "message": "Needless disable for \\"indentation\\"", "range": Object { "end": Object { - "character": 3, + "character": 46, "line": 2, }, "start": Object { @@ -440,7 +440,7 @@ Object { "message": "Needless disable for \\"indentation\\"", "range": Object { "end": Object { - "character": 1, + "character": 34, "line": 6, }, "start": Object { @@ -456,7 +456,7 @@ Object { "message": "Needless disable for \\"indentation\\"", "range": Object { "end": Object { - "character": 17, + "character": 55, "line": 13, }, "start": Object { @@ -472,7 +472,7 @@ Object { "message": "Needless disable for \\"indentation\\"", "range": Object { "end": Object { - "character": 1, + "character": 34, "line": 16, }, "start": Object { @@ -521,7 +521,7 @@ Object { "message": "Expected indentation of 2 spaces (indentation)", "range": Object { "end": Object { - "character": 4, + "character": 12, "line": 1, }, "start": Object { From d432323985339d4615077d4031384c02e480a3cf Mon Sep 17 00:00:00 2001 From: yosuke ota Date: Wed, 17 Aug 2022 11:21:49 +0900 Subject: [PATCH 3/9] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b2980612..e6236ad7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Language server can now be restarted with the "Restart Stylelint Server" command ([#339](https://github.com/stylelint/vscode-stylelint/pull/339)). - The warning shown for unsupported versions of Stylelint will now be shown in any workspace with a locally installed copy of Stylelint, regardless of the file type of the open file ([#340](https://github.com/stylelint/vscode-stylelint/pull/340)). - Language server can now be disposed with `server.dispose()` and is disposed when receiving the shutdown LSP notification ([#326](https://github.com/stylelint/vscode-stylelint/pull/326)). +- Add support for range warnings ([#358](https://github.com/stylelint/vscode-stylelint/pull/358)). ### Changed From 8b65a298901e03967617a236106b08b2a34d5281 Mon Sep 17 00:00:00 2001 From: yosuke ota Date: Tue, 23 Aug 2022 13:43:43 +0900 Subject: [PATCH 4/9] update stylelint --- package-lock.json | 48 +++++++++++++++++++++++------------------------ package.json | 2 +- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3ade341a..f564e9fd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -54,7 +54,7 @@ "postcss-sass": "^0.5.0", "postcss-scss": "^4.0.2", "prettier": "^2.5.0", - "stylelint": "^14.10.0", + "stylelint": "^14.11.0", "stylelint-processor-glamorous": "^0.3.0", "stylelint-processor-styled-components": "^1.10.0", "stylelint-scss": "^4.3.0", @@ -3000,9 +3000,9 @@ } }, "node_modules/colord": { - "version": "2.9.2", - "resolved": "https://registry.npmjs.org/colord/-/colord-2.9.2.tgz", - "integrity": "sha512-Uqbg+J445nc1TKn4FoDPS6ZZqAvEDnwrH42yo8B40JSOgSLxMZ/gt3h4nmCtPLQeXhjJJkqBx7SCY35WnIixaQ==", + "version": "2.9.3", + "resolved": "https://registry.npmjs.org/colord/-/colord-2.9.3.tgz", + "integrity": "sha512-jeC1axXpnb0/2nn/Y1LPuLdgXBLH7aDcHu4KEKfqw3CUhX7ZpfBSlPKyqXE6btIgEzfWtrX3/tyBCaCvXvMkOw==", "dev": true }, "node_modules/colors": { @@ -9748,14 +9748,14 @@ "dev": true }, "node_modules/stylelint": { - "version": "14.10.0", - "resolved": "https://registry.npmjs.org/stylelint/-/stylelint-14.10.0.tgz", - "integrity": "sha512-VAmyKrEK+wNFh9R8mNqoxEFzaa4gsHGhcT4xgkQDuOA5cjF6CaNS8loYV7gpi4tIZBPUyXesotPXzJAMN8VLOQ==", + "version": "14.11.0", + "resolved": "https://registry.npmjs.org/stylelint/-/stylelint-14.11.0.tgz", + "integrity": "sha512-OTLjLPxpvGtojEfpESWM8Ir64Z01E89xsisaBMUP/ngOx1+4VG2DPRcUyCCiin9Rd3kPXPsh/uwHd9eqnvhsYA==", "dev": true, "dependencies": { "@csstools/selector-specificity": "^2.0.2", "balanced-match": "^2.0.0", - "colord": "^2.9.2", + "colord": "^2.9.3", "cosmiconfig": "^7.0.1", "css-functions-list": "^3.1.0", "debug": "^4.3.4", @@ -9790,7 +9790,7 @@ "svg-tags": "^1.0.0", "table": "^6.8.0", "v8-compile-cache": "^2.3.0", - "write-file-atomic": "^4.0.1" + "write-file-atomic": "^4.0.2" }, "bin": { "stylelint": "bin/stylelint.js" @@ -9927,16 +9927,16 @@ } }, "node_modules/stylelint/node_modules/write-file-atomic": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-4.0.1.tgz", - "integrity": "sha512-nSKUxgAbyioruk6hU87QzVbY279oYT6uiwgDoujth2ju4mJ+TZau7SQBhtbTmUyuNYTuXnSyRn66FV0+eCgcrQ==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-4.0.2.tgz", + "integrity": "sha512-7KxauUdBmSdWnmpaGFg+ppNjKF8uNLry8LyzjauQDOVONfFLNKrKvQOxZ/VuTIcS/gge/YNahf5RIIQWTSarlg==", "dev": true, "dependencies": { "imurmurhash": "^0.1.4", "signal-exit": "^3.0.7" }, "engines": { - "node": "^12.13.0 || ^14.15.0 || >=16" + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" } }, "node_modules/supports-color": { @@ -13139,9 +13139,9 @@ } }, "colord": { - "version": "2.9.2", - "resolved": "https://registry.npmjs.org/colord/-/colord-2.9.2.tgz", - "integrity": "sha512-Uqbg+J445nc1TKn4FoDPS6ZZqAvEDnwrH42yo8B40JSOgSLxMZ/gt3h4nmCtPLQeXhjJJkqBx7SCY35WnIixaQ==", + "version": "2.9.3", + "resolved": "https://registry.npmjs.org/colord/-/colord-2.9.3.tgz", + "integrity": "sha512-jeC1axXpnb0/2nn/Y1LPuLdgXBLH7aDcHu4KEKfqw3CUhX7ZpfBSlPKyqXE6btIgEzfWtrX3/tyBCaCvXvMkOw==", "dev": true }, "colors": { @@ -18140,14 +18140,14 @@ "dev": true }, "stylelint": { - "version": "14.10.0", - "resolved": "https://registry.npmjs.org/stylelint/-/stylelint-14.10.0.tgz", - "integrity": "sha512-VAmyKrEK+wNFh9R8mNqoxEFzaa4gsHGhcT4xgkQDuOA5cjF6CaNS8loYV7gpi4tIZBPUyXesotPXzJAMN8VLOQ==", + "version": "14.11.0", + "resolved": "https://registry.npmjs.org/stylelint/-/stylelint-14.11.0.tgz", + "integrity": "sha512-OTLjLPxpvGtojEfpESWM8Ir64Z01E89xsisaBMUP/ngOx1+4VG2DPRcUyCCiin9Rd3kPXPsh/uwHd9eqnvhsYA==", "dev": true, "requires": { "@csstools/selector-specificity": "^2.0.2", "balanced-match": "^2.0.0", - "colord": "^2.9.2", + "colord": "^2.9.3", "cosmiconfig": "^7.0.1", "css-functions-list": "^3.1.0", "debug": "^4.3.4", @@ -18182,7 +18182,7 @@ "svg-tags": "^1.0.0", "table": "^6.8.0", "v8-compile-cache": "^2.3.0", - "write-file-atomic": "^4.0.1" + "write-file-atomic": "^4.0.2" }, "dependencies": { "balanced-match": { @@ -18198,9 +18198,9 @@ "dev": true }, "write-file-atomic": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-4.0.1.tgz", - "integrity": "sha512-nSKUxgAbyioruk6hU87QzVbY279oYT6uiwgDoujth2ju4mJ+TZau7SQBhtbTmUyuNYTuXnSyRn66FV0+eCgcrQ==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-4.0.2.tgz", + "integrity": "sha512-7KxauUdBmSdWnmpaGFg+ppNjKF8uNLry8LyzjauQDOVONfFLNKrKvQOxZ/VuTIcS/gge/YNahf5RIIQWTSarlg==", "dev": true, "requires": { "imurmurhash": "^0.1.4", diff --git a/package.json b/package.json index ffe03a03..15b161a0 100644 --- a/package.json +++ b/package.json @@ -237,7 +237,7 @@ "postcss-sass": "^0.5.0", "postcss-scss": "^4.0.2", "prettier": "^2.5.0", - "stylelint": "^14.10.0", + "stylelint": "^14.11.0", "stylelint-processor-glamorous": "^0.3.0", "stylelint-processor-styled-components": "^1.10.0", "stylelint-scss": "^4.3.0", From 7560578c2340aeb77574742721c234485338473e Mon Sep 17 00:00:00 2001 From: Chema Balsas Date: Wed, 16 Aug 2023 03:55:14 +0100 Subject: [PATCH 5/9] Fixes server/modules/formatter tests (#450) Fix copied from original PR https://github.com/stylelint/vscode-stylelint/pull/426/files#diff-f2680deb1906c0920d4e4b4f73879a32a741ed4288aabb2a218a2eef48f38211 --- src/server/modules/__tests__/formatter.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/server/modules/__tests__/formatter.ts b/src/server/modules/__tests__/formatter.ts index 8ca67601..f931a7d2 100644 --- a/src/server/modules/__tests__/formatter.ts +++ b/src/server/modules/__tests__/formatter.ts @@ -28,13 +28,15 @@ import { Position, TextEdit } from 'vscode-languageserver-types'; import { Notification } from '../../types'; import { FormatterModule } from '../formatter'; -const mockContext = serverMocks.getContext(); -const mockLogger = serverMocks.getLogger(); +let mockContext = serverMocks.getContext(); +let mockLogger = serverMocks.getLogger(); describe('FormatterModule', () => { beforeEach(() => { + jest.restoreAllMocks(); + mockContext = serverMocks.getContext(); mockContext.__options.validate = []; - jest.clearAllMocks(); + mockLogger = serverMocks.getLogger(); }); test('should be constructable', () => { From a6c2ac022ec45efaa5cc7f8aa4e98622b59fdce2 Mon Sep 17 00:00:00 2001 From: yosuke ota Date: Sat, 21 Oct 2023 16:33:19 +0900 Subject: [PATCH 6/9] update snapshot --- .../stylelint-vscode/__snapshots__/test.ts.snap | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/integration/stylelint-vscode/__snapshots__/test.ts.snap b/test/integration/stylelint-vscode/__snapshots__/test.ts.snap index e5d60644..2ce18d11 100644 --- a/test/integration/stylelint-vscode/__snapshots__/test.ts.snap +++ b/test/integration/stylelint-vscode/__snapshots__/test.ts.snap @@ -10,7 +10,7 @@ Array [ "message": "Unexpected unknown at-rule \\"@unknown\\" (scss/at-rule-no-unknown)", "range": Object { "end": Object { - "character": 30, + "character": 8, "line": 0, }, "start": Object { @@ -74,7 +74,7 @@ Array [ "message": "Unknown rule this-rule-does-not-exist.", "range": Object { "end": Object { - "character": 1, + "character": 4, "line": 0, }, "start": Object { @@ -90,7 +90,7 @@ Array [ "message": "Unknown rule this-rule-also-does-not-exist.", "range": Object { "end": Object { - "character": 1, + "character": 4, "line": 0, }, "start": Object { @@ -225,8 +225,8 @@ Array [ "message": "Unexpected unit (length-zero-no-unit)", "range": Object { "end": Object { - "character": 10, - "line": 1, + "character": 12, + "line": 3, }, "start": Object { "character": 10, @@ -329,7 +329,7 @@ Object { "message": "Disable for \\"indentation\\" is missing a description", "range": Object { "end": Object { - "character": 5, + "character": 48, "line": 2, }, "start": Object { @@ -345,7 +345,7 @@ Object { "message": "Disable for \\"indentation\\" is missing a description", "range": Object { "end": Object { - "character": 1, + "character": 34, "line": 5, }, "start": Object { @@ -361,7 +361,7 @@ Object { "message": "Disable for \\"indentation\\" is missing a description", "range": Object { "end": Object { - "character": 15, + "character": 53, "line": 11, }, "start": Object { From 2f3607118719f63f829d9bab20fe563dedbaa015 Mon Sep 17 00:00:00 2001 From: yosuke ota Date: Sat, 21 Oct 2023 16:46:41 +0900 Subject: [PATCH 7/9] update snapshot --- .../__tests__/__snapshots__/code-actions.ts.snap | 14 ++++++++++++++ .../report-descriptionless-disables.ts.snap | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/test/e2e/__tests__/__snapshots__/code-actions.ts.snap b/test/e2e/__tests__/__snapshots__/code-actions.ts.snap index 9386e0f7..9cb0cf8e 100644 --- a/test/e2e/__tests__/__snapshots__/code-actions.ts.snap +++ b/test/e2e/__tests__/__snapshots__/code-actions.ts.snap @@ -19,6 +19,20 @@ exports[`Code actions should disable rules for a specific line with a comment on " `; +exports[`Code actions should disable rules for a specific line with a comment on the same line 2`] = ` +"#!/usr/bin/env node +/* stylelint-disable color-no-invalid-hex */ +/* eslint-disable node/shebang */ +'use strict'; + +const css = css\` + .foo { + color: #00; + } +\`; +" +`; + exports[`Code actions should disable rules for an entire file 1`] = ` "/* stylelint-disable indentation */ a { diff --git a/test/e2e/__tests__/__snapshots__/report-descriptionless-disables.ts.snap b/test/e2e/__tests__/__snapshots__/report-descriptionless-disables.ts.snap index 602fefad..7f1d464a 100644 --- a/test/e2e/__tests__/__snapshots__/report-descriptionless-disables.ts.snap +++ b/test/e2e/__tests__/__snapshots__/report-descriptionless-disables.ts.snap @@ -7,7 +7,7 @@ Array [ "message": "Disable for \\"indentation\\" is missing a description", "range": Object { "end": Object { - "character": 5, + "character": 48, "line": 2, }, "start": Object { From c0783a5cf1a0d572b585c680b202bea740078583 Mon Sep 17 00:00:00 2001 From: yosuke ota Date: Sat, 21 Oct 2023 17:02:26 +0900 Subject: [PATCH 8/9] fix --- test/integration/stylelint-vscode/test.ts | 31 +++++++++++++---------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/test/integration/stylelint-vscode/test.ts b/test/integration/stylelint-vscode/test.ts index 36e2e651..ba4e5ddc 100644 --- a/test/integration/stylelint-vscode/test.ts +++ b/test/integration/stylelint-vscode/test.ts @@ -3,6 +3,7 @@ import { pathToFileURL } from 'url'; import { TextDocument } from 'vscode-languageserver-textdocument'; import { StylelintRunner } from '../../../src/utils/stylelint'; import { version as stylelintVersion } from 'stylelint/package.json'; +import { version as stylelintScssVersion } from 'stylelint-scss/package.json'; import semver from 'semver'; const createDocument = (uri: string | null, languageId: string, contents: string): TextDocument => @@ -264,23 +265,25 @@ a { color: #000 } expect(result.diagnostics).toMatchSnapshot(); }); - test('should be resolved with diagnostic plugin rule URL', async () => { - expect.assertions(1); - const runner = new StylelintRunner(); - const result = await runner.lintDocument( - createDocument('unknown-rule.scss', 'scss', '@unknown (max-width: 960px) {}'), - { - config: { - plugins: ['stylelint-scss'], - rules: { - 'scss/at-rule-no-unknown': true, + if (semver.satisfies(stylelintScssVersion, '^15')) { + test('should be resolved with diagnostic plugin rule URL', async () => { + expect.assertions(1); + const runner = new StylelintRunner(); + const result = await runner.lintDocument( + createDocument('unknown-rule.scss', 'scss', '@unknown (max-width: 960px) {}'), + { + config: { + plugins: ['stylelint-scss'], + rules: { + 'scss/at-rule-no-unknown': true, + }, }, }, - }, - ); + ); - expect(result.diagnostics).toMatchSnapshot(); - }); + expect(result.diagnostics).toMatchSnapshot(); + }); + } }); describe('StylelintRunner with a configuration file', () => { From 8e99e0af4e2abfd045085e990d52afbefc87c72c Mon Sep 17 00:00:00 2001 From: yosuke ota Date: Sat, 21 Oct 2023 17:07:47 +0900 Subject: [PATCH 9/9] fix: test cases --- .../__snapshots__/test.ts.snap | 24 ------------------- test/integration/stylelint-vscode/test.ts | 22 ++++++++++++++++- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/test/integration/stylelint-vscode/__snapshots__/test.ts.snap b/test/integration/stylelint-vscode/__snapshots__/test.ts.snap index 2ce18d11..d14ca119 100644 --- a/test/integration/stylelint-vscode/__snapshots__/test.ts.snap +++ b/test/integration/stylelint-vscode/__snapshots__/test.ts.snap @@ -1,29 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`StylelintRunner should be resolved with diagnostic plugin rule URL 1`] = ` -Array [ - Object { - "code": "scss/at-rule-no-unknown", - "codeDescription": Object { - "href": "https://github.com/stylelint-scss/stylelint-scss/blob/master/src/rules/at-rule-no-unknown", - }, - "message": "Unexpected unknown at-rule \\"@unknown\\" (scss/at-rule-no-unknown)", - "range": Object { - "end": Object { - "character": 8, - "line": 0, - }, - "start": Object { - "character": 0, - "line": 0, - }, - }, - "severity": 1, - "source": "Stylelint", - }, -] -`; - exports[`StylelintRunner should be resolved with diagnostics when it lints CSS successfully 1`] = ` Array [ Object { diff --git a/test/integration/stylelint-vscode/test.ts b/test/integration/stylelint-vscode/test.ts index ba4e5ddc..a3bcb9d9 100644 --- a/test/integration/stylelint-vscode/test.ts +++ b/test/integration/stylelint-vscode/test.ts @@ -281,7 +281,27 @@ a { color: #000 } }, ); - expect(result.diagnostics).toMatchSnapshot(); + expect(result.diagnostics).toEqual([ + { + code: 'scss/at-rule-no-unknown', + codeDescription: { + href: 'https://github.com/stylelint-scss/stylelint-scss/blob/master/src/rules/at-rule-no-unknown', + }, + message: 'Unexpected unknown at-rule "@unknown" (scss/at-rule-no-unknown)', + range: { + end: { + character: 8, + line: 0, + }, + start: { + character: 0, + line: 0, + }, + }, + severity: 1, + source: 'Stylelint', + }, + ]); }); } });