From 6cc0ed8b773e9299acc42007c2295031c321d0f2 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sun, 17 Jul 2022 08:31:55 +0530 Subject: [PATCH 1/8] feat: add new `allowLineSeparatedGroups` option to `sort-keys` rule --- lib/rules/sort-keys.js | 42 ++++++++ tests/lib/rules/sort-keys.js | 187 ++++++++++++++++++++++++++++++++++- 2 files changed, 228 insertions(+), 1 deletion(-) diff --git a/lib/rules/sort-keys.js b/lib/rules/sort-keys.js index 5cda81d0a7d..5345e7ceb50 100644 --- a/lib/rules/sort-keys.js +++ b/lib/rules/sort-keys.js @@ -105,6 +105,10 @@ module.exports = { type: "integer", minimum: 2, default: 2 + }, + allowLineSeparatedGroups: { + type: "boolean", + default: false } }, additionalProperties: false @@ -124,6 +128,7 @@ module.exports = { const insensitive = options && options.caseSensitive === false; const natural = options && options.natural; const minKeys = options && options.minKeys; + const allowLineSeparatedGroups = options && options.allowLineSeparatedGroups || false; const isValidOrder = isValidOrders[ order + (insensitive ? "I" : "") + (natural ? "N" : "") ]; @@ -131,10 +136,14 @@ module.exports = { // The stack to save the previous property's name for each object literals. let stack = null; + // The sourceCode use to check comment between groups + const sourceCode = context.getSourceCode(); + return { ObjectExpression(node) { stack = { upper: stack, + prevNode: null, prevName: null, numKeys: node.properties.length }; @@ -159,8 +168,41 @@ module.exports = { const numKeys = stack.numKeys; const thisName = getPropertyName(node); + // Get tokens between current node and previous node + const tokens = stack.prevNode && sourceCode + .getFirstTokensBetween(stack.prevNode, node, { skip: 0, includeComments: true }); + + let isBlankLineBetweenNodes = false; + + if (tokens) { + + // check blank line between tokens + tokens.forEach((token, index) => { + const previousToken = tokens[index - 1]; + + if (previousToken && (token.loc.start.line - previousToken.loc.end.line > 1)) { + isBlankLineBetweenNodes = true; + } + }); + + // check blank line between current node and last token + if (!isBlankLineBetweenNodes && (node.loc.start.line - tokens[tokens.length - 1].loc.start.line > 1)) { + isBlankLineBetweenNodes = true; + } + } + if (thisName !== null) { stack.prevName = thisName; + stack.prevNode = node; + } + + if (allowLineSeparatedGroups && (isBlankLineBetweenNodes || thisName === null)) { + + /* + * stack.prevNode = null; + * stack.prevName = null; + */ + return; } if (prevName === null || thisName === null || numKeys < minKeys) { diff --git a/tests/lib/rules/sort-keys.js b/tests/lib/rules/sort-keys.js index ff6482747ad..36829695606 100644 --- a/tests/lib/rules/sort-keys.js +++ b/tests/lib/rules/sort-keys.js @@ -163,7 +163,106 @@ ruleTester.run("sort-keys", rule, { { code: "var obj = {è:4, À:3, 'Z':2, '#':1}", options: ["desc", { natural: true, caseSensitive: false }] }, // desc, natural, insensitive, minKeys should ignore unsorted keys when number of keys is less than minKeys - { code: "var obj = {a:1, _:2, b:3}", options: ["desc", { natural: true, caseSensitive: false, minKeys: 4 }] } + { code: "var obj = {a:1, _:2, b:3}", options: ["desc", { natural: true, caseSensitive: false, minKeys: 4 }] }, + + // allowLineSeparatedGroups option + { + code: ` + var obj = { + e: 1, + f: 2, + g: 3, + + a: 4, + b: 5, + c: 6 + } + `, + options: ["asc", { allowLineSeparatedGroups: true }] + }, + { + code: ` + var obj = { + b: 1, + + // comment + a: 2, + c: 3 + } + `, + options: ["asc", { allowLineSeparatedGroups: true }] + }, + { + code: ` + var obj = { + c: 1, + d: 2, + + b() { + }, + e: 4 + } + `, + options: ["asc", { allowLineSeparatedGroups: true }], + parserOptions: { ecmaVersion: 6 } + }, + { + code: ` + var obj = { + b, + + [a+b]: 1, + a + } + `, + options: ["asc", { allowLineSeparatedGroups: true }], + parserOptions: { ecmaVersion: 6 } + }, + { + code: ` + var obj = { + c: 1, + d: 2, + + a() { + }, + + // abce + f: 3, + + /* + */ + [a+b]: 1, + cc: 1, + e: 2 + } + `, + options: ["asc", { allowLineSeparatedGroups: true }], + parserOptions: { ecmaVersion: 6 } + }, + { + code: ` + var obj = { + a: "/*", + + b: "*/", + } + `, + options: ["asc", { allowLineSeparatedGroups: true }] + }, + { + code: ` + var obj = { + b, + + /* + */ // + a + } + `, + options: ["asc", { allowLineSeparatedGroups: true }], + parserOptions: { ecmaVersion: 6 } + } ], invalid: [ @@ -1761,6 +1860,92 @@ ruleTester.run("sort-keys", rule, { } } ] + }, + { + code: ` + var obj = { + b, + [a+b]: 1, + a // sort-keys: 'a' should be before 'b' + } + `, + options: ["asc", { allowLineSeparatedGroups: true }], + parserOptions: { ecmaVersion: 6 }, + errors: [ + { + messageId: "sortKeys", + data: { + natural: "", + insensitive: "", + order: "asc", + thisName: "a", + prevName: "b" + } + } + ] + }, + { + code: ` + var obj = { + c: 1, + d: 2, + + z() { + }, + // abce + f: 3, + /* + */ + [a+b]: 1, + b: 1, + e: 2 + } + `, + options: ["asc", { allowLineSeparatedGroups: true }], + parserOptions: { ecmaVersion: 6 }, + errors: [ + { + messageId: "sortKeys", + data: { + natural: "", + insensitive: "", + order: "asc", + thisName: "f", + prevName: "z" + } + }, + { + messageId: "sortKeys", + data: { + natural: "", + insensitive: "", + order: "asc", + thisName: "b", + prevName: "f" + } + } + ] + }, + { + code: ` + var obj = { + b: "/*", + a: "*/", + } + `, + options: ["asc", { allowLineSeparatedGroups: true }], + errors: [ + { + messageId: "sortKeys", + data: { + natural: "", + insensitive: "", + order: "asc", + thisName: "a", + prevName: "b" + } + } + ] } ] }); From 016fb1e2cc241ce8201c0ae2f1965a9722d73f20 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sun, 17 Jul 2022 08:36:53 +0530 Subject: [PATCH 2/8] chore: cleanup --- lib/rules/sort-keys.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/rules/sort-keys.js b/lib/rules/sort-keys.js index 5345e7ceb50..631788028e8 100644 --- a/lib/rules/sort-keys.js +++ b/lib/rules/sort-keys.js @@ -197,11 +197,6 @@ module.exports = { } if (allowLineSeparatedGroups && (isBlankLineBetweenNodes || thisName === null)) { - - /* - * stack.prevNode = null; - * stack.prevName = null; - */ return; } From 321d61838aa72455f4b6f75211a650bfbb979920 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sun, 17 Jul 2022 09:36:58 +0530 Subject: [PATCH 3/8] test: add more cases --- tests/lib/rules/sort-keys.js | 232 ++++++++++++++++++++++++++++++++++- 1 file changed, 229 insertions(+), 3 deletions(-) diff --git a/tests/lib/rules/sort-keys.js b/tests/lib/rules/sort-keys.js index 36829695606..ccab0e50acf 100644 --- a/tests/lib/rules/sort-keys.js +++ b/tests/lib/rules/sort-keys.js @@ -192,12 +192,42 @@ ruleTester.run("sort-keys", rule, { `, options: ["asc", { allowLineSeparatedGroups: true }] }, + { + code: ` + var obj = { + b: 1 + + , + + // comment + a: 2, + c: 3 + } + `, + options: ["asc", { allowLineSeparatedGroups: true }] + }, + { + code: ` + var obj = { + c: 1, + d: 2, + + b() { + }, + e: 4 + } + `, + options: ["asc", { allowLineSeparatedGroups: true }], + parserOptions: { ecmaVersion: 6 } + }, { code: ` var obj = { c: 1, d: 2, + // comment + // comment b() { }, e: 4 @@ -225,12 +255,14 @@ ruleTester.run("sort-keys", rule, { d: 2, a() { + }, // abce f: 3, /* + */ [a+b]: 1, cc: 1, @@ -243,13 +275,26 @@ ruleTester.run("sort-keys", rule, { { code: ` var obj = { - a: "/*", + b: "/*", - b: "*/", + a: "*/", } `, options: ["asc", { allowLineSeparatedGroups: true }] }, + { + code: ` + var obj = { + b, + /* + */ // + + a + } + `, + options: ["asc", { allowLineSeparatedGroups: true }], + parserOptions: { ecmaVersion: 6 } + }, { code: ` var obj = { @@ -262,6 +307,32 @@ ruleTester.run("sort-keys", rule, { `, options: ["asc", { allowLineSeparatedGroups: true }], parserOptions: { ecmaVersion: 6 } + }, + { + code: ` + var obj = { + b: 1 + // comment before comma + + , + a: 2 + }; + `, + options: ["asc", { allowLineSeparatedGroups: true }], + parserOptions: { ecmaVersion: 6 } + }, + { + code: ` + var obj = { + b, + + a, + ...z, + c + } + `, + options: ["asc", { allowLineSeparatedGroups: true }], + parserOptions: { ecmaVersion: 2018 } } ], invalid: [ @@ -1861,6 +1932,109 @@ ruleTester.run("sort-keys", rule, { } ] }, + + // When allowLineSeparatedGroups option is false + { + code: ` + var obj = { + b: 1, + c: 2, + a: 3 + } + `, + options: ["asc", { allowLineSeparatedGroups: false }], + errors: [ + { + messageId: "sortKeys", + data: { + natural: "", + insensitive: "", + order: "asc", + thisName: "a", + prevName: "c" + } + } + ] + }, + + // When allowLineSeparatedGroups option is true + { + code: ` + var obj = { + b: 1, + c () { + + }, + a: 3 + } + `, + options: ["asc", { allowLineSeparatedGroups: true }], + parserOptions: { ecmaVersion: 6 }, + errors: [ + { + messageId: "sortKeys", + data: { + natural: "", + insensitive: "", + order: "asc", + thisName: "a", + prevName: "c" + } + } + ] + }, + { + code: ` + var obj = { + a: 1, + b: 2, + + z () { + + }, + y: 3 + } + `, + options: ["asc", { allowLineSeparatedGroups: true }], + parserOptions: { ecmaVersion: 6 }, + errors: [ + { + messageId: "sortKeys", + data: { + natural: "", + insensitive: "", + order: "asc", + thisName: "y", + prevName: "z" + } + } + ] + }, + { + code: ` + var obj = { + b: 1, + c () { + }, + // comment + a: 3 + } + `, + options: ["asc", { allowLineSeparatedGroups: true }], + parserOptions: { ecmaVersion: 6 }, + errors: [ + { + messageId: "sortKeys", + data: { + natural: "", + insensitive: "", + order: "asc", + thisName: "a", + prevName: "c" + } + } + ] + }, { code: ` var obj = { @@ -1884,6 +2058,33 @@ ruleTester.run("sort-keys", rule, { } ] }, + { + code: ` + var obj = { + c: 1, + d: 2, + // comment + // comment + b() { + }, + e: 4 + } + `, + options: ["asc", { allowLineSeparatedGroups: true }], + parserOptions: { ecmaVersion: 6 }, + errors: [ + { + messageId: "sortKeys", + data: { + natural: "", + insensitive: "", + order: "asc", + thisName: "b", + prevName: "d" + } + } + ] + }, { code: ` var obj = { @@ -1891,10 +2092,12 @@ ruleTester.run("sort-keys", rule, { d: 2, z() { + }, - // abce f: 3, /* + + */ [a+b]: 1, b: 1, @@ -1946,6 +2149,29 @@ ruleTester.run("sort-keys", rule, { } } ] + }, + { + code: ` + var obj = { + b: 1 + // comment before comma + , a: 2 + }; + `, + options: ["asc", { allowLineSeparatedGroups: true }], + parserOptions: { ecmaVersion: 6 }, + errors: [ + { + messageId: "sortKeys", + data: { + natural: "", + insensitive: "", + order: "asc", + thisName: "a", + prevName: "b" + } + } + ] } ] }); From 0df53875d029bf0d217864c4e8c6c85ec4dc982b Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sun, 17 Jul 2022 10:12:04 +0530 Subject: [PATCH 4/8] docs: add `allowLineSeparatedGroups` options --- docs/src/rules/sort-keys.md | 122 ++++++++++++++++++++++++++++++++++++ lib/rules/sort-keys.js | 2 - 2 files changed, 122 insertions(+), 2 deletions(-) diff --git a/docs/src/rules/sort-keys.md b/docs/src/rules/sort-keys.md index a551f4f7ab2..9e59752e77a 100644 --- a/docs/src/rules/sort-keys.md +++ b/docs/src/rules/sort-keys.md @@ -92,6 +92,7 @@ The 2nd option is an object which has 3 properties. * `caseSensitive` - if `true`, enforce properties to be in case-sensitive order. Default is `true`. * `minKeys` - Specifies the minimum number of keys that an object should have in order for the object's unsorted keys to produce an error. Default is `2`, which means by default all objects with unsorted keys will result in lint errors. * `natural` - if `true`, enforce properties to be in natural order. Default is `false`. Natural Order compares strings containing combination of letters and numbers in the way a human being would sort. It basically sorts numerically, instead of sorting alphabetically. So the number 10 comes after the number 3 in Natural Sorting. +* `allowLineSeparatedGroups` - if `true`, the rule allows to group object keys through line breaks. In other words, a blank line after a key will reset the sorting of keys. Default is `false`. Example for a list: @@ -263,6 +264,127 @@ let obj = { ::: +### minKeys + +Examples of **incorrect** code for the `{allowLineSeparatedGroups: true}` option: + +::: incorrect + +```js +/*eslint sort-keys: ["error", "asc", {allowLineSeparatedGroups: true}]*/ +/*eslint-env es6*/ + +let obj1 = { + b: 1, + c () { + + }, + a: 3 +} + +let obj2 = { + b: 1, + c: 2, + + z () { + + }, + y: 3 +} + +let obj3 = { + b: 1, + c: 2, + // comment + z () { + + }, + y: 3, +} + +let obj4 = { + b: 1 + // comment before comma + , a: 2 +}; +``` + +::: + +Examples of **correct** code for the `{minKeys: 4}` option: + +::: correct + +```js +/*eslint sort-keys: ["error", "asc", {allowLineSeparatedGroups: true}]*/ +/*eslint-env es6*/ + +let obj = { + e: 1, + f: 2, + g: 3, + + a: 4, + b: 5, + c: 6 +} + +let obj = { + b: 1, + + // comment + a: 4, + c: 5, +} + +let obj = { + c: 1, + d: 2, + + b () { + + }, + e: 3, +} + +let obj = { + c: 1, + d: 2, + // comment + + // comment + b() { + + }, + e: 4 +} + +let obj = { + b, + + [foo + bar]: 1, + a +} + +let obj = { + b: 1 + // comment before comma + + , + a: 2 +}; + +var obj = { + b: 1, + + a: 2, + ...z, + c: 3 +} +``` + +::: + ## When Not To Use It If you don't want to notify about properties' order, then it's safe to disable this rule. diff --git a/lib/rules/sort-keys.js b/lib/rules/sort-keys.js index 631788028e8..213e0789e65 100644 --- a/lib/rules/sort-keys.js +++ b/lib/rules/sort-keys.js @@ -135,8 +135,6 @@ module.exports = { // The stack to save the previous property's name for each object literals. let stack = null; - - // The sourceCode use to check comment between groups const sourceCode = context.getSourceCode(); return { From c6a9f9dd7e4413b9d1f5690363ea622f37aaa26f Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sun, 17 Jul 2022 10:15:59 +0530 Subject: [PATCH 5/8] docs: add `allowLineSeparatedGroups` options --- docs/src/rules/sort-keys.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/rules/sort-keys.md b/docs/src/rules/sort-keys.md index 9e59752e77a..006335d1495 100644 --- a/docs/src/rules/sort-keys.md +++ b/docs/src/rules/sort-keys.md @@ -264,7 +264,7 @@ let obj = { ::: -### minKeys +### allowLineSeparatedGroups Examples of **incorrect** code for the `{allowLineSeparatedGroups: true}` option: @@ -311,7 +311,7 @@ let obj4 = { ::: -Examples of **correct** code for the `{minKeys: 4}` option: +Examples of **correct** code for the `{allowLineSeparatedGroups: true}` option: ::: correct From 3c441017942220f1b8772d72767cc3506977fdc5 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Mon, 18 Jul 2022 09:28:49 +0530 Subject: [PATCH 6/8] fix: remove false negatives --- lib/rules/sort-keys.js | 11 ++++++---- tests/lib/rules/sort-keys.js | 40 ++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/lib/rules/sort-keys.js b/lib/rules/sort-keys.js index 213e0789e65..687bd7ca8ea 100644 --- a/lib/rules/sort-keys.js +++ b/lib/rules/sort-keys.js @@ -142,6 +142,7 @@ module.exports = { stack = { upper: stack, prevNode: null, + prevBlankLine: false, prevName: null, numKeys: node.properties.length }; @@ -170,7 +171,7 @@ module.exports = { const tokens = stack.prevNode && sourceCode .getFirstTokensBetween(stack.prevNode, node, { skip: 0, includeComments: true }); - let isBlankLineBetweenNodes = false; + let isBlankLineBetweenNodes = stack.prevBlankLine; if (tokens) { @@ -184,17 +185,19 @@ module.exports = { }); // check blank line between current node and last token - if (!isBlankLineBetweenNodes && (node.loc.start.line - tokens[tokens.length - 1].loc.start.line > 1)) { + if (!isBlankLineBetweenNodes && (node.loc.start.line - tokens[tokens.length - 1].loc.end.line > 1)) { isBlankLineBetweenNodes = true; } } + stack.prevNode = node; + if (thisName !== null) { stack.prevName = thisName; - stack.prevNode = node; } - if (allowLineSeparatedGroups && (isBlankLineBetweenNodes || thisName === null)) { + if (allowLineSeparatedGroups && isBlankLineBetweenNodes) { + stack.prevBlankLine = thisName === null; return; } diff --git a/tests/lib/rules/sort-keys.js b/tests/lib/rules/sort-keys.js index ccab0e50acf..35514fd169f 100644 --- a/tests/lib/rules/sort-keys.js +++ b/tests/lib/rules/sort-keys.js @@ -333,6 +333,20 @@ ruleTester.run("sort-keys", rule, { `, options: ["asc", { allowLineSeparatedGroups: true }], parserOptions: { ecmaVersion: 2018 } + }, + { + code: ` + var obj = { + b, + + [foo()]: [ + + ], + a + } + `, + options: ["asc", { allowLineSeparatedGroups: true }], + parserOptions: { ecmaVersion: 2018 } } ], invalid: [ @@ -2172,6 +2186,32 @@ ruleTester.run("sort-keys", rule, { } } ] + }, + { + code: ` + let obj = { + b, + [foo()]: [ + // ↓ this blank is inside a property and therefore should not count + + ], + a + } + `, + options: ["asc", { allowLineSeparatedGroups: true }], + parserOptions: { ecmaVersion: 2018 }, + errors: [ + { + messageId: "sortKeys", + data: { + natural: "", + insensitive: "", + order: "asc", + thisName: "a", + prevName: "b" + } + } + ] } ] }); From 4c2ba24a21ac7091b6002bac4191bbf61a74cc2f Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Tue, 19 Jul 2022 13:44:44 +0530 Subject: [PATCH 7/8] fix: check blank line between the first token and the previous node --- lib/rules/sort-keys.js | 7 ++++++- tests/lib/rules/sort-keys.js | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/lib/rules/sort-keys.js b/lib/rules/sort-keys.js index 687bd7ca8ea..b1838d1e657 100644 --- a/lib/rules/sort-keys.js +++ b/lib/rules/sort-keys.js @@ -184,10 +184,15 @@ module.exports = { } }); - // check blank line between current node and last token + // check blank line between the current node and the last token if (!isBlankLineBetweenNodes && (node.loc.start.line - tokens[tokens.length - 1].loc.end.line > 1)) { isBlankLineBetweenNodes = true; } + + // check blank line between the first token and the previous node + if (!isBlankLineBetweenNodes && (tokens[0].loc.start.line - stack.prevNode.loc.end.line > 1)) { + isBlankLineBetweenNodes = true; + } } stack.prevNode = node; diff --git a/tests/lib/rules/sort-keys.js b/tests/lib/rules/sort-keys.js index 35514fd169f..5c9523ab68c 100644 --- a/tests/lib/rules/sort-keys.js +++ b/tests/lib/rules/sort-keys.js @@ -308,6 +308,17 @@ ruleTester.run("sort-keys", rule, { options: ["asc", { allowLineSeparatedGroups: true }], parserOptions: { ecmaVersion: 6 } }, + { + code: ` + var obj = { + b: 1 + + ,a: 2 + }; + `, + options: ["asc", { allowLineSeparatedGroups: true }], + parserOptions: { ecmaVersion: 6 } + }, { code: ` var obj = { @@ -1970,6 +1981,29 @@ ruleTester.run("sort-keys", rule, { } ] }, + { + code: ` + let obj = { + b + + ,a + } + `, + options: ["asc", { allowLineSeparatedGroups: false }], + parserOptions: { ecmaVersion: 6 }, + errors: [ + { + messageId: "sortKeys", + data: { + natural: "", + insensitive: "", + order: "asc", + thisName: "a", + prevName: "b" + } + } + ] + }, // When allowLineSeparatedGroups option is true { From 45f52f1b2fd1914cce9cdc8adca70eb44c30eebe Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Fri, 22 Jul 2022 08:41:44 +0530 Subject: [PATCH 8/8] refactor: use getTokensBetween and update examples --- docs/src/rules/sort-keys.md | 5 +++-- lib/rules/sort-keys.js | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/src/rules/sort-keys.md b/docs/src/rules/sort-keys.md index 006335d1495..f4047cde3e5 100644 --- a/docs/src/rules/sort-keys.md +++ b/docs/src/rules/sort-keys.md @@ -92,7 +92,7 @@ The 2nd option is an object which has 3 properties. * `caseSensitive` - if `true`, enforce properties to be in case-sensitive order. Default is `true`. * `minKeys` - Specifies the minimum number of keys that an object should have in order for the object's unsorted keys to produce an error. Default is `2`, which means by default all objects with unsorted keys will result in lint errors. * `natural` - if `true`, enforce properties to be in natural order. Default is `false`. Natural Order compares strings containing combination of letters and numbers in the way a human being would sort. It basically sorts numerically, instead of sorting alphabetically. So the number 10 comes after the number 3 in Natural Sorting. -* `allowLineSeparatedGroups` - if `true`, the rule allows to group object keys through line breaks. In other words, a blank line after a key will reset the sorting of keys. Default is `false`. +* `allowLineSeparatedGroups` - if `true`, the rule allows to group object keys through line breaks. In other words, a blank line after a property will reset the sorting of keys. Default is `false`. Example for a list: @@ -295,10 +295,11 @@ let obj2 = { let obj3 = { b: 1, c: 2, - // comment + z () { }, + // comment y: 3, } diff --git a/lib/rules/sort-keys.js b/lib/rules/sort-keys.js index b1838d1e657..1523ab751a0 100644 --- a/lib/rules/sort-keys.js +++ b/lib/rules/sort-keys.js @@ -169,7 +169,7 @@ module.exports = { // Get tokens between current node and previous node const tokens = stack.prevNode && sourceCode - .getFirstTokensBetween(stack.prevNode, node, { skip: 0, includeComments: true }); + .getTokensBetween(stack.prevNode, node, { includeComments: true }); let isBlankLineBetweenNodes = stack.prevBlankLine;