LinuxCommandLibrary

jshint

Lint JavaScript code for errors

SYNOPSIS

jshint [OPTIONS] [FILE|DIR|GLOB]...

PARAMETERS

-h, --help
    Print command help and exit.

-v, --verbose
    Print extra information about linting process.

-c, --config=PATH
    Specify path to .jshintrc configuration file.

--reporter=REPORTER
    Use a custom reporter script or name.

--checkstyle-reporter=PATH
    Output results as Checkstyle-compatible XML.

--json
    Print results in JSON format.

--compact
    Use compact, one-line reporting per error.

--no-color
    Disable colored output.

-w, --watch
    Watch files/directories for changes and re-lint.

--stdin
    Read JavaScript from standard input.

--extract=REGEXP
    Extract and lint JS source from stdin using regex.

DESCRIPTION

JSHint is a flexible, community-driven tool for analyzing JavaScript code. It detects errors, enforces coding standards, and identifies potential bugs or inefficient patterns such as unused variables, missing semicolons, or unsafe practices.

Unlike its predecessor JSLint, JSHint is highly configurable via .jshintrc JSON files, allowing customization for browsers, Node.js, CommonJS, or custom environments. It supports linting single files, directories, globs, or stdin input.

Ideal for development workflows, it integrates with editors like Vim/Emacs, IDEs, and CI/CD pipelines. Outputs results in plain text, JSON, Checkstyle XML, or custom reporters. Use it to maintain code quality in projects of any size.

CAVEATS

Not a native Linux binary; requires Node.js and global install via npm install -g jshint. Performance may degrade on very large codebases without optimization.

CONFIGURATION

Default settings from .jshintrc (JSON) in project root or home dir. Supports env presets like browser, node.

INTEGRATION

Compatible with pre-commit hooks, Travis CI, GitHub Actions via npm scripts.

HISTORY

Forked from JSLint in 2011 by Anton Kovalyov to provide more flexibility. Actively maintained by the open-source community; version 2.13.0 released in 2022 with improved ES6+ support.

SEE ALSO

eslint(1), node(1), npm(1)

Copied to clipboard