-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
Typescript-Eslint conflict #1672
Comments
This also happens when you replace the enum with a simple array declaration - the problem seems to be the type declaration. So the minimal thing to reproduce is just to add something like this in a .vue file: const bar = [1, 2];
const foo : string = 'hi'; |
There's a related issue open in the eslint repo: eslint/eslint#10260 Also, in the repo of typescript-eslint-parser, there seem to be a coupe of issues over time concerning the that same rule, tow of which are still open and likely related: eslint/typescript-eslint-parser#449 So in that context, I would suspect this to be an upstream issue with typescript-eslint-parser for now. But since this only happens in .vue files (added a .ts file with the same enum, this was linted fine), it's somehow still related to us - possibly vue-loader? Triage with normal .ts file:// test.js
enum Direction {
Up,
Down,
}
export function dummy() { return null } importing from this file doesn't raise any linting errors, but it does in a .vue file WorkaroundAdding this entry to the rules: {
'space-infix-ops': 'off', // WORKAROUND
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
} |
/ping @michalsnik @mysticatea any ideas? |
This also happens when importing multiple classes from a module: // Component.vue
<script lang="ts">
import { Foo, Bar } from "Foobar"
...
</script> produces:
on the comma between import { Foo , Bar } from "Foobar" To get:
It does not complain on the same style of imports in |
I just noticed there must be other problems with typescript in SFC, indentation also doesn't work: @Component({
props: {
info: Object
}
})
export default class MyComponent extends Vue { } I want 4 spaces, but it doesn't indent the |
Looks like there are some parser related problem when using |
Hey guys! Unfortunately I don't have an answer yet, but I'm going to test the whole typescript integration soon and I'll let you know when I know more. For the time being you can disable the failing rule yourself or update the package to get Evan's temporary fix. |
I just confirmed this issue, and did some digging in ASTs. Looks like the produced AST for the In ESlint v5 the I'll post an update once I know more. These are my first insights. |
Oh boy, I went through So:
I'm going to come up with the fix as soon as I can :) Fun fact: You can fix it by placing |
Related issue: eslint/typescript-eslint-parser#438. It is about what I've mentioned in #1672 (comment). @michalsnik any other issues in the repositories you've mentioned that may be worth cross-referencing? |
Not sure @mario-d-s if there's anything more worth cross-referening at this moment. Regarding indentation, I think this might be relevant topic: vuejs/eslint-plugin-vue#503 Thank you for your active engagement, we really appreciate it @mario-d-s ! :) |
Also one more thing about indentation - it looks like it's the problem with native ESLint |
@michalsnik sure thing, this must have been quite a headscratcher! Thank you for all the hard work. It's unfortunate the native |
This should work fine now. My PR to typescript-eslint-parser with visitorKeys has been merged and released in v20.1.0 :) |
@michalsnik I try |
Hi. Recently, I fixed several bugs in Also, I added the support of Would you confirm whether the problem was fixed or not? |
@mysticatea I can confirm it's working now. Thank you. |
Version
3.0.0-rc.3
Reproduction link
https://github.com/marcus-blaettermann-ventoro/vue-cli-bug/tree/master
Steps to reproduce
Clone the given repo,
npm install
and thennpm run lint
Alternative: Run
vue create
with those settings:Then add this to the src/components/Hello-World.vue:
What is expected?
The linter should not find any errors, or at least should fix the errors it finds.
What is actually happening?
The linter adds a space before one of the commas in the
enum Direction
and then complains about it. Removing the space has no effect because the linter adds it the next time again. When using lint on save in an editor, the comma jumps between the first and second line.enum Direction { Up, Down }
const foo : Direction = Direction.Up;
is removed the linter doesn`t mind the enum anymore.The text was updated successfully, but these errors were encountered: