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

Issue:
Disable particular rules for template expressions
### Description

Hi,
I'd like to disable some rules for template expressions only - typically rules about typescript. Example:

```svelte
<button onClick={() => {clicked += 1}}>Increment</button> // HERE

<script lang="ts">
function fn() { // HERE
    return 3;
}
</script>
```

With my current configuration, I get the error `Missing return type on function` (`@typescript-eslint/explicit-function-return-type`) on the two lines marked by comments. This is problematic, because I can't use TS in template expressions and therefore I can't add a return type annotation to the first line of my snippet. However, I would still like to have the rule turned on for the second case, where it correctly reports that I forgot to add the return type annotation.

Currently, I found no way of doing this other than manually ignoring all the "false positives" or getting rid of any non-trivial template expressions - I would like to have a way to say to eslint that the rule `@typescript-eslint/explicit-function-return-type` should be turned off for all template expressions, however it should still check `<script />` blocks.

Pull request description:
fix: false report in `settings.ignoreWarnings`
close #257 

Patch:
diff --git a/.changeset/chilly-olives-check.md b/.changeset/chilly-olives-check.md
new file mode 100644
index 0000000..9d85b2b
--- /dev/null
+++ b/.changeset/chilly-olives-check.md
@@ -0,0 +1,5 @@
+---
+"eslint-plugin-svelte": patch
+---
+
+fix: false report in `settings.ignoreWarnings`
diff --git a/.github/workflows/NodeCI.yml b/.github/workflows/NodeCI.yml
index 53a761d..555961e 100644
--- a/.github/workflows/NodeCI.yml
+++ b/.github/workflows/NodeCI.yml
@@ -44,6 +44,11 @@ jobs:
         uses: actions/setup-node@v3
         with:
           node-version: ${{ matrix.node }}
+      - name: Remove @sveltejs/kit # Remove @sveltejs/kit because postinstall fails on old node.
+        # Use npm because yarn remove needs the lock file.
+        run: |+
+          npm uninstall @sveltejs/kit --legacy-peer-deps
+          rm -rf node_modules
       - name: Install ESLint ${{ matrix.eslint }}
         run: |+
           yarn add -D eslint@${{ matrix.eslint }} --ignore-engines
diff --git a/README.md b/README.md
index 799c077..8137b77 100644
--- a/README.md
+++ b/README.md
@@ -89,7 +89,7 @@ This plugin provides configs:
 
 - `plugin:svelte/base` ... Configuration to enable correct Svelte parsing.
 - `plugin:svelte/recommended` ... Above, plus rules to prevent errors or unintended behavior.
-- `plugin:svelte/prettier` ... Turn off rules that may conflict with [Prettier](https://prettier.io/) ([prettier-plugin-svelte](https://github.com/sveltejs/prettier-plugin-svelte)).
+- `plugin:svelte/prettier` ... Turns off rules that may conflict with [Prettier](https://prettier.io/) (You still need to configure prettier to work with svelte yourself, for example by using [prettier-plugin-svelte](https://github.com/sveltejs/prettier-plugin-svelte).).
 
 See [the rule list](https://ota-meshi.github.io/eslint-plugin-svelte/rules/) to get the `rules` that this plugin provides.
 
diff --git a/docs/user-guide.md b/docs/user-guide.md
index d5a971a..bd12959 100644
--- a/docs/user-guide.md
+++ b/docs/user-guide.md
@@ -41,7 +41,7 @@ This plugin provides configs:
 
 - `plugin:svelte/base` ... Configuration to enable correct Svelte parsing.
 - `plugin:svelte/recommended` ... Above, plus rules to prevent errors or unintended behavior.
-- `plugin:svelte/prettier` ... Turn off rules that may conflict with [Prettier](https://prettier.io/) ([prettier-plugin-svelte](https://github.com/sveltejs/prettier-plugin-svelte)).
+- `plugin:svelte/prettier` ... Turns off rules that may conflict with [Prettier](https://prettier.io/) (You still need to configure prettier to work with svelte yourself, for example by using [prettier-plugin-svelte](https://github.com/sveltejs/prettier-plugin-svelte).).
 
 See [the rule list](./rules.md) to get the `rules` that this plugin provides.
 
diff --git a/src/rules/system.ts b/src/rules/system.ts
index 9a2724a..88b15d4 100644
--- a/src/rules/system.ts
+++ b/src/rules/system.ts
@@ -63,7 +63,7 @@ export default createRule("system", {
           loc: node.startTag.loc.end,
         })
         if (node.endTag) {
-          directives.enableBlock(node.endTag.loc.start, isIgnoreRule, {
+          directives.disableBlock(node.endTag.loc.start, isIgnoreRule, {
             loc: node.endTag.loc.start,
           })
         }


Test patch:
diff --git a/tests/src/settings/ignore-warnings.ts b/tests/src/settings/ignore-warnings.ts
index 33ae318..94ee3a9 100644
--- a/tests/src/settings/ignore-warnings.ts
+++ b/tests/src/settings/ignore-warnings.ts
@@ -10,6 +10,8 @@ describe("ignore-warnings", () => {
       <script>
         a+b;
       </script>
+      {@html a+b}
+      {@debug a}
       `
 
     const linter = new eslint.ESLint({
@@ -63,6 +65,10 @@ describe("ignore-warnings", () => {
           ruleId: "no-undef",
           line: 5,
         },
+        {
+          ruleId: "svelte/no-at-html-tags",
+          line: 7,
+        },
       ],
     )
   })
@@ -73,6 +79,8 @@ describe("ignore-warnings", () => {
       <script>
         a+b;
       </script>
+      {@html a+b}
+      {@debug a}
       `
 
     const linter = new eslint.ESLint({
@@ -122,6 +130,10 @@ describe("ignore-warnings", () => {
           ruleId: "no-undef",
           line: 5,
         },
+        {
+          ruleId: "svelte/no-at-html-tags",
+          line: 7,
+        },
       ],
     )
   })
@@ -133,6 +145,8 @@ describe("ignore-warnings", () => {
       <script>
         a+b;
       </script>
+      {@html a+b}
+      {@debug a}
       `
 
     const linter = new eslint.ESLint({