Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Commit

Permalink
Merge pull request #151 from andrewblond/bugfix/require-dot-notation
Browse files Browse the repository at this point in the history
Fixed case with number for `requireDotNotation` rule
  • Loading branch information
mdevils committed Jan 10, 2014
2 parents 1fe5b3e + df63e39 commit 9611c8f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1614,6 +1614,7 @@ Values: `true`
var a = b[c];
var a = b.c;
var a = b[c.d];
var a = b[1];
var a = b['while']; //reserved word
```

Expand Down
1 change: 1 addition & 0 deletions lib/rules/require-dot-notation.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module.exports.prototype = {
check: function(file, errors) {
file.iterateNodesByType('MemberExpression', function (node) {
if (node.computed && node.property.type === 'Literal' &&
typeof node.property.value !== 'number' &&
!tokenHelper.tokenIsReservedWord(node.property)
) {
errors.add(
Expand Down
4 changes: 4 additions & 0 deletions test/test.require-dot-notation.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ describe('rules/require-dot-notation', function() {
assert(checker.checkString('var x = a[\'while\']').isEmpty());
});

it('should not report number subscription', function() {
assert(checker.checkString('var x = a[1]').isEmpty());
});

it('should not report variable subscription', function() {
assert(checker.checkString('var x = a[c]').isEmpty());
});
Expand Down

0 comments on commit 9611c8f

Please sign in to comment.