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

Disable "no-unsanitize" linter rules #2800

Open
ffoodd opened this issue Jul 3, 2023 · 2 comments
Open

Disable "no-unsanitize" linter rules #2800

ffoodd opened this issue Jul 3, 2023 · 2 comments

Comments

@ffoodd
Copy link

ffoodd commented Jul 3, 2023

Is this a feature request or a bug?

Feature request.

What is the current behavior?

I'd want to be able to disable the no-unsanitized odd linter rules. I searched through this repo, addons-linter's repo, and even eslint-plugin-no-unsanitized's repo… and from what I understand, web-ext doesn't honor addons-linter --disable-linter-rules argument.

I tried as a CLI argument, just like for addons-linter, using --disable-linter-rules=no-unsanitized/property,no-unsanitized/method, and as an eslintConfig entry in my package.json:

"eslintConfig": {
	"plugins": ["no-unsanitized"],
	"rules": {
		"no-unsanitized/method": "off",
		"no-unsanitized/property": "off"
	}
},

None of it worked. I tried mixing that up in webExt package.json entry, both at the global level and lint task level without any luck.

As I'm searching around in web-ext sources, there seems there's no way to use web-ext lint and customize rules. Is there?

This is really a nonsense since I'm only injecting translations (through chrome.i18n() API) and getting warning regarding UNSAFE_VAR_ASSIGNMENT. The Mozilla's eslint plugin recommendations are moot since it mentions the HTML Sanitizer() (not supported in Firefox ATM) and Firefox OS sanitizer.js lib which is archived for two years… Leading us to no descent way to work around those warnings.

I understand the whole topic but since web-ext lint is supposed to be an addons-linter wrapper, why can't we use addons-linter CLI flags in some way? Am I missing something?

What is the expected or desired behavior?

I'd like to be able to disable those linter rules from web-ext configuration.

Version information (for bug reports)

  • 114.0.2:
  • Ubuntu 22.04:
  • Node, npm and web-ext versions:
v19.3.0
9.2.0
7.6.2
@rpl
Copy link
Member

rpl commented Jul 6, 2023

The fact that addons-linter is using eslint internally for some (not all) of the addons-linter rules is an internal implementation detail of the addons-linter and I would really prefer to not expose that kind of internal implementation detail through web-ext cli option.

Having said that, providing a more general option (e.g. one named --only-errors or --no-warnings) that would filter out addons-linter warnings (which are not going to be blocking the submission to AMO) and only print the addons-linter errors (which would instead be blocking a submission to AMO until resolved) sounds like a more than reasonable enhancement (and it would also cover similar needs for rules that are not implemented through an eslint rule).

@rpl
Copy link
Member

rpl commented Jul 6, 2023

In the meantime, the short term workarounds could be:

  • using the addons-linter bin script, to use the options that addons-linter may be already providing
  • or using web-ext lint --output json and postprocess the json output with a small custom npm script.

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

No branches or pull requests

2 participants