diff --git a/packages/cspell/fixtures/issue-6373/cspell.config.yaml b/packages/cspell/fixtures/issue-6373/cspell.config.yaml new file mode 100644 index 00000000000..40c530ef2f2 --- /dev/null +++ b/packages/cspell/fixtures/issue-6373/cspell.config.yaml @@ -0,0 +1,7 @@ +$schema: https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json +version: '0.2' +name: issue-6373 +enableGlobDot: true +files: + - docs + - '!docs/no-check/**' diff --git a/packages/cspell/fixtures/issue-6373/docs/README.md b/packages/cspell/fixtures/issue-6373/docs/README.md new file mode 100644 index 00000000000..de035e90c60 --- /dev/null +++ b/packages/cspell/fixtures/issue-6373/docs/README.md @@ -0,0 +1,3 @@ +# Docs + +This is where the docs are. diff --git a/packages/cspell/fixtures/issue-6373/docs/no-check/README.md b/packages/cspell/fixtures/issue-6373/docs/no-check/README.md new file mode 100644 index 00000000000..7f36afe3d6c --- /dev/null +++ b/packages/cspell/fixtures/issue-6373/docs/no-check/README.md @@ -0,0 +1,5 @@ +# README.md + +Do not spell check this file. + +It has mistakkkes. diff --git a/packages/cspell/fixtures/issue-6373/docs/no-check/cspell.json b/packages/cspell/fixtures/issue-6373/docs/no-check/cspell.json new file mode 100644 index 00000000000..0967ef424bc --- /dev/null +++ b/packages/cspell/fixtures/issue-6373/docs/no-check/cspell.json @@ -0,0 +1 @@ +{} diff --git a/packages/cspell/src/app/__snapshots__/app.test.ts.snap b/packages/cspell/src/app/__snapshots__/app.test.ts.snap index 547e885558a..47043cb6df2 100644 --- a/packages/cspell/src/app/__snapshots__/app.test.ts.snap +++ b/packages/cspell/src/app/__snapshots__/app.test.ts.snap @@ -551,6 +551,26 @@ error" exports[`Validate cli > app 'issue-4811/*/README.md' Expect Error: undefined 3`] = `""`; +exports[`Validate cli > app 'issue-6373 .' Expect Error: [Function CheckFailed] 1`] = `[]`; + +exports[`Validate cli > app 'issue-6373 .' Expect Error: [Function CheckFailed] 2`] = ` +"log docs/no-check/README.md:5:8 - Unknown word (mistakkkes) +log +error CSpell: Files checked: 4, Issues found: 1 in 1 file. +error" +`; + +exports[`Validate cli > app 'issue-6373 .' Expect Error: [Function CheckFailed] 3`] = `""`; + +exports[`Validate cli > app 'issue-6373' Expect Error: undefined 1`] = `[]`; + +exports[`Validate cli > app 'issue-6373' Expect Error: undefined 2`] = ` +"error CSpell: Files checked: 1, Issues found: 0 in 0 files. +error" +`; + +exports[`Validate cli > app 'issue-6373' Expect Error: undefined 3`] = `""`; + exports[`Validate cli > app 'link add' 1`] = `""`; exports[`Validate cli > app 'link list' 1`] = `""`; diff --git a/packages/cspell/src/app/app.test.ts b/packages/cspell/src/app/app.test.ts index 0524fd9473b..7965e580e7b 100644 --- a/packages/cspell/src/app/app.test.ts +++ b/packages/cspell/src/app/app.test.ts @@ -200,6 +200,8 @@ describe('Validate cli', () => { ${'reporter'} | ${['-r', pathFix('features/reporter'), '-c', pathFix('features/reporter/cspell.config.yaml')]} | ${undefined} | ${false} | ${true} | ${false} ${'issue-4811 **/README.md'} | ${['-r', pIssues('issue-4811'), '--no-progress', '**/README.md']} | ${undefined} | ${true} | ${false} | ${false} ${'issue-4811'} | ${['-r', pIssues('issue-4811'), '--no-progress', '.']} | ${app.CheckFailed} | ${true} | ${true} | ${false} + ${'issue-6373 .'} | ${['-r', pathFix('issue-6373'), '--no-progress', '.']} | ${app.CheckFailed} | ${true} | ${true} | ${false} + ${'issue-6373'} | ${['-r', pathFix('issue-6373'), '--no-progress']} | ${undefined} | ${true} | ${false} | ${false} ${'verify globRoot works'} | ${['-r', pathFix('globRoot'), '.']} | ${undefined} | ${true} | ${false} | ${false} `('app $msg Expect Error: $errorCheck', async ({ testArgs, errorCheck, eError, eLog, eInfo }: TestCase) => { chalk.level = 1; @@ -226,8 +228,8 @@ describe('Validate cli', () => { 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)); + const result = await asyncResult(app.run(commander, args)); + expect(result).toEqual(errorCheck); eError ? expect(error).toHaveBeenCalled() : expect(error).not.toHaveBeenCalled(); @@ -426,3 +428,11 @@ function makeLogger() { function escapeRegExp(s: string): string { return s.replaceAll(/[$()*+.?[\\\]^{|}]/g, '\\$&').replaceAll('-', '\\x2d'); } + +async function asyncResult(p: Promise): Promise { + try { + return await p; + } catch (e) { + return e as Error; + } +} diff --git a/packages/cspell/src/app/lint/lint.ts b/packages/cspell/src/app/lint/lint.ts index f323d3ce029..092c1fa7055 100644 --- a/packages/cspell/src/app/lint/lint.ts +++ b/packages/cspell/src/app/lint/lint.ts @@ -530,7 +530,10 @@ async function determineGlobs(configInfo: ConfigInfo, cfg: LintRequest): Promise const cliExcludeGlobs = extractPatterns(cfg.excludes).map((p) => p.glob as Glob); const normalizedExcludes = normalizeGlobsToRoot(cliExcludeGlobs, cfg.root, true); const includeGlobs = combinedGlobs.filter((g) => !g.startsWith('!')); - const excludeGlobs = [...combinedGlobs.filter((g) => g.startsWith('!')), ...normalizedExcludes]; + const excludeGlobs = [ + ...combinedGlobs.filter((g) => g.startsWith('!')).map((g) => g.slice(1)), + ...normalizedExcludes, + ]; const fileGlobs: string[] = includeGlobs; const appGlobs = { allGlobs, gitIgnore, fileGlobs, excludeGlobs, normalizedExcludes }; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e10a0c1626b..b688c8c1146 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1095,7 +1095,7 @@ importers: version: link:../../../packages/cspell-types ts-loader: specifier: ^9.5.1 - version: 9.5.1(typescript@5.6.3)(webpack@5.95.0(@swc/core@1.7.26)(webpack-cli@5.1.4)) + version: 9.5.1(typescript@5.6.3)(webpack@5.95.0) webpack: specifier: ^5.95.0 version: 5.95.0(@swc/core@1.7.26)(webpack-cli@5.1.4) @@ -13826,17 +13826,17 @@ snapshots: '@webassemblyjs/ast': 1.12.1 '@xtuc/long': 4.2.2 - '@webpack-cli/configtest@2.1.1(webpack-cli@5.1.4(webpack@5.95.0))(webpack@5.95.0(@swc/core@1.7.26)(webpack-cli@5.1.4))': + '@webpack-cli/configtest@2.1.1(webpack-cli@5.1.4)(webpack@5.95.0)': dependencies: webpack: 5.95.0(@swc/core@1.7.26)(webpack-cli@5.1.4) webpack-cli: 5.1.4(webpack@5.95.0) - '@webpack-cli/info@2.0.2(webpack-cli@5.1.4(webpack@5.95.0))(webpack@5.95.0(@swc/core@1.7.26)(webpack-cli@5.1.4))': + '@webpack-cli/info@2.0.2(webpack-cli@5.1.4)(webpack@5.95.0)': dependencies: webpack: 5.95.0(@swc/core@1.7.26)(webpack-cli@5.1.4) webpack-cli: 5.1.4(webpack@5.95.0) - '@webpack-cli/serve@2.0.5(webpack-cli@5.1.4(webpack@5.95.0))(webpack@5.95.0(@swc/core@1.7.26)(webpack-cli@5.1.4))': + '@webpack-cli/serve@2.0.5(webpack-cli@5.1.4)(webpack@5.95.0)': dependencies: webpack: 5.95.0(@swc/core@1.7.26)(webpack-cli@5.1.4) webpack-cli: 5.1.4(webpack@5.95.0) @@ -20306,25 +20306,25 @@ snapshots: temp-dir@3.0.0: {} - terser-webpack-plugin@5.3.10(@swc/core@1.7.26)(webpack@5.95.0(@swc/core@1.7.26)(webpack-cli@5.1.4)): + terser-webpack-plugin@5.3.10(@swc/core@1.7.26)(webpack@5.95.0(@swc/core@1.7.26)): dependencies: '@jridgewell/trace-mapping': 0.3.25 jest-worker: 27.5.1 schema-utils: 3.3.0 serialize-javascript: 6.0.2 terser: 5.34.1 - webpack: 5.95.0(@swc/core@1.7.26)(webpack-cli@5.1.4) + webpack: 5.95.0(@swc/core@1.7.26) optionalDependencies: '@swc/core': 1.7.26 - terser-webpack-plugin@5.3.10(@swc/core@1.7.26)(webpack@5.95.0(@swc/core@1.7.26)): + terser-webpack-plugin@5.3.10(@swc/core@1.7.26)(webpack@5.95.0): dependencies: '@jridgewell/trace-mapping': 0.3.25 jest-worker: 27.5.1 schema-utils: 3.3.0 serialize-javascript: 6.0.2 terser: 5.34.1 - webpack: 5.95.0(@swc/core@1.7.26) + webpack: 5.95.0(@swc/core@1.7.26)(webpack-cli@5.1.4) optionalDependencies: '@swc/core': 1.7.26 @@ -20428,7 +20428,7 @@ snapshots: tslib: 2.7.0 typescript: 5.6.3 - ts-loader@9.5.1(typescript@5.6.3)(webpack@5.95.0(@swc/core@1.7.26)(webpack-cli@5.1.4)): + ts-loader@9.5.1(typescript@5.6.3)(webpack@5.95.0): dependencies: chalk: 4.1.2 enhanced-resolve: 5.17.1 @@ -20941,9 +20941,9 @@ snapshots: webpack-cli@5.1.4(webpack@5.95.0): dependencies: '@discoveryjs/json-ext': 0.5.7 - '@webpack-cli/configtest': 2.1.1(webpack-cli@5.1.4(webpack@5.95.0))(webpack@5.95.0(@swc/core@1.7.26)(webpack-cli@5.1.4)) - '@webpack-cli/info': 2.0.2(webpack-cli@5.1.4(webpack@5.95.0))(webpack@5.95.0(@swc/core@1.7.26)(webpack-cli@5.1.4)) - '@webpack-cli/serve': 2.0.5(webpack-cli@5.1.4(webpack@5.95.0))(webpack@5.95.0(@swc/core@1.7.26)(webpack-cli@5.1.4)) + '@webpack-cli/configtest': 2.1.1(webpack-cli@5.1.4)(webpack@5.95.0) + '@webpack-cli/info': 2.0.2(webpack-cli@5.1.4)(webpack@5.95.0) + '@webpack-cli/serve': 2.0.5(webpack-cli@5.1.4)(webpack@5.95.0) colorette: 2.0.20 commander: 10.0.1 cross-spawn: 7.0.3 @@ -21064,7 +21064,7 @@ snapshots: neo-async: 2.6.2 schema-utils: 3.3.0 tapable: 2.2.1 - terser-webpack-plugin: 5.3.10(@swc/core@1.7.26)(webpack@5.95.0(@swc/core@1.7.26)(webpack-cli@5.1.4)) + terser-webpack-plugin: 5.3.10(@swc/core@1.7.26)(webpack@5.95.0) watchpack: 2.4.2 webpack-sources: 3.2.3 optionalDependencies: