Skip to content

Some @typescript-eslint rules doesn't work in vue files #40

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

Closed
trygveaa opened this issue Feb 12, 2019 · 5 comments
Closed

Some @typescript-eslint rules doesn't work in vue files #40

trygveaa opened this issue Feb 12, 2019 · 5 comments

Comments

@trygveaa
Copy link

Some rules in @typescript-eslint check if the file name ends with .ts to determine if the rule should be run or not, because they don't apply to .js files.

For example, if I have this code:

const test = x => x;

If I place it in a .ts file, I will get a warning from @typescript-eslint/explicit-function-return-type. However, if I place it in a <script lang="ts"> block of a .vue file, this warning does not appear. This is because @typescript-eslint checks the file ending, and since it is .vue and not .ts, the rule isn't run.

Is there some other way @typescript-eslint could check if the code is typescript, other than by the file extension? How can it differentiate between .vue files which specify lang="ts" and those that don't?

Here is where @typescript-eslint does this check:
https://github.com/typescript-eslint/typescript-eslint/blob/7be56570de9d1983af95db5900ec730930d52712/packages/eslint-plugin/src/rules/explicit-function-return-type.ts#L83
https://github.com/typescript-eslint/typescript-eslint/blob/7be56570de9d1983af95db5900ec730930d52712/packages/eslint-plugin/src/util/misc.ts#L11-L13

@mysticatea
Copy link
Member

mysticatea commented Feb 12, 2019

Thank you for this report.

This is a tough problem.
Parsers cannot modify file names for rules, so this parser cannot solve the problem.

Hmm.

Possibly, this parser can tell the typescript parser (instead of rules) something. We need to discuss with typescript-eslint team.

@seibert-io
Copy link

Hey @mysticatea,

thanks for looking into this. Just checking in to see if anyone had a chance to discuss this with the typescript-eslint team already?

@IlCallo
Copy link

IlCallo commented Jul 15, 2019

The .ts extension check is gonna be removed into typescript-eslint in v2.0.0
typescript-eslint/typescript-eslint#594

@IlCallo
Copy link

IlCallo commented Aug 19, 2019

This should be resolved with typescript-eslint v2 and can probably be closed

@ota-meshi
Copy link
Member

I close this issue. If you have any problems, please open a new issue or follow another related issue.

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

No branches or pull requests

5 participants