Skip to content

Commit

Permalink
feat: rename rome_analyzer -> biome_analyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
ekusiadadus committed Sep 8, 2023
1 parent f243c7b commit 3dceeb3
Show file tree
Hide file tree
Showing 244 changed files with 558 additions and 407 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,20 +157,19 @@ These files should contain an array of strings where each string is a code snipp
For instance, for the rule `noVar`, the file `invalidScript.jsonc` contains:

```jsonc
[
"var x = 1; foo(x);",
"for (var x of [1,2,3]) { foo(x); }",
]
["var x = 1; foo(x);", "for (var x of [1,2,3]) { foo(x); }"]
```

Note that code in a file ending with the extension `.jsonc` are in a _script environment_.
This means that you cannot use syntax that belongs to _ECMAScript modules_ such as `import` and `export`.

Run the command

```shell
just test-lintrule myRuleName
```
and if you've done everything correctly,

and if you've done everything correctly,
you should see some snapshots emitted with diagnostics and code actions.
Check our main [contribution document](https:/biomejs/biome/blob/main/CONTRIBUTING.md#snapshot-tests)
Expand Down Expand Up @@ -203,8 +202,8 @@ the _Biome_ toolchain (JavaScript, JSX, TypeScript, ...) similar to how
blocks in Rust doc-comments are assumed to be written in Rust by default
the language of the test must be explicitly specified, for instance:
```rust,ignore
use rome_analyze::declare_rule;
````rust,ignore
use biome_analyze::declare_rule;
declare_rule! {
/// Disallow the use of `var`.
///
Expand Down Expand Up @@ -234,13 +233,13 @@ declare_rule! {
recommended: false,
}
}
```
````
Additionally, it's possible to declare that a test should emit a diagnostic
by adding `expect_diagnostic` to the language metadata:

```rust,ignore
use rome_analyze::declare_rule;
````rust,ignore
use biome_analyze::declare_rule;
declare_rule! {
/// Disallow the use of `var`.
///
Expand All @@ -257,7 +256,7 @@ use rome_analyze::declare_rule;
recommended: false,
}
}
```
````

This will cause the documentation generator to ensure the rule does emit
exactly one diagnostic for this code, and to include a snapshot for the
Expand All @@ -276,7 +275,7 @@ This command runs several sub-commands:
- `cargo codegen-configuration`, **this command must be run first** and, it will update the configuration;

- `cargo lintdoc`, it will update the website with the documentation of the rules, check [`declare_rule`](#declare_rule)
for more information about it;
for more information about it;

- `cargo codegen-bindings`, it will update the TypeScript types released inside the JS APIs;

Expand Down Expand Up @@ -325,21 +324,19 @@ This allows the rule to be configured inside `biome.json` file like:

```json
{
"linter": {
"rules": {
"recommended": true,
"nursery": {
"useExhaustiveDependencies": {
"level": "error",
"options": {
"hooks": [
["useMyEffect", 0, 1]
]
}
}
}
},
"linter": {
"rules": {
"recommended": true,
"nursery": {
"useExhaustiveDependencies": {
"level": "error",
"options": {
"hooks": [["useMyEffect", 0, 1]]
}
}
}
}
}
}
```

Expand All @@ -352,12 +349,12 @@ let options = ctx.options();
### Deprecate a rule

There are occasions when a rule must be deprecated, to avoid breaking changes. The reason
of deprecation can be multiple.
of deprecation can be multiple.

In order to do, the macro allows adding additional field to add the reason for deprecation

```rust,ignore
use rome_analyze::declare_rule;
````rust,ignore
use biome_analyze::declare_rule;

declare_rule! {
/// Disallow the use of `var`.
Expand All @@ -376,7 +373,7 @@ declare_rule! {
recommended: false,
}
}
```
````

### Custom Visitors

Expand Down Expand Up @@ -487,7 +484,7 @@ This macro is used to declare an analyzer rule type, and implement the [RuleMeta
The macro itself expect the following syntax:
```rust,ignore
use rome_analyze::declare_rule;
use biome_analyze::declare_rule;
declare_rule! {
/// Documentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
authors.workspace = true
edition.workspace = true
license.workspace = true
name = "rome_analyze"
name = "biome_analyze"
repository.workspace = true
version = "0.2.0"

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl ActionCategory {
/// ## Examples
///
/// ```
/// use rome_analyze::{ActionCategory, RefactorKind};
/// use biome_analyze::{ActionCategory, RefactorKind};
///
/// assert!(ActionCategory::QuickFix.matches("quickfix"));
/// assert!(!ActionCategory::QuickFix.matches("refactor"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ where
/// ## Examples
///
/// ```rust,ignore
/// use rome_analyze::{declare_rule, Rule, RuleCategory, RuleMeta, RuleMetadata};
/// use rome_analyze::context::RuleContext;
/// use biome_analyze::{declare_rule, Rule, RuleCategory, RuleMeta, RuleMetadata};
/// use biome_analyze::context::RuleContext;
/// use serde::Deserialize;
/// declare_rule! {
/// /// Some doc
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ use rome_rowan::{
TextSize, TokenAtOffset, TriviaPiece, TriviaPieceKind, WalkEvent,
};

/// The analyzer is the main entry point into the `rome_analyze` infrastructure.
/// The analyzer is the main entry point into the `biome_analyze` infrastructure.
/// Its role is to run a collection of [Visitor]s over a syntax tree, with each
/// visitor implementing various analysis over this syntax tree to generate
/// auxiliary data structures as well as emit "query match" events to be
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub trait RuleMeta {
/// The macro itself expect the following syntax:
///
/// ```rust,ignore
///use rome_analyze::declare_rule;
///use biome_analyze::declare_rule;
///
/// declare_rule! {
/// /// Documentation
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion crates/biome_lsp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ version = "0.0.0"
anyhow = "1.0.52"
futures = "0.3"
indexmap = { workspace = true }
rome_analyze = { workspace = true }
biome_analyze = { workspace = true }
rome_console = { workspace = true }
rome_diagnostics = { workspace = true }
rome_formatter = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_lsp/src/handlers/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::converters::line_index::LineIndex;
use crate::session::Session;
use crate::utils;
use anyhow::{Context, Result};
use rome_analyze::{ActionCategory, SourceActionKind};
use biome_analyze::{ActionCategory, SourceActionKind};
use rome_diagnostics::Applicability;
use rome_fs::RomePath;
use rome_service::workspace::{
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_lsp/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use crate::extension_settings::ExtensionSettings;
use crate::extension_settings::CONFIGURATION_SECTION;
use crate::utils;
use anyhow::Result;
use biome_analyze::RuleCategories;
use futures::stream::futures_unordered::FuturesUnordered;
use futures::StreamExt;
use rome_analyze::RuleCategories;
use rome_console::markup;
use rome_fs::{FileSystem, OsFileSystem, RomePath};
use rome_service::workspace::{
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_lsp/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::converters::line_index::LineIndex;
use crate::converters::{from_proto, to_proto, PositionEncoding};
use anyhow::{ensure, Context, Result};
use rome_analyze::ActionCategory;
use biome_analyze::ActionCategory;
use rome_console::fmt::Termcolor;
use rome_console::fmt::{self, Formatter};
use rome_console::MarkupBuf;
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_test_utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ version = "0.1.0"
[dependencies]
countme = { workspace = true, features = ["enable"] }
json_comments = "0.2.1"
rome_analyze = { workspace = true }
biome_analyze = { workspace = true }
rome_console = { workspace = true }
rome_deserialize = { workspace = true }
rome_diagnostics = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_test_utils/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use biome_analyze::{AnalyzerAction, AnalyzerOptions};
use json_comments::StripComments;
use rome_analyze::{AnalyzerAction, AnalyzerOptions};
use rome_console::fmt::{Formatter, Termcolor};
use rome_console::markup;
use rome_diagnostics::termcolor::Buffer;
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_js_analyze/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ bpaf.workspace = true
lazy_static = { workspace = true }
natord = "1.0.9"
roaring = "0.10.1"
rome_analyze = { workspace = true }
biome_analyze = { workspace = true }
rome_console = { workspace = true }
rome_control_flow = { workspace = true }
rome_deserialize = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_js_analyze/src/analyzers.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/rome_js_analyze/src/analyzers/a11y.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion crates/rome_js_analyze/src/analyzers/a11y/no_access_key.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::JsRuleAction;
use rome_analyze::{context::RuleContext, declare_rule, ActionCategory, Ast, Rule, RuleDiagnostic};
use biome_analyze::{
context::RuleContext, declare_rule, ActionCategory, Ast, Rule, RuleDiagnostic,
};
use rome_console::markup;
use rome_diagnostics::Applicability;
use rome_js_syntax::{jsx_ext::AnyJsxElement, JsxAttribute, JsxAttributeList};
Expand Down
4 changes: 3 additions & 1 deletion crates/rome_js_analyze/src/analyzers/a11y/no_auto_focus.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::JsRuleAction;
use rome_analyze::{context::RuleContext, declare_rule, ActionCategory, Ast, Rule, RuleDiagnostic};
use biome_analyze::{
context::RuleContext, declare_rule, ActionCategory, Ast, Rule, RuleDiagnostic,
};
use rome_console::markup;
use rome_diagnostics::Applicability;
use rome_js_syntax::{jsx_ext::AnyJsxElement, JsxAttribute};
Expand Down
4 changes: 2 additions & 2 deletions crates/rome_js_analyze/src/analyzers/a11y/no_blank_target.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::JsRuleAction;
use rome_analyze::context::RuleContext;
use rome_analyze::{declare_rule, ActionCategory, Ast, Rule, RuleDiagnostic};
use biome_analyze::context::RuleContext;
use biome_analyze::{declare_rule, ActionCategory, Ast, Rule, RuleDiagnostic};
use rome_console::markup;
use rome_diagnostics::Applicability;
use rome_js_factory::make::{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use rome_analyze::context::RuleContext;
use rome_analyze::{declare_rule, ActionCategory, Ast, Rule, RuleDiagnostic};
use biome_analyze::context::RuleContext;
use biome_analyze::{declare_rule, ActionCategory, Ast, Rule, RuleDiagnostic};
use rome_console::markup;
use rome_diagnostics::Applicability;
use rome_js_syntax::jsx_ext::AnyJsxElement;
Expand Down
4 changes: 2 additions & 2 deletions crates/rome_js_analyze/src/analyzers/a11y/no_header_scope.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use rome_analyze::context::RuleContext;
use rome_analyze::{declare_rule, ActionCategory, Ast, Rule, RuleDiagnostic};
use biome_analyze::context::RuleContext;
use biome_analyze::{declare_rule, ActionCategory, Ast, Rule, RuleDiagnostic};
use rome_console::markup;
use rome_diagnostics::Applicability;
use rome_js_syntax::jsx_ext::AnyJsxElement;
Expand Down
4 changes: 2 additions & 2 deletions crates/rome_js_analyze/src/analyzers/a11y/no_redundant_alt.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use rome_analyze::context::RuleContext;
use rome_analyze::{declare_rule, Ast, Rule, RuleDiagnostic};
use biome_analyze::context::RuleContext;
use biome_analyze::{declare_rule, Ast, Rule, RuleDiagnostic};
use rome_console::markup;
use rome_js_syntax::jsx_ext::AnyJsxElement;
use rome_js_syntax::{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use rome_analyze::{context::RuleContext, declare_rule, Ast, Rule, RuleDiagnostic};
use biome_analyze::{context::RuleContext, declare_rule, Ast, Rule, RuleDiagnostic};
use rome_console::markup;
use rome_js_syntax::{jsx_ext::AnyJsxElement, JsxAttribute, JsxChildList, JsxElement};
use rome_rowan::{AstNode, AstNodeList};
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_js_analyze/src/analyzers/a11y/use_alt_text.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use rome_analyze::{context::RuleContext, declare_rule, Ast, Rule, RuleDiagnostic};
use biome_analyze::{context::RuleContext, declare_rule, Ast, Rule, RuleDiagnostic};
use rome_console::{fmt::Display, fmt::Formatter, markup};
use rome_js_syntax::{jsx_ext::AnyJsxElement, TextRange};
use rome_rowan::AstNode;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use rome_analyze::context::RuleContext;
use rome_analyze::{declare_rule, Ast, Rule, RuleDiagnostic};
use biome_analyze::context::RuleContext;
use biome_analyze::{declare_rule, Ast, Rule, RuleDiagnostic};
use rome_console::markup;
use rome_js_syntax::jsx_ext::AnyJsxElement;
use rome_js_syntax::JsxElement;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use rome_analyze::{context::RuleContext, declare_rule, Ast, Rule, RuleDiagnostic};
use biome_analyze::{context::RuleContext, declare_rule, Ast, Rule, RuleDiagnostic};
use rome_console::markup;
use rome_js_syntax::{jsx_ext::AnyJsxElement, JsxElement};
use rome_rowan::AstNode;
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_js_analyze/src/analyzers/a11y/use_html_lang.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use rome_analyze::{context::RuleContext, declare_rule, Ast, Rule, RuleDiagnostic};
use biome_analyze::{context::RuleContext, declare_rule, Ast, Rule, RuleDiagnostic};
use rome_console::markup;
use rome_js_syntax::{jsx_ext::AnyJsxElement, TextRange};
use rome_rowan::AstNode;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use rome_analyze::{context::RuleContext, declare_rule, Ast, Rule, RuleDiagnostic};
use biome_analyze::{context::RuleContext, declare_rule, Ast, Rule, RuleDiagnostic};
use rome_console::markup;
use rome_js_syntax::jsx_ext::AnyJsxElement;
use rome_rowan::AstNode;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use rome_analyze::{context::RuleContext, declare_rule, Ast, Rule, RuleDiagnostic};
use biome_analyze::{context::RuleContext, declare_rule, Ast, Rule, RuleDiagnostic};
use rome_console::markup;
use rome_js_syntax::{jsx_ext::AnyJsxElement, AnyJsxAttribute, AnyJsxElementName};
use rome_rowan::AstNode;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::semantic_services::Semantic;
use rome_analyze::context::RuleContext;
use rome_analyze::{declare_rule, Rule, RuleDiagnostic};
use biome_analyze::context::RuleContext;
use biome_analyze::{declare_rule, Rule, RuleDiagnostic};
use rome_console::{markup, MarkupBuf};
use rome_js_syntax::jsx_ext::AnyJsxElement;
use rome_rowan::AstNode;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use rome_analyze::context::RuleContext;
use rome_analyze::{declare_rule, Ast, Rule, RuleDiagnostic};
use biome_analyze::context::RuleContext;
use biome_analyze::{declare_rule, Ast, Rule, RuleDiagnostic};
use rome_console::markup;
use rome_js_syntax::jsx_ext::AnyJsxElement;
use rome_js_syntax::{AnyJsxChild, JsxElement, TextRange};
Expand Down
4 changes: 2 additions & 2 deletions crates/rome_js_analyze/src/analyzers/a11y/use_valid_anchor.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use rome_analyze::context::RuleContext;
use rome_analyze::{declare_rule, Ast, Rule, RuleDiagnostic};
use biome_analyze::context::RuleContext;
use biome_analyze::{declare_rule, Ast, Rule, RuleDiagnostic};
use rome_console::{markup, MarkupBuf};
use rome_js_syntax::jsx_ext::AnyJsxElement;
use rome_rowan::{AstNode, TextRange};
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_js_analyze/src/analyzers/complexity.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use rome_analyze::{context::RuleContext, declare_rule, ActionCategory, Ast, Rule, RuleDiagnostic};
use biome_analyze::{
context::RuleContext, declare_rule, ActionCategory, Ast, Rule, RuleDiagnostic,
};
use rome_console::markup;
use rome_diagnostics::Applicability;
use rome_js_syntax::{
Expand Down
Loading

0 comments on commit 3dceeb3

Please sign in to comment.