Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Errors: Support a filter to control which errors are reported #728

Merged
merged 1 commit into from
Nov 15, 2014

Conversation

mrjoelkemp
Copy link
Member

Fixes #335

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.06%) when pulling 5192449 on mrjoelkemp:error_filter into 101eccb on jscs-dev:master.


// Return false to exclude this error
// Return true to report this error normally
return false;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic behind false was that it was like disallowing the propagation of the error to the reporter.

If enough people think true should throw the current error away, then I'll change it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine and a good description, but perhaps "writing a filter and writing a reporter" belong elsewhere in the docs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good point; the readme is pretty cluttered as is. I'm going to create a wiki page and link to it.

@mikesherov
Copy link
Contributor

@mrjoelkemp, nice work! Need a CLI option too, right?

@mdevils
Copy link
Member

mdevils commented Oct 30, 2014

Nice work! CLI option would be nice.

BTW Let's not merge before #731 please.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.05%) when pulling 55add29 on mrjoelkemp:error_filter into 101eccb on jscs-dev:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.06%) when pulling aa766f8 on mrjoelkemp:error_filter into 101eccb on jscs-dev:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.38%) when pulling 3bb0b72 on mrjoelkemp:error_filter into 52dcc50 on jscs-dev:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) when pulling 4817187 on mrjoelkemp:error_filter into 52dcc50 on jscs-dev:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) when pulling 2908a91 on mrjoelkemp:error_filter into 52dcc50 on jscs-dev:master.

mrjoelkemp pushed a commit to mrjoelkemp/node-jscs that referenced this pull request Nov 9, 2014
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) when pulling 11260f5 on mrjoelkemp:error_filter into 573ef5a on jscs-dev:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) when pulling 7d6dc3d on mrjoelkemp:error_filter into 573ef5a on jscs-dev:master.

typeof config.errorFilter === 'string' || config.errorFilter === null,
'`errorFilter` option requires a string or null value'
);
this._errorFilter = require(config.errorFilter.replace('.js', ''));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will fail for browser-version. You should declare a method like _loadPlugin and override it in NodeConfiguration.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably need to add some smoke tests for browser version, like with phantom, not sure if would need something more besides that

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we should!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created - #757

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mdevils This is a great catch. This implies that an errorFilter is a function in lib/config/configuration and a string in lib/config/node-configuration.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) when pulling 7556fdc on mrjoelkemp:error_filter into 573ef5a on jscs-dev:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) when pulling 3957b9d on mrjoelkemp:error_filter into 573ef5a on jscs-dev:master.

@@ -258,6 +270,10 @@ Configuration.prototype._processConfig = function(config) {
this._esnextEnabled = Boolean(config.esnext);
}

if (config.errorFilter) {
this._loadErrorFilter(config.errorFilter);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mdevils The fact that configuration jumps between its own functions and the overridden functions of node-configuration made this hard to follow and implement. I understand why this has to happen, but do you feel it would be more unclear if we only have lib/config/configuration and use try/catch to determine if we're in the node or browser environment?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we only have lib/config/configuration and use try/catch to determine if we're in the node or browser environment?

I think this will make the code more complext and lead to the future breaks, because you will have to include some external modules with hacks (to disallow browserify include it), put many catches. So currently I think we have simpler solution.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fair. Thanks for the insight.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) when pulling 34172b4 on mrjoelkemp:error_filter into 573ef5a on jscs-dev:master.

@mrjoelkemp
Copy link
Member Author

Ready for re-review: @mdevils and @markelog

@mrjoelkemp
Copy link
Member Author

@mikesherov Please give this a final look over when you have a chance. Just need a thumbs up to merge this. Thanks in advance.

*
* @param {Function} filter
*/
filterErrorList: function(filter) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this function should simply be called filter. errors.filterErrorList is redundant.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) when pulling 2ca671b on mrjoelkemp:error_filter into b54645c on jscs-dev:master.

@mikesherov
Copy link
Contributor

👍 LGTM to land.

@mrjoelkemp mrjoelkemp merged commit 2ca671b into jscs-dev:master Nov 15, 2014
@mrjoelkemp mrjoelkemp deleted the error_filter branch November 15, 2014 21:03
@mrjoelkemp
Copy link
Member Author

Yay! Thanks for reviewing, all.

@mikesherov
Copy link
Contributor

Great work Joel!

On Saturday, November 15, 2014, Joel Kemp notifications@github.com wrote:

Yay! Thanks for reviewing, all.

Reply to this email directly or view it on GitHub
#728 (comment).

Mike Sherov

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide filtering hook for errors so they can be suppressed by plugins
6 participants