[doc] how to add new linting rules#2551
Conversation
| * [Analyzer (FlowrAnalyzer, Projects, ...)](https://github.com/flowr-analysis/flowr/wiki/Analyzer) | ||
| * [Engines](https://github.com/flowr-analysis/flowr/wiki/Engines) | ||
| * [Linting R](https://github.com/flowr-analysis/flowr/wiki/Linter) | ||
| * [Create Linting Rules](https://github.com/flowr-analysis/flowr/wiki/Create-Linting-Rules) |
There was a problem hiding this comment.
Please remove it in the sidebar and use ctx.linkPage to add pointers to:
- link to this page in the
Linterwiki page - link to this page in the FAQ
|
|
||
| ## Step 1: Create the new rule file | ||
|
|
||
| To add a new linting rule, create a separate file for it under [\`src/linter/rules/\`](${RemoteFlowrFilePathBaseRef}/src/linter/rules/) |
There was a problem hiding this comment.
please avoid these hardcoded constructions of paths, either reference a file within or just reference the objects!
|
|
||
| For new rules, the central interface is ${ctx.link('LintingRule')}. The relevant type parameters are: | ||
|
|
||
| ${codeBlock('typescript', 'LintingRule<Result, Metadata, Config>')} |
There was a problem hiding this comment.
I'd argue this should be documented in the code and not here in the wiki
| return ` | ||
| # Create Linting Rules | ||
|
|
||
| This page explains how to add a new linting rule to flowR. |
There was a problem hiding this comment.
please also add a pointer to the linter wiki here
|
|
||
| | Part | Purpose | | ||
| |---|---| | ||
| | ${ctx.link('LintingRule::createSearch')} | Creates a flowR search query that selects potentially relevant program elements. | |
There was a problem hiding this comment.
likewise, this should print ctx.doc instead of adding a new textual explanation :D
to stay consistent with other wikis I'd also prefer to just have bullet points here and no table
|
|
||
| ## Step 5: Add tests for the rule | ||
|
|
||
| New rules should be covered by tests in [\`src/test/functionality/linter/\`](${RemoteFlowrFilePathBaseRef}/test/functionality/linter/). |
There was a problem hiding this comment.
- Likewise with the paths please do not use them like this.
- Also the tests must follow the existing pattern (of adding
lint-<rule>.test.tsto the linter rule name). - and I think it is good to mention that these tests are automatically used to generate examples in the linter wiki, which are extracted from
assertLintercalls. They can also use/* @ignore-in-wiki */to ignore some tests in the wiki.
| ## Step 5: Add tests for the rule | ||
|
|
||
| New rules should be covered by tests in [\`src/test/functionality/linter/\`](${RemoteFlowrFilePathBaseRef}/test/functionality/linter/). | ||
| `; |
There was a problem hiding this comment.
there could be another pointer that tells people how to rerun the wiki generation and explore the rule documentation
| } as const satisfies LintingRule<MyRuleResult, MyRuleMetadata, MyRuleConfig>;`)} | ||
|
|
||
|
|
||
| ## Step 4: Register the rule |
There was a problem hiding this comment.
there is a step missing, before the tests but after the registration, users must add a new rule block in the wiki-linter.ts
No description provided.