8000 FR: add rule `template/object-shorthand` · Issue #599 · angular-eslint/angular-eslint · GitHub
[go: up one dir, main page]

Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

FR: add rule template/object-shorthand #599

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
rafaelss95 opened this issue Jul 15, 2021 · 0 comments
Closed

FR: add rule template/object-shorthand #599

rafaelss95 opened this issue Jul 15, 2021 · 0 comments
Labels
package: eslint-plugin-template Angular Template rules rule proposal This issue is requesting/proposing the creation of a new rule within one of the core plugins

Comments

@rafaelss95
Copy link
Member
rafaelss95 commented Jul 15, 2021

Angular v12.1.0 brought us the support for shorthand property declarations in templates and so we can write <div [test]="{ a, b, c }"></div> instead of <div [test]="{ a: a, b: b, c: c }"></div>.

In order to help to maintain a consistent codebase, I'd like to propose a rule with the same ideia of object-shorthand, with a single option that indicates that we should always (default) or never use shorthand form.

Examples:

{
  "rules": {
    "@angular-eslint/template/object-shorthand": ["error", "always"]
  }
}
<div [test]="{ a: a, b: b, c: c }"></div> ❌ => `a`, `b` and `c` should be shorthand
<div [test]="{ a, b: 1, c: anotherName }"></div>
{
  "rules": {
    "@angular-eslint/template/object-shorthand": ["error", "never"]
  }
}
<div [test]="{ a, b: 1, c: anotherName }"></div> ❌ => `a` should not be shorthand
<div [test]="{ a: a, b: b, c: c }"></div>
@rafaelss95 rafaelss95 added rule proposal This issue is requesting/proposing the creation of a new rule within one of the core plugins package: eslint-plugin-template Angular Template rules labels Jul 15, 2021
@rafaelss95 rafaelss95 changed the title FR: add rule object-shorthand FR: add rule template/object-shorthand Jul 15, 2021
@angular-eslint angular-eslint locked and limited conversation to collaborators Nov 18, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

4152
Labels
package: eslint-plugin-template Angular Template rules rule proposal This issue is requesting/proposing the creation of a new rule within one of the core plugins
Projects
None yet
Development

No branches or pull requests

2 participants
0