+
Skip to content
This repository was archived by the owner on Aug 31, 2023. It is now read-only.

docs(rome_js_analyze): improve CONTRIBUTING and code gen #4278

Merged
merged 1 commit into from
Mar 8, 2023
Merged

docs(rome_js_analyze): improve CONTRIBUTING and code gen #4278

merged 1 commit into from
Mar 8, 2023

Conversation

Conaclos
Copy link
Contributor

@Conaclos Conaclos commented Mar 8, 2023

Summary

This PR improves the internal documentation for the analyzer in several ways:

  • Improve the flow
  • Fix title hierarchy issues
  • Shorter sentences
  • More consistent formatting
  • Fix space issues

The PR also marginally improve the code generation for just new-lintrule.

Test Plan

No change.

@netlify
Copy link

netlify bot commented Mar 8, 2023

Deploy Preview for docs-rometools canceled.

Built without sensitive environment variables

Name Link
🔨 Latest commit 99c52a4
🔍 Latest deploy log https://app.netlify.com/sites/docs-rometools/deploys/6408998e15b12c0008a93fc6

@Conaclos Conaclos merged commit b472367 into rome:main Mar 8, 2023
will use:

```shell
> just new-lintrule crates/rome_js_analyze/src/analyzers/nursery myRuleName
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing that could be improved is to have a link to how to install just. We take for granted that users can use it as it is.

Comment on lines +28 to +39
When implementing **new rules**, they have to be implemented under the group `nursery`.
New rules should always be considered unstable/not exhaustive.

In addition to selecting a group, rules may be flagged as `recommended`.
The **recommended rules** are enabled in the default configuration of the _Rome_ linter.
As a general principle, a recommended rule should catch actual programming errors.
For instance detecting a coding pattern that will throw an exception at runtime.
Pedantic rules that check for certain unwanted patterns but may have high false positive rates,
should be left off from the recommended set.
Rules intended to be recommended should be flagged as such even if they are still part of the `nursery` group,
as unstable rules are only enabled by default on unstable builds.
This gives to the project time to test the rule, find edge cases, etc.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
When implementing **new rules**, they have to be implemented under the group `nursery`.
New rules should always be considered unstable/not exhaustive.
In addition to selecting a group, rules may be flagged as `recommended`.
The **recommended rules** are enabled in the default configuration of the _Rome_ linter.
As a general principle, a recommended rule should catch actual programming errors.
For instance detecting a coding pattern that will throw an exception at runtime.
Pedantic rules that check for certain unwanted patterns but may have high false positive rates,
should be left off from the recommended set.
Rules intended to be recommended should be flagged as such even if they are still part of the `nursery` group,
as unstable rules are only enabled by default on unstable builds.
This gives to the project time to test the rule, find edge cases, etc.
When implementing **new rules**, they have to be implemented under the group `nursery`.
New rules should always be considered unstable/not exhaustive.
In addition to selecting a group, rules may be flagged as `recommended`.
The **recommended rules** are enabled in the default configuration of the _Rome_ linter.
As a general principle, a recommended rule should catch actual programming errors.
For instance, detecting a coding pattern that will throw an exception at runtime.
Pedantic rules that check for specific unwanted patterns but may have high false positive rates
should be left off from the recommended set.
Rules intended to be recommended should be flagged as such even if they are still part of the `nursery` group,
as unstable rules are only enabled by default on unstable builds.
This gives the project time to test the rule, find edge cases, etc.

Comment on lines +43 to +45
When creating or updating a lint rule, you need to be aware that there's a lot of generated code inside our toolchain.
Our CI makes sure that this code is not out of sync and fails otherwise.
See the [code generation section](#code-generation) for more details.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
When creating or updating a lint rule, you need to be aware that there's a lot of generated code inside our toolchain.
Our CI makes sure that this code is not out of sync and fails otherwise.
See the [code generation section](#code-generation) for more details.
When creating or updating a lint rule, you need to be aware that there's a lot of generated code inside our toolchain.
Our CI ensures this code is not out of sync and fails otherwise.
See the [code generation section](#code-generation) for more details.

Comment on lines +110 to +112
While implementing the diagnostic, please keep [Rome's technical principals](https://rome.tools/#technical) in mind.
This function is called of every signal emitted by the `run` function, and it may return
zero or one diagnostic.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
While implementing the diagnostic, please keep [Rome's technical principals](https://rome.tools/#technical) in mind.
This function is called of every signal emitted by the `run` function, and it may return
zero or one diagnostic.
While implementing the diagnostic, please keep [Rome's technical principals](https://rome.tools/#technical) in mind.
This function is called for every signal emitted by the `run` function, and it may return
zero or one diagnostic.

Comment on lines +123 to +126
This function is called of every signal emitted by the `run` function.
It may return zero or one code action.
When returning a code action, you will need to pass `category` and `applicability` fields.
`category` must be `ActionCategory::QuickFix`, while `applicability` must be `Applicability:MaybeIncorrect`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This function is called of every signal emitted by the `run` function.
It may return zero or one code action.
When returning a code action, you will need to pass `category` and `applicability` fields.
`category` must be `ActionCategory::QuickFix`, while `applicability` must be `Applicability:MaybeIncorrect`.
This function is called for every signal emitted by the `run` function.
It may return zero or one code action.
When returning a code action, you must pass the `category` and `applicability` fields.
`category` must be `ActionCategory::QuickFix`, while `applicability` must be `Applicability:MaybeIncorrect`.

must be seems to be a stretch; I mean, we have rules that have Applicability::Always. Maybe we should set more context of why we must set these values.


### Code generation
Don't forget to format your code with `cargo fmt` and lint with `cargo clippy`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Don't forget to format your code with `cargo fmt` and lint with `cargo clippy`.
Don't forget to format your code with `cargo format` and lint with `cargo lint`.

Better use our internal aliases because we enforce more rules.


When a rule's sole intention is to **mandate a single concept** - such as forcing the use of camel-casing - the rule should be named using the `use` prefix. For example, the rule to mandating the use of camel-cased variable names is named `useCamelCase`.
Note that code in a file ending with the extension `.jsonc` are in a _script environment_.
That's mean that you cannot use syntax that belongs to ECMAScript modules such as `import` and `export`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's => This means that...

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

Successfully merging this pull request may close these issues.

2 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载