Skip to content

Commit

Permalink
fix: #1000 (#1002)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason3S committed Feb 25, 2021
1 parent 1020d56 commit d82a4a2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 26 deletions.
4 changes: 4 additions & 0 deletions packages/cspell/src/__snapshots__/app.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,8 @@ exports[`Validate cli app with spelling errors --debug Dutch.txt Expect Error: [
exports[`Validate cli app with spelling errors --silent Dutch.txt Expect Error: [Function CheckFailed] 1`] = `Array []`;
exports[`Validate cli app with spelling errors Dutch.txt --legacy Expect Error: [Function CheckFailed] 1`] = `Array []`;
exports[`Validate cli app with spelling errors Dutch.txt Expect Error: [Function CheckFailed] 1`] = `Array []`;
exports[`Validate cli app with spelling errors Dutch.txt words only Expect Error: [Function CheckFailed] 1`] = `Array []`;
50 changes: 26 additions & 24 deletions packages/cspell/src/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,30 +107,32 @@ describe('Validate cli', () => {
});

test.each`
msg | testArgs | errorCheck | eError | eLog | eInfo
${'no-args'} | ${[]} | ${'outputHelp'} | ${false} | ${false} | ${false}
${'current_file'} | ${[__filename]} | ${undefined} | ${true} | ${false} | ${false}
${'with spelling errors Dutch.txt'} | ${[pathSamples('Dutch.txt')]} | ${app.CheckFailed} | ${true} | ${true} | ${false}
${'with spelling errors --debug Dutch.txt'} | ${['--debug', pathSamples('Dutch.txt')]} | ${app.CheckFailed} | ${true} | ${true} | ${true}
${'with spelling errors --silent Dutch.txt'} | ${['--silent', pathSamples('Dutch.txt')]} | ${app.CheckFailed} | ${false} | ${false} | ${false}
${'current_file languageId'} | ${[__filename, '--languageId=typescript']} | ${undefined} | ${true} | ${false} | ${false}
${'trace hello'} | ${['trace', 'hello']} | ${undefined} | ${false} | ${true} | ${false}
${'trace help'} | ${['trace', '-h']} | ${'outputHelp'} | ${false} | ${false} | ${false}
${'trace not-in-any-dictionary'} | ${['trace', 'not-in-any-dictionary']} | ${app.CheckFailed} | ${true} | ${true} | ${false}
${'trace missing dictionary'} | ${['trace', 'hello', '-c', 'samples/cspell-missing-dict.json']} | ${app.CheckFailed} | ${true} | ${true} | ${false}
${'check help'} | ${['check', '--help']} | ${'outputHelp'} | ${false} | ${false} | ${false}
${'check LICENSE'} | ${['check', pathRoot('LICENSE')]} | ${undefined} | ${false} | ${true} | ${false}
${'check missing'} | ${['check', pathRoot('missing-file.txt')]} | ${app.CheckFailed} | ${true} | ${true} | ${false}
${'check with spelling errors'} | ${['check', pathSamples('Dutch.txt')]} | ${app.CheckFailed} | ${false} | ${true} | ${false}
${'LICENSE'} | ${[pathRoot('LICENSE')]} | ${undefined} | ${true} | ${false} | ${false}
${'samples/Dutch.txt'} | ${[pathSamples('Dutch.txt')]} | ${app.CheckFailed} | ${true} | ${true} | ${false}
${'current_file --verbose'} | ${['--verbose', __filename]} | ${undefined} | ${true} | ${false} | ${true}
${'bad config'} | ${['-c', __filename, __filename]} | ${app.CheckFailed} | ${true} | ${false} | ${false}
${'not found error by default'} | ${['*.not']} | ${app.CheckFailed} | ${true} | ${false} | ${false}
${'must find with error'} | ${['*.not', '--must-find-files']} | ${app.CheckFailed} | ${true} | ${false} | ${false}
${'must find force no error'} | ${['*.not', '--no-must-find-files']} | ${undefined} | ${true} | ${false} | ${false}
${'cspell-bad.json'} | ${['-c', pathSamples('cspell-bad.json'), __filename]} | ${undefined} | ${true} | ${false} | ${false}
${'cspell-import-missing.json'} | ${['-c', pathSamples('linked/cspell-import-missing.json'), __filename]} | ${app.CheckFailed} | ${true} | ${false} | ${false}
msg | testArgs | errorCheck | eError | eLog | eInfo
${'no-args'} | ${[]} | ${'outputHelp'} | ${false} | ${false} | ${false}
${'current_file'} | ${[__filename]} | ${undefined} | ${true} | ${false} | ${false}
${'with spelling errors Dutch.txt'} | ${[pathSamples('Dutch.txt')]} | ${app.CheckFailed} | ${true} | ${true} | ${false}
${'with spelling errors Dutch.txt words only'} | ${[pathSamples('Dutch.txt'), '--wordsOnly']} | ${app.CheckFailed} | ${true} | ${true} | ${false}
${'with spelling errors Dutch.txt --legacy'} | ${[pathSamples('Dutch.txt'), '--legacy']} | ${app.CheckFailed} | ${true} | ${true} | ${false}
${'with spelling errors --debug Dutch.txt'} | ${['--debug', pathSamples('Dutch.txt')]} | ${app.CheckFailed} | ${true} | ${true} | ${true}
${'with spelling errors --silent Dutch.txt'} | ${['--silent', pathSamples('Dutch.txt')]} | ${app.CheckFailed} | ${false} | ${false} | ${false}
${'current_file languageId'} | ${[__filename, '--languageId=typescript']} | ${undefined} | ${true} | ${false} | ${false}
${'trace hello'} | ${['trace', 'hello']} | ${undefined} | ${false} | ${true} | ${false}
${'trace help'} | ${['trace', '-h']} | ${'outputHelp'} | ${false} | ${false} | ${false}
${'trace not-in-any-dictionary'} | ${['trace', 'not-in-any-dictionary']} | ${app.CheckFailed} | ${true} | ${true} | ${false}
${'trace missing dictionary'} | ${['trace', 'hello', '-c', 'samples/cspell-missing-dict.json']} | ${app.CheckFailed} | ${true} | ${true} | ${false}
${'check help'} | ${['check', '--help']} | ${'outputHelp'} | ${false} | ${false} | ${false}
${'check LICENSE'} | ${['check', pathRoot('LICENSE')]} | ${undefined} | ${false} | ${true} | ${false}
${'check missing'} | ${['check', pathRoot('missing-file.txt')]} | ${app.CheckFailed} | ${true} | ${true} | ${false}
${'check with spelling errors'} | ${['check', pathSamples('Dutch.txt')]} | ${app.CheckFailed} | ${false} | ${true} | ${false}
${'LICENSE'} | ${[pathRoot('LICENSE')]} | ${undefined} | ${true} | ${false} | ${false}
${'samples/Dutch.txt'} | ${[pathSamples('Dutch.txt')]} | ${app.CheckFailed} | ${true} | ${true} | ${false}
${'current_file --verbose'} | ${['--verbose', __filename]} | ${undefined} | ${true} | ${false} | ${true}
${'bad config'} | ${['-c', __filename, __filename]} | ${app.CheckFailed} | ${true} | ${false} | ${false}
${'not found error by default'} | ${['*.not']} | ${app.CheckFailed} | ${true} | ${false} | ${false}
${'must find with error'} | ${['*.not', '--must-find-files']} | ${app.CheckFailed} | ${true} | ${false} | ${false}
${'must find force no error'} | ${['*.not', '--no-must-find-files']} | ${undefined} | ${true} | ${false} | ${false}
${'cspell-bad.json'} | ${['-c', pathSamples('cspell-bad.json'), __filename]} | ${undefined} | ${true} | ${false} | ${false}
${'cspell-import-missing.json'} | ${['-c', pathSamples('linked/cspell-import-missing.json'), __filename]} | ${app.CheckFailed} | ${true} | ${false} | ${false}
`('app $msg Expect Error: $errorCheck', async ({ testArgs, errorCheck, eError, eLog, eInfo }: TestCase) => {
const commander = getCommander();
const args = argv(...testArgs);
Expand Down
4 changes: 2 additions & 2 deletions packages/cspell/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ const templateIssue = `{green $uri}:{yellow $row:$col} - Unknown word ({red $tex
const templateIssueWithSuggestions = `{green $uri}:{yellow $row:$col} - Unknown word ({red $text}) Suggestions: {yellow [$suggestions]}`;
const templateIssueWithContext = `{green $uri}:{yellow $row:$col} $padRowCol- Unknown word ({red $text})$padContext -- {gray $contextLeft}{red {underline $text}}{gray $contextRight}`;
const templateIssueWithContextWithSuggestions = `{green $uri}:{yellow $row:$col} $padRowCol- Unknown word ({red $text})$padContext -- {gray $contextLeft}{red {underline $text}}{gray $contextRight}\n\t Suggestions: {yellow [$suggestions]}`;
const templateIssueLegacy = `${chalk.green('${uri}')}[\${row}, \${col}]: Unknown word: ${chalk.red('${text}')}`;
const templateIssueWordsOnly = '${text}';
const templateIssueLegacy = `${chalk.green('$uri')}[$row, $col]: Unknown word: ${chalk.red('$text')}`;
const templateIssueWordsOnly = '$text';

function genIssueEmitter(template: string) {
const defaultWidth = 10;
Expand Down

0 comments on commit d82a4a2

Please sign in to comment.