-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix(ESLint): Causes incorrect class selection when there is only one …
…character, resolved #345
- Loading branch information
Showing
3 changed files
with
31 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export function indexOfAll(arr: any[] | string, value: any): number[] { | ||
const result = [] | ||
let i = -1 | ||
while ((i = arr.indexOf(value, i + 1)) !== -1) { | ||
result.push(i) | ||
} | ||
return result | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import findLoc from '../src/utils/find-loc' | ||
|
||
describe('findLoc', () => { | ||
it('Causes incorrect class selection when there is only one character #345', () => { | ||
const text = 'f' | ||
const lines = ['font:12 font:24@sm m:32 block font:32@md mb:48 f', 'bg:indigo font:'] | ||
const result = findLoc(text, lines, 1, 2) | ||
expect(result).toEqual({ start: { line: 1, column: 47 }, end: { line: 1, column: 48 } }) | ||
}) | ||
}) |