Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: biomejs/biome
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 54b4c9a39078836843ef363bb6986fad74834480
Choose a base ref
...
head repository: biomejs/biome
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c28d5978c1440b3ae184d1cc354233711abf8a8e
Choose a head ref

Commits on Jun 20, 2024

  1. feat(workspace): adds GraphQL parsing capabilities via feature (#3238)

    Co-authored-by: Ze-Zheng Wu <zezhengwu@proton.me>
    ematipico and Sec-ant authored Jun 20, 2024
    Copy the full SHA
    f146639 View commit details
  2. Copy the full SHA
    d91a24f View commit details
  3. Copy the full SHA
    c0a708f View commit details
  4. Copy the full SHA
    ad7881a View commit details

Commits on Jun 21, 2024

  1. Copy the full SHA
    c372484 View commit details
  2. Copy the full SHA
    cc65fe8 View commit details

Commits on Jun 22, 2024

  1. Copy the full SHA
    c502f6a View commit details
  2. feat(css_parser): implement CSS unicode range (#3251)

    Co-authored-by: ty <62130798+togami2864@users.noreply.github.com>
    denbezrukov and togami2864 authored Jun 22, 2024
    Copy the full SHA
    6ad7fbf View commit details
  3. Copy the full SHA
    86d4e7c View commit details
  4. Copy the full SHA
    fc9b1eb View commit details

Commits on Jun 24, 2024

  1. Copy the full SHA
    5fe2f68 View commit details
  2. test(parse/json): add test for bug where overrides erroneously overri…

    …de special parsing options (#3260)
    dyc3 authored Jun 24, 2024
    Copy the full SHA
    0ff8de4 View commit details
  3. Copy the full SHA
    bb5faa0 View commit details
  4. Copy the full SHA
    0c253b6 View commit details
  5. chore(deps): update @biomejs packages (#3266)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Jun 24, 2024
    Copy the full SHA
    cd3bb04 View commit details
  6. docs(useNamingConvention): add examples and improve explanations (#3277)

    Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
    Conaclos and ematipico authored Jun 24, 2024
    Copy the full SHA
    a3c2b18 View commit details
  7. Copy the full SHA
    b3d8bfd View commit details

Commits on Jun 25, 2024

  1. Copy the full SHA
    c6c5e6c View commit details
  2. Copy the full SHA
    6f9c938 View commit details
  3. Copy the full SHA
    91522a5 View commit details
  4. Copy the full SHA
    519e316 View commit details
  5. Copy the full SHA
    50c880e View commit details
  6. Copy the full SHA
    436d44b View commit details

Commits on Jun 26, 2024

  1. Copy the full SHA
    7935235 View commit details
  2. Copy the full SHA
    3f311fe View commit details

Commits on Jun 27, 2024

  1. refactor(parse/css): change fields in CssParserSettings to Option (

    …#3273)
    
    Co-authored-by: Ze-Zheng Wu <zezhengwu@proton.me>
    dyc3 and Sec-ant authored Jun 27, 2024
    Copy the full SHA
    91eca89 View commit details
  2. Copy the full SHA
    5cc8a56 View commit details
  3. fix(lint/use_arrow_function): add a trailing comma to single type par…

    …ameter when JSX is enabled (#3300)
    Sec-ant authored Jun 27, 2024
    Copy the full SHA
    b3ca28e View commit details
  4. Copy the full SHA
    55fd8ed View commit details
  5. Copy the full SHA
    f88b7b2 View commit details
  6. release: v1.8.3 (#3302)

    ematipico authored Jun 27, 2024
    Copy the full SHA
    c28d597 View commit details
Showing 316 changed files with 9,106 additions and 1,874 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/repository_dispatch.yml
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ jobs:
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

- name: Build WASM module for the web
run: wasm-pack build --out-dir ../../packages/@biomejs/wasm-web --target web --profiling --scope biomejs crates/biome_wasm
run: wasm-pack build --out-dir ../../packages/@biomejs/wasm-web --target web --profiling --scope biomejs crates/biome_wasm --features graphql

# https://github.com/actions/cache/issues/342
- name: Clear old wasm-pack cache
49 changes: 49 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -9,6 +9,54 @@ New entries must be placed in a section entitled `Unreleased`.
Read
our [guidelines for writing a good changelog entry](https://github.com/biomejs/biome/blob/main/CONTRIBUTING.md#changelog).

## v1.8.3 (2022-06-27)

### CLI

#### Bug fixes

- Fix [#3104](https://github.com/biomejs/biome/issues/3104) by suppressing node warnings when using `biome migrate`. Contributed by @SuperchupuDev

- Force colors to be off when using the GitHub reporter to properly create annotations in GitHub actions ([#3148](https://github.com/biomejs/biome/issues/3148)). Contributed by @Sec-ant

### Parser

#### Bug fixes

- Implement [CSS unicode range](https://github.com/biomejs/biome/pull/3251). Contributed by @denbezrukov

### Formatter

#### Bug fixes

- Fix [#3184](https://github.com/biomejs/biome/issues/3184) CSS formatter converts custom identifiers to lowercase. Contributed by @denbezrukov
- Fix [#3256](https://github.com/biomejs/biome/issues/3256) constant crashes when editing css files #3256. Contributed by @denbezrukov

### Linter

#### New features

- Add `nursery/useDeprecatedReason` rule. Contributed by @vohoanglong0107.
- Add [nursery/noExportedImports](https://biomejs.dev/linter/rules/no-exported-imports/). Contributed by @Conaclos

#### Bug fixes

- `useConsistentArrayType` and `useShorthandArrayType` now ignore `Array` in the `extends` and `implements` clauses. Fix [#3247](https://github.com/biomejs/biome/issues/3247). Contributed by @Conaclos
- Fixes [#3066](https://github.com/biomejs/biome/issues/3066) by taking into account the dependencies declared in the `package.json`. Contributed by @ematipico
- The code action of the `useArrowFunction` rule now preserves a trailing comma when there is only a single type parameter in the arrow function and JSX is enabled. Fixes [#3292](https://github.com/biomejs/biome/issues/3292). Contributed by @Sec-ant

#### Enhancements
- Enhance tailwind sorting lint rule [#1274](https://github.com/biomejs/biome/issues/1274) with variant support.

Every preconfigured variant is assigned a `weight` that concurs on establishing the output sorting order.
Since nesting variants on the same utility class is possible, the resulting `weight` is the Bitwise XOR of all the variants weight for that class.
Dynamic variants (e.g. `has-[.custom-class]`, `group-[:checked]`) are also supported and they take the `weight` of their base variant name the custom value attached (e.g. `has-[.custom-class]` takes `has` weight).
Arbitrary variants (e.g. `[&nth-child(2)]`) don't have a weight assigned and they are placed after every known variant.
Classes with the same amount of arbitrary variants follow lexicographical order. The class that has the highest number of nested arbitrary variants is placed last.
Screen variants (e.g. `sm:`, `max-md:`, `min-lg:`) are not supported yet.

Contributed by @lutaok

## v1.8.2 (2024-06-20)

### CLI
@@ -18,6 +66,7 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b
- Fix [#3201](https://github.com/biomejs/biome/issues/3201) by correctly injecting the source code of the file when printing the diagnostics. Contributed by @ematipico
- Fix [#3179](https://github.com/biomejs/biome/issues/3179) where comma separators are not correctly removed after running `biome migrate` and thus choke the parser. Contributed by @Sec-ant
- Fix [#3232](https://github.com/biomejs/biome/issues/3232) by correctly using the colors set by the user. Contributed by @ematipico

#### Enhancement

- Reword the reporter message `No fixes needed` to `No fixes applied`.
69 changes: 69 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -105,6 +105,7 @@ biome_diagnostics_categories = { version = "0.5.7", path = "./crates/biome_diagn
biome_diagnostics_macros = { version = "0.5.7", path = "./crates/biome_diagnostics_macros" }
biome_formatter = { version = "0.5.7", path = "./crates/biome_formatter" }
biome_fs = { version = "0.5.7", path = "./crates/biome_fs" }
biome_graphql_analyze = { version = "0.0.1", path = "./crates/biome_graphql_analyze" }
biome_graphql_factory = { version = "0.1.0", path = "./crates/biome_graphql_factory" }
biome_graphql_parser = { version = "0.1.0", path = "./crates/biome_graphql_parser" }
biome_graphql_syntax = { version = "0.1.0", path = "./crates/biome_graphql_syntax" }
40 changes: 40 additions & 0 deletions crates/biome_analyze/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -413,6 +413,46 @@ impl Rule for ForLoopCountReferences {
}
```

#### Multiple signals

Some rules require you to find all possible cases upfront in `run` function.
To achieve that you can change Signals type from `Option<()>` to `Vec<()>`.
This will call the diagnostic/action function for every item of the vec.

Taking previous example and modifying it a bit we can apply diagnostic for each item easily.
```rust
impl Rule for ForLoopCountReferences {
type Query = Semantic<JsForStatement>;
type State = TextRange;
type Signals = Vec<Self::State>; // Replaced Option with Vec
type Options = ();

fn run(ctx: &RuleContext<Self>) -> Self::Signals {
let node = ctx.query();

let model = ctx.model();

...

// Get all write references
let write_references = binding.all_writes(model);

// Find all places where variable is being written to and get node ranges
let write_ranges = write_references.into_iter().map(|write| {
let syntax = write.syntax();
let range = syntax.text_range();

Some(range)
}).collect::<Vec<_>>();

write_ranges
}

fn diagnostic(_: &RuleContext<Self>, range: &Self::State) -> Option<RuleDiagnostic> {
// This will be called for each vector item
}
}

#### Code action

A rule can implement a code action. A code action provides to the final user the option to fix or change their code.
58 changes: 58 additions & 0 deletions crates/biome_analyze/src/diagnostics.rs
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ use biome_diagnostics::{
DiagnosticTags, Error, Location, Severity, Visit,
};
use biome_rowan::TextRange;
use std::borrow::Cow;
use std::fmt::{Debug, Display, Formatter};

use crate::rule::RuleDiagnostic;
@@ -171,3 +172,60 @@ impl SuppressionDiagnostic {
self
}
}

/// Series of errors encountered when running rules on a file
#[derive(Debug, PartialEq, Eq, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
pub enum RuleError {
/// The rule with the specified name replaced the root of the file with a node that is not a valid root for that language.
ReplacedRootWithNonRootError {
rule_name: Option<(Cow<'static, str>, Cow<'static, str>)>,
},
}

impl Diagnostic for RuleError {}

impl std::fmt::Display for RuleError {
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
RuleError::ReplacedRootWithNonRootError {
rule_name: Some((group, rule)),
} => {
std::write!(
fmt,
"the rule '{group}/{rule}' replaced the root of the file with a non-root node."
)
}
RuleError::ReplacedRootWithNonRootError { rule_name: None } => {
std::write!(
fmt,
"a code action replaced the root of the file with a non-root node."
)
}
}
}
}

impl biome_console::fmt::Display for RuleError {
fn fmt(&self, fmt: &mut biome_console::fmt::Formatter) -> std::io::Result<()> {
match self {
RuleError::ReplacedRootWithNonRootError {
rule_name: Some((group, rule)),
} => {
std::write!(
fmt,
"the rule '{group}/{rule}' replaced the root of the file with a non-root node."
)
}
RuleError::ReplacedRootWithNonRootError { rule_name: None } => {
std::write!(
fmt,
"a code action replaced the root of the file with a non-root node."
)
}
}
}
}

impl std::error::Error for RuleError {}
3 changes: 1 addition & 2 deletions crates/biome_analyze/src/lib.rs
Original file line number Diff line number Diff line change
@@ -27,8 +27,7 @@ pub use crate::categories::{
ActionCategory, RefactorKind, RuleCategories, RuleCategoriesBuilder, RuleCategory,
SourceActionKind,
};
pub use crate::diagnostics::AnalyzerDiagnostic;
pub use crate::diagnostics::SuppressionDiagnostic;
pub use crate::diagnostics::{AnalyzerDiagnostic, RuleError, SuppressionDiagnostic};
pub use crate::matcher::{InspectMatcher, MatchQueryParams, QueryMatcher, RuleKey, SignalEntry};
pub use crate::options::{AnalyzerConfiguration, AnalyzerOptions, AnalyzerRules};
pub use crate::query::{AddVisitor, QueryKey, QueryMatch, Queryable};
2 changes: 1 addition & 1 deletion crates/biome_analyze/src/rule.rs
Original file line number Diff line number Diff line change
@@ -704,7 +704,7 @@ pub trait Rule: RuleMeta + Sized {
<Self::Group as RuleGroup>::NAME,
Self::METADATA.name
);
let suppression_text = format!("biome-ignore {}", rule_category);
let suppression_text = format!("biome-ignore {rule_category}");
let root = ctx.root();
let token = root.syntax().token_at_offset(text_range.start());
let mut mutation = root.begin();
2 changes: 1 addition & 1 deletion crates/biome_cli/src/cli_options.rs
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@ pub struct CliOptions {
/// Allows to change how diagnostics and summary are reported.
#[bpaf(
long("reporter"),
argument("json|json-pretty|summary"),
argument("json|json-pretty|github|junit|summary"),
fallback(CliReporter::default())
)]
pub reporter: CliReporter,
16 changes: 14 additions & 2 deletions crates/biome_cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::changed::{get_changed_files, get_staged_files};
use crate::cli_options::{cli_options, CliOptions, ColorsArg};
use crate::cli_options::{cli_options, CliOptions, CliReporter, ColorsArg};
use crate::diagnostics::{DeprecatedArgument, DeprecatedConfigurationFile};
use crate::execute::Stdin;
use crate::logging::LoggingKind;
@@ -476,7 +476,19 @@ impl BiomeCommand {

pub const fn get_color(&self) -> Option<&ColorsArg> {
match self.cli_options() {
Some(cli_options) => cli_options.colors.as_ref(),
Some(cli_options) => {
// To properly display GitHub annotations we need to disable colors
if matches!(cli_options.reporter, CliReporter::GitHub) {
return Some(&ColorsArg::Off);
}
// We want force colors in CI, to give e better UX experience
// Unless users explicitly set the colors flag
if matches!(self, BiomeCommand::Ci { .. }) && cli_options.colors.is_none() {
return Some(&ColorsArg::Force);
}
// Normal behaviors
cli_options.colors.as_ref()
}
None => None,
}
}
Loading