Optimizing web apps with the Sonarwhal linter

One of the more useful elements of the modern developer environment is also one of the oldest development tools. Originally developed as part of YACC (Yet Another Compiler Compiler), the first linter was the equivalent of a grammar checker for C code. Taking its name from the bits of loose fluff found in wool, Lint highlighted errors, bugs, and problematic code.

Lint everything

Over the years, it gave its name to a whole menagerie of linting tools, mainly focused on the C and C++ worlds, but with versions for other languages and programming models. A well-designed linter runs through your code before compilation so you can correct errors and optimize it. A modern linter is an add-on to a compiler (though many modern compilers, especially tools such as .Net’s Roslyn, offer linting features as part of multistage operation), run separately to highlight many classes of possible problems with code, including uninitialized variables, poor formatting, and license issues. Such linters can even help refactor your code.

They’re especially useful for interpreted and declarative languages, where there’s no compiler to flag errors, making it very easy to accidently publish buggy JavaScript to the web or leave Python errors in a public Jupyter Notebook. And hooking a linter up to tools like Visual Studio Code reduces the risk of errors and makes it easier to read and debug code.

Introducing Sonarwhal

One part of the modern development platform that desperately needs good linting tools is the web. Not only are you building user experiences for your applications in HTML and JavaScript, you’re using CSS for styling, and taking advantage a whole host of JavaScript browser APIs. It’s not only the familiar web, either: You’re also using the same technologies in progressive web apps (PWAs), running as standalone applications downloaded from the Microsoft Store. That’s where Sonarwhal comes in, offering linting services that fit into a web development workflow. Version 1.0 was released recently.

Leave a Reply

Your email address will not be published. Required fields are marked *