Skip to content
Merged
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
11 changes: 8 additions & 3 deletions packages/rstack/src/rslintConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,22 @@ import { existsSync } from 'node:fs';
import { join } from 'node:path';
import { loadRstackConfig, type LoadedRstackConfig } from './config.ts';
import type { RslintConfig } from '@rslint/core';
import { color, logger } from 'rslog';

// Expose the loaded config so `rs check` can pass it to fmt instead of loading
// and executing the Rstack config a second time.
export const loadedConfig: LoadedRstackConfig = await loadRstackConfig();
const { configs } = loadedConfig;
const lintDefinition = configs.lint ?? [];
const lintDefinition = configs.lint;

let lintConfig: RslintConfig;

// TODO: support function in Rslint core
if (typeof lintDefinition === 'function') {
if (lintDefinition === undefined) {
logger.error(
`No lint configuration found. Add ${color.cyan('define.lint(...)')} to your Rstack config file.`,
);
process.exit(1);
} else if (typeof lintDefinition === 'function') {
lintConfig = await lintDefinition();
} else {
lintConfig = lintDefinition;
Expand Down