angular-eslint icon indicating copy to clipboard operation
angular-eslint copied to clipboard

[no-interpolation-in-attributes] add config to allow interpolation for a substring of the attribute value

Open daiscog opened this issue 5 months ago • 0 comments

Description and reproduction of the issue

I'd love to use the no-interpolation-in-attributes but be able to ignore cases where interpolation is used for a substring of the attribute value.

<button
  class="btn btn--{{size}}"
  title="Poke user {{username}}"
  i18n-title="@@poke-btn-title"
>

Note the rule is actively harmful in the case of attributes requiring i18n as the alternative - binding with something like [attr]="'literal value ' + variable" - is not possible to easily translate via i18n-* attributes.

Suggestion: Add a config option, e.g., allow-substring-interpolation: boolean, which when set to true means only attributes where the entire value is a single interpolation are considered violations of the rule.

Versions

package version
@angular-eslint/eslint-plugin-template 18.3.0
@angular-eslint/template-parser 18.3.0
@typescript-eslint/parser 7.18.0
ESLint 8.57.0
node 20.17.0
Angular CLI: 18.2.0
Node: 20.17.0
Package Manager: pnpm 9.4.0
OS: darwin arm64

Angular: 18.2.0
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1802.0
@angular-devkit/build-angular   18.2.0
@angular-devkit/core            18.2.0
@angular-devkit/schematics      18.2.0
@schematics/angular             18.2.0
rxjs                            7.8.1
typescript                      5.5.4
  • [x] I have tried restarting my IDE and the issue persists.
  • [x] I have updated to the latest supported version of the packages and checked my ng version output per the instructions given here.

daiscog avatar Sep 15 '24 09:09 daiscog