Skip to content

feat: support upward config discovery and directory arguments in CLI#560

Merged
fansenze merged 1 commit intomainfrom
feat/cli-config-discovery-20260321
Mar 24, 2026
Merged

feat: support upward config discovery and directory arguments in CLI#560
fansenze merged 1 commit intomainfrom
feat/cli-config-discovery-20260321

Conversation

@fansenze
Copy link
Copy Markdown
Contributor

@fansenze fansenze commented Mar 21, 2026

Summary

Config Discovery

  • Add upward directory traversal for config file discovery, where config is searched from the target file/directory location upward to the filesystem root
  • Scan for nested configs within the target scope (no-args and dir-args), enabling automatic per-package config discovery in monorepos
  • Support multi-config for monorepo scenarios: different files from different packages can use different rslint.config.* files

CLI Enhancements

  • Support directory arguments (rslint src/) with proper scoping — only files under the specified directory are linted
  • No-args implicitly scopes linting to CWD (same as rslint .)
  • Resolve symlinks in file/directory arguments for consistent path matching
  • Fix parseArgs to register known Go string flags (--format, --max-warnings, etc.) so their values are not mistaken for file arguments
  • Tolerate broken config files in multi-config mode (skip with warning, continue with remaining configs)

Code Quality

  • Refactor internal utilities into src/utils/ (args.ts, config-discovery.ts) for cleaner public API and testability
  • Extract createProgramsForConfig and parseConfigPayload on Go side to eliminate duplication
  • New multi-config stdin payload format { configs: [...] } with backward compatibility

Project Config Migration

  • Migrate project root config from rslint.json to rslint.config.ts using ts.configs.recommended preset
  • Update package.json lint command to use --config rslint.config.ts

Known Limitation

When a project mixes JSON config (root) with JS configs (sub-packages), the JS config path takes precedence and the JSON config is bypassed. JSON config is deprecated — projects should migrate to JS/TS config.

Related Links

ESLint v10 config lookup behavior: https://eslint.org/docs/latest/use/configure/configuration-files

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the rslint CLI's configuration discovery and application mechanisms. The changes align its behavior more closely with modern linting tools like ESLint v10, particularly in how it locates and applies configurations across different parts of a project or monorepo. This improves flexibility for users working with complex project structures and provides more intuitive control over linting targets, whether specifying individual files, entire directories, or relying on implicit CWD scoping.

Highlights

  • Config Discovery Alignment: Implemented upward directory traversal for config file discovery, mirroring ESLint v10's behavior where configuration is searched from the target file/directory location up to the filesystem root.
  • Multi-Config Support: Added support for multi-config scenarios, enabling different files from different packages within a monorepo to utilize distinct rslint.config.* files.
  • Directory Argument Handling: Enhanced the CLI to properly handle directory arguments (e.g., rslint src/), ensuring that only files within the specified directory are linted.
  • Implicit CWD Scoping: Modified the CLI to implicitly scope linting to the current working directory (CWD) when no arguments are provided, preventing unintended full-project linting if a config is found in a parent directory.
  • Code Refactoring and Testability: Extracted createProgramsForConfig and parseConfigPayload into separate functions to eliminate code duplication and improve the overall testability of the codebase.
  • New Multi-Config Stdin Payload Format: Introduced a new multi-config stdin payload format ({ configs: [...] }) while maintaining backward compatibility for the legacy single-config format.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This is an excellent pull request that significantly improves configuration discovery to align with ESLint v10's behavior. The introduction of upward directory traversal, multi-config support for monorepos, and the refactoring of payload parsing and program creation logic are all well-executed. The addition of comprehensive tests for both the Go and TypeScript changes is particularly commendable and ensures the new logic is robust.

I have found one area for improvement in the Go CLI implementation to ensure the new implicit CWD scoping feature is applied consistently across all configuration types, not just the new multi-config format. Please see the detailed comment.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Mar 21, 2026

Deploying rslint with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1bac9b1
Status: ✅  Deploy successful!
Preview URL: https://fb28c266.rslint.pages.dev
Branch Preview URL: https://feat-cli-config-discovery-20.rslint.pages.dev

View logs

@fansenze fansenze force-pushed the feat/cli-config-discovery-20260321 branch 5 times, most recently from b11f005 to 9f6a948 Compare March 23, 2026 08:03
@fansenze fansenze changed the title feat: align CLI config discovery with ESLint v10 feat: support upward config discovery and directory arguments in CLI Mar 23, 2026
@fansenze fansenze force-pushed the feat/cli-config-discovery-20260321 branch 7 times, most recently from 5982f8b to 6d5e3ab Compare March 23, 2026 10:25
chenjiahan
chenjiahan previously approved these changes Mar 23, 2026
@fansenze fansenze marked this pull request as draft March 23, 2026 10:57
@fansenze fansenze force-pushed the feat/cli-config-discovery-20260321 branch 3 times, most recently from 3bba73c to 7cc64e1 Compare March 24, 2026 02:50
Add upward directory traversal for config file discovery, multi-config
support for monorepo scenarios, and directory argument support with
proper scoping.

- Config discovery walks up from file/directory location to filesystem
  root, finding the nearest config file
- Multiple files from different packages can use different configs
- Directory arguments (e.g. `rslint src/`) scope linting to that subtree
- No-args implicitly scopes to CWD (same as `rslint .`)
- Extract `createProgramsForConfig` to eliminate program creation
  duplication across config paths
- Extract `parseConfigPayload` for testable stdin payload parsing
- New multi-config stdin payload format: `{ configs: [...] }`
  with backward compatibility for legacy single-config format
- Update CLI and configuration docs
@fansenze fansenze force-pushed the feat/cli-config-discovery-20260321 branch from 7cc64e1 to 1bac9b1 Compare March 24, 2026 03:47
@fansenze fansenze marked this pull request as ready for review March 24, 2026 03:55
@fansenze fansenze merged commit 86f2fdd into main Mar 24, 2026
16 checks passed
@fansenze fansenze deleted the feat/cli-config-discovery-20260321 branch March 24, 2026 05:36
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.

3 participants