coffee-jshint
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -5,2 +5,12 @@ # Change Log | ||
<a name="1.1.0"></a> | ||
# [1.1.0](https://github.com/marviq/coffee-jshint/compare/v1.0.1...v1.1.0) (2017-11-06) | ||
### Features | ||
* include `loopfunc` with the default relaxing `jshint` options. ([4b21a36](https://github.com/marviq/coffee-jshint/commit/4b21a36)), closes [#25](https://github.com/marviq/coffee-jshint/issues/25) | ||
<a name="1.0.1"></a> | ||
@@ -7,0 +17,0 @@ ## [1.0.1](https://github.com/marviq/coffee-jshint/compare/v1.0.0...v1.0.1) (2017-10-24) |
@@ -35,12 +35,20 @@ // Generated by CoffeeScript 2.0.1 | ||
defaultOptions = [ | ||
'undef', | ||
//# options to relax for cs | ||
//# http://jshint.com/docs/options/#enforcing-options | ||
//# | ||
'eqnull', | ||
'expr', | ||
'shadow', | ||
'sub', | ||
'multistr' | ||
'undef', //# http://jshint.com/docs/options/#undef | ||
//# Options to relax for cs. | ||
//# | ||
//# http://jshint.com/docs/options/#relaxing-options | ||
//# | ||
'eqnull', //# http://jshint.com/docs/options/#eqnull | ||
'expr', //# http://jshint.com/docs/options/#expr | ||
'loopfunc', //# http://jshint.com/docs/options/#loopfunc | ||
'multistr', //# http://jshint.com/docs/options/#multistr | ||
'shadow', //# http://jshint.com/docs/options/#shadow | ||
'sub' //# http://jshint.com/docs/options/#sub | ||
]; | ||
//# Warnings / errors for which no relaxing options exist will be filtered away. | ||
//# | ||
errorsToSkip = {}; | ||
@@ -47,0 +55,0 @@ |
@@ -55,3 +55,3 @@ { | ||
}, | ||
"version": "1.0.1" | ||
"version": "1.1.0" | ||
} |
@@ -6,11 +6,17 @@ # Coffee->JSHint | ||
Runs your CoffeeScript source through [JSHint](http://www.jshint.com/) to check for errors. | ||
Runs your [CoffeeScript](http://coffeescript.org/) source through [JSHint](http://jshint.com/) to check for errors. | ||
**NOTE: As of version `1.0.0`, `coffee-jshint` changed its dependencies to be on [`coffeescript`](https://www.npmjs.com/package/coffeescript) in favor of the, now deprecated, [`coffee-script`](https://www.npmjs.com/package/coffee-script) name.** | ||
**NOTE: As of version `1.0.0`, `coffee-jshint` changed its dependencies to be on [`coffeescript`](https://www.npmjs.com/package/coffeescript) in favor of the, | ||
now deprecated, [`coffee-script`](https://www.npmjs.com/package/coffee-script) name.** | ||
## Installation | ||
npm install coffeescript -g // See package.json for supported versions (most) | ||
npm install coffee-jshint -g | ||
```sh | ||
npm install coffeescript -g ## See package.json for supported versions (most) | ||
npm install coffee-jshint -g | ||
``` | ||
## Usage | ||
@@ -20,15 +26,27 @@ | ||
coffee-jshint file1.coffee file2.coffee ... | ||
```sh | ||
coffee-jshint file1.coffee file2.coffee ... | ||
``` | ||
### Options | ||
JSHint takes [a bunch of options](http://www.jshint.com/docs/#options) that tell it various rules to enforce or relax. Some of these don't make much sense to check for JS generated by the CoffeeScript compiler, so by default these options are turned on: | ||
JSHint takes [a bunch of options](http://jshint.com/docs/options/) that tell it various rules to enforce or relax. Some of these don't make much sense to | ||
check for JS generated by the CoffeeScript compiler, so by default these options are turned on: | ||
- **undef:** warns about use of undeclared variables | ||
- **eqnull:** suppresses warnings about `== null`, which CoffeeScript uses in its generated JS | ||
- **expr:** suppresses warnings about expressions in unexpected positions, which can only occur in generated JS when the CoffeeScript compiler does it on purpose | ||
- **shadow:** suppresses warnings about variable shadowing, which is fine since CoffeeScript has sane scoping rules and generates safely scoped JS that uses shadowed variables | ||
- **sub:** suppresses warnings about using bracket object lookup notation (`obj['field']`) when you could use dot notation (`obj.field`) since we're grown ups and can make our own decisions about what lookup syntax is best | ||
- **multistr:** suppresses warnings about multiline strings, since CoffeeScript takes care of them | ||
#### Enforcing options | ||
- **[`undef`](http://jshint.com/docs/options/#undef):** warns about the use of explicitly undeclared variables; | ||
#### Relaxing options | ||
- **[`eqnull`](http://jshint.com/docs/options/#eqnull):** suppresses warnings about `== null` comparisons, which CoffeeScript uses in its generated JS; | ||
- **[`expr`](http://jshint.com/docs/options/#expr):** suppresses warnings about the use of expressions where normally you would expect to see assignments or function calls, which can only occur in the generated JS when the CoffeeScript compiler does it on purpose; | ||
- **[`loopfunc`](http://jshint.com/docs/options/#loopfunc):** suppresses warnings about functions inside of loops, which CoffeeScript produces so often that it becomes too hard to spot the legitimate reports between the false-positives (introduced with version `1.1.0`); | ||
- **[`multistr`](http://jshint.com/docs/options/#multistr):** suppresses warnings about multi-line strings, since CoffeeScript takes care of them; | ||
- **[`shadow`](http://jshint.com/docs/options/#shadow):** suppresses warnings about variable shadowing i.e. declaring a variable that had been already declared somewhere in the outer scope, which is fine since CoffeeScript has sane scoping rules and generates safely scoped JS that uses shadowed variables; | ||
- **[`sub`](http://jshint.com/docs/options/#sub):** suppresses warnings about using `[]` notation when it can be expressed in dot notation since we're grown ups and can make our own decisions about what lookup syntax is best; | ||
To turn on more options, you can use the `--options` or `-o` flag: | ||
@@ -38,2 +56,3 @@ | ||
If you really must turn off some of the default options, use the `--default-options-off` flag (you can always use `--options` to turn some back on): | ||
@@ -43,20 +62,42 @@ | ||
#### About [`esversion`](http://jshint.com/docs/options/#esversion) | ||
Since [the CoffeeScript compiler as of version `2` will produce ES6](http://coffeescript.org/announcing-coffeescript-2/), Coffee->JSHint (as of version | ||
`1.0.1`) detects if your `coffeescript` has a semver version number `>= 2`, in which case the JSHint `esversion: 6` option will be set, and if not | ||
`esversion: 5`. This happens independent of the `--default-options-off` command line flag and currently there's no way to override this behaviour. | ||
### Globals | ||
You'll probably get a lot of complaints from Coffee->JSHint about undefined global variables like `console`, `$`, or `require`. Depending on where you're running your code, you might want to allow a few global variables. One easy way to handle this is to use JSHint's built in [environment options](http://www.jshint.com/docs/#environments). | ||
You'll probably get a lot of complaints from Coffee->JSHint about undefined global variables like `console`, `$`, or `require`. Depending on where you're | ||
running your code, you might want to allow a few global variables. One easy way to handle this is to use JSHint's built in | ||
[environment options](http://jshint.com/docs/options/#environments). | ||
For instance, if you're running your code using Node.js, then you'll want to turn on the `node` option. It works like any other option: | ||
coffee-jshint -o node ... | ||
```sh | ||
coffee-jshint -o node ... | ||
``` | ||
If you have some globals that aren't covered by any of environments, well then you should probably check yo'self before you wreck yo'self. But if you really want to turn off warnings for some global variables, Coffee->JSHint supports it using the `--globals` or `-g` option. One use case is when using [Mocha](http://mochajs.org/), a testing library: | ||
If you have some globals that aren't covered by any of environments, well then you should probably check yo'self before you wreck yo'self. But if you really | ||
want to turn off warnings for some global variables, Coffee->JSHint supports it using the `--globals` or `-g` option. One use case is when using | ||
[Mocha](http://mochajs.org/), a testing library: | ||
coffee-jshint -o node --globals describe,it ... | ||
```sh | ||
coffee-jshint -o node --globals describe,it ... | ||
``` | ||
### Shell scripting | ||
Coffee->JSHint plays nicely with your favorite Unix utilities. If you want to recursively search all the files in a directory, try piping in the results of a `find`. Here's an example that also uses `grep` to filter out files in `node_modules/`: | ||
Coffee->JSHint plays nicely with your favorite Unix utilities. If you want to recursively search all the files in a directory, try piping in the results of a | ||
`find`. Here's an example that also filters away any files under the `node_modules/` tree: | ||
find . -type f -path "*.coffee" | grep -v "node_modules/" | xargs coffee-jshint | ||
```sh | ||
find . -name node_modules -prune -o -type f -name \*.coffee -print0 | xargs -0 coffee-jshint | ||
``` | ||
### Git hook | ||
@@ -76,2 +117,3 @@ | ||
## Contributing | ||
@@ -78,0 +120,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19079
304
127