# tools - JavaScript linters
# definition
Lint (software) : en.wikipedia.org
In computer programming, lint is a Unix utility that flags some suspicious and non-portable constructs (likely to be bugs) in C language source code; generically, lint or a linter is any tool that flags suspicious usage in software written in any computer language. The term lint-like behavior is sometimes applied to the process of flagging suspicious language usage. Lint-like tools generally perform static analysis of source code.
Lint as a term can also refer more broadly to syntactic discrepancies in general, especially in interpreted languages like JavaScript and Python. For example, modern lint checkers are often used to find code that doesn't correspond to certain style guidelines. Because these languages lack a compiling phase that shows a list of errors prior to execution, they can also be used as simple debuggers for common errors (showing syntactic discrepancies as errors) or hard to find errors such as heisenbugs (drawing attention on suspicious code as "possible errors").
# TLDR
A linter performs static analysis of source code to find :
- undected errors on interpreted languages (they have no compiling phase) (ex : accessing an undefined var)
- styleguide issues (tab length, naming, etc ...)
# JavaScript linters
Linting JavaScript in 2015 : tech.lauritz.me
A Comparison of JavaScript Linting Tools : www.sitepoint.com 20150305
- a set of rules which they use to analyze and report problems in JavaScript files
- installed via npm
- available as plugins for tools like Grunt or Gulp (also throught EDI)
- support using comments for configuration
# JSLint
The older one. Created by Douglas Crockford in 2002. Have strongly inspired his books, "JavaScript: The Good Parts (2008)".
Still maintained : douglascrockford/JSLint.
Not configurable or extensible.
# JSHint
JSHint is a program that flags suspicious usage in programs written in JavaScript.
JSHint is a 2010 fork of JSLint.
Still maintained : jshint/jshint.
Configurable but no custom rule support.
# links
# JSCS
Unmaintained and merged with eslint in 2016. See this.
Style checker only.
# ESLint
Created in 2013.
Still maintained : eslint/eslint
TLDR : It is JSHint + plugin system.
Usually 2-3x slower then JSHint on a single file (src).
Support JSX (React) and ES6.
Lots of pluggins ( babel-eslint, eslint-plugin-angular )
# linters style guide superset
5 JavaScript Style Guides — Including AirBnB, GitHub, & Google - 20171105
The idea is to build a preconfired linter with no config available regarding to code style to avoid wasting time on useless debate like spaces or tabs.
GitHub collections/clean-code-linters
# airbnb
Provide npm packages for easy ESLint config :
npx install-peerdeps --dev eslint-config-airbnb-base
npx install-peerdeps --dev eslint-config-airbnb
# stantardjs
Provide his own package to encapsulate and hide ESLint.
Used by thousands of companies including big ones like NPM, GitHub, mongoDB, ZenDesk, ...
# jQuery
jQuery foundation JavaScript Style Guide
# prettiers
They limit to the formatting rules and don't deal with code quality.
Comparison to ESLint/TSLint/stylelint