1
0
mirror of https://github.com/sasjs/lint.git synced 2026-01-16 00:30:05 +00:00

feat: add a new config attribute for allowedGremlins

This commit is contained in:
2023-01-09 17:13:19 +05:00
parent 9984a373df
commit 844f1ad154
4 changed files with 54 additions and 8 deletions

View File

@@ -10,15 +10,18 @@ const message = 'Line contains a gremlin'
const test = (value: string, lineNumber: number, config?: LintConfig) => {
const severity = config?.severityLevel[name] || Severity.Warning
const allowedGremlins = config?.allowedGremlins || []
const diagnostics: Diagnostic[] = []
const gremlins: any = {}
for (const [hexCode, config] of Object.entries(gremlinCharacters)) {
gremlins[charFromHex(hexCode)] = Object.assign({}, config, {
hexCode
})
for (const [hexCode, gremlinConfig] of Object.entries(gremlinCharacters)) {
if (!allowedGremlins.includes(hexCode)) {
gremlins[charFromHex(hexCode)] = Object.assign({}, gremlinConfig, {
hexCode
})
}
}
const regexpWithAllChars = new RegExp(
@@ -56,4 +59,5 @@ export const noGremlins: LineLintRule = {
test
}
const charFromHex = (hexCode: string) => String.fromCodePoint(parseInt(hexCode))
export const charFromHex = (hexCode: string) =>
String.fromCodePoint(parseInt(hexCode))