mirror of
https://github.com/sasjs/lint.git
synced 2026-01-09 05:20:06 +00:00
feat: add a new config maxHeaderLineLength
This commit is contained in:
25
src/utils/getHeaderLinesCount.ts
Normal file
25
src/utils/getHeaderLinesCount.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { LintConfig } from '../types'
|
||||
import { splitText } from './splitText'
|
||||
|
||||
/**
|
||||
* This funtion returns the number of lines header spans upon.
|
||||
*/
|
||||
export const getHeaderLinesCount = (text: string, config: LintConfig) => {
|
||||
text = text.replace('/*', '/**')
|
||||
text = text.replace('*/', '**/')
|
||||
|
||||
let count = 0
|
||||
|
||||
if (text.trimStart().startsWith('/**')) {
|
||||
const lines = splitText(text, config)
|
||||
|
||||
for (const line of lines) {
|
||||
count++
|
||||
if (line.match(/\*\*\//)) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return count
|
||||
}
|
||||
Reference in New Issue
Block a user