Repository navigation
Do not crash on namespace and side-effect imports - #2893
Merged
NullVoxPopuli merged 1 commit intoNov 19, 2026
Merged
NullVoxPopuli merged 1 commit into
NullVoxPopuli merged 1 commit into
Conversation
no-unused-services read spec.imported.name for an
`import * as x from '@ember/object/computed'`, no-old-shims and
use-ember-data-rfc-395-imports did the same while building the fix for
a namespace import, and no-ember-testing-in-module-scope and
use-ember-get-and-set read specifiers[0] of `import 'ember'`.
getEmberImportAliasName now returns the default import name (or null),
so `import { run } from 'ember'` no longer makes `run` the Ember alias.
A namespace import of an old module is still reported, without a fix.
NullVoxPopuli
approved these changes
Nov 19, 2026
Contributor
|
highly recommend against using namespace imports btw <3 and |
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.
Five rules crash with
TypeError: Cannot read properties of undefinedon import forms they did not expect:no-unused-servicesimport * as macros from '@ember/object/computed';no-old-shimsimport * as Application from 'ember-application';use-ember-data-rfc-395-importsimport * as DSModel from 'ember-data/model';no-ember-testing-in-module-scopeimport 'ember';use-ember-get-and-setimport 'ember';ESLint stops linting the whole file when a rule throws, so one of these lines breaks lint for that file.
Causes:
no-unused-servicesskipped only default specifiers and then readspec.imported.name. A namespace specifier has noimported. It now looks at named specifiers only.no-old-shimsanduse-ember-data-rfc-395-importssharebuildFixinlib/utils/new-module.js, which readspecifier.imported.nametoo. A namespace import has no single new module to point to, so the fix now returnsnull. The import is still reported, just without an autofix.getEmberImportAliasNamereturnedspecifiers[0].local.name. Withimport 'ember'there is no specifier. Withimport { run } from 'ember'it returnedrun, sono-ember-testing-in-module-scopethen watchedrun.testingand missed a laterEmber.testing. It now returns the default import name, ornull.Tests: one case per rule plus two util cases. 7 of them fail on master and pass with this change. Full suite: 9973 passed.
eslintandprettier --checkare clean on the changed files.I found these by running every rule over all code samples in the test suite, plus namespace / side-effect imports of every module the rules know. These five were the only crashes on realistic code.