Skip to content

Commit

Permalink
Fix: invalid token checking in computed-property-spacing (fixes #12198)…
Browse files Browse the repository at this point in the history
… (#12533)

* Fix: invalid token checking in computed-property-spacing (fixes #12198)

* Add more test cases
  • Loading branch information
yeonjuan authored and btmills committed Nov 22, 2019
1 parent 4f8a1ee commit 62c7038
Show file tree
Hide file tree
Showing 2 changed files with 397 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/rules/computed-property-spacing.js
Expand Up @@ -153,10 +153,10 @@ module.exports = {

const property = node[propertyName];

const before = sourceCode.getTokenBefore(property),
first = sourceCode.getFirstToken(property),
last = sourceCode.getLastToken(property),
after = sourceCode.getTokenAfter(property);
const before = sourceCode.getTokenBefore(property, astUtils.isOpeningBracketToken),
first = sourceCode.getTokenAfter(before, { includeComments: true }),
after = sourceCode.getTokenAfter(property, astUtils.isClosingBracketToken),
last = sourceCode.getTokenBefore(after, { includeComments: true });

if (astUtils.isTokenOnSameLine(before, first)) {
if (propertyNameMustBeSpaced) {
Expand Down

0 comments on commit 62c7038

Please sign in to comment.