• Stars
    star
    274
  • Rank 150,274 (Top 3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 11 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Wrapper around JSHint for linting JSX files. 100% compatible with existing tools using JSHint.

build status

Deprecated

JSXHint is, and always was, a bad hack to make JSX lintable in the early days of React. It will always be inferior to proper linters like ESLint because it is not able to lint JSX or ES6 syntax, it instead compiles to ES5 then lints. You may get weird linter errors, especially with more involved transforms.

Don't use JSXHint anymore if you can switch to ESLint.


JSXHint

A wrapper around JSHint to allow linting of files containing JSX syntax.

Accepts the same input as JSHint and emits the same output. Switches sent to jsxhint are forwarded on to jshint.

Glob parsing, ignores, and jshintrc parsing are all performed by jshint.

Automatically lints all files with the .js and .jsx extensions.

Rationale

This module is intended for use as part of SublimeLinter-jsxhint, but it can be used separately as a smart replacement for JSHint. It will automatically convert any file with the jsx extension into JS using react-tools, then present the file to JSHint for validation.

Note that as of React 0.12, it is recommended to use the .jsx file extension rather than the pragma in .js files. If you are already using the .jsx extension, add the option --jsx-only. This will skip attempted conversion of .js files to JSX, but still lint those files. This is useful for running an entire project.

JSXHint is safe to use as a drop-in replacement for JSHint, even when JSX files are not present in a project.

JSXHint offers a simple workflow that accepts JSX files without modification. Additionally, JSXHint actually lints the object definitions generated by the JSX compiler, allowing you to catch mistakes in your templates (such as undefined variables, syntax errors, and missing modules).

JSXHint cli allows for pattern arrays via glob-all

Examples

# Lint entire project. JSXHint will only lint .js and .jsx files.
jsxhint .

# Lint files in `src` folder only.
jsxhint src

# Lint Project using only `.jsx` extension for JSX.
# Will lint .js files with jshint, .jsx files with jsxhint.
jsxhint --jsx-only .

# Basic globbing
jsxhint --config ./other-directory/.jshintrc src/foo/*.jsx

# Multiple patterns
jsxhint 'jsx/**/*' '!scripts/**/*' 'scripts/outlier.jsx'

# Common multiple patterns usecase - lint .js and .jsx, ignore modules and build
jsxhint '**/*.js*' '!node_modules/**/*' '!build/**/*'

# Accepts stdin with '-'
jsxhint - < src/file.jsx

# Exclude files
jsxhint --exclude excludeme.jsx src/foo/*.jsx

# Lint project using babel (previously 6to5)
# Note that you must explicitly install `babel` if you wish to use it.
jsxhint --babel src

Installation

npm install -g jsxhint

Usage

Usage:
  jsxhint[OPTIONS] [ARGS]

Options:
  -c, --config STRING    Custom configuration file
      --reporter STRING  Custom reporter (<PATH>|jslint|checkstyle|unix)
      --exclude STRING   Exclude files matching the given filename pattern
                         (same as .jshintignore)
      --exclude-path STRINGPass in a custom jshintignore file path
      --filename STRING  Pass in a filename when using STDIN to emulate config
                         lookup for that file name
      --verbose          Show message codes
      --show-non-errors  Show additional data generated by jshint
  -e, --extra-ext STRING Comma-separated list of file extensions to use
                         (default is .js)
      --extract [STRING] Extract inline scripts contained in HTML
                         (auto|always|never, default to never)  (Default is never)
      --jslint-reporter  Use a jslint compatible reporter (DEPRECATED, use
                         --reporter=jslint instead)
      --checkstyle-reporter Use a CheckStyle compatible XML reporter
                            (DEPRECATED, use --reporter=checkstyle
                            instead)
  -v, --version          Display the current version
  -h, --help             Display help and usage details

The above options are native to JSHint, which JSXHint extends.

JSXHint Options:
      --jsx-only         Only transform files with the .jsx extension.
                         Will run somewhat faster.
      --babel            Use babel (6to5) instead of react esprima.
                         Useful if you are using es6-module, etc. You must
                         install the module `babel` manually with npm.
      --babel-experimental  Use babel with experimental support for ES7.
                            Useful if you are using es7-async, etc.
      --harmony          Use react esprima with ES6 transformation support.
                         Useful if you are using both es6-class and react.
      --es6module             Pass the --es6module flag to react tools.
      --non-strict-es6module  Pass this flag to react tools.

More Repositories

1

strml.net

STRML: Projects & Work
JavaScript
2,576
star
2

react-router-component

Declarative router component for React.
JavaScript
874
star
3

textFit

A jQuery-free component that quickly fits single and multi-line text to the width (and optionally height) of its container.
JavaScript
598
star
4

keyMirror

Simple util to create an object with its keys mirrored as values. Standalone port of react/lib/keyMirror.
JavaScript
386
star
5

react-localstorage

Simple componentized localstorage implementation for Facebook's React.
JavaScript
288
star
6

react-router-component-transition

Example code for router which does animated page transitions using ReactCSSTranstionGroup
JavaScript
244
star
7

securesha.re-client

Client-side files for Securesha.re, a simple end-to-end encrypted file sharing website.
JavaScript
107
star
8

Healthcare.gov-Marketplace

Community-driven fixes to healthcare.gov's unstable marketplace.
JavaScript
85
star
9

json-to-flow

Convert model schemata into Flow types (.js.flow)
JavaScript
64
star
10

mongoose-filter-denormalize

Simple filtering and denormalization for Mongoose.
JavaScript
53
star
11

async-limiter

A minimal library for throttling async concurrency.
JavaScript
30
star
12

react-document-events

Declarative method for binding handlers to document and window - and cleaning them up.
JavaScript
25
star
13

Imgur-to-Gfycat

Chrome extension that replaces gifs hosted by imgur to HTML5-optimized video converted and hosted by gfycat.
JavaScript
23
star
14

init

Configs
Lua
22
star
15

wayback-machine-machine

Teleport your browser back in time.
JavaScript
18
star
16

babel-preset-es2015-maybe-webpack

JavaScript
13
star
17

backbone.routeNotFound

Simple plugin that fires an event to let the application know that no routes matched, so you can fire a custom 404 handler.
JavaScript
11
star
18

backbone.queryRouter

Drop-in Backbone.Router replacement with support for listening to query parameters.
JavaScript
9
star
19

react-addons

Simple packaging of react addons to avoid fiddly 'react/addons' npm module.
JavaScript
8
star
20

jquery.scrollingShadows

A simple jQuery plugin that creates a shadow on the edge of a scrolling box, indicating that there is more content below.
JavaScript
8
star
21

presentations

JavaScript
8
star
22

forward-emitter

Forward events from any Node EventEmitter to another EventEmitter.
JavaScript
6
star
23

bootstrap-components

Web Components for Bootstrap.
4
star
24

fluxxor-autobind

AutoBind plugin for Fluxxor to help prevent spaghetti props wiring.
JavaScript
4
star
25

js-slack-bot

REPL in Slack.
JavaScript
4
star
26

wheresMyMoneyCampBX

CampBX Auto-Withdrawal Script. Tries to recover your coins.
Python
3
star
27

bitmex-blockclock

Push BitMEX prices to your Blockclock
JavaScript
3
star
28

healthcare.gov

JavaScript
2
star
29

strml.github.com

JavaScript
1
star
30

yarn-link-bug

Reproduction of a yarn --link-duplicates bug
1
star
31

flux-connect

A Redux-style @connect decorator for any Flux app, with proper Flow typing.
JavaScript
1
star
32

openbazaar-ui

CSS
1
star
33

bitmex-DTC

DTC to BitMEX API adapter
OCaml
1
star
34

parse-stream

Parse streams of binary data of arbitrary lengths, handling broken/incomplete chunks.
JavaScript
1
star