↓ Skip to main content

Suppress SPFx warnings w/ Regex

·1 min
Tom Daly
Author
Tom Daly
Developer, Designer, Thinker, Problem Solver, Office Servers and Services MVP, & Collaboration Director @ SoHo Dragon.

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.

New call-to-action

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!

Related

SPFx Automatically Generating Revision Numbers

·3 mins
I like automatic revision numbers while I’m developing. I don’t have to manually be making changes while pushing packages out and testing. While working on…