Skip to content

Conversation

@delino
Copy link
Contributor

@delino delino bot commented Dec 26, 2025

Summary

This PR implements the ban-tslint-comment rule from typescript-eslint to detect and flag legacy TSLint directive comments.

Background

TSLint has been deprecated (see palantir/tslint#4534) and its directive comments are no longer useful. This rule helps in the migration from TSLint to ESLint by identifying and removing these legacy configuration comments.

Implementation Details

Rule Implementation

  • Location: internal/plugins/typescript/rules/ban_tslint_comment/ban_tslint_comment.go
  • Pattern Matching: Uses regex to detect TSLint directives:
    • tslint:disable
    • tslint:enable
    • tslint:disable-line
    • tslint:disable-next-line
    • tslint:enable-line
  • Comment Types: Handles both single-line (//) and multi-line (/* */) comments
  • Message ID: Reports violations with commentDetected message ID

Test Coverage

  • Go Tests: Comprehensive test suite at internal/plugins/typescript/rules/ban_tslint_comment/ban_tslint_comment_test.go
    • Valid cases: Regular comments that should NOT be flagged
    • Invalid cases: TSLint directives that should be flagged
    • Edge cases: Multiple spaces, tabs, inline comments, multiple directives
  • TypeScript Tests: Enhanced test file at packages/rslint-test-tools/tests/typescript-eslint/rules/ban-tslint-comment.test.ts
  • Test Enabled: Uncommented line 36 in packages/rslint-test-tools/rstest.config.mts

Registration

  • Plugin Registry: Added rule registration in internal/config/config.go
  • Rule Name: @typescript-eslint/ban-tslint-comment

Testing

The implementation includes comprehensive test cases covering:

  • ✅ Basic TSLint directives (tslint:disable, tslint:enable)
  • ✅ Line-specific directives (tslint:disable-line, tslint:disable-next-line)
  • ✅ Directives with specific rules (e.g., tslint:disable:rule1 rule2)
  • ✅ Various comment formats (single-line, multi-line)
  • ✅ Edge cases (whitespace, tabs, inline comments)
  • ✅ Multiple directives in a single file
  • ✅ Comments that mention "tslint" but are not directives

References

Checklist

  • Rule implementation complete
  • Comprehensive test coverage (Go)
  • TypeScript test file enhanced
  • Test enabled in rstest.config.mts
  • Rule registered in plugin registry
  • Follows existing rslint patterns
  • Documentation in code comments

🤖 Generated with Claude Code

Implement the `ban-tslint-comment` rule from typescript-eslint to detect
and flag legacy TSLint directive comments. TSLint has been deprecated and
its directive comments are no longer useful.

**Implementation:**
- Created complete rule implementation in Go at `internal/plugins/typescript/rules/ban_tslint_comment/ban_tslint_comment.go`
- Detects TSLint directives using regex pattern matching:
  - `tslint:disable`
  - `tslint:enable`
  - `tslint:disable-line`
  - `tslint:disable-next-line`
  - `tslint:enable-line`
- Handles both single-line (`//`) and multi-line (`/* */`) comments
- Reports violations with `commentDetected` message ID

**Testing:**
- Created comprehensive test suite in Go with valid and invalid test cases
- Added TypeScript test file with additional edge cases
- Enabled test in `packages/rslint-test-tools/rstest.config.mts`

**Registration:**
- Registered rule in plugin registry at `internal/config/config.go`
- Added import for the new rule package
- Rule is now available as `@typescript-eslint/ban-tslint-comment`

This rule helps in the migration from TSLint to ESLint by identifying
and removing legacy TSLint configuration comments.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
@netlify
Copy link

netlify bot commented Dec 26, 2025

Deploy Preview for rslint ready!

Name Link
🔨 Latest commit e1259fd
🔍 Latest deploy log https://app.netlify.com/projects/rslint/deploys/694e89d2613c8d0008c2f30e
😎 Deploy Preview https://deploy-preview-423--rslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Collaborator

kdy1 commented Dec 26, 2025

🤖 This pull request has been linked to DevBird Task #2648

View the task details and manage the automated development workflow in DevBird.

Learn more about DevBird here or the announcement blog post here.

Copy link
Collaborator

kdy1 commented Dec 26, 2025

📋 DevBird Task Prompt

Objective

Implement the ban-tslint-comment rule from typescript-eslint from scratch with complete test coverage.

Documentation & Resources

Rule Description

This rule flags TSLint directive comments (e.g., // tslint:disable, // tslint:enable). TSLint has been deprecated and its directive comments are no longer useful. This rule helps in the migration from TSLint to ESLint.

Scope

Create a complete implementation of the ban-tslint-comment rule including:

  1. Full rule implementation in Go at internal/rules/ban_tslint_comment/ban_tslint_comment.go
  2. Comprehensive test suite at internal/rules/ban_tslint_comment/ban_tslint_comment_test.go
  3. Copy ALL test cases from the original typescript-eslint test file
  4. Enable the test in packages/rslint-test-tools/rstest.config.mts by uncommenting line 36

Technical Requirements

  • Follow the existing rslint rule implementation pattern (see internal/rules/no_debugger/ for reference)
  • Use typescript-go AST node types and traversal
  • Detect tslint directive comments in various formats
  • Implement proper error messages matching the original rule
  • Handle both single-line and multi-line comment directives
  • Register rule in the appropriate plugin registry

Implementation Pattern

package ban_tslint_comment

import (
    "github.com/microsoft/typescript-go/shim/ast"
    "github.com/web-infra-dev/rslint/internal/rule"
)

var BanTslintCommentRule = rule.Rule{
    Name: "ban-tslint-comment",
    Run: func(ctx rule.RuleContext, options any) rule.RuleListeners {
        // Implementation here
        return rule.RuleListeners{
            // AST node listeners
        }
    },
}

Test Requirements

Success Criteria

  • Rule implementation is complete and handles all edge cases
  • All tests pass
  • Test is enabled in packages/rslint-test-tools/rstest.config.mts
  • Code follows existing rslint patterns and conventions
  • Rule is properly registered in the plugin system

This comment was automatically added by DevBird. You can disable this feature in DevBird Settings.

@kdy1
Copy link
Collaborator

kdy1 commented Dec 26, 2025

AI will fix the CI (until it passes)

Copy link
Collaborator

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

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

Fix CI

…lints

- Replace HasPrefix/HasSuffix + manual slicing with TrimPrefix/TrimSuffix
- Add TrimSpace to properly handle whitespace in comments
- Fixes staticcheck S1017 violations

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
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.

2 participants