vscode-spell-checker icon indicating copy to clipboard operation
vscode-spell-checker copied to clipboard

Ignore variables from external libraries (import node_modules).

Open infacto opened this issue 4 years ago • 8 comments

Imported variables should be ignored. e.g.

import { MatDatepickerInputEvent } from '@angular/material/datepicker';

someMethod(event: MatDatepickerInputEvent);

MatDatepickerInputEvent comes form an external library. In this case Angular from node_modules and the word "Datepicker" is a spelling issue. These variables should be ignored in the whole file. So ignoreRegExpList etc. will not work.

Do you know the ESLint TypeScript Naming Convention rules? This plugin can detect such import and ignores it. I have no idea how it works, but it may help to implement it.

The goal of this issue is to display only spelling issues of own sources what can be changed. Not from 3rd party libs.

infacto avatar Apr 12 '21 10:04 infacto

This would break the tool for those wanting to spell check their aliases. import { A as Badlynamed } from ...

Tatsh avatar Apr 19 '21 00:04 Tatsh

It should also ignore method calls to libraries when typescript says they're valid.

shayded-exe avatar Mar 27 '22 03:03 shayded-exe

@rshea0, @Tatsh, @infacto

I know it is not the same, but we have recently released an ESLint plugin that does what you ask: @cspell/eslint-plugin - npm

Feedback is welcome.

Note: Full support is planned, but the ESLint plugin is a good stop-gap option.

The plugin correctly checks import aliases, like import { A as Badlynamed } from ...

Jason3S avatar Mar 27 '22 06:03 Jason3S

@Jason3S Thanks, I'll check it out!

shayded-exe avatar Mar 27 '22 06:03 shayded-exe

There is a way to ignore package names?

import { mapState } from 'pinia';

Here, pinia is detected as error, but package names are not always good-spelled words and does not require spell-checking.

nelson6e65 avatar Nov 03 '22 12:11 nelson6e65

There is a way to ignore package names?

import { mapState } from 'pinia';

Here, pinia is detected as error, but package names are not always good-spelled words and does not require spell-checking.

You can use the package Jason mentioned above. https://www.npmjs.com/package/@cspell/eslint-plugin

shayded-exe avatar Nov 04 '22 21:11 shayded-exe

Oh, that should work for JavaScript modules.

There's one for PHP too? 👀

nelson6e65 avatar Nov 04 '22 23:11 nelson6e65

@nelson6e65,

It is possible to tell cspell to use the composer.json file as if it was a dictionary.

Example cspell.json:

{
    "dictionaries": ["php", "custom-dictionary", "fullstack", "html", "composer"],
    "ignorePaths": ["vendor/**", "*.phar", "*.lock"],
    "dictionaryDefinitions": [
        {
            "name": "custom-dictionary",
            "path": "./custom-dictionary.txt",
            "addWords": true
        },
        {
            "name": "composer",
            "path": "./composer.json",
            "type": "C",
            "addWords": false
        }
    ]
}

"type": "C", tells cspell to split out words from "code".

Jason3S avatar Nov 05 '22 07:11 Jason3S