-
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: make sure to export all needed cspell types. (#1006)
* ci: spell check `.github` as well. * Update cspellrc.json * Update cspell.yml * Update cspell-dict.txt * Update test.yml * Update cspell.json * fix: make sure the types are exported. * dev: add some tests * testing: update cspell integration test
- Loading branch information
Showing
10 changed files
with
163 additions
and
24 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 |
---|---|---|
@@ -1,23 +1,13 @@ | ||
name: cSpell TS/MD | ||
on: | ||
pull_request: | ||
paths: | ||
- "**/*.md" | ||
- "**/*.ts" | ||
- "cspell-dict.txt" | ||
- "cspell.json" | ||
push: | ||
branches: | ||
- master | ||
paths: | ||
- "**/*.md" | ||
- "**/*.ts" | ||
- "cspell-dict.txt" | ||
- "cspell.json" | ||
|
||
jobs: | ||
cspell: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: npx cspell "**/*.*" | ||
- run: npx cspell@latest "**/*" |
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
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,7 @@ | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/master/cspell.schema.json", | ||
"version": "0.2", | ||
"name": "Run Config", | ||
"files": ["**/*", ".github/**/*"], | ||
"import": ["./cspell.json"] | ||
} |
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 |
---|---|---|
@@ -1,7 +1,62 @@ | ||
import * as index from './index'; | ||
|
||
// Make sure the types are exported. | ||
import { CSpellApplicationOptions, RunResult, Emitters, Issue, ProgressFileComplete } from './index'; | ||
|
||
describe('Validate index.ts', () => { | ||
test('index', () => { | ||
expect(index).toBeDefined(); | ||
}); | ||
|
||
test('quick run', async () => { | ||
const appOptions: CSpellApplicationOptions = {}; | ||
const logger = new Logger(); | ||
|
||
const result: RunResult = await index.lint(['*.md'], appOptions, logger); | ||
|
||
expect(result).toEqual( | ||
expect.objectContaining({ | ||
errors: 0, | ||
issues: 0, | ||
}) | ||
); | ||
}); | ||
}); | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
export * from './application'; | ||
export * from './emitters'; | ||
export { BaseOptions, CSpellApplicationOptions, TraceOptions } from './options'; | ||
export { RunResult } from './lint'; |
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 |
---|---|---|
@@ -1,14 +1,75 @@ | ||
import { assert } from 'console'; | ||
import { checkText, lint, trace } from 'cspell/dist/application'; | ||
import { | ||
checkText, | ||
lint, | ||
trace, | ||
Emitters, | ||
Issue, | ||
ProgressFileComplete, | ||
CSpellApplicationOptions, | ||
RunResult, | ||
} from 'cspell'; | ||
import { run } from 'cspell/dist/app'; | ||
|
||
console.log('start'); | ||
async function test() { | ||
console.log('start'); | ||
|
||
/** | ||
* The main goal here is to make sure it compiles. The unit tests are validation that it compiled as expected. | ||
*/ | ||
const functions = [checkText, lint, trace, run]; | ||
/** | ||
* The main goal here is to make sure it compiles. The unit tests are validation that it compiled as expected. | ||
*/ | ||
const functions = [checkText, lint, trace, run]; | ||
|
||
functions.forEach((fn) => assert(typeof fn === 'function', "typeof %o === 'function'", fn)); | ||
functions.forEach((fn) => assert(typeof fn === 'function', "typeof %o === 'function'", fn)); | ||
|
||
console.log('done'); | ||
const logger = new ConsoleLogger(); | ||
|
||
const options: CSpellApplicationOptions = {}; | ||
|
||
const result: RunResult = await lint(['*.md'], options, logger); | ||
assert(result.errors === 0); | ||
assert(result.issues === 0); | ||
assert(result.files === 2); | ||
|
||
console.log(JSON.stringify(result)); | ||
|
||
console.log('done'); | ||
} | ||
|
||
class ConsoleLogger implements Emitters { | ||
log: string[] = []; | ||
issueCount = 0; | ||
errorCount = 0; | ||
debugCount = 0; | ||
infoCount = 0; | ||
progressCount = 0; | ||
issues: Issue[] = []; | ||
|
||
issue = (issue: Issue) => { | ||
this.issueCount += 1; | ||
const { uri, row, col, text } = issue; | ||
console.log(`Issue: ${uri}[${row}, ${col}]: Unknown word: ${text}`); | ||
}; | ||
|
||
error = (message: string, error: Error) => { | ||
this.errorCount += 1; | ||
console.error(`Error: ${message} ${error.toString()}`); | ||
return Promise.resolve(); | ||
}; | ||
|
||
info = (_message: string) => { | ||
this.infoCount += 1; | ||
// console.info(`Info: ${message}`); | ||
}; | ||
|
||
debug = (_message: string) => { | ||
this.debugCount += 1; | ||
// console.debug(`Debug: ${message}`); | ||
}; | ||
|
||
progress = (p: ProgressFileComplete) => { | ||
this.progressCount += 1; | ||
console.error(`Progress: ${p.type} ${p.fileNum} ${p.fileCount} ${p.filename}`); | ||
}; | ||
} | ||
|
||
test(); |