Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vscode] the plugin reports catch but I'm using ignoreCatch: true #85

Open
JounQin opened this issue Feb 28, 2021 · 10 comments
Open

[vscode] the plugin reports catch but I'm using ignoreCatch: true #85

JounQin opened this issue Feb 28, 2021 · 10 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@JounQin
Copy link
Contributor

JounQin commented Feb 28, 2021

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:

image


Besides, this cli works correctly.

@plantain-00
Copy link
Owner

I can't reproduce this
屏幕快照 2021-03-01 14 32 51
屏幕快照 2021-03-01 14 32 41

@plantain-00 plantain-00 added question Further information is requested and removed Investigating labels Mar 1, 2021
@JounQin
Copy link
Contributor Author

JounQin commented Mar 1, 2021

So the vscode plugin will not read type-coverage configuration from package.json? It doesn't make sense to me.

@plantain-00 plantain-00 added Investigating and removed question Further information is requested labels Mar 1, 2021
@JounQin
Copy link
Contributor Author

JounQin commented Mar 1, 2021

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.

@plantain-00
Copy link
Owner

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.

@plantain-00 plantain-00 added question Further information is requested and removed Investigating labels Mar 1, 2021
@JounQin
Copy link
Contributor Author

JounQin commented Mar 1, 2021

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)

@plantain-00
Copy link
Owner

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

@plantain-00 plantain-00 added enhancement New feature or request help wanted Extra attention is needed and removed question Further information is requested labels Mar 1, 2021
@JounQin
Copy link
Contributor Author

JounQin commented Mar 15, 2021

@plantain-00 I have this option enabled in vscode but still not working

image

image

@plantain-00
Copy link
Owner

I can't reproduce it.
屏幕快照 2021-03-15 22 58 42
屏幕快照 2021-03-15 22 58 27

@JounQin
Copy link
Contributor Author

JounQin commented Mar 15, 2021

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?

@plantain-00
Copy link
Owner

Still can not reproduce it. The catch any is ignored and other any is reported.
屏幕快照 2021-03-16 21 32 33
屏幕快照 2021-03-16 21 33 01

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants