Suppress SPFx warnings w/ Regex
My goal is to write clean and readable code. The least I can do is make sure it’s formatted correctly. One of my favorite Visual Studio plugins is called Prettier. I use that plugin to make sure everything is formatted consistently throughout my code. My biggest issue is that it adds semicolons to every single function.
But it doesn’t treat all functions equal.
The SPFx tslint rules don’t like that.
Prettier has the option to enable / disable semicolons at the end of every statement. Disabling that setting takes away all the semicolons from all lines. I like to have semicolons after each statement.
You could disable the semi-colon check in SPFx project’s tslint.json file
OR you could edit your gulpfile.js and add suppression to prevent the message.
The build.AddSuppression will accept a string or a regex. You can see here I’ve added a regex value to suppress errors that end with ‘error semicolon: Unecessary semicolon”
Either way works for me – no more semicolon warnings!