Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Read this reference when the project uses the `lint-staged` binary, a lint-stage
## Steps

1. Replace direct `lint-staged` script invocations with `rs staged`.
2. Move a plain task map into `define.staged` in `rstack.config.*`.
2. Move the lint-staged config into `define.staged` in `rstack.config.*`.
Comment thread
chenjiahan marked this conversation as resolved.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Remove stale function-config caveat

When this skill migrates a project that uses a JavaScript/function-based lint-staged config, this broadened step now tells it to move the whole config into define.staged, but the same reference still says to keep standalone lint-staged when the workflow requires function-based configs. That contradiction can make the migration guidance stop or leave duplicate lint-staged setup even though define.staged now accepts these configs; update the Unsupported Cases section alongside this generalized step.

Useful? React with 👍 / 👎.

3. Remove the old manifest key or config file.
4. Remove the direct `lint-staged` dependency only when no script, config, or programmatic API still uses it.

Expand Down
5 changes: 1 addition & 4 deletions packages/rstack/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ import type { RslibConfigDefinition } from '@rslib/core';
import type { RslintConfig } from '@rslint/core';
import type { UserConfig, UserConfigAsyncFn } from '@rspress/core';
import type { RstestConfigExport } from '@rstest/core';

export type StagedTask = string | string[];

export type StagedConfig = Record<string, StagedTask>;
import type { StagedConfig } from './staged.js';

export type RslintConfigDefinition = RslintConfig | (() => Promise<RslintConfig>);
export type RspressConfigDefinition = UserConfig | UserConfigAsyncFn;
Expand Down
21 changes: 21 additions & 0 deletions packages/rstack/src/staged.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@ import { parseArgs } from 'node:util';
import { color } from 'rslog';
import { loadRstackConfig } from './config.js';

export type StagedSyncTaskGenerator = (stagedFileNames: readonly string[]) => string | string[];

export type StagedAsyncTaskGenerator = (
stagedFileNames: readonly string[],
) => Promise<string | string[]>;

export type StagedTaskGenerator = StagedSyncTaskGenerator | StagedAsyncTaskGenerator;

export type StagedFunctionTask = {
title: string;
task: (stagedFileNames: readonly string[]) => void | Promise<void>;
};

export type StagedTask =
| string
| StagedFunctionTask
| StagedTaskGenerator
| (string | StagedTaskGenerator)[];

export type StagedConfig = Record<string, StagedTask> | StagedTaskGenerator;

const stagedHelpMessage = `Rstack v${RSTACK_VERSION}

${color.cyan('Usage')}:
Expand Down