Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support postcss #600

Merged
merged 2 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/silver-swans-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"svelte-eslint-parser": patch
---

feat: support postcss
7 changes: 4 additions & 3 deletions src/parser/style-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
*/
export function parseStyleContext(
styleElement: SvelteStyleElement | undefined,
ctx: Context,
ctx: Context

Check failure on line 40 in src/parser/style-context.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `,`
): StyleContext {
if (!styleElement || !styleElement.endTag) {
return { status: "no-style-element" };
Expand All @@ -56,6 +56,7 @@
let parseFn: Parser<Root>, sourceAst: Root;
switch (sourceLang) {
case "css":
case "postcss":
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main change is only here.

parseFn = postcss.parse;
break;
case "scss":
Expand All @@ -66,7 +67,7 @@
}
const styleCode = ctx.code.slice(
styleElement.startTag.range[1],
styleElement.endTag.range[0],
styleElement.endTag.range[0]

Check failure on line 70 in src/parser/style-context.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `,`
);
try {
sourceAst = parseFn(styleCode, {
Expand Down Expand Up @@ -109,7 +110,7 @@
* Extracts a node range (like that of any ESLint node) from a parsed svelte style node.
*/
export function styleNodeRange(
node: Node,
node: Node

Check failure on line 113 in src/parser/style-context.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `,`
): [number | undefined, number | undefined] {
if (node.source === undefined) {
return [undefined, undefined];
Expand Down
6 changes: 6 additions & 0 deletions tests/fixtures/parser/ast/postcss-input.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<style lang="postcss">
body {
colour: white;
background-colour: grey;
}
</style>
Loading
Loading