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]: --config flag does not work #4750

Closed
4 tasks done
Zamiell opened this issue Aug 26, 2023 · 7 comments
Closed
4 tasks done

[Bug]: --config flag does not work #4750

Zamiell opened this issue Aug 26, 2023 · 7 comments

Comments

@Zamiell
Copy link
Contributor

Zamiell commented Aug 26, 2023

Info

Kind of Issue

  • runtime - command-line tools

Which Tool or library

  • cspell -- the command-line spelling tool

Which Version

Version: 7.0.1

Issue with supporting library?

  • No

OS:

  • Windows

version:

10

Bug Description

Describe the bug

The --config command line flag does not work.

To Reproduce

Steps to reproduce the behavior:

mkdir test
cd test
echo "misspelledword" > README.md
echo '{ "words": ["misspelledword"] }' > cspell.json
npx cspell README.md # Results in 0 errors, as expected.
echo "{}" > cspell.temp.json
npx cspell README.md --config cspell.temp.json # Results in 0 errors, even though "misspelledword" should be an illegal word.

Here, CSpell seems to ignore the --config flag and instead use the config at the default path. So maybe we need to turn off the "find default config" logic when the --config flag is specified?

@Jason3S
Copy link
Collaborator

Jason3S commented Aug 27, 2023

@Zamiell,

Thank you for the excellent example.

CSpell will search for the nearest CSpell config file for every file checked.

Please try:

echo '{"noConfigSearch": true}' > cspell.temp.json

@Zamiell
Copy link
Contributor Author

Zamiell commented Aug 27, 2023

Ah, that does work, thank you.

I propose that the noConfigSearch option should be automatically enabled when the CLI is invoked with the --config flag. What do you think about that?

@Zamiell
Copy link
Contributor Author

Zamiell commented Sep 13, 2023

@Jason3S any update on this?

@Jason3S
Copy link
Collaborator

Jason3S commented Sep 14, 2023

@Zamiell,

I don't think it is a good idea to change the behavior. Although I see how its current behavior was unexpected.

The original idea, was the local config has more knowledge of the files being checked than a global config.

This allows for things like specifying the language.

For example:

cspell.config.yaml - language: en
i18n/de/cspell.config.yaml - language: de
i18n/de/README.md

At the root:

  • cspell "**/*.md", would use German when spellchecking i18n/de/README.md.

But by automatically turning on noConfigSearch, the following would break:

  • cspell --config cspell.config.yaml "**/*.md" would use English instead of German.

Even though both invocations of cspell use cspell.config.yaml, the behavior would be different.

I propose added two new options: --no-config-search and --config-root.

  • --no-config-search would just enabled adding the behavior to the command line.
  • --stop-config-search-at <dir> would tell the spellchecker to not look further up the hierarchy than the specified <dir>. It also makes sense that more than one stop could be wanted.

@Zamiell
Copy link
Contributor Author

Zamiell commented Sep 14, 2023

Sounds good, thank you!

@Jason3S
Copy link
Collaborator

Jason3S commented Oct 15, 2023

I'm going to close this, since #4836 will take care of the remaining issue.

@Jason3S Jason3S closed this as completed Oct 15, 2023
Copy link
Contributor

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants