Next steps and conclusion
In summary:
- JSLint is great for checking snippets or single files. One of its potential downsides is that it isn’t suitable for large projects.
- StandardJS is ideal for those who want to get started with little to no fuss and/or build a linter into their workflows and build scripts. But, it’s not configurable. So if you need to make custom rules you’ll probably want to look at JSHint or ESLint.
- JSHint can also be installed through npm and its linting rules are completely configurable. This could be good or bad, depending on your needs and skill level. You could start with the default rules and customize as needed. It also features a single page site you can use to lint snippets or single files.
- ESLint can be installed through npm and built into workflows just like JSHint. And the question and answer format of its CLI can help you learn as you get started. In its out-of-the-box form it includes industry standard, open source style guides and linting rules that can be applied to any project.
All four of the linters we’ve looked at are reliable and reputable by virtue of being used and developed by well-known people and organizations in the web development community. Anyone would be well served by any of them. If you’ve mastered the basics discussed in this article, a great next step would be learning how to integrate them further into your workflow using npm scripts or a bundler like Webpack.
Any tool is only as good as the use you get out of it. This is true for linters and for the code they help you perfect. Even if you’re developing alone and don’t need to worry about code consistency across a team of developers, you can still benefit from a built-in editor. It’s an incredibly effective way to learn to write JavaScript correctly. Regardless of which linter you use, using a linter can only help you. You can bet the quality of your code will improve, as will your skill as a developer.
LogRocket: Debug JavaScript errors more easily by understanding the context
Debugging code is always a tedious task. But the more you understand your errors, the easier it is to fix them.
LogRocket allows you to understand these errors in new and unique ways. Our frontend monitoring solution tracks user engagement with your JavaScript frontends to give you the ability to see exactly what the user did that led to an error.
LogRocket records console logs, page load times, stack traces, slow network requests/responses with headers + bodies, browser metadata, and custom logs. Understanding the impact of your JavaScript code will never be easier!
One Reply to "4 options to help you get started linting your JavaScript"
Ok, great overview..
However, I wasted a few hours trying to figure out why the cmd to create the config file
$ ./node_modules/.bin/eslint –init
was NOT WORKING; Turns out this is another case of authors on Linux typically ignoring their Windows readers. Use backslashes if you are a Windows user and it will work for you. Don’t waste a few hours of your life like I did !