[vscode] the plugin reports `catch` but I'm using `ignoreCatch: true`
JounQin opened this issue · 10 comments
Version(if relevant): 2.16.3
Environment(if relevant):
Code(if relevant):
export const requirePkg = <T>(
plugin: string,
prefix: string,
filePath?: string,
): T => {
if (filePath && /^\.\.?([/\\]|$)/.test(plugin)) {
plugin = path.resolve(path.dirname(filePath), plugin)
}
prefix = prefix.endsWith('-') ? prefix : prefix + '-'
const packages = [
plugin,
plugin.startsWith('@')
? plugin.replace('/', '/' + prefix)
: prefix + plugin,
]
let error: Error
for (const pkg of packages) {
try {
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports, @typescript-eslint/no-unsafe-return
return require(pkg)
} catch (err) {
if (!error) {
error = err
}
}
}
throw error
}
Expected:
No warning reported
Actual:
Besides, this cli works correctly.
So the vscode plugin will not read type-coverage
configuration from package.json
? It doesn't make sense to me.
Then I have an idea that we should provide an option which presents whether to enable this plugin's function, reading type-coverage
configuration by default.
What means when no type-coverage
configuration found, this plugin should be disabled.
The CLI read package.json
from process.cwd()
, but the vscode plugin doesn't know where is your CLI process.cwd()
.
For example in a monorepo repository, you can run type-coverage
in the root directory, or in a package directory, they have different package.json
.
A lot of tools like eslint, tslint, prettier, etc have similar situation but they are just working when they are enabled specifically.
We can find up package.json
for type-coverage
configuration from current file to top workpace folder. (Of course, cache is required for better performance)
I checked what tslint does, default tslint.json and configured tslint.json is relative to the project root(tsconfig.json) rather than top workspace folder: https://github.com/Microsoft/typescript-tslint-plugin#configuration-options
That's weird then. I'm using a mono repo in workspace with multi projects.
Can you try https://github.com/mdx-js/eslint-mdx at https://github.com/mdx-js/eslint-mdx/blob/master/packages/eslint-mdx/src/parser.ts#L225?