mirror of
https://github.com/sasjs/lint.git
synced 2026-01-06 20:20:06 +00:00
chore: getLineNumber utility removed
This commit is contained in:
@@ -7,7 +7,7 @@ describe('getColumnNumber', () => {
|
||||
|
||||
it('should throw an error when the specified string is not found within the text', () => {
|
||||
expect(() => getColumnNumber('foo bar', 'baz')).toThrowError(
|
||||
"String 'baz' was not found in statement 'foo bar'"
|
||||
"String 'baz' was not found in line 'foo bar'"
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
export const getColumnNumber = (statement: string, text: string): number => {
|
||||
const index = (statement.split('\n').pop() as string).indexOf(text)
|
||||
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 statement '${statement}'`
|
||||
)
|
||||
throw new Error(`String '${text}' was not found in line '${line}'`)
|
||||
}
|
||||
return (statement.split('\n').pop() as string).indexOf(text) + 1
|
||||
return (line.split('\n').pop() as string).indexOf(text) + 1
|
||||
}
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
export const getLineNumber = (lines: string[], index: number): number => {
|
||||
const combinedCode = lines.slice(0, index).join('\n')
|
||||
return (combinedCode.match(/\n/g) || []).length + 1
|
||||
}
|
||||
Reference in New Issue
Block a user