Skip to content

Commit

Permalink
Fix: Support type annotations in array-bracket-spacing (#7445)
Browse files Browse the repository at this point in the history
* Fix: Support type annotations in array-bracket-spacing

* Fix per PR comments

* Use getTokenBefore
  • Loading branch information
taion authored and platinumazure committed Oct 28, 2016
1 parent 5ed8b9b commit b200086
Show file tree
Hide file tree
Showing 4 changed files with 1,208 additions and 6 deletions.
6 changes: 4 additions & 2 deletions lib/rules/array-bracket-spacing.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,10 @@ module.exports = {

const first = sourceCode.getFirstToken(node),
second = sourceCode.getFirstToken(node, 1),
penultimate = sourceCode.getLastToken(node, 1),
last = sourceCode.getLastToken(node),
last = node.typeAnnotation
? sourceCode.getTokenBefore(node.typeAnnotation)
: sourceCode.getLastToken(node),
penultimate = sourceCode.getTokenBefore(last),
firstElement = node.elements[0],
lastElement = node.elements[node.elements.length - 1];

Expand Down
Loading

0 comments on commit b200086

Please sign in to comment.