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

Don't report words from external libs (node_modules). Ignore path list. #1253

Open
infacto opened this issue May 19, 2021 · 2 comments
Open
Labels
enhancement File Parsing File Parsing is needed.
Milestone

Comments

@infacto
Copy link

infacto commented May 19, 2021

It should not report "Unknown word"s when the variable comes from an external source. For example:
I installed a npm package (node_modules) and import it into Angular. In this case cSpell should ignore what.

We could define some paths to ignore the source. To be neutral to the workspace. And set some defauls like "node_modules".
I don't know how cSpell works. I guess cSpell currently have no way to know where a variable comes from.

import { SomeEnum } from `external-lib`;

const myValue = SomeEnum.UnknownWordWhatTriggersCodeSpellMuahahaha;

I don't want to set this word into my ignore list. It's would be better if we can ignore that node_modules.

Btw. The ESLint plugin TypeScript Naming Convention can detect external libs and ignores it. Maybe this helps? But I have no idea how cSpell works and how to implement such feature.

I know the setting cSpell.ignorePaths. And there is already set nore_modules. But this does not work with imported variables.


My current workaround is to ignore all imports by adding this to the ignoreRegExpList: "^import.+$"
I could add more details to this regex to be more unique. ...
I think this is ok, since I still see spelling issues on the related files.

But note: This does not fix the further use of an external imported variable. This is only a solution for the import itself.
And this workaround also obfuscates issues in file names. Ok, this could be fixed by check for dots in path too. External imports does not have a dot after the quote (this is not 100% the truth I know. You also can have absolute path. Therefore e.g. src). Like "^import((?!src|\\.).)*$"

@Jason3S
Copy link
Collaborator

Jason3S commented Aug 9, 2021

Related to #974

@Jason3S Jason3S removed the new issue label Oct 9, 2021
@Jason3S
Copy link
Collaborator

Jason3S commented Mar 12, 2022

@infacto,

The new @cspell/eslint-plugin - npm will do most of what you ask. But it does not yet support SomeEnum.UnknownWordWhatTriggersCodeSpellMuahahaha.

It does support:

import { muahahaha } from 'external-lib';

muahahaha('express twisted glee');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement File Parsing File Parsing is needed.
Projects
None yet
Development

No branches or pull requests

2 participants