Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Latest commit

 

History

History
52 lines (33 loc) · 3.59 KB

README.md

File metadata and controls

52 lines (33 loc) · 3.59 KB

VS Code JSHint extension

Integrates JSHint into VS Code.

Setup

The extension looks for a jshint module in the current directory and in the global package location. You can install jshint locally with npm install jshint or globally with npm install -g jshint. If your jshint module is in a different location, use the jshint.nodePath setting to specify the correct path. The jshint.packageManager setting can be used to specify which package manager you are using, npm or yarn.

To check where jshint is loaded from, use the JSHint: Show output command after the extension has started to view the extension logs in the output panel.

Configuration Options

The jshint extension uses the standard jshint configuration options described on the jshint web site.

The options can be specified in a number of locations mostly mimicing jshint's default behavior. The extension looks for its configuration options the following way and stops at the first positive match:

  1. An options file specified in the user or workspace settings like this: "jshint.config" : "<file path>". The file path is interpreted relative to the workspace's root folder.
  2. The value of the jshintConfig attribute in a package.json file located in the current directory or any parent of the current directory.
  3. A .jshintrc file located in the current directory or any parent of the current directory.
  4. A .jshintrc file located in the user's home directory.
  5. The values specified within jshint.options in the user or workspace settings. By default jshint.options is empty.

.jshintrc files can be chained using the extends attribute as described here.

Exclude Options

In order to ignore specific files or folders from being linted exclude options can be specified in a number of locations mostly mimicing jshint's default behavior. The extenion looks for its exclude options the following way and stops at the first positive match:

  1. A file specified in the user or workspace settings like this: "jshint.excludePath" : "<file path>". The file path is interpreted relative to the workspace's root folder. The file contains glob patterns specifying files that should be excluded. The glob patterns are interpreted relative to the workspace's root folder.
  2. A .jshintignore file located in the current directory or any parent of the current directory. The glob patterns in this file are interpreted relative to the location of the .jshintignore file.
  3. The value of the jshint.exclude attribute in the user or workspace settings. The attribute has the following form: "jshint.exclude" : { "<glob pattern>" : true, "<glob pattern>" : true }. The glob patterns are interpreted relative to the workspace's root folder.

The glob patterns are interpreted using the npm minimatch module. Be aware that there are slight differences between minimatch and how .gitignore patterns are interpreted. Most noteably, **/name and name are not the same in minimatch whereas they are consider equal in .gitignore. Always use **/name if you want to match a name within a subtree.

No files are excluded by default.

Disable JSHint

In order to disable jshint for a workspace specify "jshint.enable" : false in the workspace settings. jshint is enabled by default.

Contributing

Contributions to the extension are welcome! Please see contributing for information on how to develop the extension.