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

Modified error message to include the module's name (fixes #453) #461

Merged
merged 1 commit into from
Jul 27, 2016
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
This change log adheres to standards from [Keep a CHANGELOG](http://keepachangelog.com).

## [Unreleased]
### Modified
- Modified [`no-nodejs-modules`] error message to include the module's name ([#453], [#461])

## [1.12.0] - 2016-07-26
### Added
Expand Down Expand Up @@ -269,6 +271,7 @@ for info on changes for earlier releases.
[`prefer-default-export`]: ./docs/rules/prefer-default-export.md
[`no-restricted-paths`]: ./docs/rules/no-restricted-paths.md

[#461]: https://github.com/benmosher/eslint-plugin-import/pull/461
[#444]: https://github.com/benmosher/eslint-plugin-import/pull/444
[#428]: https://github.com/benmosher/eslint-plugin-import/pull/428
[#395]: https://github.com/benmosher/eslint-plugin-import/pull/395
Expand Down Expand Up @@ -304,6 +307,7 @@ for info on changes for earlier releases.
[#157]: https://github.com/benmosher/eslint-plugin-import/pull/157
[#314]: https://github.com/benmosher/eslint-plugin-import/pull/314

[#453]: https://github.com/benmosher/eslint-plugin-import/issues/453
[#441]: https://github.com/benmosher/eslint-plugin-import/issues/441
[#423]: https://github.com/benmosher/eslint-plugin-import/issues/423
[#415]: https://github.com/benmosher/eslint-plugin-import/issues/415
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-nodejs-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import isStaticRequire from '../core/staticRequire'

function reportIfMissing(context, node, name) {
if (importType(name, context) === 'builtin') {
context.report(node, 'Do not import Node.js builtin modules')
context.report(node, 'Do not import Node.js builtin module "' + name + '"')
}
}

Expand Down
14 changes: 7 additions & 7 deletions tests/src/rules/no-nodejs-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { RuleTester } from 'eslint'
const ruleTester = new RuleTester()
, rule = require('rules/no-nodejs-modules')

const errors = [{
const error = message => ({
ruleId: 'no-nodejs-modules',
message: 'Do not import Node.js builtin modules',
}]
message,
})

ruleTester.run('no-nodejs-modules', rule, {
valid: [
Expand All @@ -30,19 +30,19 @@ ruleTester.run('no-nodejs-modules', rule, {
invalid: [
test({
code: 'import path from "path"',
errors,
errors: [error('Do not import Node.js builtin module "path"')],
}),
test({
code: 'import fs from "fs"',
errors,
errors: [error('Do not import Node.js builtin module "fs"')],
}),
test({
code: 'var path = require("path")',
errors,
errors: [error('Do not import Node.js builtin module "path"')],
}),
test({
code: 'var fs = require("fs")',
errors,
errors: [error('Do not import Node.js builtin module "fs"')],
}),
],
})