streetsidesoftware / vscode-spell-checker

A simple source code spell checker for code
https://streetsidesoftware.github.io/vscode-spell-checker/
Other
1.44k stars 130 forks source link

[Bug]: false positive with package.json #2864

Closed Zamiell closed 1 year ago

Zamiell commented 1 year ago

Description

The CSpell VSCode extension shows a blue squiggly line under the word "heroicons" inside of a "package.json" file.

However, when running CSpell from command line, no errors are triggered.

This is a bug because I expect the output of the VSCode extension to exactly match that of the command line tool.

Steps to Reproduce

git clone git@github.com:Zamiell/isaac-streaking.git
cd isaac-streaking
git checkout caf2be00ec8da6f211f746ed65be26cd0d476184
yarn install
npx cspell package.json # Notice that there are no errors.
code .

Then, open "package.json" in VSCode and observe that there is a blue squiggly underline.

Jason3S commented 1 year ago

@Zamiell,

I was not able to reproduce this.

But, it might be related to #2666. I hope #2868 will help with this sort of issue.

Zamiell commented 1 year ago

Here's another reproduction:

git clone git@github.com:Zamiell/isaac-among-us.git
cd isaac-among-us
yarn install
npx cspell --no-progress . # Notice that there are no errors.
code .

Then, do Ctrl + P, open "SabotageType.ts" in VSCode and observe that there is a blue squiggly underline.

Jason3S commented 1 year ago

@Zamiell,

Do you mean comms?

image

That is because comms was recently added to the dictionary and the extension has not yet been updated.

Zamiell commented 1 year ago

Ah. Shouldn't the two be updated at the same time to prevent unfixable errors like this?

Zamiell commented 1 year ago

@Jason3S Can you respond to my previous comment?

Additionally, I found the same bug yet again with a trivial reproduction that does not involve cloning any existing repositories:

mkdir foo
cd foo
npm init --yes
npm install --save cspell clsx
npx cspell package.json # Notice that there are 0 errors.
code . # Notice that if you open "package.json", there is a blue squiggly line in VSCode.

Please let me know if this reproduction works for you.

Jason3S commented 1 year ago

@Zamiell,

I try to keep the code extension up to date with the cspell releases, but it is going though a major update at the moment, hence a delayed release.

Given that, if cspell is installed in the repository, the extension should pick up the latest dictionaries. Then the results would match as long as no new dictionaries were added.

[edit] The latest dictionaries will be loaded only if they are explicitly imported. See below:

cspell.config.yaml

import:
  - "@cspell/cspell-bundled-dicts"
Jason3S commented 1 year ago

Additionally, I found the same bug yet again with a trivial reproduction that does not involve cloning any existing repositories:

mkdir foo
cd foo
npm init --yes
npm install --save cspell clsx
npx cspell package.json # Notice that there are 0 errors.
code . # Notice that if you open "package.json", there is a blue squiggly line in VSCode.

Please let me know if this reproduction works for you.

It doesn't pick up the latest dictionaries from node_modules. This is by design, it searches for the dictionary from the place it was imported. Since the extension imported it from the extension directory, it has the old copy.

This is a workaround:

cspell.config.yaml

import:
  - "@cspell/cspell-bundled-dicts"
Zamiell commented 1 year ago

Awesome, thanks Jason. Thank you for your work on CSpell; I eagerly await version 4.0!

github-actions[bot] commented 11 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.