-
-
Notifications
You must be signed in to change notification settings - Fork 204
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
Add new use-ember-data-rfc-395-imports
rule
#450
Conversation
This is ready now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Nice work!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe there should be a new entry for this rule in README.md
and in recommended-rules.js
(with a value of "off" for now). To achieve this use npm run update
no-ember-data-global-imports
rule
@bmish - Mind doing one more pass on this one before we land / release? |
I dislike being pedantic especially when I feel the name has been changed a few times, but is
There was a suggestion to name the rule after the rfc, I think it's probably the way to go.
|
Yeah, that seems fine to me. My only real objection was the "new" in the original name, I'm sorry for the run around / bike shedding here. |
No worries, I prefer to make it right! |
no-ember-data-global-imports
ruleuse-ember-data-rfc-395-imports
rule
..to `lib/utils/new-module`
It contains the mappings to migrate to new ember-data packages.
This rule aims at highlighting old ember-data imports. The goal is to help users to migrate to new packages imports. New ember-data imports are available from version `3.11`. It prevents the following imports: ``` import DS from "ember-data;" const { Model } = DS; ``` or ``` import Model from "ember-data/model"; ``` Instead, these imports should be used: ``` import Model from "@ember-data/model"; ``` This rule provides a fixer (or to be precise: this rule leverages the `no-old-shims` fixer) for some cases. For the other cases, a codemod is available.
@dcyriller don't worry, I'm not going to require you to refactor existing code if you're just moving it around. I commented about the excessive length and complexity of some of the functions because it makes the review difficult, and it could be a good time to clean this up. But we can merge the PR soon if you're done with your changes. |
@bmish should be good now. |
I've made fun splitting utils functions into smaller ones (I really did 😀). I'm not 100% convinced it makes the code better though. |
@dcyriller @bmish @rwjblue this caused a crashing regression. Let me know if there's any way I can help get this resolved as it's blocking me updating to the latest |
Description
This PR introduces a new rule to ease ember-data migration to new packages:
use-ember-data-rfc-395-imports
.Examples of incorrect code for this rule:
Examples of correct code for this rule:
Note
Split into 5 commits that may be reviewed one after the other.
It leverages what have been done in the past with Ember globals and ember-cli-shims.
A few discussion are still in progress around https://github.com/ember-data/ember-data-rfc395-data/ (the data set). Hence the WIP!Links
ember-data RFC
a related codemod
EDIT: I've updated this description to reflect the changes made following ember-data/ember-data-rfc395-data#7