Skip to content
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

eslint-disable comments not applying inside <template> #2622

Open
2 tasks done
marcopixel opened this issue Nov 26, 2024 · 0 comments
Open
2 tasks done

eslint-disable comments not applying inside <template> #2622

marcopixel opened this issue Nov 26, 2024 · 0 comments

Comments

@marcopixel
Copy link

marcopixel commented Nov 26, 2024

Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have read the FAQ and my problem is not listed.

Tell us about your environment

  • ESLint version: 9.15.0
  • eslint-plugin-vue version: 9.20.1
  • Vue version: 3.5.13
  • Node version: 22.3.0
  • Operating System: Windows 11 24H2

Please show your full configuration:

// parser
import parserTypescript from "@typescript-eslint/parser"
import parserVue from "vue-eslint-parser"

// plugins
import globals from "globals"
import pluginUnicorn from "eslint-plugin-unicorn"
import pluginTypescript from "@typescript-eslint/eslint-plugin"
import pluginVue from "eslint-plugin-vue"

// shared rules
const sharedRules = {
  "@typescript-eslint/ban-ts-comment": "off",
  "@typescript-eslint/no-unused-vars": "off",
  "unicorn/filename-case": [
    "error",
    {
      cases: {
        pascalCase: true,
        camelCase: true,
        kebabCase: false
      },
      ignore: [
        "globals.d.ts",
        "vite-env.d.ts",
        "vite.config.ts",
        "vite-environment.d.ts",
        String.raw`\.spec.ts(x)?`,
        String.raw`\.types.ts(x)?`,
        String.raw`\.stories.ts(x)?`,
        String.raw`\.styled.ts(x)?`,
        String.raw`\.styles.ts(x)?`
      ]
    }
  ],
  "unicorn/no-abusive-eslint-disable": "off",
  "unicorn/no-useless-undefined": "off",
  "unicorn/numeric-separators-style": "off",
  "unicorn/prefer-global-this": "off",
  "unicorn/prevent-abbreviations": "off"
}

// config object
export default [
  {
    ignores: ["public", "build", "dist", "node_modules", "coverage", ".nuxt", ".output"]
  },
  {
    files: ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.cjs", "**/*.mjs"],
    languageOptions: {
      parser: parserTypescript,
      globals: globals.builtin
    },
    plugins: {
      "unicorn": pluginUnicorn,
      "@typescript-eslint": pluginTypescript
    },
    rules: {
      ...pluginUnicorn.configs.recommended.rules,
      ...pluginTypescript.configs.recommended.rules,
      ...sharedRules
    }
  },
  {
    files: ["**/*.vue"],
    languageOptions: {
      parser: parserVue,
      parserOptions: {
        parser: parserTypescript
      }
    },
    plugins: {
      "unicorn": pluginUnicorn,
      "vue": pluginVue,
      "@typescript-eslint": pluginTypescript
    },
    rules: {
      ...pluginUnicorn.configs.recommended.rules,
      ...pluginVue.configs.recommended.rules,
      ...pluginTypescript.configs.recommended.rules,
      ...sharedRules,
      "vue/script-setup-uses-vars": "error",
      "vue/no-v-html": "error"
    }
  }
]

What did you do?

<template>
  <!-- eslint-disable vue/no-v-html -->
  <div>
    <h1>Test Heading</h1>
    <div v-if="testHtml" v-html="testHtml"></div>
  </div>
</template>

<script setup lang="ts">
const testHtml = '<h2>HTML</h2>';
</script>

What did you expect to happen?
The rule vue/no-v-html should be disabled.

What actually happened?
The rule still applies to the file, ignoring any eslint-disable comments within or outside the <template> tags.

Repository to reproduce this issue
https://stackblitz.com/edit/vitejs-vite-7gdlmv?file=src%2FApp.vue
You can either download the repro case or just open a new terminal within StackBlitz and execute npm run lint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant