Skip to content

Commit

Permalink
Modified error message to include the module's name (fixes #453) (#461)
Browse files Browse the repository at this point in the history
  • Loading branch information
jfmengels authored and benmosher committed Jul 27, 2016
1 parent 2252874 commit 30e55b6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
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"')],
}),
],
})

0 comments on commit 30e55b6

Please sign in to comment.