-
-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: file globs listed on the command line override files in the conf…
…ig. (#1117) * fix: file globs listed on the command line override files in the config. Fixes #1115 * test: Add a unit test for command line file overrides.
- Loading branch information
Showing
5 changed files
with
77 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/master/cspell.schema.json", | ||
// Version of the setting file. Always 0.1 | ||
"version": "0.2", | ||
// language - current active spelling language | ||
"language": "en", | ||
"files": [ | ||
"**/*.tex" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { runLint } from './lint'; | ||
import { CSpellApplicationConfiguration } from './CSpellApplicationConfiguration'; | ||
import { Emitters, Issue, ProgressFileComplete } from './emitters'; | ||
import * as path from 'path'; | ||
|
||
const samples = path.resolve(__dirname, '../samples'); | ||
const latexSamples = path.resolve(samples, 'latex'); | ||
|
||
describe('Linter Validation Tests', () => { | ||
test('globs on the command line override globs in the config.', async () => { | ||
const options = { root: latexSamples }; | ||
const logger = new Logger(); | ||
const rWithoutFiles = await runLint(new CSpellApplicationConfiguration([], options, logger)); | ||
expect(rWithoutFiles.files).toBe(4); | ||
const rWithFiles = await runLint(new CSpellApplicationConfiguration(['**/ebook.tex'], options, logger)); | ||
expect(rWithFiles.files).toBe(1); | ||
}); | ||
}); | ||
|
||
class Logger implements Emitters { | ||
log: string[] = []; | ||
issueCount = 0; | ||
errorCount = 0; | ||
debugCount = 0; | ||
infoCount = 0; | ||
progressCount = 0; | ||
issues: Issue[] = []; | ||
|
||
issue = (issue: Issue) => { | ||
this.issues.push(issue); | ||
this.issueCount += 1; | ||
const { uri, row, col, text } = issue; | ||
this.log.push(`Issue: ${uri}[${row}, ${col}]: Unknown word: ${text}`); | ||
}; | ||
|
||
error = (message: string, error: Error) => { | ||
this.errorCount += 1; | ||
this.log.push(`Error: ${message} ${error.toString()}`); | ||
return Promise.resolve(); | ||
}; | ||
|
||
info = (message: string) => { | ||
this.infoCount += 1; | ||
this.log.push(`Info: ${message}`); | ||
}; | ||
|
||
debug = (message: string) => { | ||
this.debugCount += 1; | ||
this.log.push(`Debug: ${message}`); | ||
}; | ||
|
||
progress = (p: ProgressFileComplete) => { | ||
this.progressCount += 1; | ||
this.log.push(`Progress: ${p.type} ${p.fileNum} ${p.fileCount} ${p.filename}`); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters