Skip to content

Refine require-new-url-try-catch safe-argument detection#46190

Merged
pelikhan merged 5 commits into
mainfrom
copilot/eslint-factory-require-new-url-try-catch-fix
Jul 18, 2026
Merged

Refine require-new-url-try-catch safe-argument detection#46190
pelikhan merged 5 commits into
mainfrom
copilot/eslint-factory-require-new-url-try-catch-fix

Conversation

Copilot AI commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

require-new-url-try-catch was over-classifying some new URL(...) calls as runtime-risky. In particular, it flagged provably constant string concatenations and new URL(import.meta.url), even though both are syntactically safe and non-throwing in the cases covered here.

  • Rule precision

    • teach the rule to treat recursively constant string expressions as static:
      • string literals
      • expression-less template literals
      • + concatenations composed only of the above
    • reuse the existing import.meta.url safe-value exemption for the first argument, not just the base argument
  • Behavioral effect

    • stop reporting false positives such as:
      new URL("https://github.com" + "/owner/repo");
      const u = new URL(import.meta.url);
    • keep reporting genuinely dynamic inputs, including variable-based concatenation:
      const u = new URL(host + "/x");
  • Coverage

    • add valid-case tests for constant concatenation and import.meta.url in first-argument position
    • add an invalid regression test confirming variable concatenation remains in scope

Copilot AI and others added 2 commits July 17, 2026 09:07
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix false positives for non-throwing URL constructor arguments Refine require-new-url-try-catch safe-argument detection Jul 17, 2026
Copilot AI requested a review from pelikhan July 17, 2026 09:20
@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Hey @app/copilot-swe-agent 👋 — great work on refining the require-new-url-try-catch rule! The fix for false positives on constant string concatenations and import.meta.url is well-targeted, and the added test coverage is solid. This PR looks ready for review! 🎉

Generated by ✅ Contribution Check · 74.6 AIC · ⌖ 16.7 AIC · ⊞ 6.2K ·

@pelikhan
pelikhan marked this pull request as ready for review July 17, 2026 11:28
Copilot AI review requested due to automatic review settings July 17, 2026 11:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refines URL lint-rule precision for statically safe arguments.

Changes:

  • Recognizes recursively constant string concatenations.
  • Exempts import.meta.url as the first argument.
  • Adds regression coverage and changes the auto-upgrade schedule.
Show a summary per file
File Description
eslint-factory/src/rules/require-new-url-try-catch.ts Refines static argument detection.
eslint-factory/src/rules/require-new-url-try-catch.test.ts Tests new valid and invalid cases.
.github/workflows/agentic-auto-upgrade.yml Unrelated generated schedule change requiring removal.

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: 1
  • Review effort level: Medium

Comment thread .github/workflows/agentic-auto-upgrade.yml Outdated
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, address unresolved review feedback, investigate any failed checks listed below, refresh the branch if needed, and rerun checks once ready.

Unresolved review threads (newest first):

Generated by pr-sous-chef: https://github.com/github/gh-aw/actions/runs/29590499747

Generated by 👨‍🍳 PR Sous Chef · 8.3 AIC · ⌖ 10.9 AIC · ⊞ 7.5K ·
Comment /souschef to run again

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, address unresolved review feedback, investigate any failed checks listed below, refresh the branch if needed, and rerun checks once ready.

Unresolved revi...

Reverted the incidental cron schedule change in agentic-auto-upgrade.yml — restored it to "21 3 * * 5" (Friday) in commit revert: restore agentic-auto-upgrade.yml cron schedule to Friday. The URL rule refinement changes are unchanged. Local validation passes.

Copilot AI requested a review from gh-aw-bot July 17, 2026 15:29
@pelikhan
pelikhan merged commit 69c911d into main Jul 18, 2026
@pelikhan
pelikhan deleted the copilot/eslint-factory-require-new-url-try-catch-fix branch July 18, 2026 05:29
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.82.13

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

eslint-factory: require-new-url-try-catch — false positives for provably non-throwing new URL(...) arguments

4 participants