Skip to content

[Feature]: Add rule type definitions to defineConfig (Auto-generate TS types from Go) #778

Description

@fansenze

What problem does this feature solve?

Currently, when using defineConfig in rslint.config.js (or similar config files), there is no type hinting or auto-completion for the specific rules available in Rslint.
To improve the developer experience, it would be great if defineConfig could provide strict TypeScript definitions for all supported rules, similar to what typescript-eslint or eslint-define-config does.

Since Rslint's core rules are implemented in Go, manually maintaining a TypeScript definition file for these rules would be error-prone and hard to keep in sync.
Therefore, we need to consider a way to automatically generate TypeScript type definitions from the Go source code (e.g., extracting rule names and their options from Go structs) during the build process.

What does the proposed API of configuration look like?

import { defineConfig } from '@rslint/core';
export default defineConfig({
  rules: {
    // Typing "no-" should trigger IDE auto-completion for all available rules
    "no-unused-vars": "error",
    // Should also provide type hints for rule-specific options
    "some-complex-rule": ["error", { "allow": ["foo"] }] 
  }
});

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions