Skip to content

Commit

Permalink
Handle export of unnamed default export in no-reassign (fixes #29).
Browse files Browse the repository at this point in the history
  • Loading branch information
benmosher committed Jun 5, 2015
1 parent 73cf137 commit 5c89f27
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/rules/no-reassign.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ module.exports = function (context) {
},

'FunctionDeclaration': function (fn) {
checkIdentifier(fn.id)
if (fn.id != null) checkIdentifier(fn.id)

fn.params.forEach(function (p) {
if (p.type !== 'Identifier') return
Expand Down
10 changes: 8 additions & 2 deletions tests/lib/rules/no-reassign.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@ eslintTester.addRuleTest('lib/rules/no-reassign', {
valid: [
test({code: 'import { foo } from \'./bar\'; bar = 42;'})
// may assign to imported names\' members
, test({code: 'import { foo } from \'./bar\'; foo.x = 42; '}),
, test({code: 'import { foo } from \'./bar\'; foo.x = 42; '})
// may assign to imported namespaces\' names\' members
test({code: 'import * as foo from \'./bar\'; foo.x.y = 42; '})
, test({code: 'import * as foo from \'./bar\'; foo.x.y = 42; '})

// ensure unnamed imports work
, test({code: 'import \'./bar\'; '})

// support anonymous default function
, test({code: 'export default function () { }'})

// ensure object literals are not compromised
, test({code: 'import * as foo from \'./bar\'; var x = {foo: 42}; '})
Expand Down

0 comments on commit 5c89f27

Please sign in to comment.