-
-
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 "no-old-shims" rule #90
Conversation
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.
Looks really good @Turbo87, thanks for working on this!
@@ -0,0 +1,79 @@ | |||
'use strict'; | |||
|
|||
const oldShimsData = require('ember-rfc176-data/old-shims.json'); |
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 one!
lib/rules/no-old-shims.js
Outdated
let localName; | ||
let importedName; | ||
if (specifier.type === 'ImportDefaultSpecifier') { | ||
localName = specifier.local.name; |
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.
Looks like we can move localName
outside of this condition and use const instead:
const localName = specifier.local.name;
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.
fixed
lib/rules/no-old-shims.js
Outdated
|
||
return { | ||
ImportDeclaration(node) { | ||
const source = node.source.value; |
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.
What do you think about packageName
or moduleName
instead of source
? For a person that looks at this code for the first time it will probably be more understandable. It's just a suggestion though
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.
fixed
One more thing @Turbo87 I think we should add this rule in |
I'd recommend to try this out for a bit in a minor release and then enable it later if everything works as expected. Since the rule is only useful if you use Babel 6 I'd could also lead to a few false positives if it's enabled by default. |
Alright, that makes perfect sense to me. |
Released as |
This PR resolves a major part of #86
Example from the documentation:
The rule also supports
eslint --fix
/cc @michalsnik @rwjblue @cibernox