Closed Bug 1739708 Opened 3 years ago Closed 3 years ago

ES Lint rules for SJS files incorrectly emit warnings on importation of the URLSearchParams method.

Categories

(Developer Infrastructure :: Lint and Formatting, defect)

defect

Tracking

(firefox-esr91 unaffected, firefox94 unaffected, firefox95 wontfix, firefox96 fixed)

RESOLVED FIXED
96 Branch
Tracking Status
firefox-esr91 --- unaffected
firefox94 --- unaffected
firefox95 --- wontfix
firefox96 --- fixed

People

(Reporter: bigiri, Assigned: standard8)

References

(Regression)

Details

(Keywords: regression)

Attachments

(1 file)

Many *.sjs files use Components.utils.importGlobalProperties(["URLSearchParams"]); to import the URLSearchParams method. Unfortunately, the ES Lint rules trigger a warning for this common use case.

The ES Lint warning for this is warning Use Cu rather than Components.utils mozilla/use-cc-etc (eslint) If the suggestion replace Components.utls with Cu is followed then the following warning show up instead Unnecessary call to Cu.importGlobalProperties (webidl names are automatically imported)

Unfortunately, that import is necessary to use URLSearchParams in an *.sjs file.

ES Lint rules should be modified to allow the import of URLSearchParams and anything else that may be necessary in *.sjs files without emitting warnings.

These warning are emitted here:

The Bugbug bot thinks this bug is a defect, but please change it back in case of error.

Type: task → defect

(In reply to Bernard Igiri from comment #0)

Many *.sjs files use Components.utils.importGlobalProperties(["URLSearchParams"]); to import the URLSearchParams method. Unfortunately, the ES Lint rules trigger a warning for this common use case.

The ES Lint warning for this is warning Use Cu rather than Components.utils mozilla/use-cc-etc (eslint).

To be clear, this warning is correct. It's purely stylistic, Components.utils is the same as Cu, but the latter is shorter and easier to read.

If the suggestion replace Components.utils with Cu is followed then the following warning show up instead Unnecessary call to Cu.importGlobalProperties (webidl names are automatically imported)

Unfortunately, that import is necessary to use URLSearchParams in an *.sjs file.

This seems to mean that we should drop this rule from the .sjs file list. Mark, does that seem right?

Flags: needinfo?(standard8)

(In reply to :Gijs (he/him) from comment #2)

(In reply to Bernard Igiri from comment #0)

Many *.sjs files use Components.utils.importGlobalProperties(["URLSearchParams"]); to import the URLSearchParams method. Unfortunately, the ES Lint rules trigger a warning for this common use case.

The ES Lint warning for this is warning Use Cu rather than Components.utils mozilla/use-cc-etc (eslint).

To be clear, this warning is correct. It's purely stylistic, Components.utils is the same as Cu, but the latter is shorter and easier to read.

In production code, Cu is slightly better performance than Components.utils as it avoids the dot. Keeping the same style everywhere is what we should do though.

If the suggestion replace Components.utils with Cu is followed then the following warning show up instead Unnecessary call to Cu.importGlobalProperties (webidl names are automatically imported)

Unfortunately, that import is necessary to use URLSearchParams in an *.sjs file.

This seems to mean that we should drop this rule from the .sjs file list. Mark, does that seem right?

I checked with Nika today about possible solutions. Whilst we will at some stage need to fix it for bug 1501127 and friends, there isn't a quick and easy solution for sjs files which use a custom sandbox.

Therefore, for now at least, we'll disable the rule on sjs files.

Assignee: nobody → standard8
Flags: needinfo?(standard8)

sjs files have a separate sandbox, and require Cu.importGlobalProperties for now.

Pushed by mbanner@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/3cc7d8e26398 Turn off ESLint rule mozilla/reject-importGlobalProperties for sjs files. r=Gijs,webdriver-reviewers,whimboo

Set release status flags based on info from the regressing bug 1576768

Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 96 Branch
Has Regression Range: --- → yes
Product: Firefox Build System → Developer Infrastructure
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: