Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow ember-data type registry imports in use-ember-data-rfc-395-imports rule #2027

Merged
merged 2 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/rules/use-ember-data-rfc-395-imports.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ The goal of this rule is to ease the migration to the new @ember-data packages.

ember-data has been split in multiple packages. For instance, its store is now released in "@ember-data/store" package. These packages have been released starting from ember-data version 3.11.

For TypeScript users, imports from `ember-data/types/registries/*` are still allowed since there is currently no equivalent in the new packages.

## Examples

Examples of **incorrect** code for this rule:
Expand Down
6 changes: 5 additions & 1 deletion lib/rules/use-ember-data-rfc-395-imports.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ module.exports = {
return;
}

if (node.source.value === 'ember-data' || node.source.value.startsWith('ember-data/')) {
if (
node.source.value === 'ember-data' ||
(node.source.value.startsWith('ember-data/') &&
!node.source.value.startsWith('ember-data/types/registries/'))
) {
context.report({ node, message });
}
},
Expand Down
4 changes: 4 additions & 0 deletions tests/lib/rules/use-ember-data-rfc-395-imports.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ ruleTester.run('use-ember-data-rfc-395-imports', rule, {
name: SomethingRandom.DS('string')
});
`,
"import AdapterRegistry from 'ember-data/types/registries/adapter';",
"import ModelRegistry from 'ember-data/types/registries/model';",
"import SerializerRegistry from 'ember-data/types/registries/serializer';",
"import TransformRegistry from 'ember-data/types/registries/transform';",
],

invalid: [
Expand Down