Skip to content

refactor(eslint-plugin): concise-method shorthand for rule visitor objects (reconstruct #542 on master) - #757

Draft
kriscendobot wants to merge 2 commits into
master-87823d8from
reconstruct/ebfb-pr542-eslint-visitor-shorthand
Draft

refactor(eslint-plugin): concise-method shorthand for rule visitor objects (reconstruct #542 on master)#757
kriscendobot wants to merge 2 commits into
master-87823d8from
reconstruct/ebfb-pr542-eslint-visitor-shorthand

Conversation

@kriscendobot

Copy link
Copy Markdown
Collaborator

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 upstream
endojs/endo equivalent merged (or closed explicitly), not merged into the fork's
master. Fork master periodically hard-re-mirrors from upstream and silently drops
fork 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/endo or close.

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/endo PR
exists 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-plugin rule visitor objects to concise-method shorthand, and @erights
asked 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-shorthand rule runs with avoidQuotes: true (inherited from
eslint-config-airbnb-base via @endo/style). Quoted AST-selector visitor keys
('Program:exit'(node) { ... }) are exactly the case avoidQuotes exempts, so those
handlers were left as non-shorthand properties in #474.

The change

  1. Scoped relaxation. Adds an overrides entry to
    packages/eslint-plugin/package.json's eslintConfig, scoped to lib/rules/*.js,
    setting object-shorthand: ['error', 'always', { avoidQuotes: false }]. This is a
    targeted relaxation for the rule-file visitor-object idiom, not a global flip.
  2. Applies the shorthand to the now-eligible handler. Running eslint . in the
    package after the relaxation flags exactly one handler: the anonymous
    'Program:exit': function () { ... } in lib/rules/harden-exports.js. It becomes
    'Program:exit'() { ... }, and the func-names disable directive the conversion
    orphaned is removed.

The assert-fail-as-throw.js 'Program:exit' / Program handlers are named
function expressions (restoreAssertFailAsThrow, installAssertFailAsThrow), which
object-shorthand never converts (shorthand would drop the name), so they are correctly
left untouched.

Pure-shorthand conversion: no behavioral change.


Draft: reconstruction surfaced for maintainer triage (ferry upstream or close). Base is
the frozen snapshot master-87823d8.

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.
@kriscendobot

Copy link
Copy Markdown
Collaborator Author

Shepherd update

Head SHA: 142dd0e760c72374b77479d5c59647543d8625d1

  • 142dd0e760 (chore(ci): refresh setup-node v6 pin) updates the pinned actions/setup-node v6 commit across the workflows, resolving the persistent zizmor version-comment findings.
  • The initial matrix-wide setup-node failures were transient GitHub action-manifest resolution failures; a rerun passed once service resolution recovered. No product-code change was needed.

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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant