Skip to content

Commit e0c328d

Browse files
mwiencekgajus
authored andcommitted
fix: object-type-delimeter with new babel-eslint (#317)
Using babel-eslint 8.2.1, the object-type-delimeter rule does nothing, apparently because the ObjectType{CallProperty,Indexer,Property} nodes no longer contain trailing semicolons/commas, but their parent ObjectTypeAnnotation nodes do. I tried to keep compatibility with both cases, because it's not clear what version this project is targeting. However, I don't know of a good way to test the new behavior given the version of babel-eslint now locked in devDependencies.
1 parent 3cd70b8 commit e0c328d

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

Diff for: src/rules/objectTypeDelimiter.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,18 @@ const create = (context) => {
2424
}
2525

2626
const requireProperPunctuation = (node) => {
27-
const tokens = context.getSourceCode().getTokens(node);
28-
const lastToken = tokens[tokens.length - 1];
27+
const sourceCode = context.getSourceCode();
28+
const tokens = sourceCode.getTokens(node);
29+
let lastToken;
30+
31+
lastToken = tokens[tokens.length - 1];
32+
if (lastToken.type !== 'Punctuator' ||
33+
!(lastToken.value === SEMICOLON.char ||
34+
lastToken.value === COMMA.char)) {
35+
const parentTokens = sourceCode.getTokens(node.parent);
36+
37+
lastToken = parentTokens[parentTokens.indexOf(lastToken) + 1];
38+
}
2939

3040
if (lastToken.type === 'Punctuator') {
3141
if (lastToken.value === BAD.char) {

0 commit comments

Comments
 (0)