1
0
mirror of https://github.com/sasjs/lint.git synced 2025-12-10 17:34:36 +00:00
Files
lint/src/utils/getColumnNumber.ts
2021-04-07 16:49:24 +05:00

8 lines
297 B
TypeScript

export const getColumnNumber = (line: string, text: string): number => {
const index = (line.split('\n').pop() as string).indexOf(text)
if (index < 0) {
throw new Error(`String '${text}' was not found in line '${line}'`)
}
return (line.split('\n').pop() as string).indexOf(text) + 1
}