Skip to content

Commit a4d31f0

Browse files
authored
fix: update postcss to 8.4.28 (#396)
* fix: update postcss to 8.4.28 * Create smart-turkeys-fold.md
1 parent aeeec8f commit a4d31f0

11 files changed

+111
-8
lines changed

.changeset/smart-turkeys-fold.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"svelte-eslint-parser": patch
3+
---
4+
5+
fix: update postcss to 8.4.28

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"eslint-scope": "^7.0.0",
5757
"eslint-visitor-keys": "^3.0.0",
5858
"espree": "^9.0.0",
59-
"postcss": "^8.4.25",
59+
"postcss": "^8.4.28",
6060
"postcss-scss": "^4.0.6"
6161
},
6262
"devDependencies": {

tests/fixtures/parser/style-context/empty-style-element-output.json

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
"type": "root",
99
"nodes": [],
1010
"source": {
11+
"end": {
12+
"column": 8,
13+
"line": 7,
14+
"offset": 52
15+
},
1116
"inputId": 0,
1217
"start": {
1318
"column": 8,

tests/fixtures/parser/style-context/one-line-css-output.json

+5
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@
5959
}
6060
],
6161
"source": {
62+
"end": {
63+
"column": 34,
64+
"line": 7,
65+
"offset": 103
66+
},
6267
"inputId": 0,
6368
"start": {
6469
"column": 8,

tests/fixtures/parser/style-context/simple-css-output.json

+5
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@
108108
}
109109
],
110110
"source": {
111+
"end": {
112+
"column": 1,
113+
"line": 17,
114+
"offset": 159
115+
},
111116
"inputId": 0,
112117
"start": {
113118
"column": 8,

tests/fixtures/parser/style-context/simple-scss-output.json

+5
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,11 @@
159159
}
160160
],
161161
"source": {
162+
"end": {
163+
"column": 1,
164+
"line": 18,
165+
"offset": 276
166+
},
162167
"inputId": 0,
163168
"start": {
164169
"column": 20,

tests/fixtures/parser/style-context/unrelated-style-attr-output.json

+5
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@
108108
}
109109
],
110110
"source": {
111+
"end": {
112+
"column": 1,
113+
"line": 17,
114+
"offset": 176
115+
},
111116
"inputId": 0,
112117
"start": {
113118
"column": 25,

tests/fixtures/parser/style-location-converter/simple-css-output.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@
44
"start": {
55
"line": 9,
66
"column": 7
7+
},
8+
"end": {
9+
"line": 17,
10+
"column": 1
711
}
812
},
913
[
1014
89,
11-
null
15+
160
1216
]
1317
],
1418
[

tests/fixtures/parser/style-location-converter/simple-scss-output.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@
44
"start": {
55
"line": 7,
66
"column": 19
7+
},
8+
"end": {
9+
"line": 18,
10+
"column": 1
711
}
812
},
913
[
1014
130,
11-
null
15+
277
1216
]
1317
],
1418
[

tests/src/parser/style-context.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ describe("Check for AST.", () => {
4141

4242
function styleContextToJson(styleContext: StyleContext): string {
4343
return JSON.stringify(styleContext, nodeReplacer, 2);
44-
}
4544

46-
function nodeReplacer(key: string, value: any): any {
47-
if (key === "file" || key === "url") {
48-
return undefined;
45+
function nodeReplacer(key: string, value: any): any {
46+
if (key === "file" || key === "url") {
47+
return undefined;
48+
}
49+
return value;
4950
}
50-
return value;
5151
}

tools/update-fixtures.ts

+65
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,22 @@ import {
1414
import type ts from "typescript";
1515
import type ESTree from "estree";
1616
import * as tsESLintParser from "@typescript-eslint/parser";
17+
import type { SourceLocation } from "../src/ast";
1718

1819
const ERROR_FIXTURE_ROOT = path.resolve(
1920
__dirname,
2021
"../tests/fixtures/parser/error",
2122
);
2223

24+
const STYLE_CONTEXT_FIXTURE_ROOT = path.resolve(
25+
__dirname,
26+
"../tests/fixtures/parser/style-context",
27+
);
28+
const STYLE_LOCATION_FIXTURE_ROOT = path.resolve(
29+
__dirname,
30+
"../tests/fixtures/parser/style-location-converter",
31+
);
32+
2333
const RULES = [
2434
"no-unused-labels",
2535
"no-extra-label",
@@ -128,6 +138,61 @@ for (const { input, inputFileName, outputFileName, config } of listupFixtures(
128138
}
129139
}
130140

141+
for (const { input, inputFileName, outputFileName, config } of listupFixtures(
142+
STYLE_CONTEXT_FIXTURE_ROOT,
143+
)) {
144+
const result = parse(input, inputFileName, config);
145+
const styleContext = result.services.getStyleContext();
146+
fs.writeFileSync(
147+
outputFileName,
148+
`${styleContextToJson(styleContext)}\n`,
149+
"utf8",
150+
);
151+
}
152+
153+
/** StyleContext to JSON string */
154+
function styleContextToJson(styleContext: parser.StyleContext): string {
155+
return JSON.stringify(styleContext, nodeReplacer, 2);
156+
157+
/** JSON string replacer for StyleContext */
158+
function nodeReplacer(key: string, value: any): any {
159+
if (key === "file" || key === "url") {
160+
return undefined;
161+
}
162+
return value;
163+
}
164+
}
165+
166+
for (const { input, inputFileName, outputFileName, config } of listupFixtures(
167+
STYLE_LOCATION_FIXTURE_ROOT,
168+
)) {
169+
const services = parse(input, inputFileName, config).services;
170+
const styleContext = services.getStyleContext();
171+
if (styleContext.status !== "success") {
172+
continue;
173+
}
174+
const locations: [
175+
Partial<SourceLocation>,
176+
[number | undefined, number | undefined],
177+
][] = [
178+
[
179+
services.styleNodeLoc(styleContext.sourceAst),
180+
services.styleNodeRange(styleContext.sourceAst),
181+
],
182+
];
183+
styleContext.sourceAst.walk((node) => {
184+
locations.push([
185+
services.styleNodeLoc(node),
186+
services.styleNodeRange(node),
187+
]);
188+
});
189+
fs.writeFileSync(
190+
outputFileName,
191+
`${JSON.stringify(locations, undefined, 2)}\n`,
192+
"utf8",
193+
);
194+
}
195+
131196
// eslint-disable-next-line require-jsdoc -- X
132197
function createLinter() {
133198
const linter = new Linter();

0 commit comments

Comments
 (0)