cucumber / monaco

Configure Monaco editor to use cucumber-language-service
MIT License
16 stars 4 forks source link

Strange behavior of the linter #125

Closed papipsycho closed 6 months ago

papipsycho commented 7 months ago

👓 What did you see?

the linter return When something as en error when it shouldn't be

✅ What did you expect to see?

i shouldn't considair as an error

📦 Which tool/library version are you using?

you can do the test on the live demo

🔬 How could we reproduce it?

go on the live demo and you will see And this is an undefined step, i f you want you can replace it with anything else everytime this line will appear in error

Screenshot 2024-04-16 at 02 59 27

📚 Any additional context?

No response

papipsycho commented 7 months ago

Oh ok i understood how is work, so you first check if the function is written or not,

there is anyway to implement a simple linter with getGherkinDiagnostics ?

kieran-ryan commented 7 months ago

Hi @papipsycho, welcome 👋

Oh ok i understood how is work, so you first check if the function is written or not,

there is anyway to implement a simple linter with getGherkinDiagnostics ?

The functionality is perhaps clearer when used through the VSCode extension - as we can see the step definitions being matched against; but effectively with this Monaco demo, it demonstrates the functionality of being able to mark steps as undefined or not; though one could replace the diagnostics with a call to another linter for example - providing it adhered to the same API. The diagnostics implementation for Cucumber Monaco is implemented in the Cucumber Language Service.

So in summary, you could replace getGherkinDiagnostics with a call to another linter. Could you advise what functionalities or linting rules you would desire?

https://github.com/cucumber/monaco/blob/77c220da9271804a44e6196a7d6c8fcfb22bcd98/src/configureMonaco.ts#L79-L93

papipsycho commented 7 months ago

Thanks for your answer.

i want to check if the gherkin written by the user is correct or not, which is not necessarily linked with the step definition

For instance, I want to show an error in case of :

Scenario Outline: login with user and password
When i on login page
Then i set the user and password
Then i click on the button sign in

this should give an error cause is Scenario Outline without example

and I checked deeply in the function getGherkinDiagnostics which unfortunately doesn't have an option to disable the check into the step definition

kieran-ryan commented 6 months ago

Gotcha. Configuration for disabling diagnostics is presently unsupported - though could be turned off by overriding that API to not return any diagnostics.

Likewise on listing whether a Scenario Outline does not contain an examples table. There are gherkin linters that support this functionality which could be integrated through some effort; but functionality is not integrated in the Language Service.

You raise valid requests - if something you'd like see, would welcome a PR if you have a direction to resolve. Thanks for your interest in the project! 👍

kieran-ryan commented 6 months ago

Closing as behaviour was clarified. Feel free to raise an issue for any feature requests - thanks for your interest in the project @papipsycho!