-
-
Notifications
You must be signed in to change notification settings - Fork 75
Indent rule regression starting with v20.1.0 #586
Comments
Same issue appears when using spaces instead of tabs: {
"parser": "typescript-eslint-parser",
"rules": {
"indent": ["error", 2, {"VariableDeclarator": {"const": 3}}]
}
} // No type annotation..OK
const foo = {
a: 1,
b: 2
},
bar = 1;
// With type annotation..OK
const foo: Foo = {
a: 1,
b: 2
},
bar = 1;
// With type annotation..not OK
const foo: Foo = {
a: 1,
b: 2
},
bar = 1; 7:1 error Expected indentation of 2 spaces but found 8 indent
8:1 error Expected indentation of 2 spaces but found 8 indent
9:1 error Expected indentation of 0 spaces but found 6 indent |
you should consider using https://github.com/bradzacher/eslint-plugin-typescript/blob/master/docs/rules/indent.md |
Thanks @armano2. It looks like this is a new rule in Generally I prefer not to use dependencies labelled as |
@scottohara i'm not using unstable versions to, but i will suggest you to test if this will solve your issue (if not you can report issue) :) |
Unfortunately, the same problem occurs when using {
"parser": "typescript-eslint-parser",
"plugins": ["typescript"],
"rules": {
"indent": "off",
"typescript/indent": ["error", "tab", {"VariableDeclarator": {"const": 3}}]
}
} interface Foo {
a: number;
b: number;
}
const foo: Foo = {
a: 1,
b: 2
},
bar = 1; 7:1 error Expected indentation of 1 tab but found 4 typescript/indent
8:1 error Expected indentation of 1 tab but found 4 typescript/indent
9:1 error Expected indentation of 0 tabs but found 3 typescript/indent |
can you open this issue in eslint-plugin-typescript? |
Sure, no problem. I'll create an issue over there refer back to this thread. It is worth reiterating that the problem only affects So from an outsider's perspective, it sure does feel like the problem is in the parser, not the plugin/rules.
|
issue is with new nodes, and with fact that rules can affect them now. v20.1.0 introduced visitor keys #516 if you are using version before 20.1.0 those nodes are just ignored, and formatting for them is not working at all. |
I think this issue was resolved, but feel free to open a new issue on the new project https://github.com/typescript-eslint/typescript-eslint at any time. It will contain the parser and the plugin, so we can write the strongest possible integration tests for issues like this. Many thanks! |
What version of ESLint are you using?
5.11.1
What version of TypeScript are you using?
3.1.1
What version of
typescript-eslint-parser
are you using?Any version from 20.1.0 onwards
What code were you trying to parse?
(in the code below,
^
represents a tab character)What did you expect to happen?
No errors
What happened?
In
[email protected]
, code passes with no errors.With
[email protected]
onwards, the errors below occur:The code can be modified like below to pass, but clearly this is not what the config intends:
Vanilla JS code without a type annotation passes as expected:
The text was updated successfully, but these errors were encountered: