- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 690
Open
Description
I'd like to be able to lint my .vue
file script sections only if lang="ts"
. At the moment ESLint is linting script
sections that are just plain JS (ie. <script setup>
) as well as TS ones (<script setup lang="ts">
) when I run eslint . --ext .vue --ignore-path .gitignore
. A good solution would perhaps be to be able to say in .eslintrc.cjs
which script section languages should be linted. Another solution would be to allow to set which rules get linted based on language; obviously certain TS rules I apply do not apply to plain JS because plain JS cannot set types.
Tell us about your environment
- ESLint version: ^8.22.0
- eslint-plugin-vue version: ^9.3.0
- Node version: 16.17.0
kawazoe and so1ve
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
jez9999 commentedon Nov 8, 2022
Guys, you advise opening new issues like this and reaching out and yet an issue can go weeks and have absolutely no response. It's kind of frustrating. Why don't you make some effort to give some response??? I'd really like some direction on this, it's rather screwing up my linting. Quote: "If you can't find the right solution, don't hesitate to reach out in issues – we're happy to help!"
FloEdelmann commentedon Nov 10, 2022
Please watch your tone, this is an open-source repository and we all work in our spare time on triaging, commenting, reviewing and coding.
Limiting rules to only
.vue
files withlang="ts"
seems like a good idea, but it is currently not possible. I don't know if extra support for that would maybe need to be implemented in https://github.com/vuejs/vue-eslint-parser. Also, there could already be (closed) issues in this repository suggesting the same thing, have you looked at those already? @ota-meshi Maybe you know what needs to be done to get support for this?yuntian001 commentedon Nov 21, 2022
这个功能是有必要的,因为如果设置规则
@typescript-eslint/naming-convention
会报错Error: Error while loading rule '@typescript-eslint/naming-convention': You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project" property for @typescript-eslint/parser.
原因是为.vue
中的<script>
应用了@typescript-eslint/naming-convention
rules, 而现在无法为.vue
中的<script>
和<script lang="ts">
分别设置规则kawazoe commentedon Jan 5, 2023
I've hit the same issue as @yuntian001 . I have
@typescript-eslint/prefer-optional-chain
set and it crashes when eslint process vue files that uses plain javascript.I'm not too sure if this is possible, but maybe there's a way to automatically skip rules that requires
context.parserServices.hasFullTypeInformation
to be true when parsing js code? They usually don't make sense anyway.In the mean time, the best solution is to always set
lang="ts"
in vue files if you use TS in some.wenfangdu commentedon Jun 10, 2023
@kawazoe Tracked here: #2211
so1ve commentedon Oct 4, 2023
I think this is currently impossible unless eslint-plugin-vue do a huge refactor to use eslint's preprocessor api.