summaryrefslogtreecommitdiff
path: root/tools/eslint/lib/rules/object-curly-newline.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/eslint/lib/rules/object-curly-newline.js')
-rw-r--r--tools/eslint/lib/rules/object-curly-newline.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/tools/eslint/lib/rules/object-curly-newline.js b/tools/eslint/lib/rules/object-curly-newline.js
index 42f2778739..ebad69de2e 100644
--- a/tools/eslint/lib/rules/object-curly-newline.js
+++ b/tools/eslint/lib/rules/object-curly-newline.js
@@ -131,8 +131,15 @@ module.exports = {
*/
function check(node) {
const options = normalizedOptions[node.type];
- const openBrace = sourceCode.getFirstToken(node);
- const closeBrace = sourceCode.getLastToken(node);
+ const openBrace = sourceCode.getFirstToken(node, token => token.value === "{");
+ let closeBrace;
+
+ if (node.typeAnnotation) {
+ closeBrace = sourceCode.getTokenBefore(node.typeAnnotation);
+ } else {
+ closeBrace = sourceCode.getLastToken(node);
+ }
+
let first = sourceCode.getTokenAfter(openBrace, { includeComments: true });
let last = sourceCode.getTokenBefore(closeBrace, { includeComments: true });
const needsLinebreaks = (