Skip to content

Add ESLint rule to enforce "pull request" over "PR" in user-facing strings#7693

Merged
alexr00 merged 5 commits intomainfrom
copilot/fix-42d2eb9e-b2c0-42c1-87a5-c345e0fcc5d4
Aug 28, 2025
Merged

Add ESLint rule to enforce "pull request" over "PR" in user-facing strings#7693
alexr00 merged 5 commits intomainfrom
copilot/fix-42d2eb9e-b2c0-42c1-87a5-c345e0fcc5d4

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Aug 28, 2025

This PR adds a custom ESLint rule no-pr-in-user-strings that detects usage of "PR" in user-facing strings and enforces the use of "pull request" instead for better accessibility and consistency.

Implementation

The rule implements the following functionality:

  • Detects "PR" in localized strings: Checks string literals passed to vscode.l10n.t() and l10n.t() calls
  • Word boundary matching: Uses /\bPR\b/ regex to match "PR" as a standalone word, avoiding false positives like "APRICOT"
  • Clear error messaging: Provides helpful error message suggesting "pull request" instead of "PR"
  • Error-level enforcement: Configured as an error to prevent commits with violations

Files Added/Modified

  • NEW: build/eslint-rules/no-pr-in-user-strings.js - The ESLint rule implementation
  • MODIFIED: build/eslint-rules/index.js - Export the new rule
  • MODIFIED: .eslintrc.js - Configure rule as error level for TypeScript files
  • MODIFIED: src/issues/issueFeatureRegistrar.ts - Fix existing violation

Example Usage

The rule catches cases like:

// ❌ This will trigger an error
const message = vscode.l10n.t('Creating PR failed');

// ✅ This is correct
const message = vscode.l10n.t('Creating pull request failed');

// ✅ This won't trigger (not in l10n call)
const debug = 'PR debugging info';

// ✅ This won't trigger (PR not standalone)
const fruit = vscode.l10n.t('APRICOT is delicious');

Validation

The rule successfully detected and helped fix 1 existing violation in the codebase:

  • Before: @githubpr Summarize PR {0}/{1}#{2}
  • After: @githubpr Summarize pull request {0}/{1}#{2}

All existing lint rules continue to work, and both npm run lint and npm run hygiene pass successfully.

Created from VS Code via the GitHub Pull Request extension.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits August 28, 2025 08:29
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
- Add no-pr-in-user-strings.js rule to detect PR in vscode.l10n.t() calls
- Export rule from build/eslint-rules/index.js
- Configure rule as error level in .eslintrc.js
- Rule uses word boundary regex to detect standalone 'PR'
- Successfully detects existing issue in issueFeatureRegistrar.ts

The rule correctly identifies 1 existing violation which will need to be fixed
in a follow-up commit to demonstrate the rule is working properly.
Replace 'PR' with 'pull request' in @githubpr Summarize command to comply with new ESLint rule

Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Copilot AI changed the title [WIP] Add lint rule to check for "PR" in user-facing strings Add ESLint rule to enforce "pull request" over "PR" in user-facing strings Aug 28, 2025
Copilot AI requested a review from alexr00 August 28, 2025 08:39
@alexr00 alexr00 marked this pull request as ready for review August 28, 2025 09:16
@alexr00 alexr00 enabled auto-merge (squash) August 28, 2025 09:16
@vs-code-engineering vs-code-engineering Bot added this to the August 2025 milestone Aug 28, 2025
@alexr00 alexr00 merged commit 7960240 into main Aug 28, 2025
3 checks passed
@alexr00 alexr00 deleted the copilot/fix-42d2eb9e-b2c0-42c1-87a5-c345e0fcc5d4 branch August 28, 2025 09:20
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.

3 participants