Closed klonos closed 1 day ago
Another thing that I would like to please get an answer for is the following: does this feature allow complex code suggestions, or is it only "simple words". For instance, I have kept things simple, by adding the following:
"flagWords": [
"clicked_button: triggering_element"
],
However, once we get the overall flagWords/suggestions thing working, I would like to ideally have this instead:
"flagWords": [
"$form_state['clicked_button']: $form_state['triggering_element']"
],
Would that be something that works with this feature, or would it be "too confusing" and adding such complex words/suggestions would break things?
Another similar use case is the use of phrases instead of words: would things work with multiple words for the flagged word and suggestion(s), or do the word/suggestion pairs need to be single words? In other words, would something like this be expected to work? (notice the spaces in the items between the :
separator):
"flagWords": [
"say one thing: suggest another thing",
"singleword: suggestion with many words",
"multiple words forbidden: singlewordsuggestion"
],
PS: Admittedly, the above is not "spell-checking" per se, rather than using CSpell as a means to flag usage of deprecated things in code - however I still think that it'd be useful.
@klonos,
Thank you for the link to the repository. I took a quick look. It seems the cspell action is failing to load the configuration:
I think changing the path to the config to be relative might help. The error message is confusing and it should have failed the run, but it didn't. 🤔
- uses: actions/checkout@v4
name: Checkout code
- uses: streetsidesoftware/cspell-action@v5
name: Run CSpell
with:
incremental_files_only: true
- config: .cspell/cspell.json
+ config: "./.cspell/cspell.json"
You got the format correct. To test it, I added blacklist
to the README and misspelled Backddrop
.
npx cspell -c ./.cspell/cspell.json README.md --no-progress
To make things easier, I suggest either moving all of .cspell
to .config
or to add a cspell.json
file to the root or in .config
.
.config/cpsell.json
{
"import": ["../.cspell/cspell.json"]
}
If you do that, you can test with:
npx cspell .
Thanks for taking the time to have a look and make suggestions @Jason3S 🙏🏼 ...I'll have a crack at it and report back soon.
But as you said, it is odd that it is not failing in any obvious way - CSpell is otherwise working (as in it is detecting typos in our PRs and seems to be respecting words/files excluded or words added to the custom dictionary etc.).
...sorry, I just realized that the suggestion here is only for the command line, rather than the GitHub Action. I don't suppose there's any progress on https://github.com/streetsidesoftware/cspell-action/issues/1455 though (?).
Yes, thank you @Jason3S ...I will do that 👍🏼 (was actually looking at the release history last night to catch up on changes). I'll let you know once done.
@klonos,
I have release cspell-action@v6.5.0 that contains suggestions. Please let me know how well it works for you.
I'm going to close this for now, because cspell
is working as expected and suggestions were a feature request: cspell-action: Support suggestions #1455.
Kind regards, Jason
Thanks @Jason3S 🙏🏼 ...this is exciting! ...and to see how serious I was on actually testing this on first chance, I had this tab open in a dedicated screen, as a constant reminder 😁 ...just real life/work seems to be getting in the way of fun things.
Another thing that I would like to please get an answer for is the following: does this feature allow complex code suggestions, or is it only "simple words". For instance, I have kept things simple, by adding the following:
"flagWords": [ "clicked_button: triggering_element" ],
However, once we get the overall flagWords/suggestions thing working, I would like to ideally have this instead:
"flagWords": [ "$form_state['clicked_button']: $form_state['triggering_element']" ],
Would that be something that works with this feature, or would it be "too confusing" and adding such complex words/suggestions would break things?
Another similar use case is the use of phrases instead of words: would things work with multiple words for the flagged word and suggestion(s), or do the word/suggestion pairs need to be single words? In other words, would something like this be expected to work? (notice the spaces in the items between the
:
separator):"flagWords": [ "say one thing: suggest another thing", "singleword: suggestion with many words", "multiple words forbidden: singlewordsuggestion" ],
PS: Admittedly, the above is not "spell-checking" per se, rather than using CSpell as a means to flag usage of deprecated things in code - however I still think that it'd be useful.
I just realized that I didn't fully respond to this.
At the moment, there isn't any plan to support complex detection and suggestions. It has been asked for, but most of the requests were like "$form_state['clicked_button']: $form_state['triggering_element']"
which as you point out, is not a spelling issue, but more of a lint issue.
In addition, detecting multi word issues has challenges:
Given:
flagWords:
- all four one->all for one
Detecting the following would be easy:
One for all and all four one.
But what about when there is a line break?
One for all and all four one.
Or in code: 'one for all and all' + ' four one.'
?
Kind of Issue
Runtime - command-line tools (GitHub Action actually)
Description
Over in #4133 it is implied that something like this would work:
The above suggests a .yml format, however as per the documentation here: https://cspell.org/docs/getting-started/#1-create-a-configuration-file, a .json file can also be used. If I am thinking correctly, then the equivalent for the above in the .json file would be as follows:
Is that ^^ correct? Is the expected format
"<forbidden word>: <suggestions separated by commas>"
or something else?We currently have the following specified, but it does not seem to work (no suggestions offered):
Also in #4133, @gituserjava mentioned the following:
But I could not find any reference to that flag in the documentation of
flagWords
here: https://cspell.org/docs/forbidden-wordsSo, is
enableSuggestions
a thing, and if so, then how does it get set? Is it a thing that goes intocspell.json
, or somewhere else?cspell.json
Example Repository
https://github.com/backdrop/backdrop
Code of Conduct