Skip to content

Commit 1edbbd0

Browse files
chsuhljharb
authored andcommitted
[Fix] no-common-js: Also throw an error when assigning
1 parent f63dd26 commit 1edbbd0

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

Diff for: src/rules/no-commonjs.js

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ module.exports = {
9191
if (
9292
call.parent.type !== 'ExpressionStatement'
9393
&& call.parent.type !== 'VariableDeclarator'
94+
&& call.parent.type !== 'AssignmentExpression'
9495
) return
9596

9697
if (call.callee.type !== 'Identifier') return

Diff for: tests/src/rules/no-commonjs.js

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ ruleTester.run('no-commonjs', require('rules/no-commonjs'), {
6060

6161
// imports
6262
{ code: 'var x = require("x")', errors: [ { message: IMPORT_MESSAGE }] },
63+
{ code: 'x = require("x")', errors: [ { message: IMPORT_MESSAGE }] },
6364
{ code: 'require("x")', errors: [ { message: IMPORT_MESSAGE }] },
6465

6566
// exports

0 commit comments

Comments
 (0)