mirror of
https://github.com/sasjs/lint.git
synced 2026-01-11 14:30:04 +00:00
feat(lint): implement v1 with 3 rules - trailing spaces, encoded passwords and Doxygen header
This commit is contained in:
24
src/rules/noEncodedPasswords.ts
Normal file
24
src/rules/noEncodedPasswords.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { LineLintRule } from '../types/LintRule'
|
||||
import { LintRuleType } from '../types/LintRuleType'
|
||||
|
||||
const name = 'noEncodedPasswords'
|
||||
const description = 'Disallow encoded passwords in SAS code.'
|
||||
const warning = 'Line contains encoded password'
|
||||
const test = (value: string, lineNumber: number) => {
|
||||
const regex = new RegExp(/{sas\d{2,4}}[^;"'\s]*/, 'gi')
|
||||
const matches = value.match(regex)
|
||||
if (!matches || !matches.length) return []
|
||||
return matches.map((match) => ({
|
||||
warning,
|
||||
lineNumber,
|
||||
columnNumber: value.indexOf(match) + 1
|
||||
}))
|
||||
}
|
||||
|
||||
export const noEncodedPasswords: LineLintRule = {
|
||||
type: LintRuleType.Line,
|
||||
name,
|
||||
description,
|
||||
warning,
|
||||
test
|
||||
}
|
||||
Reference in New Issue
Block a user