Skip to content

Commit

Permalink
feat: add vscode configuration of not validating js file
Browse files Browse the repository at this point in the history
  • Loading branch information
plantain-00 committed Feb 28, 2021
1 parent 20ab419 commit 6a11a9a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion packages/plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ function init(modules: { typescript: typeof tsserverlibrary }) {
const proxy: tsserverlibrary.LanguageService = {
...info.languageService,
getSemanticDiagnostics(fileName) {
const config = info.config as LintOptions & { doNotValidateJavascriptFile?: boolean }
const prior = info.languageService.getSemanticDiagnostics(fileName)
if (config.doNotValidateJavascriptFile && (fileName.endsWith('.js') || fileName.endsWith('.jsx'))) {
return prior
}
const result = lintSync(
info.project.getCompilerOptions(),
info.project.getRootFiles(),
{
...(lintOptions || info.config as LintOptions),
...(lintOptions || config),
files: [fileName],
oldProgram,
},
Expand Down
4 changes: 4 additions & 0 deletions packages/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
"typeCoverage.ignoreCatch": {
"type": "boolean",
"description": "ignore catch."
},
"typeCoverage.doNotValidateJavascriptFile": {
"type": "boolean",
"description": "do not validate javascript file."
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion packages/vscode/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ function synchronizeConfiguration(api: API) {
const configuration = vscode.workspace.getConfiguration(configurationSection)
const options = {
strict: configuration.get('strict'),
ignoreCatch: configuration.get('ignoreCatch')
ignoreCatch: configuration.get('ignoreCatch'),
doNotValidateJavascriptFile: configuration.get('doNotValidateJavascriptFile'),
}
api.configurePlugin(configId, options)
}
Expand Down

0 comments on commit 6a11a9a

Please sign in to comment.