question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rule conflict between `no-invalid-aria-attributes` and `no-unnecessary-concat`

See original GitHub issue

no-invalid-aria-attributes was recently patched to allow for handlebars as acceptable for aria attributes, #2389 e.g.: <div aria-label="{{@name}}"></div>

However no-unnecessary-concat prefers <div aria-label={{@name}}></div> but no-invalid-aria-attributes marks this as invalid without the quotes. Both however correctly evaluate to a string.

It seems like no-invalid-aria-attributes should be aware of no-unnecessary-concat requirements – opening this issue per https://github.com/ember-template-lint/ember-template-lint/pull/2389#issuecomment-1053609716

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
rrennocommented, Apr 7, 2022

In my effort to distill this down into a base case I think I over generalized the issue. Each incorrectly flagged instance contains a conditional – which I believe should not be flagged by the linter, correct?.

E.g. aria-label={{if @label @label @placeholder}} aria-label={{unless @label @label @placeholder}}

addon/components/zb-input/template.hbs
  16:4  error  The value for aria-label must be a string.  no-invalid-aria-attributes
  34:4  error  The value for aria-label must be a string.  no-invalid-aria-attributes

Switching to: aria-label="{{if @label @label @placeholder}}" aria-label="{{unless @label @label @placeholder}}" “Fixes” the no-invalid-aria-attributes error but then throws

addon/components/zb-input/template.hbs
  20:19  error  Unnecessary string concatenation. Use {{if @label @label @placeholder}} instead of "{{if @label @label @placeholder}}".  no-unnecessary-concat
  36:19  error  Unnecessary string concatenation. Use {{unless @label @label @placeholder}} instead of "{{unless @label @label @placeholder}}".  no-unnecessary-concat

I’m also noticing a similar issue with conditionals and aria-describedby when conditional without quotes is used. e.g.

addon/components/zb-input/template.hbs
  33:4  error  The value for aria-describedby must be a list of strings that represent DOM element IDs (idlist)  no-invalid-aria-attributes

Sorry for the misdirection, let me know if I can help clarify further.

0reactions
drewleecommented, Apr 12, 2022

@judithhinlung As discussed earlier, I think we need to make the rule more permissive in how it handles mustache statements. They may evaluate into any number of values or types at runtime, so I don’t think we have an accurate means of making that assessment just from the template alone.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found