I need to write an Angular Typescript rule to warn people if they utilize certain 'keywords/phrases'. For example, if keyword "Birthdate" or "SSN" is in the source file directly, it should give a warning.
How would someone write this rule to restrict words using ESLint?
Trying to research currently, did not see any articles in Stackoverflow article search archive,
Curious how to manipulate example code below or (open to any other solutions),
I applied the following below "id-blacklist": ["SSN","Birthdate"], receiving error
https://eslint.org/docs/rules/id-blacklist
module.exports = {
"env": {
"browser": true,
"es6": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"id-blacklist": ["SSN","Birthdate"]
}
};
Error:
Configuration for rule "id-blacklist" is invalid:Severity should be one of the following: 0 = off, 1 = warn, 2 = error
Other Resources:
https://rangle.io/blog/custom-tslint-for-angular/
https://medium.com/@andrey.igorevich.borisov/writing-custom-tslint-rules-from-scratch-62e7f0237124