Skip to content

Commit

Permalink
Annotate when exceptions are caught but ignored; closes #3354 (#3356)
Browse files Browse the repository at this point in the history
* style(*various*): Annotate when exceptions are caught but ignored

There's an existing convertion to name intentionally ignored errors in catch block as `ignore`.
Modified codebase to follow it.

Fixes #3354

* style(bin/options.js): Turn off prettier for single line

Prettier reformatting is just wrong here. fs.readFileSync() should **not** be split across multiple
lines.

* Revert "style(bin/options.js): Turn off prettier for single line"

This reverts commit eb034dd.

* style(bin/options.js): Revert un-Prettier comment per Boneskull's request
  • Loading branch information
plroebuck authored and boneskull committed May 4, 2018
1 parent 1606f35 commit 4547268
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
12 changes: 12 additions & 0 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"linters": {
"(bin/*|**/*.js)": [
"prettier-eslint --write",
"git add"
]
},
"ignore": [
"docs/**/*.js",
"test/**/*.fixture.js"
]
}
4 changes: 2 additions & 2 deletions bin/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ function getOptions() {
process.argv = process.argv
.slice(0, 2)
.concat(opts.concat(process.argv.slice(2)));
} catch (err) {
// ignore
} catch (ignore) {
// NOTE: should console.error() and throw the error
}

process.env.LOADED_MOCHA_OPTS = true;
Expand Down
2 changes: 1 addition & 1 deletion lib/browser/progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Progress.prototype.draw = function(ctx) {
var w = ctx.measureText(text).width;

ctx.fillText(text, x - w / 2 + 1, y + fontSize / 2 - 1);
} catch (err) {
} catch (ignore) {
// don't fail if we can't render progress
}
return this;
Expand Down
2 changes: 1 addition & 1 deletion lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ Runner.prototype.fail = function(test, err) {
try {
err.stack =
this.fullStackTrace || !err.stack ? err.stack : stackFilter(err.stack);
} catch (ignored) {
} catch (ignore) {
// some environments do not take kindly to monkeying with the stack
}

Expand Down
9 changes: 2 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,8 @@
"scripts": {
"prepublishOnly": "nps test clean build",
"start": "nps",
"test": "nps test"
"test": "nps test",
"precommit": "lint-staged"
},
"dependencies": {
"browser-stdout": "1.3.1",
Expand Down Expand Up @@ -527,12 +528,6 @@
},
"homepage": "https://mochajs.org",
"logo": "https://cldup.com/S9uQ-cOLYz.svg",
"lint-staged": {
"*.js": [
"prettier-eslint --write",
"git add"
]
},
"prettier": {
"singleQuote": true,
"bracketSpacing": false
Expand Down

0 comments on commit 4547268

Please sign in to comment.