-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[indent] parameter with decorator wrongly indented #1232
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
Looks like this bug was an unwanted side effect introduced by #1189. Using the following configuration: {
"rules": {
"@typescript-eslint/indent": ["error", 2]
}
} ✅ Under eslint-plugin@=2.7.0 the following indentation passes linting, as desired: export default class CreateMigration extends Command {
public execute(
@param({ description: 'Migration name', required: true, type: String })
name: string,
@param({ description: 'Timestamp (optional, default will use current time)', required: false, type: Number })
timestamp?: number,
): void {
return;
}
} ❌ Under eslint-plugin@^2.8.0 the following error is thrown:
The indentation it expects looks, nonsensically, like the following: export default class CreateMigration extends Command {
public execute(
@param({ description: 'Migration name', required: true, type: String })
name: string,
@param({ description: 'Timestamp (optional, default will use current time)', required: false, type: Number })
timestamp?: number,
): void {
return;
}
} It is not allowed to have the decorators aligned with the parameters either, as in: export default class CreateMigration extends Command {
public execute(
@param({ description: 'Migration name', required: true, type: String })
name: string,
@param({ description: 'Timestamp (optional, default will use current time)', required: false, type: Number })
timestamp?: number,
): void {
return;
}
} ❌ This produces the following errors:
|
Happy to accept a PR.
I looked into converting the rule to a first-class implementation (hence this unused code exists in the package), but as per reasons (1) and (3), it's more work than I have time to do. I've always offered the same response: |
I agree original implementation it's a bit crazy, I think all the turmoil regarding this rule is that, everyone tries not to disable it, because it is responsible to indent the code of your entire codebase Maybe it would be just ok to start from scratch supporting very few use cases for indent, scrapping the original |
Merging into #1824 |
Repro
Expected Result
Actual Result
Additional Info
The 2nd parameter
@Body
was wrongly indented 6 spaces ( should be 4 spaces).Works in
@typescript-eslint/eslint-plugin
and@typescript-eslint/parser
2.7.0Versions
@typescript-eslint/eslint-plugin
2.8.0
@typescript-eslint/parser
2.8.0
TypeScript
3.7.2
ESLint
6.6.0
The text was updated successfully, but these errors were encountered: