coffee-jshint
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -5,2 +5,12 @@ # Change Log | ||
<a name="1.0.1"></a> | ||
## [1.0.1](https://github.com/marviq/coffee-jshint/compare/v1.0.0...v1.0.1) (2017-10-24) | ||
### Bug Fixes | ||
* set correct `jshint` `esversion` depending on coffeescript's version ([dbb4eae](https://github.com/marviq/coffee-jshint/commit/dbb4eae)) | ||
<a name="1.0.0"></a> | ||
@@ -7,0 +17,0 @@ # [1.0.0](https://github.com/marviq/coffee-jshint/compare/v0.2.7...v1.0.0) (2017-10-03) |
19
cli.js
@@ -5,7 +5,7 @@ #!/usr/bin/env node | ||
_ = require("underscore"); | ||
_ = require('underscore'); | ||
hintFiles = require("./lib-js/hint"); | ||
hintFiles = require('./lib-js/hint'); | ||
({argv, help} = require("optimist").usage('$0 [options] filename.coffee ...').options({ | ||
({argv, help} = require('optimist').usage('$0 [options] filename.coffee ...').options({ | ||
options: { | ||
@@ -41,3 +41,3 @@ alias: 'o', | ||
case !argv.version: | ||
console.log(require("./package.json").version); | ||
console.log(require('./package.json').version); | ||
break; | ||
@@ -52,12 +52,13 @@ case !argv.help: | ||
}; | ||
// Filter out non-coffee paths | ||
({coffee, other} = _(argv._).groupBy(function(path) { | ||
//# Filter out non-coffee paths. | ||
//# | ||
({coffee, other} = _.groupBy(argv._, function(path) { | ||
if (/.+\.coffee$/.test(path)) { | ||
return "coffee"; | ||
return 'coffee'; | ||
} else { | ||
return "other"; | ||
return 'other'; | ||
} | ||
})); | ||
if (argv.verbose && (other != null ? other.length : void 0) > 0) { | ||
console.log("Skipping files that don't end in .coffee:\n" + other.join('\n')); | ||
console.log(`Skipping files that don't end in .coffee:\n${other.join('\n')}`); | ||
} | ||
@@ -64,0 +65,0 @@ errors = hintFiles(coffee, { |
// Generated by CoffeeScript 2.0.1 | ||
var _, argv, coffee, errors, help, hintFiles, other, splitArgs; | ||
_ = require("underscore"); | ||
_ = require('underscore'); | ||
hintFiles = require("./lib-js/hint"); | ||
hintFiles = require('./lib-js/hint'); | ||
({argv, help} = require("optimist").usage('$0 [options] filename.coffee ...').options({ | ||
({argv, help} = require('optimist').usage('$0 [options] filename.coffee ...').options({ | ||
options: { | ||
@@ -39,3 +39,3 @@ alias: 'o', | ||
case !argv.version: | ||
console.log(require("./package.json").version); | ||
console.log(require('./package.json').version); | ||
break; | ||
@@ -50,12 +50,13 @@ case !argv.help: | ||
}; | ||
// Filter out non-coffee paths | ||
({coffee, other} = _(argv._).groupBy(function(path) { | ||
//# Filter out non-coffee paths. | ||
//# | ||
({coffee, other} = _.groupBy(argv._, function(path) { | ||
if (/.+\.coffee$/.test(path)) { | ||
return "coffee"; | ||
return 'coffee'; | ||
} else { | ||
return "other"; | ||
return 'other'; | ||
} | ||
})); | ||
if (argv.verbose && (other != null ? other.length : void 0) > 0) { | ||
console.log("Skipping files that don't end in .coffee:\n" + other.join('\n')); | ||
console.log(`Skipping files that don't end in .coffee:\n${other.join('\n')}`); | ||
} | ||
@@ -62,0 +63,0 @@ errors = hintFiles(coffee, { |
// Generated by CoffeeScript 2.0.1 | ||
var CoffeeScript, _, buildTrueObj, defaultOptions, errorsToSkip, formatErrors, fs, hint, hintFiles, jshint; | ||
var CoffeeScript, _, buildTrueObj, csVersion, defaultOptions, error, errorsToSkip, formatErrors, fs, hint, hintFiles, j, jshint, len, ref, semver, supplant, supplantRe; | ||
CoffeeScript = require('coffeescript'); | ||
csVersion = require('coffeescript/package.json').version; | ||
fs = require('fs'); | ||
CoffeeScript = require('coffeescript'); | ||
jshint = require('jshint').JSHINT; | ||
semver = require('semver'); | ||
_ = require('underscore'); | ||
jshint = require('jshint').JSHINT; | ||
//# Adapted from https://github.com/jshint/jshint/blob/1553e3af6d2453eb52507a2c97971094897794d3/src/jshint.js#L158 | ||
//# | ||
supplantRe = /\{([^{}]*)\}/g; | ||
supplant = function(str, args) { | ||
return str.replace(supplantRe, function(matched, argName) { | ||
var argValue; | ||
argValue = args[argName]; | ||
switch (typeof argValue) { | ||
case 'number': | ||
case 'string': | ||
return argValue; | ||
default: | ||
return matched; | ||
} | ||
}); | ||
}; | ||
defaultOptions = [ | ||
'undef', | ||
// options to relax for cs | ||
//# options to relax for cs | ||
//# | ||
'eqnull', | ||
@@ -22,15 +45,66 @@ 'expr', | ||
errorsToSkip = [ | ||
"Did you mean to return a conditional instead of an assignment?", | ||
"Confusing use of '!'.", | ||
"Wrap the /regexp/ literal in parens to disambiguate the slash operator.", | ||
"Creating global 'for' variable. Should be 'for (var", | ||
"Missing '()' invoking a constructor.", // covered by coffeelint rule non_empty_constructor_needs_parens | ||
"Bad number '2e308'." | ||
errorsToSkip = {}; | ||
ref = [ | ||
{ | ||
code: 'W018', | ||
args: { | ||
a: '!' | ||
} | ||
}, | ||
{ | ||
code: 'W032' | ||
}, | ||
{ | ||
code: 'W045', | ||
args: { | ||
a: '2e308' | ||
} | ||
}, | ||
{ | ||
code: 'W058' | ||
}, | ||
{ | ||
code: 'W088', | ||
args: void 0 | ||
}, | ||
{ | ||
code: 'W092' | ||
}, | ||
{ | ||
code: 'W093' | ||
} | ||
]; | ||
//# > Confusing use of '{a}'. | ||
//# | ||
//# > Unnecessary semicolon. | ||
//# | ||
//# > Bad number '{a}'. | ||
//# | ||
//# > Missing '()' invoking a constructor. | ||
//# | ||
//# Note: covered by coffeelint rule non_empty_constructor_needs_parens | ||
//# | ||
//# > Creating global 'for' variable. Should be 'for (var {a} ...'. | ||
//# | ||
//# because it don't matter what `{a}` is. | ||
//# > Wrap the /regexp/ literal in parens to disambiguate the slash operator. | ||
//# | ||
//# Note: removed from jshint as of version `2.4.1`. | ||
//# | ||
//# > Did you mean to return a conditional instead of an assignment? | ||
//# | ||
for (j = 0, len = ref.length; j < len; j++) { | ||
error = ref[j]; | ||
errorsToSkip[error.code] = error; | ||
} | ||
// If log is true, prints out results after processing each file | ||
//# If log is true, prints out results after processing each file. | ||
//# | ||
hintFiles = function(paths, config, log) { | ||
var options; | ||
options = buildTrueObj(config.withDefaults ? _.union(config.options, defaultOptions) : config.options); | ||
//# Ensure a matching `esversion` is set, depending on whether this is `coffeescript@<2`. | ||
//# | ||
options.esversion = semver.satisfies(csVersion, '<2') ? 5 : 6; | ||
return _.map(paths, function(path) { | ||
@@ -49,3 +123,3 @@ var err, errors, source; | ||
if (log && errors.length > 0) { | ||
console.log("--------------------------------"); | ||
console.log('--------------------------------'); | ||
console.log(formatErrors(path, errors)); | ||
@@ -61,33 +135,29 @@ } | ||
sourceMap: true, | ||
filename: "doesn't matter" | ||
filename: 'doesn\'t matter' | ||
}; | ||
({js, v3SourceMap, sourceMap} = CoffeeScript.compile(coffeeSource.toString(), csOptions)); | ||
if (jshint(js, options, globals)) { | ||
return []; | ||
} else if (jshint.errors == null) { | ||
console.log("jshint didn't pass but returned no errors"); | ||
return []; | ||
} else { | ||
// Last jshint.errors item could be null if it bailed because too many errors | ||
// Convert errors to use coffee source locations instead of js locations | ||
return _.chain(jshint.errors).compact().map(function(error) { | ||
var col, line; | ||
try { | ||
[line, col] = sourceMap.sourceLocation([error.line - 1, error.character - 1]); | ||
} catch (error1) {} | ||
return _.extend(error, { | ||
line: line != null ? line + 1 : '?', | ||
character: col != null ? col + 1 : '?' | ||
}); | ||
// Get rid of errors that don't apply to coffee very well | ||
}).filter(function(error) { | ||
return !_.any(errorsToSkip, function(to_skip) { | ||
return error.reason.indexOf(to_skip) >= 0; | ||
}); | ||
}).value(); | ||
} | ||
//# Last jshint.errors item could be null if it bailed because too many errors | ||
//# | ||
//# Get rid of errors that don't apply to coffee very well | ||
//# | ||
return ((jshint(js, options, globals)) ? [] : jshint.errors == null ? (console.log('jshint didn\'t pass but returned no errors'), []) : _.compact(jshint.errors).filter(function(error) { | ||
var skip; | ||
skip = errorsToSkip[error.code]; | ||
return !skip || (skip.args && (supplant(error.raw, skip.args) !== error.reason)); | ||
//# Convert errors to use coffee source locations instead of js locations | ||
//# | ||
}).map(function(error) { | ||
var col, line; | ||
try { | ||
[line, col] = sourceMap.sourceLocation([error.line - 1, error.character - 1]); | ||
} catch (error1) {} | ||
return _.extend(error, { | ||
line: line != null ? line + 1 : '?', | ||
character: col != null ? col + 1 : '?' | ||
}); | ||
})); | ||
}; | ||
formatErrors = function(path, errors) { | ||
return `${path}\n` + _(errors).map(function(error) { | ||
return `${path}\n` + errors.map(function(error) { | ||
return `${error.line}:${error.character}: ${error.reason}`; | ||
@@ -100,5 +170,5 @@ }).join('\n'); | ||
return _.object(keys, (function() { | ||
var j, ref, results; | ||
var k, ref1, results; | ||
results = []; | ||
for (i = j = 0, ref = keys.length; 0 <= ref ? j <= ref : j >= ref; i = 0 <= ref ? ++j : --j) { | ||
for (i = k = 0, ref1 = keys.length; 0 <= ref1 ? k <= ref1 : k >= ref1; i = 0 <= ref1 ? ++k : --k) { | ||
results.push(true); | ||
@@ -105,0 +175,0 @@ } |
@@ -11,2 +11,3 @@ { | ||
"optimist": "~0.6.1", | ||
"semver": "^5.4.1", | ||
"underscore": "~1.8.3" | ||
@@ -55,3 +56,3 @@ }, | ||
}, | ||
"version": "1.0.0" | ||
"version": "1.0.1" | ||
} |
# Coffee->JSHint | ||
[![npm version](https://badge.fury.io/js/coffee-jshint.svg)](http://badge.fury.io/js/coffee-jshint) | ||
[![npm version](https://badge.fury.io/js/coffee-jshint.svg)](https://badge.fury.io/js/coffee-jshint) | ||
[![David dependency drift detection](https://david-dm.org/marviq/coffee-jshint.svg)](https://david-dm.org/marviq/coffee-jshint) | ||
@@ -74,96 +74,7 @@ | ||
### Prerequisites | ||
See [CONTRIBUTING](./CONTRIBUTING.md). | ||
* [npm and node](https://nodejs.org/en/download/) | ||
* [jq](https://stedolan.github.io/jq/download/) | ||
* Some form of [make](https://en.wikipedia.org/wiki/Make_%28software%29) | ||
## Change Log | ||
### Setup | ||
Clone this repository somewhere, switch to it, then: | ||
```bash | ||
$ git config commit.template ./.gitmessage | ||
$ npm install | ||
``` | ||
This will: | ||
* Set up [a helpful reminder](.gitmessage) of how to make [a good commit message](#commit-message-format-discipline). If you adhere to this, then a | ||
detailed, meaningful [CHANGELOG](./CHANGELOG.md) can be constructed automatically; | ||
* Install all required dependencies; | ||
* The latter command will also invoke `make` (no args) for you, creating a build. | ||
### Build | ||
```bash | ||
make | ||
``` | ||
### Commit | ||
#### Commit Message Format Discipline | ||
This project uses [`conventional-changelog/standard-version`](https://github.com/conventional-changelog/standard-version) for automatic versioning and | ||
[CHANGELOG](./CHANGELOG.md) management. | ||
To make this work, *please* ensure that your commit messages adhere to the | ||
[Commit Message Format](https://github.com/bcoe/conventional-changelog-standard/blob/master/convention.md#commit-message-format). Setting your `git config` to | ||
have the `commit.template` as referenced below will help you with [a detailed reminder](.gitmessage) of how to do this on every `git commit`. | ||
```bash | ||
$ git config commit.template ./.gitmessage | ||
``` | ||
### Release | ||
* Determine what your next [semver](https://docs.npmjs.com/getting-started/semantic-versioning#semver-for-publishers) `<version>` should be: | ||
```bash | ||
$ version="<version>" | ||
``` | ||
* Bump the package's `.version`, update the [CHANGELOG](./CHANGELOG.md), commit these, and tag the commit as `v<version>`: | ||
```bash | ||
$ npm run release | ||
``` | ||
* If all is well this new `version` **should** be identical to your intended `<version>`: | ||
```bash | ||
$ jq ".version == \"${version}\"" package.json | ||
``` | ||
*If this is not the case*, then either your assumptions about what changed are wrong, or (at least) one of your commits did not adhere to the | ||
[Commit Message Format Discipline](#commit-message-format-discipline); **Abort the release, and sort it out first.** | ||
### Publish | ||
#### To NPM | ||
```bash | ||
$ npm publish | ||
``` | ||
#### On GitHub | ||
```bash | ||
git push --follow-tags --all | ||
``` | ||
* Go to [https://github.com/marviq/coffee-jshint/releases](https://github.com/marviq/coffee-jshint/releases); | ||
* Click the `Draft a new release` button; | ||
* Select the appropriate `v<version>` tag from the dropdown menu; | ||
* You could enter a title and some release notes here but most of it _should_ have already been covered in the [CHANGELOG](./CHANGELOG.md). | ||
* Click the `Publish release` button; | ||
## ChangeLog | ||
See [CHANGELOG](./CHANGELOG.md). | ||
@@ -170,0 +81,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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
297
0
16884
5
85
+ Addedsemver@^5.4.1
+ Addedsemver@5.7.2(transitive)