feat: add (opt-in ember-template-lint parity) recommended-template config #2702
Open
johanrd wants to merge 5 commits intoember-cli:masterfrom
Open
feat: add (opt-in ember-template-lint parity) recommended-template config #2702johanrd wants to merge 5 commits intoember-cli:masterfrom
johanrd wants to merge 5 commits intoember-cli:masterfrom
Conversation
…ecommended
Adds `eslint-plugin-ember/configs/recommended-template` — an opt-in flat
config that enables the same ~94 template rules as ember-template-lint's
recommended preset, making it easy to drop ember-template-lint and keep
equivalent coverage.
The config is intentionally not part of the main `recommended` export.
Template linting is a separate concern and many projects will want to
adopt it incrementally or tune individual rules (e.g. no-bare-strings
allowlists, no-inline-styles) before committing to the full set.
Unlike ember-template-lint's recommended.js, this config carries no
gjs/gts overrides. The original ETL overrides existed because template-
lint has no JS scope tracker and couldn't distinguish `{{foo}}` (a JS
binding) from `{{foo}}` (an implicit-this lookup). The ported rules in
this plugin walk ESLint's scope chain directly, so no-implicit-this and
no-curly-component-invocation already skip JS-scoped identifiers, and
no-builtin-form-components / no-unknown-arguments-for-builtin-components
explicitly check for imports in gjs/gts files. The overrides would only
suppress correct behaviour.
88a6caf to
4f24085
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
eslint-plugin-ember/configs/recommended-template— an opt-in flat config that enables the same ~94 template rules as ember-template-lint'srecommendedpreset, making it straightforward to dropember-template-lintand keep equivalent coverage.Why not part of
recommended?Template linting is a separate concern from Ember JS linting, and many projects will want to adopt it incrementally or tune individual rules (e.g.
no-bare-stringsallowlists,no-inline-styles) before committing to the full set. Keeping it opt-in avoids a breaking change and lets teams migrate at their own pace.Why no gjs/gts overrides?
ember-template-lint's
recommendedconfig disables several rules for.gjs/.gtsfiles (no-curly-component-invocation,no-implicit-this,builtin-component-arguments,no-builtin-form-components,no-unknown-arguments-for-builtin-components) because template-lint has no JS scope tracker and can't distinguish a JS-scoped binding from an implicit-this lookup inside<template>.The ported rules in this plugin don't have that limitation:
no-implicit-thisandno-curly-component-invocationwalk ESLint's scope chain and skip any identifier that resolves to a JS binding (import, const, param, block param).no-builtin-form-componentsexplicitly checksfilename.endsWith('.gjs/.gts')and only flags components imported from@ember/component.no-unknown-arguments-for-builtin-componentschecks whether a tag is shadowed by a JS-scope variable before flagging.Adding the overrides would suppress correct behaviour in gjs/gts, not fix a real problem.