-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Implement three ESLint core duplicate detection rules #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Implement no-dupe-keys, no-duplicate-case, and no-duplicate-imports rules to detect common duplicate patterns in JavaScript/TypeScript code. **Rules Implemented:** 1. **no-dupe-keys**: Disallow duplicate keys in object literals - Detects duplicate property names in object literals - Handles string, numeric, and computed property names - Supports getter/setter distinction - Special handling for __proto__ 2. **no-duplicate-case**: Disallow duplicate case labels - Detects duplicate case expressions in switch statements - Normalizes whitespace for comparison - Works with all expression types 3. **no-duplicate-imports**: Disallow duplicate module imports - Detects duplicate import statements from the same module - Supports includeExports option to check re-exports - Tracks both import and export declarations **Test Coverage:** - Comprehensive test suites ported from ESLint - Valid and invalid test cases for each rule - Option testing for no-duplicate-imports **Infrastructure:** - Created fixtures directory for core rules - Registered all three rules in the global registry - Added core rule registration function 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
🤖 This pull request has been linked to DevBird Task #917 View the task details and manage the automated development workflow in DevBird. Learn more about DevBird here or the announcement blog post here. |
📋 DevBird Task PromptObjective: Port 3 ESLint core "Possible Problems" rules to RSLint (Go implementation) Rules to implement:
Documentation & Test Resources:
Implementation Requirements:
Success Criteria:
This comment was automatically added by DevBird. You can disable this feature in DevBird Settings. |
Pull Request Review: ESLint Core Duplicate Detection RulesSummaryThis PR implements three well-structured ESLint core rules for detecting duplicate patterns in JavaScript/TypeScript code. The implementation quality is generally high with comprehensive test coverage and proper handling of edge cases. ✅ Strengths1. Excellent Test Coverage
2. Proper Edge Case Handling
3. Clean Code Structure
4. Good Documentation
🐛 Potential Issues & Recommendations1. Numeric Normalization Edge Cases (
|
Fixed three issues causing CI failures: 1. **no_duplicate_case**: Fixed compilation error by using AsCaseOrDefaultClause() instead of AsCaseClause() which doesn't exist in the typescript-go AST API 2. **no_dupe_keys**: Fixed handling of empty string keys and BigInt literals - Empty string "" is now correctly recognized as a valid key - Added support for ast.KindBigIntLiteral in getKeyName() - BigInt literals (e.g., 1n) now properly normalize to match numeric keys 3. **no_duplicate_imports**: Fixed error column reporting to match ESLint behavior - Changed to report on the entire import/export declaration node - Instead of just the module specifier for accurate column positions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Pull Request Review: ESLint Core Duplicate Detection RulesThank you for this well-structured PR implementing three core ESLint rules! Overall, this is a high-quality implementation with excellent test coverage. Code Quality & Best PracticesStrengths:
Suggestions:
Potential Bugs & Edge CasesCritical Issues:
switch(x) {
case "hello world": break;
case "hello world": break; // Different strings detected as duplicate!
}Consider AST-based comparison instead.
Performance ConsiderationsGood:
Optimization:
SecurityNo security concerns identified. Test CoverageExcellent coverage overall! Suggested additions:
SummaryOverall Assessment: Approve with minor suggestions Priority fixes:
Great work! The implementation is solid and well-tested. |
Summary
This PR implements 3 ESLint core "Possible Problems" rules to detect common duplicate patterns in JavaScript/TypeScript code:
no-dupe-keys- Disallow duplicate keys in object literalsno-duplicate-case- Disallow duplicate case labelsno-duplicate-imports- Disallow duplicate module importsImplementation Details
no-dupe-keys
__proto__(literal vs computed property)no-duplicate-case
no-duplicate-imports
includeExportsoption to also check re-export statementsTest Coverage
Each rule includes comprehensive test suites ported from ESLint:
Infrastructure Changes
internal/rules/fixtures/directory for core rule testingregisterAllCoreEslintRules()function to register core rulesDocumentation & References
ESLint rule documentation:
ESLint test suites:
Testing
Next Steps
🤖 Generated with Claude Code