Skip to content

Commit

Permalink
Also throw an error when assigning
Browse files Browse the repository at this point in the history
  • Loading branch information
chsuh committed May 6, 2019
1 parent f63dd26 commit 77390d2
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 77390d2

Please sign in to comment.