1293

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"?

1
  • 13
    I've been hearing this term only since visual studio code became a thing. before it was just "intellisense"-like. Even though this term dates back from 1978 from wikipedia, it seems to me it's been popular only recently.
    – v.oddou
    Commented Apr 11, 2018 at 13:22

8 Answers 8

1254

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.

8
  • 185
    Cite from wikipedia - “The term was derived from the name of the undesirable bits of fiber and fluff found in sheep's wool.”
    – tan9
    Commented Jul 21, 2016 at 5:39
  • 25
    @HasanBaidoon - it just reports violations of a style policy, doesn't necessarily act on them on behalf of the user.
    – Oded
    Commented Jun 15, 2017 at 14:53
  • 1
    Would stylecop be considered a linter? Commented Aug 15, 2017 at 13:13
  • 2
    @Adam - usually a linter would also have the option to auto-fix issues it found.
    – Oded
    Commented Aug 15, 2017 at 13:48
  • 3
    @tan9 probably the term lint derives first to the stuff in clothes drying machines' filters as I doubt many programmers have face-to-face experience with sheep Commented May 9, 2018 at 3:03
222

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.

153

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

74

Apart from what others have mentioned, I would like to add that linting will run through your source code to

  • find formatting discrepancies,
  • find non-adherence to coding standards and conventions,
  • pinpoint possible logical errors in your program.

Running a lint program over your source code, helps to ensure that source code is legible, readable, less polluted and easier to maintain.

40

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.

30

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.

10

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:

0
3

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.