Closed Bug 1280883 Opened 9 years ago Closed 8 years ago

ESLint shows unreachable statement for xbl fields

Categories

(Developer Infrastructure :: Lint and Formatting, defect)

3 Branch
defect
Not set
normal

Tracking

(firefox50 fixed, firefox52 fixed)

RESOLVED FIXED
mozilla50
Tracking Status
firefox50 --- fixed
firefox52 --- fixed

People

(Reporter: Fallen, Assigned: Fallen)

References

Details

Attachments

(2 files, 1 obsolete file)

If you use the following in xbl: <field name="mArray">[]</field> The preprocessor generates this: get mArray() { return [] }, Which causes an error for an unreachable statement. I proposed changing the generated js to: get mAlarm() { return ( [] ); },
Attached patch Fix - v1 (obsolete) — Splinter Review
Attachment #8763507 - Flags: review?(ahalberstadt)
Blocks: 1280898
Comment on attachment 8763507 [details] [diff] [review] Fix - v1 Review of attachment 8763507 [details] [diff] [review]: ----------------------------------------------------------------- I'm not qualified to review this. I'd suggest either :Mossop or :miker, though both appear to be on PTO atm unfortunately.
Attachment #8763507 - Flags: review?(ahalberstadt)
Comment on attachment 8763507 [details] [diff] [review] Fix - v1 Review of attachment 8763507 [details] [diff] [review]: ----------------------------------------------------------------- Thanks for the note, I assumed so from your name appearing in hg log, but I guess you also just submitted a patch :) Deferring to :miker for when he is back.
Attachment #8763507 - Flags: review?(mratcliffe)
Attachment #8763507 - Flags: review?(mratcliffe) → review+
Patch with updated commit message for checkin.
Attachment #8763507 - Attachment is obsolete: true
Attachment #8765402 - Flags: review+
Pushed by cbook@mozilla.com: https://hg.mozilla.org/integration/fx-team/rev/b82022d2347a ESLint shows unreachable statement for xbl fields. r=miker
Keywords: checkin-needed
IIRC you'll also need to: 1. Bump the version number[1] of the ESLint plugin 2. Update the version the mach command checks for to match (so local users know to update) 3. Update the ESLint archive in tooltool using the update script[3] so automation uses the new code [1]: https://dxr.mozilla.org/mozilla-central/source/tools/lint/eslint/eslint-plugin-mozilla/package.json [2]: https://dxr.mozilla.org/mozilla-central/source/tools/lint/mach_commands.py#36 [3]: https://dxr.mozilla.org/mozilla-central/source/tools/lint/eslint/update
Thanks for the note! I'll take care of that once I have all calendar rules enabled, in case I find more issues.
Flags: needinfo?(philipp)
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla50
Unfortunately, this change appears to cause errors of its own: TEST-UNEXPECTED-ERROR | browser/base/content/socialchat.xml:98:23 | Parsing error: Unexpected token ; (null) TEST-UNEXPECTED-ERROR | browser/base/content/tabbrowser.xml:43:66 | Parsing error: Unexpected token ; (null) TEST-UNEXPECTED-ERROR | browser/base/content/urlbarBindings.xml:57:93 | Parsing error: Unexpected token ; (null) I guess we didn't realize until now since it was never packaged for automation. I believe we should now require the steps I mentioned in comment 6 as part of any change to the Mozilla plugin to avoid this. A commit hook for Mozilla plugin changes would also help. Backout: https://hg.mozilla.org/integration/mozilla-inbound/rev/bd4fd5d4436f
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Ah I see, sorry about that. All usages in comm-central/calendar actually omit the final ; so I didn't notice. I will run it against m-c next time. I think it would be impractical to bump the version on each patch, but on the other hand since changes to this preprocessor are not so often it may be ok. Now to fix it correctly, I guess it depends on what we expect the right syntax to be. 1) Accept both with and without semicolon (just strip it in the preprocessor) 2) Force use of semicolon (by adding it to the end of the return statement if it is there, and then relying on the semi rule) 3) Force omitting semicolon (by keeping the patch as is?) As I have noticed, if a lot of rules are enabled there are inevitably conflicts (indent being the worst). Adding () as this patch did also triggers other rules (I believe it was no-extra-parens). I have another patch pending that adds eslint-disable-line to each generated line so that most issues are not a problem. Therefore I would like to avoid any tricks that are too smart, because there is bound to be a rule that breaks it. I would prefer either (1) or alternatively (3). I think fields look better without semicolon. What do you think? Here a few examples from code to help the thought process: <field name="_remote">false</field> <field name="closingTabsEnum" readonly="true">({ ALL: 0, OTHER: 1, TO_END: 2 });</field> <field name="mTabBox" readonly="true"> document.getAnonymousElementByAttribute(this, "anonid", "tabbox"); </field>
Flags: needinfo?(philipp)
Flags: needinfo?(mratcliffe)
Flags: needinfo?(jryans)
I think 1 is best so stripping it in the preprocessor makes sense.
Flags: needinfo?(mratcliffe)
(In reply to Philipp Kewisch [:Fallen] from comment #10) > Ah I see, sorry about that. All usages in comm-central/calendar actually > omit the final ; so I didn't notice. I will run it against m-c next time. I > think it would be impractical to bump the version on each patch, but on the > other hand since changes to this preprocessor are not so often it may be ok. Unfortunately for the moment I think we need to bump the version on any changes to the ESLint plugin and go through the automation steps because otherwise we don't know if they actually work everywhere and local users (other than yourself as the patch author) won't be updated to the changes either. Hopefully the process can be improved, but that's what we have for the moment. > 1) Accept both with and without semicolon (just strip it in the preprocessor) > 2) Force use of semicolon (by adding it to the end of the return statement > if it is there, and then relying on the semi rule) > 3) Force omitting semicolon (by keeping the patch as is?) I don't have a strong opinion about the change here as long as it works. :)
Flags: needinfo?(jryans)
Depends on: 1231509
No longer depends on: 1231509
Depends on: 1231509
Attachment #8765402 - Attachment description: Fix - v2 → [backed out] Fix - v2
Comment on attachment 8799620 [details] Bug 1280883 - Avoid effects of ASI when preprocessing XBL for eslint. https://reviewboard.mozilla.org/r/84758/#review85482
Comment on attachment 8799620 [details] Bug 1280883 - Avoid effects of ASI when preprocessing XBL for eslint. https://reviewboard.mozilla.org/r/84758/#review85484
Attachment #8799620 - Flags: review?(mratcliffe) → review+
Comment on attachment 8799620 [details] Bug 1280883 - Avoid effects of ASI when preprocessing XBL for eslint. https://reviewboard.mozilla.org/r/84758/#review85486
Pushed by mozilla@kewis.ch: https://hg.mozilla.org/integration/autoland/rev/4e5a650aca25 Avoid effects of ASI when preprocessing XBL for eslint. r=miker
Status: REOPENED → RESOLVED
Closed: 9 years ago8 years ago
Resolution: --- → FIXED
Product: Testing → Firefox Build System
Version: Version 3 → 3 Branch
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: