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

[Bug]: doesn''t in yaml is not recognized correctly #5150

Open
2 tasks done
JounQin opened this issue Jan 8, 2024 · 4 comments
Open
2 tasks done

[Bug]: doesn''t in yaml is not recognized correctly #5150

JounQin opened this issue Jan 8, 2024 · 4 comments

Comments

@JounQin
Copy link

JounQin commented Jan 8, 2024

Info

Kind of Issue

  • runtime - command-line tools

Which Tool or library

  • cspell -- the command-line spelling tool

Which Version

Version: 7.3.2

Bug Description

Describe the bug

doesn''t means doesn't in yaml

To Reproduce

Steps to reproduce the behavior:

N/A

Expected behavior

No error

Screenshots

doesn is reported as unknown word

Additional context

N/A

cspell.json

N/A

Example Repository (Optional)

N/A

@Jason3S
Copy link
Collaborator

Jason3S commented Jan 8, 2024

@JounQin,

Thank you. I hadn't realized that is how single quotes are embedded in a single quoted string.

At the moment, the spell checker isn't using a sophisticated parser, it basically treats the whole file as a text document. The plan is to allow custom parser per file type.

As a work around, it is possible to add doesn''t to a word list.

items:
  - name: name
    description: 'This path / doesn''t exist'

# cspell:ignore doesn''t

or

cspell.config.yaml

# yaml-language-server: $schema=https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json

dictionaryDefinitions:
  - name: special-yaml-words
    words:
      - doesn''t
      - hasn''t
      - isn''t
languageSettings:
  - languageId: yaml
    locale: en,en-US,en-GB
    dictionaries:
      - special-yaml-words

@JounQin
Copy link
Author

JounQin commented Jan 8, 2024

Yeah, I'm using disable comment for workaround. And for cspell core it could treat those words as known for yaml files?

@Jason3S
Copy link
Collaborator

Jason3S commented Jan 11, 2024

@JounQin,

I have to think about how to do it. The core is language and file type agnostic. Everything is configuration driven.

There are two approaches that could work:

  1. Parser
    The spell checker supports a parser that can be used to transform text before it is spell checked. This is how the ESLint plug-in works. But, the parser is not currently a public API. The idea with the parser is to also annotate blocks of text by tagging them as string, identifier, comment, import, keyword, field name, etc. These tags could then be used to have different spell checking rules like field names should be in English, but string values should be in French for i18n files. In this case, the Yaml parser would transform 'doesn''t' into doesn't before it is checked.
  2. Using a tryMap. A tryMap is used to replace equivalent character sequences when checking a dictionary. For example: ä with ae or æ when searching for word matches. This is currently supported at the dictionary level, meaning each dictionary, German, French, English, have their own tryMap, but it is not currently available at the file type level.

Both of these approaches have their merits. My preference is to get option 1, the parser, finished, but it is the longest away from being finished. Option 2, is much easier, since most of the support is already there.

If you have any ideas on funding, they would be most welcome.

By the way, thank you for synckit, I use it with the ESlint plugin.

@JounQin
Copy link
Author

JounQin commented Jan 11, 2024

I also prefer option 1, this issue is not in a emergency status, it could be a known issue for now, but with a correct parser, a lot of hidden issues will be fixed at once.

Challenging but worthful.

I can do some help if you want any from me.


By the way, thank you for synckit, I use it with the ESlint plugin.

That's my pleasure. 🩷

I definitely should add a section Who is using synckit in its README.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants