Repository: ota-meshi/eslint-plugin-svelte (ts)

Issue:
`block-lang` triggers on non-svelte files
Hi
`block-lang` reports plain `.ts` files as well, no just svelte files - kind of a false positive.

I'll try to fix it, but I am not sure how to find out whether a file is a svelte file - @ota-meshi, do you just check for file extension? I can't check for `<script>` or `<style>` blocks as they theoretically may not be present...

Pull request:
Fixed `block-lang` false positives for non-svelte files
Closes #393

Patch:
diff --git a/.changeset/eleven-guests-chew.md b/.changeset/eleven-guests-chew.md
new file mode 100644
index 0000000..a84c331
--- /dev/null
+++ b/.changeset/eleven-guests-chew.md
@@ -0,0 +1,5 @@
+---
+"eslint-plugin-svelte": patch
+---
+
+fix(block-lang): fixed false positives for non-svelte files
diff --git a/src/rules/block-lang.ts b/src/rules/block-lang.ts
index 19c50f0..d526ef1 100644
--- a/src/rules/block-lang.ts
+++ b/src/rules/block-lang.ts
@@ -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 =


Test patch:
diff --git a/tests/fixtures/rules/block-lang/valid/non-svelte/_config.json b/tests/fixtures/rules/block-lang/valid/non-svelte/_config.json
new file mode 100644
index 0000000..5e80e5a
--- /dev/null
+++ b/tests/fixtures/rules/block-lang/valid/non-svelte/_config.json
@@ -0,0 +1,10 @@
+{
+  "options": [
+    {
+      "enforceScriptPresent": true,
+      "enforceStylePresent": true,
+      "script": "ts",
+      "style": "scss"
+    }
+  ]
+}
diff --git a/tests/fixtures/rules/block-lang/valid/non-svelte/non-svelte01-input.ts b/tests/fixtures/rules/block-lang/valid/non-svelte/non-svelte01-input.ts
new file mode 100644
index 0000000..c7a2e01
--- /dev/null
+++ b/tests/fixtures/rules/block-lang/valid/non-svelte/non-svelte01-input.ts
@@ -0,0 +1,1 @@
+export const value: boolean | number = false
diff --git a/tests/fixtures/rules/block-lang/valid/non-svelte/non-svelte02-input.js b/tests/fixtures/rules/block-lang/valid/non-svelte/non-svelte02-input.js
new file mode 100644
index 0000000..38241da
--- /dev/null
+++ b/tests/fixtures/rules/block-lang/valid/non-svelte/non-svelte02-input.js
@@ -0,0 +1,1 @@
+export const value = false