From a4aadc6a2b2d537750ed9717ee02d5136115d1be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20R=C3=B8ed?= Date: Fri, 31 Jul 2026 16:43:21 +0200 Subject: [PATCH] fix(template-no-template-lint-directives): preserve directive scope on conversion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The fixer emitted `eslint-disable` for every `template-lint-disable`, but that directive carries three different scopes depending on placement, and only one of them is file-wide. ember-template-lint's docs/configuration.md: An in-element instruction will apply to only that element An in-element instruction with the `-tree` suffix will apply to that element and all its descendants Converting either in-element form to a file-wide `eslint-disable` widened a one-element suppression into the rest of the file, so a single migrated directive silently swallowed every later violation of that rule:
ember-template-lint reports the ; after `--fix` nothing reported at all. ESLint has no element scope, but an `eslint-disable` / `eslint-enable` pair delimits an arbitrary region, which reproduces every template-lint scope exactly. Closing the region as the element's first child covers the opening tag alone; closing it after the element covers the subtree. So: standing alone -> eslint-disable (rest of file) in opening tag -> eslint-disable before element, eslint-enable first child `-tree` suffix -> eslint-disable before element, eslint-enable after it `-tree` directives were previously not matched at all and migrated to nothing without a report; they now convert. Removing the converted directive is by line only when the comment has that line to itself. A directive written inline — `
` — shares its line with the tag, and reaching back to the line start would delete `
+{{!eslint-enable ember/template-no-invalid-role}} +``` + +The [`template-no-template-lint-directives`](docs/rules/template-no-template-lint-directives.md) rule (enabled by the `template-lint-migration` config) does this rewrite for you: run `eslint --fix` once and it converts every `template-lint-disable` / `template-lint-enable` comment in your templates, including the element-scoped and `-tree` forms, preserving each directive's original scope. To disable a rule for an entire `.gjs`/`.gts` file, use a regular ESLint file-level directive in the JS region — it applies to the `