Replace fragile string matching with robust configuration-based code example generation#28
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…example generation Co-authored-by: BorDevTech <73800053+BorDevTech@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] The code example generation relies on string matching against error messages, which is fragile and could break if error message formats change. Consider using more robust pattern matching or a configuration-based approach to map rule patterns to examples.
Replace fragile string matching with robust configuration-based code example generation
Sep 21, 2025
Contributor
There was a problem hiding this comment.
Pull Request Overview
Refactors lint automation code example generation from fragile string checks to a configuration-driven, context-aware approach to improve resilience and maintainability.
- Introduces ExampleConfig with identifierPattern and contextPatterns to extract identifiers and infer context from source.
- Updates exampleGenerator signature to accept context and adds new generators for several rules (e.g., no-unused-vars, no-explicit-any, no-unused-imports).
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
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.
The code example generation in the lint automation system was using fragile string matching against error messages, which could break if ESLint message formats change. This PR refactors the system to use a more robust, configuration-based approach.
Problem
The
generateCodeExamplemethod inscripts/lint-automation/github-issue-creator.tsrelied on hardcoded string matching like:This approach was brittle because:
Solution
Replaced the fragile string matching with a robust configuration-based system:
1. Regex-based Identifier Extraction
identifierPattern: /'([^']+)' is (defined but never used|assigned a value but never used)/2. Context-Aware Pattern Detection
3. Generic Example Generators
Examples now work with any identifier name and adapt based on detected context, not hardcoded strings.
Benefits
Testing
Comprehensive testing confirmed:
DatabaseConfig,mySpecialVariable)Fixes #27.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.