diff --git a/src/rules/no-commonjs.js b/src/rules/no-commonjs.js index b6f11a7f0..261654bbf 100644 --- a/src/rules/no-commonjs.js +++ b/src/rules/no-commonjs.js @@ -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 diff --git a/tests/src/rules/no-commonjs.js b/tests/src/rules/no-commonjs.js index 72d5bfb19..c8155938b 100644 --- a/tests/src/rules/no-commonjs.js +++ b/tests/src/rules/no-commonjs.js @@ -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