From 90487783f8663553e6251bdf915d1e6f4d9a65d7 Mon Sep 17 00:00:00 2001 From: ematipico Date: Tue, 6 Dec 2022 16:36:48 +0000 Subject: [PATCH 1/5] chore: update contribution guidelines --- .github/PULL_REQUEST_TEMPLATE.md | 7 +++++++ CONTRIBUTING.md | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 5dff0d4a201..b4356938853 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -17,3 +17,10 @@ ## Test Plan + +## Documentation + + + +- [ ] The PR requires documentation +- [ ] I will create a new PR to update the documentation diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index eacba164734..b5f540906c7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -175,6 +175,14 @@ test(lint): add more cases to handle invalid rules When creating a new pull request, it's preferable to use a conventional commit-formatted title, as this title will be used as the default commit message on the squashed commit after merging. +Please use the template provided. + +If you PR requires some update on the website (new features, breaking changes, etc.), a new follow-up +PR should be created against the "release" PR. If you can't create a new PR, please let the team know, +the template should help to give all the information to the team. + +The team will prepare a new PR after each new release, just search for "release" among the opened pull requests. + Here are some other scripts that you might find useful. #### If you are a core contributor From babe423c28917fc17fc1bb1388ceb134706133bb Mon Sep 17 00:00:00 2001 From: ematipico Date: Mon, 12 Dec 2022 10:19:13 +0000 Subject: [PATCH 2/5] chore: update contribution guidelines --- CONTRIBUTING.md | 17 ++++++++++++++++- crates/rome_analyze/CONTRIBUTING.md | 29 +++++++++++++++-------------- justfile | 4 ++-- 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b5f540906c7..c4532b63e0a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -228,7 +228,22 @@ the new snapshot tests. ### Using just -A lot of the commands above are mor easily acessible using our Just recipes. For example: +A lot of the commands above are mor easily accessible using our [Just](https://just.systems/man/en/) recipes. For example: + +### Install just + +You can install `just` using cargo: + +```shell +cargo install just +``` + +Or, using different methods, like explained in their [documentation](https://just.systems/man/en/chapter_4.html). + +It's advised to install `just` using a package manager, so +you can run `just` as a binary. + +### Usage ```ignore ❯ just diff --git a/crates/rome_analyze/CONTRIBUTING.md b/crates/rome_analyze/CONTRIBUTING.md index 1c16e8ea2e8..77aeff3831e 100644 --- a/crates/rome_analyze/CONTRIBUTING.md +++ b/crates/rome_analyze/CONTRIBUTING.md @@ -1,7 +1,7 @@ # Analyzer The analyzer is a generic crate aimed to implement a visitor-like infrastructure, where -it's possible to inspect a piece of AST and emit diagnostics or actions based on a +it's possible to inspect a piece of AST and emit diagnostics or actions based on a static check. # Folder structure @@ -11,8 +11,9 @@ is going to be implemented for the JavaScript language (and its super languages) will be implemented inside the `rome_js_analyze` crate. Rules are divided by capabilities: -- `analyzers/` folder contains rules that don't require any particular capabilities; -- `semantic_analyzer/` folder contains rules that require the use of the semantic model; +- `analyzers/` folder contains rules that don't require any particular capabilities, via the `Ast<>` query type; +- `semantic_analyzer/` folder contains rules that require the use of the semantic model, via `Semantic<>` query type; +- `aria_analyzers/` folder contains rules that require the use ARIA metadata, via `Aria<>` query type; - `assists/` folder contains rules that contribute to refactor code, with not associated diagnostics; these are rules that are usually meant for editors/IDEs; @@ -52,10 +53,10 @@ inside the `semantic_analyzers` folder 3. from there, use the [`declare_rule`](#declare_rule) macro to create a new type ```rust,ignore use rome_analyze::declare_rule; - + declare_rule! { /// Promotes the use of awesome tricks - /// + /// /// ## Examples /// /// ### Invalid @@ -72,20 +73,20 @@ inside the `semantic_analyzers` folder use rome_analyze::{Rule, RuleCategory}; use rome_js_syntax::JsAnyExpression; use rome_analyze::context::RuleContext; - + impl Rule for UseAwesomeTricks { const CATEGORY: RuleCategory = RuleCategory::Lint; type Query = Semantic; type State = String; type Signals = Option; type Options = (); - + fn run(ctx: &RuleContext) -> Self::Signals {} } ``` 5. the const `CATEGORY` must be `RuleCategory::Lint` otherwise it won't work 6. the `Query` needs to have the `Semantic` type, because we want to have access to the semantic model. -`Query` tells the engine on which AST node we want to trigger the rule. +`Query` tells the engine on which AST node we want to trigger the rule. 7. The `State` type doesn't have to be used, so it can be considered optional, but it has be defined as `type State = ()` 8. The `run` function must be implemented. This function is called every time the analyzer @@ -99,7 +100,7 @@ finds a match for the query specified by the rule, and may return zero or more " ``` 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. + zero or one diagnostic. You will have to manually update the file `rome_diagnostics_categories/src/categories.rs` and add a new category for the new rule you're about to create. @@ -225,9 +226,9 @@ declare_rule! { use rome_analyze::declare_rule; declare_rule! { /// Disallow the use of `var` - /// + /// /// ### Invalid - /// + /// /// ```js,expect_diagnostic /// var a, b; /// ``` @@ -255,9 +256,9 @@ use rome_analyze::declare_rule; declare_rule! { /// Disallow the use of `var` - /// + /// /// ### Invalid - /// + /// /// ```js,expect_diagnostic /// var a, b; /// ``` @@ -409,4 +410,4 @@ And at the end, to test our commits are ready to be push we can call > just check-ready ``` -For more details on the available automations, look at our `justfile` at the root of the repository. \ No newline at end of file +For more details on the available automations, look at our `justfile` at the root of the repository. diff --git a/justfile b/justfile index 2c5fa17c193..da01c08c5e2 100644 --- a/justfile +++ b/justfile @@ -1,12 +1,12 @@ _default: just --list -u - + codegen: cargo codegen all cargo codegen-configuration cargo codegen-schema cargo codegen-bindings - + documentation: cargo lintdoc cargo documentation From 014dc69204d0be2cd0fbc50777168e7ac1a48aa9 Mon Sep 17 00:00:00 2001 From: ematipico Date: Mon, 12 Dec 2022 10:32:53 +0000 Subject: [PATCH 3/5] chore: code suggestions --- .github/PULL_REQUEST_TEMPLATE.md | 8 +++++++- CONTRIBUTING.md | 14 ++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index b4356938853..ad4dd5f2c3a 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -20,7 +20,13 @@ ## Documentation - + - [ ] The PR requires documentation - [ ] I will create a new PR to update the documentation diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c4532b63e0a..9634e3d5ea8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -177,11 +177,17 @@ When creating a new pull request, it's preferable to use a conventional commit-f Please use the template provided. -If you PR requires some update on the website (new features, breaking changes, etc.), a new follow-up -PR should be created against the "release" PR. If you can't create a new PR, please let the team know, -the template should help to give all the information to the team. +#### Write documentation -The team will prepare a new PR after each new release, just search for "release" among the opened pull requests. +If your PR requires some update on the website (new features, breaking changes, etc.), you should create a new PR once the previous PR is successfully merged. + +Go to the issues section and check the pinned issues. +You will find a _**pinned issue**_ that starts with "Documentation and Focus". Inside, you will find the details of: +- the name of the branch where to point the PR that updates the documentation; +- the PR that we will merge when the release is ready; + +If you can't create a new PR, please let the team know. +The template should help to give all the information to the team. Here are some other scripts that you might find useful. From a5ef50a70e1c352e3c76b95f5486451d0d244114 Mon Sep 17 00:00:00 2001 From: ematipico Date: Mon, 12 Dec 2022 12:08:47 +0000 Subject: [PATCH 4/5] chore: remove old code --- crates/rome_analyze/CONTRIBUTING.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/crates/rome_analyze/CONTRIBUTING.md b/crates/rome_analyze/CONTRIBUTING.md index 77aeff3831e..f96cd0e750d 100644 --- a/crates/rome_analyze/CONTRIBUTING.md +++ b/crates/rome_analyze/CONTRIBUTING.md @@ -75,7 +75,6 @@ inside the `semantic_analyzers` folder use rome_analyze::context::RuleContext; impl Rule for UseAwesomeTricks { - const CATEGORY: RuleCategory = RuleCategory::Lint; type Query = Semantic; type State = String; type Signals = Option; @@ -84,14 +83,13 @@ inside the `semantic_analyzers` folder fn run(ctx: &RuleContext) -> Self::Signals {} } ``` -5. the const `CATEGORY` must be `RuleCategory::Lint` otherwise it won't work -6. the `Query` needs to have the `Semantic` type, because we want to have access to the semantic model. +5. the `Query` needs to have the `Semantic` type, because we want to have access to the semantic model. `Query` tells the engine on which AST node we want to trigger the rule. -7. The `State` type doesn't have to be used, so it can be considered optional, but it has +6. The `State` type doesn't have to be used, so it can be considered optional, but it has be defined as `type State = ()` -8. The `run` function must be implemented. This function is called every time the analyzer +7. The `run` function must be implemented. This function is called every time the analyzer finds a match for the query specified by the rule, and may return zero or more "signals". -9. Implement the optional `diagnostic` function, to tell the user where's the error and why: +8. Implement the optional `diagnostic` function, to tell the user where's the error and why: ```rust,ignore impl Rule for UseAwesomeTricks { // .. code @@ -104,7 +102,7 @@ finds a match for the query specified by the rule, and may return zero or more " You will have to manually update the file `rome_diagnostics_categories/src/categories.rs` and add a new category for the new rule you're about to create. -10. Implement the optional `action` function, if we are able to provide automatic code fix to the rule: +9. Implement the optional `action` function, if we are able to provide automatic code fix to the rule: ```rust,ignore impl Rule for UseAwesomeTricks { // .. code From a749af57d4904ae213c7abb3e5a3bb95b061d5ad Mon Sep 17 00:00:00 2001 From: ematipico Date: Tue, 13 Dec 2022 09:25:53 +0000 Subject: [PATCH 5/5] chore: code suggestions --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- CONTRIBUTING.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index ad4dd5f2c3a..023806a1802 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -22,7 +22,7 @@