feat(eslint-factory): add Object.assign suggestion to no-throw-plain-object rule#45299
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
Hey This PR is in early WIP stages with no diff yet. Once the implementation lands, these will be important:
If you would like a hand, you can assign this prompt to your coding agent:
|
…object rule Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
PR Triage (run 29275650494)\n\nCategory: feature | Risk: medium | Score: 58/100 | Action: fast_track\n\nScore: Impact 28/50 + Urgency 15/30 + Quality 15/20\n\nAdds Object.assign suggestion to no-throw-plain-object ESLint rule - addresses 22 production sites. Small change (3 files, +210/-10). DRAFT - undraft when ready.
|
There was a problem hiding this comment.
Pull request overview
Adds an ESLint suggestion (not an auto-fix) to help remediate throw { ... } sites flagged by no-throw-plain-object, and updates rule tests accordingly. The PR also includes unrelated changes to a generated workflow lock file that should be explicitly called out in the PR scope/description.
Changes:
- Add
meta.hasSuggestionsand a suggestion that rewritesthrow { ... }intonew Error(...)/Object.assign(new Error(...), { ... })when safe. - Update rule tests to assert suggestion outputs and add skip-coverage for unsafe object-literal shapes.
- Update
smoke-call-workflow.lock.yml(safe-outputs tool schema + caller permissions/secrets for a reusable workflow call).
Show a summary per file
| File | Description |
|---|---|
| eslint-factory/src/rules/no-throw-plain-object.ts | Adds a suggestion fixer path to rewrite plain-object throws into Error-compatible throws when the object literal is safe to transform. |
| eslint-factory/src/rules/no-throw-plain-object.test.ts | Adds/updates invalid cases to assert the new suggestion outputs and skip behavior. |
| .github/workflows/smoke-call-workflow.lock.yml | Updates generated safe-outputs tool schema and reusable-workflow call wiring (inputs/permissions/secrets). |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/3 changed files
- Comments generated: 3
- Review effort level: Low
| @@ -1102,15 +1107,25 @@ jobs: | |||
| needs: safe_outputs | |||
| if: needs.safe_outputs.outputs.call_workflow_name == 'smoke-workflow-call' | |||
| # Imported from called workflow "smoke-workflow-call" because GitHub requires the caller job to grant permissions requested by reusable workflow jobs. | |||
| # Review the called workflow's frontmatter permissions in ./.github/workflows/smoke-workflow-call.md. | |||
| # Review the called workflow's job-level permissions in ./.github/workflows/smoke-workflow-call.lock.yml. | |||
| permissions: | |||
| actions: read | |||
| contents: read | |||
| pull-requests: read | |||
| issues: write | |||
| pull-requests: write | |||
| uses: ./.github/workflows/smoke-workflow-call.lock.yml | |||
| with: | |||
| aw_context: ${{ fromJSON(needs.safe_outputs.outputs.call_workflow_payload).aw_context }} | |||
| payload: ${{ needs.safe_outputs.outputs.call_workflow_payload }} | |||
| task-description: ${{ fromJSON(needs.safe_outputs.outputs.call_workflow_payload)['task-description'] }} | |||
| secrets: inherit | |||
| secrets: | |||
| COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }} | |||
| GH_AW_GITHUB_MCP_SERVER_TOKEN: ${{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN }} | |||
| GH_AW_GITHUB_TOKEN: ${{ secrets.GH_AW_GITHUB_TOKEN }} | |||
|
Run: https://github.com/github/gh-aw/actions/runs/29286484887
|
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Addressed remaining in-scope feedback in d33042c:
Re-ran local checks ( I also reviewed the referenced workflow run; it completed successfully with no failed jobs. |
|
Run: https://github.com/github/gh-aw/actions/runs/29289965782
|
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Addressed the remaining unresolved review feedback in 520a438 by removing the unrelated Re-ran checks locally after the update: Note: CI on this new head won’t auto-rerun from an agent push; a maintainer will need to re-trigger workflows. |
no-throw-plain-objectcorrectly flagsthrow { ... }but provided no fixer, leaving 22 production sites (JSON-RPC error objects inmcp_server_core.cjsandsafe_outputs_handlers.cjs) with manual remediation only.Changes
no-throw-plain-object.ts— addshasSuggestions: trueand a manual suggestion (not auto-fix) that rewrites plain object throws toError-compatible forms:Suggestion is skipped (report-only) for objects with computed keys, spread elements, methods, or getters/setters to avoid emitting syntactically invalid rewrites.
no-throw-plain-object.test.ts— updates all existing invalid cases withsuggestionsassertions; adds new cases covering: without-message, JSON-RPC{ code, message, data }shape, computed-key skip, spread skip.A suggestion rather than auto-fix is intentional: catch/serialize sites may
JSON.stringifythe thrown value, where the non-enumerableError.messagewould be dropped — a human should confirm the catch side per call site.