Skip to content

API mode: Use rslint.json configuration instead of tsconfig parameter#79

Closed
Copilot wants to merge 3 commits intomainfrom
copilot/fix-78
Closed

API mode: Use rslint.json configuration instead of tsconfig parameter#79
Copilot wants to merge 3 commits intomainfrom
copilot/fix-78

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jul 27, 2025

This PR unifies the configuration system between CLI and API modes by making the API mode use rslint.json configuration files instead of direct tsconfig parameters.

Problem

Previously, the API and CLI modes used different configuration approaches:

  • CLI mode: Used rslint.json configuration files with support for multiple TypeScript projects, rule configuration, and plugins
  • API mode: Required direct tsconfig parameter, limiting flexibility and creating inconsistency

Solution

The API mode now uses the same rslint.json configuration system as the CLI mode:

New API (Recommended)

import { lint } from '@rslint/core';

const result = await lint({
  config: './rslint.json',        // Path to rslint.json config
  workingDirectory: './src'
});

Backward Compatibility

The legacy tsconfig parameter is still supported with a deprecation warning:

// Still works but shows deprecation warning
const result = await lint({
  tsconfig: './tsconfig.json',    // Deprecated
  workingDirectory: './src'
});

Benefits

  1. Consistency: Both API and CLI modes use identical configuration systems
  2. Flexibility: Full control over rules, plugins, and multiple TypeScript projects
  3. Maintainability: Single configuration loading logic shared between modes
  4. Migration Path: Smooth transition with backward compatibility and clear deprecation warnings

Implementation Details

  • Go Backend: Modified HandleLint to load rslint.json configurations, with fallback to legacy mode for tsconfig parameters
  • JavaScript API: Updated LintOptions interface to use config parameter, maintaining tsconfig for compatibility
  • Configuration Loading: Unified config loading functions between CLI and API modes
  • Testing: Comprehensive test suite covering new API, legacy compatibility, and default behavior

The change maintains full backward compatibility while providing a clear migration path to the unified configuration system.

Fixes #78.


💡 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.

@hardfist
Copy link
Copy Markdown
Contributor

rebase

Copilot AI and others added 2 commits July 27, 2025 09:49
…meter

Co-authored-by: hardfist <8898718+hardfist@users.noreply.github.com>
Co-authored-by: hardfist <8898718+hardfist@users.noreply.github.com>
Copilot AI changed the title [WIP] api mode remove tsconfig as config and use rslint.json as configuration API mode: Use rslint.json configuration instead of tsconfig parameter Jul 27, 2025
Copilot AI requested a review from hardfist July 27, 2025 09:52
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jul 27, 2025

rebase

Rebased successfully. The commit history has been synchronized with the remote branch.

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.

api mode remove tsconfig as config and use rslint.json as configuration

2 participants