Skip to content
forked from STRML/JSXHint

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

License

Notifications You must be signed in to change notification settings

gaearon/JSXHint

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

90 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

build status

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

Accepts the same input and 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).

##Examples

# Lint entire project
jsxhint src/**/*

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

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

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

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

# Lint project using 6to5 acorn parser
jsxhint --6to5 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)
      --exclude STRING   Exclude files matching the given filename pattern
                         (same as .jsxhintignore)
      --exclude-path STRINGPass in a custom jsxhintignore 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 jsxhint
  -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
      --jsx-only         Only transform files with the .jsx extension.
                         Will run somewhat faster.
      --6to5             Use 6to5 (acorn parser) instead of react esprima.
                         Useful if you are using es6-module/es7-async/etc.

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%