-
-
Notifications
You must be signed in to change notification settings - Fork 664
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
Add ESLint Processor to differentiate Vue SFC <script>
lang
s to apply different rules, parsers, etc.
#1910
Comments
Just wanted to ask, if this issue is still relevant. Will this be implemented in v10 or is it too complex? Is there anything I could help with? |
Using ESLint's processor gives the code block a virtual filename that doesn't exist, making it impossible to provide TypeScript type information. So for now I don't think using a processor will work. For now, if you want to configure a rule with only e.g. const glob = require('fast-glob');
const scriptTs = 'lang="ts"';
const vueTsFiles = glob
.sync(['**/*.vue', '!**/node_modules/**'], {cwd: path.resolve()})
.filter((filePath) => fs.readFileSync(filePath, 'utf8').includes(scriptTs));
module.exports = {
overrides: [
...
{
files: vueTsFiles,
parser: 'vue-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser',
...
},
extends: [...],
rules: {...}
}
]
}; |
Thank you very much for your thorough answer 💚 |
Thank you for your answer, it works! |
Tell us about your environment
The problem you want to solve.
It would be awesome to be able to filter
.vue
withlang="ts"
in ESLintoverrides
.Currently, it seems to be not possible.
But if there was an ESLint Processor for Vue, it would be possible to filter for the
<script>
lang
(or even<template>
?):https://eslint.org/docs/user-guide/configuring/plugins#specifying-processor.
Your take on the correct solution to problem.
Implement an ESLint Processor for Vue SFCs.
Something like the following could be possible?
.eslintrc.js
Additional context
Addresses:
@typescript-eslint/eslint-plugin
crashes when applying rules to Vue SFC<script>
not parsed with@typescript-eslint/parser
vue-eslint-parser#156The text was updated successfully, but these errors were encountered: