Skip to content

Commit

Permalink
Fixed block-lang false positives for non-svelte files (#394)
Browse files Browse the repository at this point in the history
Co-authored-by: ota-meshi <otameshiyo23@gmail.com>
  • Loading branch information
marekdedic and ota-meshi committed Mar 7, 2023
1 parent 3097b1b commit 4c5be6f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
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

0 comments on commit 4c5be6f

Please sign in to comment.