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

(v3.7.0) JavaScript: jsxhint

LCD 47 edited this page Oct 6, 2015 · 1 revision

Maintainer: Thomas Boyt me@thomasboyt.com

JSXHint is a wrapper around JSHint for linting JSX syntax, which is inline markup-in-JS used by React.

See the project's page for details.

Installation

Install it with:

npm install -g jsxhint

Only versions v0.4.1 and later of JSXHint are supported. You also need JSHint v1.1.0 or later.

Once installed, you also need to configure syntastic to use it:

let g:syntastic_javascript_checkers = ['jsxhint']

Note

Since JSXHint is a wrapper around JSHint, the following note relevant to the latter still applies:

If you're checking files containing tab characters then JSHint's idea of tabstop must match Vim's tabstop, otherwise syntastic will highlight the errors at shifted positions. By default JSHint's tabstop is 4, while Vim's default tabstop is 8.

In order to change JSHint's tabstop you have to change its indent config option. One way to do that is to put it in a file named .jshintrc in the current directory, the parent directories, or your home directory. The file is supposed to be in JSON format. For example:

{
    "indent": 8
}

See JSHint documentation for more details.

Please note however that setting indent also triggers the indentation checks in JSHint. If that is undesirable, your only other option is to leave JSHint's tabstop alone, and change Vim's tabstop to 4. To change Vim's tabstop, you can add this to your vimrc:

set tabstop=4

Alternative

JSXHint will not show JSX-related errors in syntastic, because failed JSX compiles will result in the uncompiled data being passed to JSHint. See this issue. To get around this, Syntastic-React can be used as a replacement for JSXHint.

Clone this wiki locally