Skip to content

Commit 5c89f27

Browse files
committed
Handle export of unnamed default export in no-reassign (fixes #29).
1 parent 73cf137 commit 5c89f27

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lib/rules/no-reassign.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ module.exports = function (context) {
5050
},
5151

5252
'FunctionDeclaration': function (fn) {
53-
checkIdentifier(fn.id)
53+
if (fn.id != null) checkIdentifier(fn.id)
5454

5555
fn.params.forEach(function (p) {
5656
if (p.type !== 'Identifier') return

tests/lib/rules/no-reassign.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,15 @@ eslintTester.addRuleTest('lib/rules/no-reassign', {
1111
valid: [
1212
test({code: 'import { foo } from \'./bar\'; bar = 42;'})
1313
// may assign to imported names\' members
14-
, test({code: 'import { foo } from \'./bar\'; foo.x = 42; '}),
14+
, test({code: 'import { foo } from \'./bar\'; foo.x = 42; '})
1515
// may assign to imported namespaces\' names\' members
16-
test({code: 'import * as foo from \'./bar\'; foo.x.y = 42; '})
16+
, test({code: 'import * as foo from \'./bar\'; foo.x.y = 42; '})
17+
18+
// ensure unnamed imports work
19+
, test({code: 'import \'./bar\'; '})
20+
21+
// support anonymous default function
22+
, test({code: 'export default function () { }'})
1723

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

0 commit comments

Comments
 (0)