LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

jshint

JavaScript code quality tool

TLDR

Lint JavaScript file
$ jshint [file.js]
copy
Lint multiple files
$ jshint [file1.js] [file2.js]
copy
Use config file
$ jshint --config [.jshintrc] [file.js]
copy
Check all JS files
$ jshint [src/]
copy
Verbose output
$ jshint --verbose [file.js]
copy
Show non-error data
$ jshint --show-non-errors [file.js]
copy
Exclude paths
$ jshint --exclude [node_modules/,vendor/] [src/]
copy
Use a custom reporter
$ jshint --reporter [checkstyle] [src/]
copy

SYNOPSIS

jshint [options] file...

DESCRIPTION

JSHint is a JavaScript static analysis tool that detects errors and potential problems in code. It is configurable through a .jshintrc JSON file (or a jshintConfig field in package.json), allowing teams to enforce a chosen coding style.The CLI accepts files, directories, or stdin (use - as the filename). When given a directory, JSHint recursively lints every file with an extension matching --extra-ext (.js by default). Ignored paths can be listed in .jshintignore.

PARAMETERS

FILE

JavaScript files to lint.
--config FILE
Path to the configuration file (default: .jshintrc lookup from the file's directory upward).
--verbose
Include warning/error code (e.g. W117) in the output.
--reporter NAME
Use a custom reporter: jslint, checkstyle, unix, or a path to a reporter module.
--extract MODE
Extract JavaScript from HTML before linting: auto, always, never (default never).
--extra-ext LIST
Comma-separated list of additional file extensions to lint (default .js).
--exclude PATHS
Comma-separated list of directories or files to skip.
--exclude-path FILE
Use a file in .gitignore syntax (e.g. .jshintignore) to skip paths.
--prereq FILES
Files included before each linted file to provide globals.
--filename NAME
Treat stdin input as having this filename when matching configuration.
--show-non-errors
Show additional analysis data (functions, globals).
--version
Print the installed version.
--help
Display help information.

CAVEATS

Requires Node.js. JSHint development has slowed; ESLint is generally preferred for new projects, especially when using modern ECMAScript or TypeScript. JSHint does not understand JSX or TypeScript natively.

HISTORY

JSHint was forked from JSLint by Anton Kovalyov in 2011 to provide a more configurable JavaScript linter.

SEE ALSO

eslint(1), prettier(1), tslint(1), node(1)

Copied to clipboard
Kai