Skip to content

fix(template-no-template-lint-directives): unquote rule names when converting - #2832

Merged
NullVoxPopuli merged 1 commit into
ember-cli:masterfrom
johanrd:fix/template-lint-directive-quoted-rule-names
Aug 2, 2026
Merged

fix(template-no-template-lint-directives): unquote rule names when converting#2832
NullVoxPopuli merged 1 commit into
ember-cli:masterfrom
johanrd:fix/template-lint-directive-quoted-rule-names

Conversation

@johanrd

@johanrd johanrd commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Reported during an ember-template-lint → eslint-plugin-ember migration.

Quoted rule names are valid in both linters

  • ember-template-lint maps its unquote helper over every name in a template-lint-disable / template-lint-enable list (_base.js). Verified against 7.9.3: {{! template-lint-disable "no-invalid-role" }} suppresses no-invalid-role, while {{! template-lint-disable "no-positive-tabindex" }} does not — so quotes really are stripped before matching, and this isn't the "no arguments disables everything" path.
  • ESLint core unquotes too: /* eslint-disable "no-console" */ suppresses no-console, /* eslint-disable "no-debugger" */ does not, and /* eslint-disable "zzz-nope" */ reports Definition for rule 'zzz-nope' was not found — quotes already stripped in the message.

So this isn't an exotic ember-template-lint-ism being dragged into ESLint; both sides accept it.

It also occurs in the wild. A narrow GitHub code search for the quoted form in .hbs returns 16 files (a floor — code search only indexes public repos), including the official ember-learn/ember-website:

{{!-- template-lint-disable "no-forbidden-elements" --}}   ember-learn/ember-website
{{! template-lint-disable "attribute-indentation" }}       mirego/accent
{{!template-lint-disable "no-negated-condition"}}          burningmantech/ranger-clubhouse-web
<label {{!template-lint-disable "no-nested-interactive"}}> NYCPlanning/labs-streets

Problem

The conversion fixer passed the name through verbatim, so the ember/template- prefix landed outside the quotes:

{{! template-lint-disable "no-log" }}{{! eslint-disable ember/template-"no-log" }}

That name is quoted in the middle, so neither linter's unquoting applies. Verified — it does not suppress:

Definition for rule ember/template-"no-log" was not found. | Unexpected log statement in template.

eslint --fix over a codebase using quoted names therefore silently converted working suppressions into dead ones, re-reporting violations the author had deliberately disabled. That is the exact failure this rule exists to prevent.

Fix

Unquote each name before prefixing, mirroring upstream's unquote semantics: strip only when the first and last character are the same quote character (single or double), so "no-log' and other mismatched-quote inputs still pass through unchanged.

Tests

Double-quoted, single-quoted, mixed quoted/unquoted lists, template-lint-enable, and the mismatched-quote pass-through case.

…nverting

ember-template-lint accepts quoted rule names in its directives — it maps
`unquote` over every name in a `template-lint-disable` / `-enable` list — so
`{{! template-lint-disable "no-log" }}` is a live directive, not a typo.

The conversion fixer pasted the name through verbatim and emitted
`ember/template-"no-log"`, a rule name that matches nothing. Running `--fix`
over a codebase that used quoted names therefore silently dropped those
suppressions.

Mirror upstream's `unquote`: strip only when the first and last character are
the same quote character, so a mismatched quote is still passed through
unchanged.
@johanrd
johanrd marked this pull request as draft July 31, 2026 13:21
@johanrd
johanrd marked this pull request as ready for review July 31, 2026 13:33
@NullVoxPopuli
NullVoxPopuli merged commit 9309271 into ember-cli:master Aug 2, 2026
12 checks passed
@github-actions github-actions Bot mentioned this pull request Aug 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants