Skip to content

Commit

Permalink
[Fix] no-common-js: Also throw an error when assigning
Browse files Browse the repository at this point in the history
  • Loading branch information
chsuh authored and ljharb committed May 5, 2019
1 parent f63dd26 commit 1edbbd0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/rules/no-commonjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ module.exports = {
if (
call.parent.type !== 'ExpressionStatement'
&& call.parent.type !== 'VariableDeclarator'
&& call.parent.type !== 'AssignmentExpression'
) return

if (call.callee.type !== 'Identifier') return
Expand Down
1 change: 1 addition & 0 deletions tests/src/rules/no-commonjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ ruleTester.run('no-commonjs', require('rules/no-commonjs'), {

// imports
{ code: 'var x = require("x")', errors: [ { message: IMPORT_MESSAGE }] },
{ code: 'x = require("x")', errors: [ { message: IMPORT_MESSAGE }] },
{ code: 'require("x")', errors: [ { message: IMPORT_MESSAGE }] },

// exports
Expand Down

0 comments on commit 1edbbd0

Please sign in to comment.