refactor(eslint-plugin): concise-method shorthand for rule visitor objects (reconstruct #542 on master) - #757
Draft
kriscendobot wants to merge 2 commits into
Draft
Conversation
Relax object-shorthand's avoidQuotes for the rule files under lib/rules/*.js so quoted AST-selector visitor keys become eligible for concise-method shorthand, then convert the now-eligible handler. Only harden-exports.js's anonymous 'Program:exit' handler qualifies; the assert-fail-as-throw.js handlers are named function expressions that object-shorthand never converts (shorthand would drop the name). Also removes the func-names disable directive that the conversion made orphaned.
Collaborator
Author
|
Shepherd update Head SHA:
Verification: all checks are green on the head SHA, including CI, Workflow security audit, and mutual-dependency build. CI: https://github.com/endojs/endo-but-for-bots/actions/runs/29543258286 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Provenance (why this PR exists)
Reconstructs #542, which was errantly merged to
master--a
master-based (upstream-destined) change should have been closed once its upstreamendojs/endoequivalent merged (or closed explicitly), not merged into the fork'smaster. Forkmasterperiodically hard-re-mirrors from upstream and silently dropsfork merge-commits, so this change is on borrowed time and invisible upstream. Reopened
here (as a fresh PR, since GitHub cannot reopen a merged PR) to surface it for maintainer
attention -- to ferry upstream to
endojs/endoor close.1bb6e7fc22(mergedf87f2cc928intomaster)f87f2cc928onto a frozen snapshot ofmastertaken at87823d83d1(the original merge's first parent -- the state after refactor: retire function-keyword in favor of arrow/method syntax per erights review #474, before refactor(eslint-plugin): concise-method shorthand for rule visitor objects #542),so the diff shown here is exactly the original change. The reconstructed diff was
verified byte-identical to
git diff 87823d83d1 f87f2cc928.Relationship to #474 (bundle the ferry if desired)
This is a follow-up to #474 (retire-function-keyword), whose
upstream form is endojs/endo#3312 / endojs/endo#3318. No upstream
endojs/endoPRexists for this shorthand follow-up yet. If the maintainer ferries #474's upstream
equivalent, this change (concise-method shorthand for the rule-file visitor objects) is
a natural companion to bundle alongside it.
What this does (original #542 description)
Follow-up to #474. On #474, @kriscendobot offered to convert the
@endo/eslint-pluginrule visitor objects to concise-method shorthand, and @erightsasked for it in a follow-up PR ("Please do so in a follow-up PR"). This is that follow-up.
Why #474 could not do it
The
object-shorthandrule runs withavoidQuotes: true(inherited fromeslint-config-airbnb-basevia@endo/style). Quoted AST-selector visitor keys(
'Program:exit'(node) { ... }) are exactly the caseavoidQuotesexempts, so thosehandlers were left as non-shorthand properties in #474.
The change
overridesentry topackages/eslint-plugin/package.json'seslintConfig, scoped tolib/rules/*.js,setting
object-shorthand: ['error', 'always', { avoidQuotes: false }]. This is atargeted relaxation for the rule-file visitor-object idiom, not a global flip.
eslint .in thepackage after the relaxation flags exactly one handler: the anonymous
'Program:exit': function () { ... }inlib/rules/harden-exports.js. It becomes'Program:exit'() { ... }, and thefunc-namesdisable directive the conversionorphaned is removed.
The
assert-fail-as-throw.js'Program:exit'/Programhandlers are namedfunction expressions (
restoreAssertFailAsThrow,installAssertFailAsThrow), whichobject-shorthandnever converts (shorthand would drop the name), so they are correctlyleft untouched.
Pure-shorthand conversion: no behavioral change.
Draft: reconstruction surfaced for maintainer triage (ferry upstream or close). Base is
the frozen snapshot
master-87823d8.