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
6 changes: 3 additions & 3 deletions @internal/tsdown/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export type { UserConfig } from 'tsdown';
export { defineConfig } from 'tsdown';

export const defaultDeps: DepsConfig = {
onlyAllowBundle: [],
onlyBundle: [],
};

export const defaultConfig: UserConfig = {
outDir: 'dist',
format: ['esm'],
target: 'Node20',
target: 'Node22',
dts: true,
sourcemap: true,
clean: true,
Expand All @@ -39,7 +39,7 @@ export function createConfig(config: UserConfig | UserConfig[]): UserConfig | Us
* const config = createConfig({
* entry: ['src/index.ts'],
* outDir: 'dist',
* ...deps({ onlyAllowBundle: ['gensequence'] }),
* ...deps({ onlyBundle: ['gensequence'] }),
* });
* ```
* @param deps - config to merge
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"clean-build": "pnpm run clean && pnpm -r --stream --workspace-concurrency=2 run build",
"clean-dist": "shx rm -rf \"packages/*/dist\"",
"clean": "shx rm -rf \"{*,*/*}/{*.tsbuildinfo,*.tsbuildInfo,temp,coverage,*.cpuprofile}\" \"**/dist/**/*.tsbuildInfo\" lcov.info && pnpm -r run clean",
"#coverage-collect": "globcat \"packages/*/coverage/lcov.info\" > lcov.info",
"coverage-collect": "shx cat packages/*/coverage/lcov.info > lcov.info",
"coverage": "pnpm --stream -r --workspace-concurrency=1 run coverage && pnpm run coverage-collect",
"eslint-fix": "eslint . --fix --cache",
Expand Down
2 changes: 1 addition & 1 deletion packages/cspell-dictionary-bundler-plugin/tsdown.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const baseConfig: UserConfig = {
outDir: 'dist',
format: ['esm'],
deps: {
onlyAllowBundle: false,
onlyBundle: false,
},
};

Expand Down
4 changes: 4 additions & 0 deletions packages/cspell-lib/api/api.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion packages/cspell-lib/src/lib/textValidation/docValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ export interface DocumentValidatorOptions extends ValidateTextOptions {
* If not set, the current working directory will be used.
*/
resolveImportsRelativeTo?: string | URL;

/**
* If true, the document will be checked even if it would normally be excluded.
*/
forceCheck?: boolean;
}

const ERROR_NOT_PREPARED = 'Validator Must be prepared before calling this function.';
Expand Down Expand Up @@ -188,7 +193,7 @@ export class DocumentValidator {
const recShouldCheckTime = recordPerfTime(this.perfTiming, '_shouldCheck');

// eslint-disable-next-line unicorn/prefer-regexp-test
const shouldCheck = !matcher.match(uriToFilePath(uri)) && (docSettings.enabled ?? true);
const shouldCheck = options.forceCheck || (!matcher.match(uriToFilePath(uri)) && (docSettings.enabled ?? true));

recShouldCheckTime();

Expand Down
2 changes: 1 addition & 1 deletion packages/cspell-trie-lib/tsdown.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const baseConfig: UserConfig = {
outDir: 'dist',
fixedExtension: false,
platform: 'neutral',
...deps({ onlyAllowBundle: ['gensequence'] }),
...deps({ onlyBundle: ['gensequence'] }),
};

const config: UserConfig[] = createConfig([baseConfig]);
Expand Down
2 changes: 1 addition & 1 deletion packages/cspell/bin.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ run(program, process.argv).catch((e) => {
// It is possible an explicit exit code was set, use it if it was.
process.exitCode = process.exitCode || 1;
}
if (e instanceof CheckFailed) {
if (e instanceof CheckFailed || e instanceof CommanderError) {
process.exitCode = e.exitCode;
}
});
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
../../../src/app.ts
../../../src/app.mts
../../../README.md
41 changes: 39 additions & 2 deletions packages/cspell/src/__snapshots__/app.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ exports[`Validate cli > app '--fail-fast with config' Expect Error: [Function Ch
error
log first-fail.txt:1:1 - Unknown word (iamtypo)
log
error CSpell: Files checked: 1, Issues found: 1 in 1 file.
error CSpell: Files checked: 1, skipped: 1, Issues found: 1 in 1 file.
error"
`;

Expand All @@ -113,7 +113,7 @@ exports[`Validate cli > app '--fail-fast with option' Expect Error: [Function Ch
error
log first-fail.txt:1:1 - Unknown word (iamtypo)
log
error CSpell: Files checked: 1, Issues found: 1 in 1 file.
error CSpell: Files checked: 1, skipped: 1, Issues found: 1 in 1 file.
error"
`;

Expand Down Expand Up @@ -1014,6 +1014,8 @@ exports[`Validate cli > app 'no-args' Expect Error: 'outputHelp' 1`] = `
" line.",
" --file [file...] Specify files to spell check. They are filtered",
" by the [globs...].",
" --force-check Force the --file or --file-list documents to be",
" checked even if it would normally be excluded.",
" --no-issues Do not show the spelling errors.",
" --no-progress Turn off progress messages",
" --no-summary Turn off summary message in console.",
Expand Down Expand Up @@ -3823,6 +3825,35 @@ error"

exports[`Validate cli > app 'with spelling errors Dutch.txt' Expect Error: [Function CheckFailed] 3`] = `""`;

exports[`Validate cli > app --force-check 'lint --file package.json --force-check' Expect Error: undefined 1`] = `[]`;

exports[`Validate cli > app --force-check 'lint --file package.json --force-check' Expect Error: undefined 2`] = `
"error 1/1 package.json 0.00ms
error
error CSpell: Files checked: 1, Issues found: 0 in 0 files.
error"
`;

exports[`Validate cli > app --force-check 'lint --file package.json --force-check' Expect Error: undefined 3`] = `""`;

exports[`Validate cli > app --force-check 'lint README.md --file package.json' Expect Error: 'error: mixing globs and --file is not supported' 1`] = `[]`;

exports[`Validate cli > app --force-check 'lint README.md --file package.json' Expect Error: 'error: mixing globs and --file is not supported' 2`] = `""`;

exports[`Validate cli > app --force-check 'lint README.md --file package.json' Expect Error: 'error: mixing globs and --file is not supported' 3`] = `
"error: mixing globs and --file is not supported
"
`;

exports[`Validate cli > app --force-check 'lint README.md --force-check' Expect Error: 'error: --force-check requires --file, --files, or --file-list to be specified' 1`] = `[]`;

exports[`Validate cli > app --force-check 'lint README.md --force-check' Expect Error: 'error: --force-check requires --file, --files, or --file-list to be specified' 2`] = `""`;

exports[`Validate cli > app --force-check 'lint README.md --force-check' Expect Error: 'error: --force-check requires --file, --files, or --file-list to be specified' 3`] = `
"error: --force-check requires --file, --files, or --file-list to be specified
"
`;

exports[`Validate cli > app dictionary [ 'dictionaries' ] 1`] = `[]`;

exports[`Validate cli > app dictionary [ 'dictionaries' ] 2`] = `
Expand Down Expand Up @@ -4328,6 +4359,8 @@ exports[`Validate cli > app help [ 'lint', '--help' ] 1`] = `
" line.",
" --file [file...] Specify files to spell check. They are filtered",
" by the [globs...].",
" --force-check Force the --file or --file-list documents to be",
" checked even if it would normally be excluded.",
" --no-issues Do not show the spelling errors.",
" --no-progress Turn off progress messages",
" --no-summary Turn off summary message in console.",
Expand Down Expand Up @@ -4462,6 +4495,8 @@ exports[`Validate cli > app help [ 'lint', '--help', '--issue-template' ] 1`] =
" line.",
" --file [file...] Specify files to spell check. They are filtered",
" by the [globs...].",
" --force-check Force the --file or --file-list documents to be",
" checked even if it would normally be excluded.",
" --no-issues Do not show the spelling errors.",
" --no-progress Turn off progress messages",
" --no-summary Turn off summary message in console.",
Expand Down Expand Up @@ -4623,6 +4658,8 @@ exports[`Validate cli > app help [ 'lint', '--help', '--verbose' ] 1`] = `
" line.",
" --file [file...] Specify files to spell check. They are filtered",
" by the [globs...].",
" --force-check Force the --file or --file-list documents to be",
" checked even if it would normally be excluded.",
" --no-issues Do not show the spelling errors.",
" --no-progress Turn off progress messages",
" --no-summary Turn off summary message in console.",
Expand Down
33 changes: 33 additions & 0 deletions packages/cspell/src/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ interface TestCase {
eInfo: boolean;
}

interface ArgsTestCase {
args: string | string[];
errorCheck: ErrorCheck;
eError: boolean;
eLog: boolean;
eInfo: boolean;
}

class RecordStdStream {
private static columnWidth = 80;
private write = process.stdout.write.bind(process.stdout);
Expand Down Expand Up @@ -320,6 +328,31 @@ describe('Validate cli', () => {
expect(normalizeOutput(captureStderr.text)).toMatchSnapshot();
});

test.each`
args | errorCheck | eError | eLog | eInfo
${'lint --file package.json --force-check'} | ${undefined} | ${true} | ${false} | ${false}
${'lint README.md --file package.json'} | ${'error: mixing globs and --file is not supported'} | ${false} | ${false} | ${false}
${'lint README.md --force-check'} | ${'error: --force-check requires --file, --files, or --file-list to be specified'} | ${false} | ${false} | ${false}
`(
'app --force-check $args Expect Error: $errorCheck',
async ({ args: testArgs, errorCheck, eError, eLog, eInfo }: ArgsTestCase) => {
testArgs = typeof testArgs === 'string' ? testArgs.split(' ') : testArgs;
chalk.level = 1;
const commander = getCommander();
const args = argv(...testArgs);
const result = app.run(commander, args);
await (!errorCheck ? expect(result).resolves.toBeUndefined() : expect(result).rejects.toThrow(errorCheck));

eError ? expect(error).toHaveBeenCalled() : expect(error).not.toHaveBeenCalled();
eLog ? expect(log).toHaveBeenCalled() : expect(log).not.toHaveBeenCalled();
eInfo ? expect(info).toHaveBeenCalled() : expect(info).not.toHaveBeenCalled();

expect(captureStdout.text).toMatchSnapshot();
expect(logger.normalizedHistory()).toMatchSnapshot();
expect(normalizeOutput(captureStderr.text)).toMatchSnapshot();
},
);

test.each`
cmdArgs
${['--help']}
Expand Down
4 changes: 2 additions & 2 deletions packages/cspell/src/cli-reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,10 @@ export function getReporter(options: ReporterOptions, config?: CSpellReporterCon
}

const resultEmitter = (result: RunResult) => {
if (!fileGlobs.length && !result.files) {
const { files, issues, cachedFiles, filesWithIssues, errors, skippedFiles } = result;
if (!fileGlobs.length && !files && !skippedFiles && !errors && !issues) {
return;
}
const { files, issues, cachedFiles, filesWithIssues, errors, skippedFiles } = result;
const numFilesWithIssues = filesWithIssues.size;
const chalk = stderr.chalk;

Expand Down
12 changes: 11 additions & 1 deletion packages/cspell/src/commandLint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ export function commandLint(prog: Command, opts: CommandOptions): Command {
)
.option('--file [file...]', 'Specify files to spell check. They are filtered by the [globs...].', collect)
.addOption(crOpt('--files [file...]', 'Alias of "--file". Files to spell check.', collect).hideHelp())
.option(
'--force-check',
'Force the --file or --file-list documents to be checked even if it would normally be excluded.',
)
.option('--no-issues', 'Do not show the spelling errors.')
.option('--no-progress', 'Turn off progress messages')
.option('--no-summary', 'Turn off summary message in console.')
Expand Down Expand Up @@ -213,7 +217,13 @@ async function action(this: Command, fileGlobs: string[], cliOptions: LinterCliC
if (maxFileSizeErr) {
this.error(`error: invalid option value for --max-file-size: ${maxFileSizeErr}`);
}
const { mustFindFiles, fileList, files, file } = options;
const { mustFindFiles, fileList, files, file, forceCheck } = options;
if (forceCheck && !file?.length && !files?.length && !fileList?.length) {
this.error('error: --force-check requires --file, --files, or --file-list to be specified');
}
if (fileGlobs.length && (file?.length || files?.length)) {
this.error('error: mixing globs and --file is not supported');
}
const result = await App.lint(fileGlobs, options);
if (!fileGlobs.length && !result.files && !result.errors && !fileList && !files?.length && !file?.length) {
this.outputHelp();
Expand Down
Loading