-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[indent] multiple false positives in recent versions #121
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
Comments
In actual fact, the indent rule seems broken in a few places since the last change to it... private static _store: Map<string, Foo> =
new Map<string, Foo>();
// linter complains that it doesn't look like this
private static _store: Map<string, Foo> =
new Map<string, Foo>(); Another: private _endpoint: string =
'/foo';
// linter complains that it should be
private _endpoint: string =
'/foo'; Another: protected _messageMap =
new Map<number, Message>([
[-1, msg]
]);
// linter complains that it should be
protected _messageMap =
new Map<number, Message>([
[-1, msg]
]); There are too many instances of this for it to be a coincidence. My guess is something broke the rule in the most recent changes. This is all with config: "@typescript-eslint/indent": ["warn", 2, {
"FunctionDeclaration": {
"parameters": 2
},
"FunctionExpression": {
"parameters": 2
},
"CallExpression": {
"arguments": 1
},
"SwitchCase": 1
}], Before I updated to the scoped package from the monorepo, there were no lint errors with the same config and sources. |
confirmed against master. |
this one bradzacher/eslint-plugin-typescript#271 is still an issue in latest release |
Let me add another test case, where currently there's a false positive error:
I simplified it to this, which still throws an error:
Also, removing the generic type parameter and/or the multi-line "parameter list" solves the problem:
|
I'm getting this const foo = [1, 2, 3]
const bar = foo
.reduce<number>((acc, val) => {
return acc + val
}, 0) to throw errors
with this config module.exports = {
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
extends: ['plugin:@typescript-eslint/recommended'],
rules: { "@typescript-eslint/indent": ["error", 2] }
} So running it with --fix produces this const foo = [1, 2, 3]
const bar = foo
.reduce<number>((acc, val) => {
return acc + val
}, 0) |
I got the same issue with indenting using generics, both of this is valid using indent of 4; let list = [1, 2, 3]
.map(value => {
return String(value)
})
let list = [1, 2, 3]
.map<string>(value => {
return String(value)
}) |
I also have an issue with the indent on enums export enum AnEnum
{
SOMETHING = "something",
ELSE = "else",
} with the following rules
will show an error on the opening brace on the new line, saying the indentation of 0 should be 4 :/ [edit] could it be related to the brace-style not picking up enums, opened here #1274 [/edit] |
I also see this issue with annotations: @injectable()
class FooClass {
public constructor(
@inject(mongoClientProviderToken) mongoClientProvider: MongoClientProvider,
@inject(FooConfig) config: FooConfig
) {
// code
} eslint wants it to look like: @injectable()
class FooClass {
public constructor(
@inject(mongoClientProviderToken) mongoClientProvider: MongoClientProvider,
@inject(FooConfig) config: FooConfig
) {
// code
} If I remove the first annotation, everything is fine. |
@stevenhair Same issue here. Did you ever manage to figure out a workaround short of disabling the indentation rule? |
@AnthonyIacono unfortunately not, I just disabled the rule for the file. |
Merging into #1824 |
Example
Expected Result
Identation is linted.
Actual Result
Indentation is not linted.
Additional Info
It seems we simply don't deal with type aliases.
We should probably be handling
TSIntersectionType
andTSUnionType
. I am happy to PR this but wasn't sure what the best solution is... maybe to transform into aLogicalExpression
?The text was updated successfully, but these errors were encountered: