Skip to content

Commit

Permalink
fix: update postcss to 8.4.28 (#396)
Browse files Browse the repository at this point in the history
* fix: update postcss to 8.4.28

* Create smart-turkeys-fold.md
  • Loading branch information
ota-meshi authored Aug 16, 2023
1 parent aeeec8f commit a4d31f0
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/smart-turkeys-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"svelte-eslint-parser": patch
---

fix: update postcss to 8.4.28
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
"type": "root",
"nodes": [],
"source": {
"end": {
"column": 8,
"line": 7,
"offset": 52
},
"inputId": 0,
"start": {
"column": 8,
Expand Down
5 changes: 5 additions & 0 deletions tests/fixtures/parser/style-context/one-line-css-output.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@
}
],
"source": {
"end": {
"column": 34,
"line": 7,
"offset": 103
},
"inputId": 0,
"start": {
"column": 8,
Expand Down
5 changes: 5 additions & 0 deletions tests/fixtures/parser/style-context/simple-css-output.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@
}
],
"source": {
"end": {
"column": 1,
"line": 17,
"offset": 159
},
"inputId": 0,
"start": {
"column": 8,
Expand Down
5 changes: 5 additions & 0 deletions tests/fixtures/parser/style-context/simple-scss-output.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@
}
],
"source": {
"end": {
"column": 1,
"line": 18,
"offset": 276
},
"inputId": 0,
"start": {
"column": 20,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@
}
],
"source": {
"end": {
"column": 1,
"line": 17,
"offset": 176
},
"inputId": 0,
"start": {
"column": 25,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
"start": {
"line": 9,
"column": 7
},
"end": {
"line": 17,
"column": 1
}
},
[
89,
null
160
]
],
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
"start": {
"line": 7,
"column": 19
},
"end": {
"line": 18,
"column": 1
}
},
[
130,
null
277
]
],
[
Expand Down
10 changes: 5 additions & 5 deletions tests/src/parser/style-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
65 changes: 65 additions & 0 deletions tools/update-fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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<SourceLocation>,
[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();
Expand Down

0 comments on commit a4d31f0

Please sign in to comment.