Skip to content

Commit 4c5be6f

Browse files
Fixed block-lang false positives for non-svelte files (#394)
Co-authored-by: ota-meshi <[email protected]>
1 parent 3097b1b commit 4c5be6f

File tree

5 files changed

+20
-0
lines changed

5 files changed

+20
-0
lines changed

.changeset/eleven-guests-chew.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-plugin-svelte": patch
3+
---
4+
5+
fix(block-lang): fixed false positives for non-svelte files

src/rules/block-lang.ts

+3
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ export default createRule("block-lang", {
5959
type: "suggestion",
6060
},
6161
create(context) {
62+
if (!context.parserServices.isSvelte) {
63+
return {}
64+
}
6265
const enforceScriptPresent: boolean =
6366
context.options[0]?.enforceScriptPresent ?? false
6467
const enforceStylePresent: boolean =
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"options": [
3+
{
4+
"enforceScriptPresent": true,
5+
"enforceStylePresent": true,
6+
"script": "ts",
7+
"style": "scss"
8+
}
9+
]
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const value: boolean | number = false
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const value = false

0 commit comments

Comments
 (0)