diff --git a/.changeset/smart-turkeys-fold.md b/.changeset/smart-turkeys-fold.md new file mode 100644 index 00000000..9d309a6e --- /dev/null +++ b/.changeset/smart-turkeys-fold.md @@ -0,0 +1,5 @@ +--- +"svelte-eslint-parser": patch +--- + +fix: update postcss to 8.4.28 diff --git a/package.json b/package.json index d70139c4..eca561d1 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "eslint-scope": "^7.0.0", "eslint-visitor-keys": "^3.0.0", "espree": "^9.0.0", - "postcss": "^8.4.25", + "postcss": "^8.4.28", "postcss-scss": "^4.0.6" }, "devDependencies": { diff --git a/tests/fixtures/parser/style-context/empty-style-element-output.json b/tests/fixtures/parser/style-context/empty-style-element-output.json index f7793306..e03a6244 100644 --- a/tests/fixtures/parser/style-context/empty-style-element-output.json +++ b/tests/fixtures/parser/style-context/empty-style-element-output.json @@ -8,6 +8,11 @@ "type": "root", "nodes": [], "source": { + "end": { + "column": 8, + "line": 7, + "offset": 52 + }, "inputId": 0, "start": { "column": 8, diff --git a/tests/fixtures/parser/style-context/one-line-css-output.json b/tests/fixtures/parser/style-context/one-line-css-output.json index f1c33607..052d8177 100644 --- a/tests/fixtures/parser/style-context/one-line-css-output.json +++ b/tests/fixtures/parser/style-context/one-line-css-output.json @@ -59,6 +59,11 @@ } ], "source": { + "end": { + "column": 34, + "line": 7, + "offset": 103 + }, "inputId": 0, "start": { "column": 8, diff --git a/tests/fixtures/parser/style-context/simple-css-output.json b/tests/fixtures/parser/style-context/simple-css-output.json index c17e3e9c..26b4888c 100644 --- a/tests/fixtures/parser/style-context/simple-css-output.json +++ b/tests/fixtures/parser/style-context/simple-css-output.json @@ -108,6 +108,11 @@ } ], "source": { + "end": { + "column": 1, + "line": 17, + "offset": 159 + }, "inputId": 0, "start": { "column": 8, diff --git a/tests/fixtures/parser/style-context/simple-scss-output.json b/tests/fixtures/parser/style-context/simple-scss-output.json index 600b9962..42a09d6e 100644 --- a/tests/fixtures/parser/style-context/simple-scss-output.json +++ b/tests/fixtures/parser/style-context/simple-scss-output.json @@ -159,6 +159,11 @@ } ], "source": { + "end": { + "column": 1, + "line": 18, + "offset": 276 + }, "inputId": 0, "start": { "column": 20, diff --git a/tests/fixtures/parser/style-context/unrelated-style-attr-output.json b/tests/fixtures/parser/style-context/unrelated-style-attr-output.json index 4d7100d8..c5744ce8 100644 --- a/tests/fixtures/parser/style-context/unrelated-style-attr-output.json +++ b/tests/fixtures/parser/style-context/unrelated-style-attr-output.json @@ -108,6 +108,11 @@ } ], "source": { + "end": { + "column": 1, + "line": 17, + "offset": 176 + }, "inputId": 0, "start": { "column": 25, diff --git a/tests/fixtures/parser/style-location-converter/simple-css-output.json b/tests/fixtures/parser/style-location-converter/simple-css-output.json index af8eed52..c2f8d1ad 100644 --- a/tests/fixtures/parser/style-location-converter/simple-css-output.json +++ b/tests/fixtures/parser/style-location-converter/simple-css-output.json @@ -4,11 +4,15 @@ "start": { "line": 9, "column": 7 + }, + "end": { + "line": 17, + "column": 1 } }, [ 89, - null + 160 ] ], [ diff --git a/tests/fixtures/parser/style-location-converter/simple-scss-output.json b/tests/fixtures/parser/style-location-converter/simple-scss-output.json index 2e622e5c..01cb982b 100644 --- a/tests/fixtures/parser/style-location-converter/simple-scss-output.json +++ b/tests/fixtures/parser/style-location-converter/simple-scss-output.json @@ -4,11 +4,15 @@ "start": { "line": 7, "column": 19 + }, + "end": { + "line": 18, + "column": 1 } }, [ 130, - null + 277 ] ], [ diff --git a/tests/src/parser/style-context.ts b/tests/src/parser/style-context.ts index f4e96d37..69a2750f 100644 --- a/tests/src/parser/style-context.ts +++ b/tests/src/parser/style-context.ts @@ -41,11 +41,11 @@ describe("Check for AST.", () => { function styleContextToJson(styleContext: StyleContext): string { return JSON.stringify(styleContext, nodeReplacer, 2); -} -function nodeReplacer(key: string, value: any): any { - if (key === "file" || key === "url") { - return undefined; + function nodeReplacer(key: string, value: any): any { + if (key === "file" || key === "url") { + return undefined; + } + return value; } - return value; } diff --git a/tools/update-fixtures.ts b/tools/update-fixtures.ts index b3ad86a0..11c8b99c 100644 --- a/tools/update-fixtures.ts +++ b/tools/update-fixtures.ts @@ -14,12 +14,22 @@ import { import type ts from "typescript"; import type ESTree from "estree"; import * as tsESLintParser from "@typescript-eslint/parser"; +import type { SourceLocation } from "../src/ast"; const ERROR_FIXTURE_ROOT = path.resolve( __dirname, "../tests/fixtures/parser/error", ); +const STYLE_CONTEXT_FIXTURE_ROOT = path.resolve( + __dirname, + "../tests/fixtures/parser/style-context", +); +const STYLE_LOCATION_FIXTURE_ROOT = path.resolve( + __dirname, + "../tests/fixtures/parser/style-location-converter", +); + const RULES = [ "no-unused-labels", "no-extra-label", @@ -128,6 +138,61 @@ for (const { input, inputFileName, outputFileName, config } of listupFixtures( } } +for (const { input, inputFileName, outputFileName, config } of listupFixtures( + STYLE_CONTEXT_FIXTURE_ROOT, +)) { + const result = parse(input, inputFileName, config); + const styleContext = result.services.getStyleContext(); + fs.writeFileSync( + outputFileName, + `${styleContextToJson(styleContext)}\n`, + "utf8", + ); +} + +/** StyleContext to JSON string */ +function styleContextToJson(styleContext: parser.StyleContext): string { + return JSON.stringify(styleContext, nodeReplacer, 2); + + /** JSON string replacer for StyleContext */ + function nodeReplacer(key: string, value: any): any { + if (key === "file" || key === "url") { + return undefined; + } + return value; + } +} + +for (const { input, inputFileName, outputFileName, config } of listupFixtures( + STYLE_LOCATION_FIXTURE_ROOT, +)) { + const services = parse(input, inputFileName, config).services; + const styleContext = services.getStyleContext(); + if (styleContext.status !== "success") { + continue; + } + const locations: [ + Partial, + [number | undefined, number | undefined], + ][] = [ + [ + services.styleNodeLoc(styleContext.sourceAst), + services.styleNodeRange(styleContext.sourceAst), + ], + ]; + styleContext.sourceAst.walk((node) => { + locations.push([ + services.styleNodeLoc(node), + services.styleNodeRange(node), + ]); + }); + fs.writeFileSync( + outputFileName, + `${JSON.stringify(locations, undefined, 2)}\n`, + "utf8", + ); +} + // eslint-disable-next-line require-jsdoc -- X function createLinter() { const linter = new Linter();