Reputation: 22334
PHPLint, JSLint, and I recently came across "you can lint your JS code on the fly" while reading something about some IDE.
So, what is "linting"?
Upvotes: 1310
Views: 570890
Reputation: 461
Linting is a process by a linter program that analyzes source code in a particular programming language and flag potential problems like syntax errors, deviations from a prescribed coding style or using constructs known to be unsafe.
For example, a JavaScript linter would flag the first use of parseInt below as unsafe:
// without a radix argument - Unsafe
var count = parseInt(countString);
// with a radix paremeter specified - Safe
var count = parseInt(countString, 10);
See lint on wikipedia:
Upvotes: 10
Reputation: 1566
Linting is the process of using static code analysis tool identify stylistic errors in your code.
Linting is especially useful for dynamically typed languages like JavaScript and Python. As these languages typically do not enforce strict rules prior to execution.
Popular Linting tools for the coding are:
Linting tools usage:
Linting tools can be configured with other tools like git pre commit hook and husky, to ensure that the linting is done of the code that is being committed to a certain repository.
This will make sure that coding standards are maintained and code is formatted and language specific best practices are adhered before code is committed to the repository.
Engineers will be able to make the commit only if the said coding standards are met.
Upvotes: 3
Reputation: 6193
A linter is a tool that is used to mark occurrences of suspicious and non-structural code (i.e. potential bugs) in source code. It was a static code analysis tool in C at the beginning, later it became the generic term used to describe the software analysis tool that mark the suspicious code.
Upvotes: 40
Reputation: 11420
Apart from what others have mentioned, I would like to add that linting will run through your source code to
Running a lint program over your source code, helps to ensure that source code is legible, readable, less polluted and easier to maintain.
Upvotes: 75
Reputation: 11800
Interpreted languages like Python and JavaScript benefit greatly from linting, as these languages don’t have a compiling phase to display errors before execution.
Linters are also useful for code formatting and/or adhering to language specific best practices.
Lately I have been using ESLint for JS/React and will occasionally use it with an airbnb-config file.
Upvotes: 30
Reputation: 3761
Linting is the process of checking the source code for Programmatic as well as Stylistic errors. This is most helpful in identifying some common and uncommon mistakes that are made during coding.
A Lint
or a Linter
is a program that supports linting (verifying code quality). They are available for most languages like JavaScript, CSS, HTML, Python, etc..
Some of the useful linters are JSLint, CSSLint, JSHint, Pylint
Upvotes: 153
Reputation: 499212
Linting is the process of running a program that will analyse code for potential errors.
See lint on wikipedia:
lint was the name originally given to a particular program that flagged some suspicious and non-portable constructs (likely to be bugs) in C language source code. The term is now applied generically to tools that flag suspicious usage in software written in any computer language.
Upvotes: 1267
Reputation: 308958
Lint was the name of a program that would go through your C code and identify problems before you compiled, linked, and ran it. It was a static checker, much like FindBugs today for Java.
Like Google, "lint" became a verb that meant static checking your source code.
Upvotes: 222