Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add options for ignoring specific lints #68

Merged
merged 6 commits into from
Jun 27, 2023

Conversation

MoralCode
Copy link
Contributor

@MoralCode MoralCode commented Jun 26, 2023

fixes #67

This adds two new flags in the constructor as documented (hopefully in a way that makes sense - may need rewording) in the README.

Features:

  • this allows specific linter errors to be ignored by passing in an object containing some of the key properties that can identify an error (currently implemented: code, message, file). If all of the provided values match an error from the linter, that error is filtered out before deciding whether the program should raise an error or not.
  • includes a shortcut (ignoreKnownChromeLintFailures) that ignore lint failures that are raised due to differences between firefox and chrome manifest formats (see Manifest Version 3 background.Service_Worker is currently disabled mozilla/web-ext#2532 for an example). This is not a mechanism that fullly supports validating chrome extensions, but it is a way to prevent this linter from failing when given a valid chrome extension
  • plays nice with the existing lintWarningsAsErrors, allowing warnings to be filtered as well if this option is true

Testing:
Tested using the build scripts of a web extension I've been working on recently that uses this plugin. Output in most scenarios (such as with and without lintWarningsAsErrors, valid filters, invalid filters, and handling of junk data) seems to match what would reasonably be expected.

as an example:

filterLintFailures: [{
	code: "MANIFEST_FIELD_UNSUPPORTED",
	message: '"/background" is in an unsupported format.'
},
{
	code: "MANIFEST_FIELD_PPORTED",
	message: '"/background" is in an unsupported format.'
},{
	totally:"fake",
	data:"here"
}],

This sample data successfully filters the error indicated by the first rule, and essentially ignores the other two. This set of filters is (currently) the same as what ignoreKnownChromeLintFailures would add automatically.

Changes to be made:

  • Bump version number (maybe? not sure what it should be set to)
  • Automated testing would probably be a good idea to add given the number of combinations/branches of behavior involved here*

* I would do this, but I'm skeptical that the way I set up junit in a project recently may cause other things to break. maybe vitest as mentioned in the linked issue works differently?

@birtles
Copy link
Collaborator

birtles commented Jun 27, 2023

This is spot on. Great job. Thank you!

@birtles birtles merged commit d471284 into hiikezoe:master Jun 27, 2023
@birtles
Copy link
Collaborator

birtles commented Jun 27, 2023

I've published this now as v2.8.0. Please let me know if it works for you. Thanks again!

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

Successfully merging this pull request may close these issues.

Add an option to disable or ignore specific linter errors when validating chrome extensions
2 participants