Skip to content

Fixed block-lang false positives for non-svelte files #394

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

Merged
merged 11 commits into from
Mar 7, 2023
Merged
5 changes: 5 additions & 0 deletions .changeset/eleven-guests-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"eslint-plugin-svelte": patch
---

fix(block-lang): fixed false positives for non-svelte files
3 changes: 3 additions & 0 deletions src/rules/block-lang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ export default createRule("block-lang", {
type: "suggestion",
},
create(context) {
if (!context.parserServices.isSvelte) {
return {}
}
const enforceScriptPresent: boolean =
context.options[0]?.enforceScriptPresent ?? false
const enforceStylePresent: boolean =
Expand Down
10 changes: 10 additions & 0 deletions tests/fixtures/rules/block-lang/valid/non-svelte/_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"options": [
{
"enforceScriptPresent": true,
"enforceStylePresent": true,
"script": "ts",
"style": "scss"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const value: boolean | number = false
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const value = false