Repository navigation
Add ember/no-deprecated-imports rule - #2855
NullVoxPopuli wants to merge 2 commits into
Conversation
Flags imports of APIs deprecated in ember-source, gated on the installed
ember-source version. `reportAll: true` opts in to upcoming deprecations,
and `imports: { '<path>': { report: true|false } }` overrides per path.
Does nothing when ember-source is not found, unless something opts in.
The deprecation data lives in lib/utils/deprecated-imports.js and covers
6.3 through 7.5, including deprecations from open and draft ember.js PRs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🏎️ Benchmark Comparison
Full mitata output |
The APIs on the list have had better replacements for a long time, so new code shouldn't use them even before ember-source ships the deprecation. Version gating is now opt-in with `reportAll: false`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Curious about the logic behind this decision:
Though we could probably merge this as is and add support for that later. |
Can we make this opt-out? My thought is that during a TypeScript conversion of a large codebase I'd rather not have to be disabling
Thoughts? |
if someone were to export * as whatever from '@ember/array/proxy'that is fully deprecated -- whereas export * as whatever from '@ember/component';is not |
I don't agree with having an opt out for type-only ~ |
New rule
ember/no-deprecated-importsflags imports of APIs that ember-source has deprecated or is about to deprecate.By default it reports every deprecation on the list, including ones ember-source hasn't shipped yet. These APIs have had better replacements for a long time, so new code shouldn't use them regardless of Ember version.
How a deprecation gets reported:
reportwins over everything else.reportAll: true(the default), everything is reported and ember-source is never looked up.reportAll: false, it is reported once the installed ember-source reaches the deprecation'ssince.enabledversion, orsince.availablewhen it is not enabled yet. Prereleases count, so7.4.0-beta.1is 7.4. If ember-source can't be found, only per-pathreport: trueentries are reported.The data is in
lib/utils/deprecated-imports.js: 24 entries over 17 import paths, frominjectin@ember/service(6.3) andimport Ember from 'ember'(6.5) through the 7.4 and 7.5 work (mixins, Evented, proxies,@ember/utils, computed macros,@ember/array, Observable, Enumerable,ControllerMixin, the@ember/componentand@ember/objectdefault exports). Versions and ids follow the ember-source deprecation registry. Each entry has astatus(released,merged,pr,draft), because several come from ember.js PRs that are not merged yet: #21588, #21687, #21630 and #21674.It reports per imported name, so
computedfrom@ember/object/computedis fine whilealiasis not. It also checksimport typeandexport ... from. Namespace imports andexport *are only reported when the whole module is deprecated.Things reviewers may want to weigh in on:
emberuses the umbrella iddeprecate-import-ember-from-ember(deprecation-app build(deps-dev): bump prettier from 2.4.1 to 2.5.0 #1383). ember-source registers one id perEmber.*member.@ember/objectis listed. Whethercomputed/get/setwill be deprecated is not settled in #21674.until: 7.9.0for Enumerable, MutableEnumerable andControllerMixin, which might be a typo for 8.0.0. The data copies the PR.@ember/componentdefault overlap withno-proxiesandno-classic-components. Paths already covered byno-tracked-built-insandno-legacy-helper-importsare left out.lib/utils/ember-source-version.jsnow also exportsgetEmberSourceVersionandisVersionAtLeast.🤖 Generated with Claude Code