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

Add allow option to no-nodejs-modules rule (fixes #452) #509

Merged
merged 3 commits into from
Aug 23, 2016
Merged
Changes from 1 commit
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: 1 addition & 1 deletion src/rules/no-nodejs-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import importType from '../core/importType'
import isStaticRequire from '../core/staticRequire'

function reportIfMissing(context, node, allowed, name) {
if (!allowed.includes(name) && importType(name, context) === 'builtin') {
if (allowed.indexOf(name) === -1 && importType(name, context) === 'builtin') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, bummer, I also thought Node v4 had includes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that surprising actually, since it's not even ES2015, but an ES2016 feature. I thought Babel would actually take care of this, but I guess was too hopeful (or it's just something to add). Anyway indexOf is fine.

context.report(node, 'Do not import Node.js builtin module "' + name + '"')
}
}
Expand Down