Skip to content

Commit

Permalink
Allow ember-data type registry imports
Browse files Browse the repository at this point in the history
  • Loading branch information
wagenet committed Dec 11, 2023
1 parent 186376c commit e73069e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
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
2 changes: 1 addition & 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,7 @@ 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/'))) {

Check failure on line 105 in lib/rules/use-ember-data-rfc-395-imports.js

View workflow job for this annotation

GitHub Actions / build (ubuntu, 18.x)

Replace `node.source.value·===·'ember-data'·||·(node.source.value.startsWith('ember-data/')·&&·!node.source.value.startsWith('ember-data/types/registries/'))` with `⏎··········node.source.value·===·'ember-data'·||⏎··········(node.source.value.startsWith('ember-data/')·&&⏎············!node.source.value.startsWith('ember-data/types/registries/'))⏎········`

Check failure on line 105 in lib/rules/use-ember-data-rfc-395-imports.js

View workflow job for this annotation

GitHub Actions / build (ubuntu, 20.x)

Replace `node.source.value·===·'ember-data'·||·(node.source.value.startsWith('ember-data/')·&&·!node.source.value.startsWith('ember-data/types/registries/'))` with `⏎··········node.source.value·===·'ember-data'·||⏎··········(node.source.value.startsWith('ember-data/')·&&⏎············!node.source.value.startsWith('ember-data/types/registries/'))⏎········`

Check failure on line 105 in lib/rules/use-ember-data-rfc-395-imports.js

View workflow job for this annotation

GitHub Actions / build (ubuntu, 21.x)

Replace `node.source.value·===·'ember-data'·||·(node.source.value.startsWith('ember-data/')·&&·!node.source.value.startsWith('ember-data/types/registries/'))` with `⏎··········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';"

Check failure on line 46 in tests/lib/rules/use-ember-data-rfc-395-imports.js

View workflow job for this annotation

GitHub Actions / build (ubuntu, 18.x)

Insert `,`

Check failure on line 46 in tests/lib/rules/use-ember-data-rfc-395-imports.js

View workflow job for this annotation

GitHub Actions / build (ubuntu, 20.x)

Insert `,`

Check failure on line 46 in tests/lib/rules/use-ember-data-rfc-395-imports.js

View workflow job for this annotation

GitHub Actions / build (ubuntu, 21.x)

Insert `,`
],

invalid: [
Expand Down

0 comments on commit e73069e

Please sign in to comment.