Skip to content

Commit

Permalink
Incorporate feedback :)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaicataldo committed Oct 24, 2019
1 parent 95cefe7 commit e8f642d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion lib/source-code/source-code.js
Expand Up @@ -420,9 +420,10 @@ class SourceCode extends TokenStore {
* @public
*/
isSpaceBetweenTokens(first, second) {
const finalToken = (this.getFirstToken(second) || second);
let currentToken = this.getLastToken(first) || first;

while (currentToken !== (this.getFirstToken(second) || second)) {
while (currentToken !== finalToken) {
const nextToken = this.getTokenAfter(currentToken, { includeComments: true });

if (/\s/u.test(this.text.slice(currentToken.range[1], nextToken.range[0]))) {
Expand Down
10 changes: 5 additions & 5 deletions tests/lib/source-code/source-code.js
Expand Up @@ -1797,7 +1797,7 @@ describe("SourceCode", () => {
["let/**/foo", false],
["let/*\n*/foo", false]
], (code, expected) => {
it("should return true when there is at least one whitespace character between two tokens", () => {
it(`should return true when there is at least one whitespace character between two tokens: ${code}`, () => {
const ast = espree.parse(code, DEFAULT_CONFIG),
sourceCode = new SourceCode(code, ast);

Expand Down Expand Up @@ -1843,7 +1843,7 @@ describe("SourceCode", () => {
["a/* */+` /*\n*/ ` /* */+c", true],
["a/* */+ ` /*\n*/ ` /* */+c", true]
], (code, expected) => {
it("should return true when there is at least one whitespace character between two tokens", () => {
it(`should return true when there is at least one whitespace character between two tokens: ${code}`, () => {
const ast = espree.parse(code, DEFAULT_CONFIG),
sourceCode = new SourceCode(code, ast);

Expand Down Expand Up @@ -1885,7 +1885,7 @@ describe("SourceCode", () => {
[";\n/**/\nlet foo = bar", true],
[";\n/* */\nlet foo = bar", true]
], (code, expected) => {
it("should return true when there is at least one whitespace character between a token and a node", () => {
it(`should return true when there is at least one whitespace character between a token and a node: ${code}`, () => {
const ast = espree.parse(code, DEFAULT_CONFIG),
sourceCode = new SourceCode(code, ast);

Expand Down Expand Up @@ -1927,7 +1927,7 @@ describe("SourceCode", () => {
["let foo = bar;\n/**/\n;", true],
["let foo = bar;\n/* */\n;", true]
], (code, expected) => {
it("should return true when there is at least one whitespace character between a node and a token", () => {
it(`should return true when there is at least one whitespace character between a node and a token: ${code}`, () => {
const ast = espree.parse(code, DEFAULT_CONFIG),
sourceCode = new SourceCode(code, ast);

Expand Down Expand Up @@ -1967,7 +1967,7 @@ describe("SourceCode", () => {
["let foo = bar;\n/* */\nlet baz = qux;", true],
["let foo = 1;let foo2 = 2; let foo3 = 3;", true]
], (code, expected) => {
it("should return true when there is at least one whitespace character between two nodes", () => {
it(`should return true when there is at least one whitespace character between two nodes: ${code}`, () => {
const ast = espree.parse(code, DEFAULT_CONFIG),
sourceCode = new SourceCode(code, ast);

Expand Down

0 comments on commit e8f642d

Please sign in to comment.