Linting
The process of running a program that analyzes code for potential errors, bugs, stylistic issues, and suspicious constructs.
定义
A linter is a static analysis tool that flags programming errors, bugs, stylistic errors, and suspicious constructs. The term comes from a Unix tool called "lint" that examined C source code. Modern linters like ESLint (JavaScript), Pylint (Python), and RuboCop (Ruby) check for syntax errors, undefined variables, unused code, formatting inconsistencies, and potential bugs.
为什么重要
Linting catches common mistakes instantly as you code. It enforces consistent code style across teams, reducing code review friction. Most IDEs integrate linters for real-time feedback. ESLint alone catches approximately 25% of JavaScript bugs before code even runs.
示例
ESLint flags a variable that's declared but never used, a missing semicolon, and an undefined function call — all before the code is even committed.