@fimbul/mithotyn
Advanced tools
Comparing version 0.24.0-dev.20210218 to 0.24.0-dev.20210219
31
index.js
@@ -28,7 +28,7 @@ "use strict"; | ||
const lsPlugin = r('@fimbul/wotan/language-service'); | ||
if (lsPlugin.version !== '1') // in case we need to make breaking changes to the plugin API | ||
if (lsPlugin.version !== '1' && lsPlugin.version !== '2') // in case we need to make breaking changes to the API | ||
throw new Error(`Unsupported version of '@fimbul/wotan'. Consider updating '${config.name}'.`); | ||
log('setting up plugin'); | ||
plugin = new lsPlugin.LanguageServiceInterceptor(config, project, serverHost, languageService, r, log); | ||
const proxy = createProxy(languageService, plugin, log); | ||
const proxy = createProxy(languageService, plugin, log, lsPlugin.version); | ||
if (!('getSupportedCodeFixes' in languageService) && typeof plugin.getSupportedCodeFixes === 'function') { | ||
@@ -56,16 +56,21 @@ // TODO avoid monkey-patching: https://github.com/Microsoft/TypeScript/issues/28966#issuecomment-446729292 | ||
}; | ||
function createProxy(ls, interceptor, log) { | ||
function createProxy(ls, interceptor, log, version) { | ||
const proxy = Object.create(null); | ||
for (const method of Object.keys(ls)) { | ||
if (typeof interceptor[method] === 'function') { | ||
proxy[method] = (...args) => { | ||
const prev = ls[method](...args); | ||
try { | ||
return interceptor[method](prev, ...args); | ||
} | ||
catch (e) { | ||
log(`interceptor for '${method}' failed: ${e && e.message}`); | ||
return prev; | ||
} | ||
}; | ||
if (version === '1') { | ||
proxy[method] = (...args) => { | ||
const prev = ls[method](...args); | ||
try { | ||
return interceptor[method](prev, ...args); | ||
} | ||
catch (e) { | ||
log(`interceptor for '${method}' failed: ${e === null || e === void 0 ? void 0 : e.message}`); | ||
return prev; | ||
} | ||
}; | ||
} | ||
else { | ||
proxy[method] = interceptor[method].bind(interceptor); | ||
} | ||
} | ||
@@ -72,0 +77,0 @@ else { |
{ | ||
"name": "@fimbul/mithotyn", | ||
"version": "0.24.0-dev.20210218", | ||
"version": "0.24.0-dev.20210219", | ||
"description": "TypeScript LanguageService plugin for the Fimbullinter project", | ||
@@ -5,0 +5,0 @@ "main": "index", |
@@ -57,3 +57,3 @@ # Mithotyn | ||
* `displayErrorsAsWarnings: boolean`: Report findings with severity `error` as warning to make them distinguishable from real type errors (e.g. green instead of red squiggles in VS Code) | ||
* `displayErrorsAsWarnings: boolean`: Report findings with severity `error` as warning to make them distinguishable from real type errors (e.g. yellow instead of red squiggles in VS Code) | ||
@@ -99,3 +99,2 @@ Example: | ||
* Currently only works with TypeScript installed in your workspace, see [Usage in VS Code](#usage-in-vs-code) | ||
* doesn't provide code fixes for findings | ||
* doesn't validate `.wotanrc.yaml` and `.fimbullinter.yaml` files | ||
@@ -102,0 +101,0 @@ * doesn't refresh lint findings if configuration changes; you need to reopen or change the file |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20326
81
104