
To lint or not to lint...
Let’s put a stop to the sneaky 500 error crashes due to syntax errors! Just update to SSJS Manager v0.8.1
(and beyond)!
Linting SSJS - finally
So, what’s “linting”? It’s a way to check your code for errors and warnings. It’s like a spell checker for your code.
It’s not a new concept, but it’s somewhat new to SSJS. Here I have to give credit to Jörn Berkefeld for the first SSJS linter configuration out there. This is a pretty much new implementation though, due to many changes in the recent versions of ESLint. It also packs tons of brand new rules and features to make your code better.
What does it do?
Here is a short list of the things this checks for:
- ECMAScript 3 compatibility, like basic syntax, missing semicolons, closed curly braces, and more,
- custom check for last array item not having a comma (happened to me “a few” times),
- custom parsing error rules for newer versions of ECMAScript - like when you attempt to use
const
orlet
, - checks for
<script>
tags validity, - and more…
No installs needed
Yes, you’ve heard it. No additional installs needed, no extra configuration files. Just update and use!
There is some new config in the VScode preferences you might want to check out (like if to override auto-deploy on major errors), but this is not necessary to use.
And if you by any chance do not use the in-built lint? Just turn it off and use it by command only when you need.
Usage
There are two ways to use the linting:
1. In-built linting
This is the default way to use the linting. It’s turned on by default and will run automatically when you save a file. You can change its behavior in the VScode preferences.
2. VSCode Command linting
You can also use the linting by command. This is useful if you want to run the linting on a specific file or a specific folder. By default, this works on ampscript
and html
files.
Also, by adding to additional files, you can support other file types as well, like .js
files.
The command is SSJS: Lint Current SSJS File
.
That’s all folks
And that’s all for now. I hope this update will make your life a little easier.
If you have any questions or feedback, feel free to ask me on LinkedIn.
If you want to support this project, you can always help to spread the word, rate it on VSCode Marketplace, or just like and comment on my LinkedIn post.