web-ext icon indicating copy to clipboard operation
web-ext copied to clipboard

Disable "no-unsanitize" linter rules

Open ffoodd opened this issue 2 years ago • 2 comments

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

ffoodd avatar Jul 03 '23 13:07 ffoodd

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 avatar Jul 06 '23 19:07 rpl

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.

rpl avatar Jul 06 '23 20:07 rpl