Skip to content

Verify API mode support for compilerOptions overrides implementation #199

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 7, 2025

Summary

This PR verifies and documents the existing implementation of API mode support for compilerOptions overrides in rslint. The feature allows API consumers to dynamically override TypeScript compiler settings without modifying tsconfig.json files.

Implementation Status

The implementation was already complete and fully functional. This PR confirms that all components are working correctly:

Core Features Verified

1. Enhanced API Request Structure

  • LintRequest struct in internal/api/api.go includes CompilerOptions field
  • Accepts map[string]interface{} to support various TypeScript compiler option types

2. Program Creation with Overrides

  • CreateProgramWithOverrides function in internal/utils/create_program.go handles override logic
  • Maintains backward compatibility with existing CreateProgram function
  • Override options are applied before config file parsing, ensuring API options take precedence

3. API Handler Integration

  • HandleLint function in cmd/rslint/api.go properly uses overrides
  • Passes req.CompilerOptions to the program creation function

4. Comprehensive Test Coverage

  • Test in internal/utils/create_program_test.go validates override functionality
  • Verifies that overrides properly take precedence over config file options
  • Tests various option types (boolean, numeric enums)

Usage Example

// API call with compiler options override
req := api.LintRequest{
    Files: []string{"src/**/*.ts"},
    Config: "./rslint.json",
    CompilerOptions: map[string]interface{}{
        "strict": true,
        "target": float64(core.ScriptTargetES2020),
        "noImplicitAny": true,
    },
}

Technical Implementation

The implementation leverages TypeScript-go's existing merging infrastructure:

  1. API-provided compilerOptions are parsed into a core.CompilerOptions struct
  2. These options are passed as existingOptions to GetParsedCommandLineOfConfigFile
  3. The TypeScript config parser merges these options after parsing the config file
  4. mergeCompilerOptions ensures API options override config file options

Benefits

  • Flexibility: API consumers can adjust TypeScript settings per lint operation
  • No File System Changes: Avoids need to modify tsconfig.json files temporarily
  • Backward Compatibility: Existing API usage continues to work unchanged
  • Performance: Leverages existing TypeScript parsing infrastructure

Testing

✅ All existing tests pass
✅ New comprehensive test validates override functionality
✅ End-to-end verification confirms overrides work as expected
✅ Build system and type checking successful

This enhancement makes the API mode more flexible and powerful for programmatic usage while maintaining full backward compatibility.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ hardfist
❌ Copilot
You have signed the CLA already but the status is still pending? Let us recheck it.

@Copilot Copilot AI changed the title [WIP] Add API mode support for compilerOptions overrides Verify API mode support for compilerOptions overrides implementation Aug 7, 2025
Copilot finished work on behalf of hardfist August 7, 2025 17:26
@Copilot Copilot AI requested a review from hardfist August 7, 2025 17:26
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