mirror of
https://github.com/sasjs/lint.git
synced 2026-01-11 14:30:04 +00:00
chore(*): add PR template, add TSDoc comments
This commit is contained in:
10
src/lint.ts
10
src/lint.ts
@@ -2,11 +2,21 @@ import { Diagnostic } from './types/Diagnostic'
|
||||
import { LintConfig } from './types/LintConfig'
|
||||
import { getLintConfig } from './utils/getLintConfig'
|
||||
|
||||
/**
|
||||
* Analyses and produces a set of diagnostics for the given text content.
|
||||
* @param {string} text - the text content to be linted.
|
||||
* @returns {Diagnostic[]} array of diagnostic objects, each containing a warning, line number and column number.
|
||||
*/
|
||||
export const lint = async (text: string) => {
|
||||
const config = await getLintConfig()
|
||||
return processText(text, config)
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits the given content into a list of lines, regardless of CRLF or LF line endings.
|
||||
* @param {string} text - the text content to be split into lines.
|
||||
* @returns {string[]} an array of lines from the given text
|
||||
*/
|
||||
export const splitText = (text: string): string[] => {
|
||||
if (!text) return []
|
||||
return text.replace(/\r\n/g, '\n').split('\n')
|
||||
|
||||
Reference in New Issue
Block a user