Skip to content
Permalink
Browse files

Also throw an error when assigning

  • Loading branch information...
chsuh committed May 5, 2019
1 parent 7ee86a0 commit 5d0513488a48b5c3fa21f2d29568cf3394f40ad9
Showing with 2 additions and 0 deletions.
  1. +1 −0 src/rules/no-commonjs.js
  2. +1 −0 tests/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
@@ -60,6 +60,7 @@ ruleTester.run('no-commonjs', require('rules/no-commonjs'), {

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

// exports

0 comments on commit 5d05134

Please sign in to comment.
You can’t perform that action at this time.