Analyzer
Enhancements
CLI
New features
-
Add a new option
--rule
to the commandbiome lint
(#58).This new option allows you to execute a single rule or a rule group.
This option is convenient to test a rule or apply the code fixes of a single rule.For example, you can execute the
style/useNamingConvention
rule on the working directory:biome lint --rule=style/useNamingConvention ./
If the rule has a code action (autofix), you can use
--apply
to apply the fix:biome lint --rule=style/useNamingConvention --apply ./
The option takes the rule options in the Biome configuration file into account.
Only, the severity level of the rule is overridden by its default value,
i.e.error
for a recommended rule orwarn
otherwise.You can also run a group of rules:
biome lint --rule=suspicious src/main.js
In this case, the severity level of a rule is not overridden.
Thus, the disabled rules stay disabled.
To ensure that the group is run, therecommended
field of the group is turned on.
Thenursery
group cannot be passed because no rules are enabled in the nursery group by default.The option is compatible with other options such as
--apply
,--apply-unsafe
and--reporter
.Contributed by @Conaclos
-
Add new command
biome clean
. Use this command to purge all the logs emitted by the Biome daemon. This command is really useful, because the Biome daemon tends
log many files and contents during its lifecycle. This means that if your editor is open for hours (or even days), thebiome-logs
folder could become quite heavy. Contributed by @ematipico -
Add support for formatting and linting CSS files from the CLI. These operations are opt-in for the time being.
If you don't have a configuration file, you can enable these features with
--css-formatter-enabled
and--css-linter-enabled
:biome check --css-formatter-enabled=true --css-linter-enabled=true ./
Contributed by @ematipico
-
Add new CLI options to control the CSS formatting. Check the CLI reference page for more details. Contributed by @ematipico
-
Add new options
--write
,--fix
(alias of--write
) and--unsafe
to the commandbiome lint
andbiome check
.
Add a new option--fix
(alias of--write
) to the commandbiome format
andbiome migrate
.biome <lint|check> --<write|fix> [--unsafe] biome format --<write|fix> biome migrate --<write|fix>
The
biome <lint|check> --<write|fix>
has the same behavior asbiome <lint|check> --apply
.
Thebiome <lint|check> --<write|fix> --unsafe
has the same behavior asbiome <lint|check> --apply-unsafe
.
Thebiome format --fix
has the same behavior asbiome format --write
.
Thebiome migrate --fix
has the same behavior asbiome migrate --write
.This change allows these commands to write modifications in the same options.
With this change, the--apply
and--apply-unsafe
options are deprecated.Contributed by @unvalley
Enhancements
-
Biome now executes commands (lint, format, check and ci) on the working directory by default. #2266 Contributed by @unvalley
- biome check . + biome check # You can run the command without the path
-
biome migrate eslint
now tries to convert ESLint ignore patterns into Biome ignore patterns.ESLint uses gitignore patterns.
Biome now tries to convert these patterns into Biome ignore patterns.For example, the gitignore pattern
/src
is a relative path to the file in which it appears.
Biome now recognizes this and translates this pattern to./src
.Contributed by @Conaclos
-
biome migrate eslint
now supports theeslintIgnore
field inpackage.json
.ESLint allows the use of
package.json
as an ESLint configuration file.
ESLint supports two fields:eslintConfig
andeslintIgnore
.
Biome only supported the former. It now supports both.Contributed by @Conaclos
-
biome migrate eslint
now propagates NodeJS errors to the user.This will help users to identify why Biome is unable to load some ESLint configurations.
Contributed by @Conaclos
-
Add a new
--reporter
calledsummary
. This reporter will print diagnostics in a different way, based on the tools (formatter, linter, etc.) that are executed.
Import sorting and formatter shows the name of the files that require formatting. Instead, the linter will group the number of rules triggered and the number of errors/warnings:Formatter ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ The following files needs to be formatted: main.ts index.ts Organize Imports ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ The following files needs to have their imports sorted: main.ts index.ts Analyzer ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Some analyzer rules were triggered Rule Name Diagnostics lint/suspicious/noImplicitAnyLet 12 (12 error(s), 0 warning(s), 0 info(s)) lint/suspicious/noDoubleEquals 8 (8 error(s), 0 warning(s), 0 info(s)) lint/suspicious/noRedeclare 12 (12 error(s), 0 warning(s), 0 info(s)) lint/suspicious/noDebugger 20 (20 error(s), 0 warning(s), 0 info(s))
Contributed by @ematipico
-
biome ci
now enforces printing the output using colours. If you were previously using--colors=force
, you can remove it because it's automatically set. Contributed by @ematipico
Configuration
New features
-
Add an rule option
fix
to override the code fix kind of a rule (#2882).A rule can provide a safe or an unsafe code action.
You can now tune the kind of code actions thanks to thefix
option.
This rule option takes a value among:none
: the rule no longer emits code actions.safe
: the rule emits safe code action.unsafe
: the rule emits unsafe code action.
The following configuration disables the code actions of
noUnusedVariables
, makes the emitted code actions ofstyle/useConst
andstyle/useTemplate
unsafe and safe respectively.{ "linter": { "rules": { "correctness": { "noUnusedVariables": { "level": "error", "fix": "none" }, "style": { "useConst": { "level": "warn", "fix": "unsafe" }, "useTemplate": { "level": "warn", "fix": "safe" } } } } } }
Contributed by @Conaclos
-
Add option
javascript.linter.enabled
to control the linter for JavaScript (and its super languages) files. Contributed by @ematipico -
Add option
json.linter.enabled
to control the linter for JSON (and its super languages) files. Contributed by @ematipico -
Add option
css.linter.enabled
to control the linter for CSS (and its super languages) files. Contributed by @ematipico -
Add option
css.formatter
, to control the formatter options for CSS (and its super languages) files. Contributed by @ematipico
Enhancements
- The
javascript.formatter.trailingComma
option is deprecated and renamed tojavascript.formatter.trailingCommas
. The corresponding CLI option--trailing-comma
is also deprecated and renamed to--trailing-commas
. Details can be checked in #2492. Contributed by @Sec-ant
Editors
New features
- Add support for LSP Workspaces
Bug fixes
- Fixes #2781, by correctly computing the configuration to apply to a specific file. Contributed by @ematipico
Formatter
Bug fixes
- Fix #2470 by avoid introducing linebreaks in single line string interpolations. Contributed by @ah-yu
- Resolve deadlocks by narrowing the scope of locks. Contributed by @mechairoi
- Fix #2782 by computing the enabled rules by taking the override settings into consideration. Contributed by @ematipico
JavaScript APIs
Linter
New features
-
Add nursery/useThrowOnlyError. Contributed by @minht11
-
Add nursery/useImportExtensions. Contributed by @minht11
-
useNamingConvention now supports an option to enforce custom conventions (#1900).
For example, you can enforce the use of a prefix for private class members:
{ "linter": { "rules": { "style": { "useNamingConvention": { "level": "error", "options": { "conventions": [ { "selector": { "kind": "classMember", "modifiers": ["private"] }, "match": "_(.*)", "formats": ["camelCase"] } ] } } } } } }
Please, find more details in the rule documentation.
Contributed by @Conaclos
-
Add nursery/useNumberToFixedDigitsArgument.
Contributed by @minht11 -
Add nursery/useThrowNewError.
Contributed by @minht11 -
Add nursery/useTopLevelRegex, which enforces defining regular expressions at the top level of a module. #2148 Contributed by @dyc3.
-
Add nursery/noCssEmptyBlock. #2513 Contributed by @togami2864
-
Add nursery/noDuplicateAtImportRules. #2658 Contributed by @DerTimonius
-
Add nursery/noDuplicateFontNames. #2308 Contributed by @togami2864
-
Add nursery/noDuplicateSelectorsKeyframeBlock. #2534 Contributed by @isnakode
-
Add nursery/noImportantInKeyframe. #2542 Contributed by @isnakode
-
Add nursery/noInvalidPositionAtImportRule. #2717 Contributed by @t-shiratori
-
Add nursery/noUnknownFunction. #2570 Contributed by @neokidev
-
Add nursery/noUnknownMediaFeatureName. #2751 Contributed by @Kazuhiro-Mimaki
-
Add nursery/noUnknownProperty. #2755 Contributed by @chansuke
-
Add nursery/noUnknownSelectorPseudoElement. #2655 Contributed by @keita-hino
-
Add nursery/noUnknownUnit. #2535 Contributed by @neokidev
-
Add nursery/noUnmatchableAnbSelector. #2706 Contributed by @togami2864
-
Add nursery/useGenericFontNames. #2573 Contributed by @togami2864
-
Add nursery/noYodaExpression. Contributed by @michellocana
Enhancements
-
Add a code action for noConfusingVoidType and improve the diagnostics.
The rule now suggests using
undefined
instead ofvoid
in confusing places.
The diagnosis is also clearer.Contributed by @Conaclos
Bug fixes
-
noUndeclaredVariables and noUnusedImports now correctly handle import namespaces (#2796).
Previously, Biome bound unqualified type to import namespaces.
Import namespaces can only be used as qualified names in a type (ambient) context.// Unused import import * as Ns1 from ""; // This doesn't reference the import namespace `Ns1` type T1 = Ns1; // Undeclared variable `Ns1` // Unused import import type * as Ns2 from ""; // This doesn't reference the import namespace `Ns2` type T2 = Ns2; // Undeclared variable `Ns2` import type * as Ns3 from ""; // This references the import namespace because it is a qualified name. type T3 = Ns3.Inner; // This also references the import namespace. export type { Ns3 }
Contributed by @Conaclos
-
noUndeclaredVariables now ignores
this
in JSX components (#2636).The rule no longer reports
this
as undeclared in following code.import { Component } from 'react'; export class MyComponent extends Component { render() { return <this.foo /> } }
-
useJsxKeyInIterable
now handles more cases involving fragments. See the snippets below. Contributed by @dyc3
// valid
[].map((item) => {
return <>{item.condition ? <div key={item.id} /> : <div key={item.id}>foo</div>}</>;
});
// invalid
[].map((item) => {
return <>{item.condition ? <div /> : <div>foo</div>}</>;
});
noExcessiveNestedTestSuites
no longer erroneously alerts ondescribe
calls that are not invoking the globaldescribe
function. #2599 Contributed by @dyc3
// now valid
z.object({})
.describe('')
.describe('')
.describe('')
.describe('')
.describe('')
.describe('');
-
noExportsInTest rule no longer treats files with in-source testing as test files #2859. Contributed by @ah-yu
-
useSortedClasses now keeps leading and trailing spaces when applying the code action inside template literals:
i Unsafe fix: Sort the classes. 1 1 │ <> 2 │ - → <div·class={`${variable}·px-2·foo·p-4·bar`}/> 2 │ + → <div·class={`${variable}·foo·bar·p-4·px-2`}/> 3 3 │ <div class={`px-2 foo p-4 bar ${variable}`}/> 4 4 │ </>
-
noUndeclaredDependencies is correctly triggered when running
biome ci
. Contributed by @ematipico -
noUnusedVariables no longer panics when a certain combination of characters is typed. Contributed by @ematipico
Parser
Enhancements
Bug fixes
-
The
const
modifier for type parameters is now accepted for TypeScriptnew
signatures (#2825).The following code is now correctly parsed:
interface I { new<const T>(x: T): T }
Contributed by @Conaclos
-
Some invalid TypeScript syntax caused the Biome parser to crash.
The following invalid syntax no longer causes the Biome parser to crash:
declare using x: null; declare qwait using x: null;
Contributed by @Conaclos
What's Changed
Other changes
- release: js-api by @ematipico in #2745
- chore: add Grit target node bindings by @arendjr in #2746
- fix(lint/noUselessStringConcat): add missing fix_kind by @michellocana in #2748
- refactor(parser): implement NthToken for T by @denbezrukov in #2727
- fix(cli): workspace deadlock by @ematipico in #2753
- feat(biome_graphql_parser): parse union type definition by @vohoanglong0107 in #2719
- feat(biome_graphql_parser): parse enum type definition by @vohoanglong0107 in #2759
- fix(lint/useJsxKeyInIterable): handle ternaries outside jsx expressions by @dyc3 in #2749
- feat(bench): add CSS analyzer to the benchmarks by @ematipico in #2762
- feat(biome_css_analyzer): noUnknownProperty by @chansuke in #2755
- chore: add all packages by @ematipico in #2537
- feat(cli): command
clean
by @ematipico in #2528 - feat(biome_graphql_parser): parse input object definition by @vohoanglong0107 in #2761
- feat(css_formatter): use format_number_token utils for css number by @denbezrukov in #2769
- chore: add Financial Contributions section to GOVERNANCE by @arendjr in #2693
- test(biome_graphql_parser): move union tests to inside definitions by @vohoanglong0107 in #2775
- ci: fix knope release workflow by @ematipico in #2780
- feat(biome_graphql_parser): parse directive definition by @vohoanglong0107 in #2774
- fix(biome_graphql_parser): improve operation handling by @vohoanglong0107 in #2779
- chore: move
@nissy-dev
to past maintainer by @ematipico in #2785 - feat(biome_js_analyze): implement useFocusableInteractive by @DerTimonius in #2710
- chore: remove libs that panic by @ematipico in #2791
- fix(css_parser): resolve CSS parsing issues by @denbezrukov in #2792
- fix(biome_graphql_parser): prevent empty interface list in implement clause by @vohoanglong0107 in #2776
- refactor(biome_graphql_parser): use is_nth_at_* by @vohoanglong0107 in #2795
- feat(biome_css_analyzer): implement noInvalidPositionAtImportRule by @t-shiratori in #2717
- feat(biome_css_analyzer): implement noUnknownMediaFeatureName by @Kazuhiro-Mimaki in #2751
- fix: missing codeblock by @ematipico in #2804
- fix(format/js): fix arrow function type annotation inconsistency with prettier by @dyc3 in #2766
- feat(biome_analyze): make jsx_runtime optional inside the analyzer by @Kazuhiro-Mimaki in #2813
- fix(lint/useJsxKeyInIterable): flag jsx in variable declarations by @dyc3 in #2803
- refactor(analyze): add
language
field to rule metadata by @dyc3 in #2811 - feat(analyze): serialize rule metadata by @ematipico in #2824
- chore(deps): update @biomejs packages by @renovate in #2826
- chore(deps): update rust crate enumflags2 to 0.7.9 by @renovate in #2829
- chore(deps): update rust crate proc-macro2 to 1.0.82 by @renovate in #2831
- chore(deps): update rust crate schemars to 0.8.19 by @renovate in #2832
- chore(deps): update rust crate getrandom to 0.2.15 by @renovate in #2830
- chore(deps): update rust crate anyhow to 1.0.83 by @renovate in #2828
- chore(deps): update rust crate rayon to 1.10.0 by @renovate in #2835
- chore(deps): update rust crate serde_json to 1.0.117 by @renovate in #2834
- chore(deps): update github-actions by @renovate in #2827
- chore(deps): update rust crate serde to 1.0.201 by @renovate in #2833
- fix(biome_graphql_parser): allow keyword to be used as identifier by @vohoanglong0107 in #2814
- feat(bench): add graphql parser by @ematipico in #2836
- refactor(biome_fs): make
BiomePath::extension_as_str
not panic by @dyc3 in #2838 - refactor(readme): add l2beat silver sponsor by @Conaclos in #2840
- feat: yaml file source by @Netail in #2839
- feat(migrate): migrate nursery rules by @ematipico in #2382
- docs(useFilenamingConvention): how to ignore files by @Conaclos in #2843
- ci: fix workflow preapre relase by @ematipico in #2844
- ci: fix workflow preapre relase by @ematipico in #2846
- ci: the CLI has now a different package name by @ematipico in #2847
- chore: add graphql_parser bench to
Cargo.toml
by @ematipico in #2848 - dcos(useFilenamingConvention): fix JSON by @Conaclos in #2849
- feat(biome_grit_formatter): initial infrastructure by @abidjappie in #2837
- fix: stale
Cargo.lock
by @Sec-ant in #2851 - feat(biome_deserialize): implement necessary traits for
#[deserializable(rest)]
by @NicholasLYang in #2857 - refactor(noUndeclaredVariables): suggest using javascript.globals by @Conaclos in #2850
- refactor(biome_analyze): add
RuleAction::new
by @dyc3 in #2820 - fix(docs): noImplicitBoolean is inspired by @ematipico in #2873
- feat(biome_deserialize_derive): adding a rest attribute by @NicholasLYang in #2757
- refactor(biome_analyze): expose
RuleMetadata
viaRuleContext
by @dyc3 in #2821 - feat(biome_configuration): add helpers for parsing .editorconfig files by @dyc3 in #2852
- docs: update no_non_null_assertion.rs by @iOnline247 in #2878
- refactor(codemod/biome_js_analyze): remove manual construction of
JsRuleAction
by @dyc3 in #2874 - docs: fix incorrect bullet char + fix links by @MacFJA in #2875
- docs(cli): add details about the
--rule
option by @Conaclos in #2888 - refactor(biome_analyze): derive
Applicability
fromFixKind
by @dyc3 in #2885 - fix(biome_migrate): add
FixKind
toNurseryRules
migration by @dyc3 in #2890 - refactor: use an unordered set for interned paths by @Conaclos in #2893
- chore: fix typos in the
useNamingConvention
documentation by @mrazauskas in #2895 - chore: add CodeRabbit as bronze sponsor by @ematipico in #2896
- refactor(biome_graphql_parser): remove is_at_*_definition by @vohoanglong0107 in #2841
- refactor: improve diagnostic for too large files by @Conaclos in #2905
- chore(linter): remove unused
NoColorInvalidHex
by @togami2864 in #2909 - refactor(codemod/biome_js_analyze): derive
Applicability
for all lint rule actions by @dyc3 in #2889 - docs: improve analyze guide by @ematipico in #2910
- docs: add more tips around the analyzer by @ematipico in #2913
- build(deps): remove itertools by @Conaclos in #2914
- chore(deps): update @biomejs packages by @renovate in #2919
- feat(lint): useSemanticElements by @fujiyamaorange in #2867
- chore(deps): update actions/checkout action to v4.1.6 by @renovate in #2920
- feat(biome_service,biome_cli): resolve
.editorconfig
files and merge configuration by @dyc3 in #2884 - fix(deps): update rust crates by @renovate in #2641
- feat(biome_graphql_parser): parse schema extension by @vohoanglong0107 in #2842
- ci: update
time
, as it's causing some fails in CI by @ematipico in #2923 - refactor(diagnostics): change enum hierarchy for configuration diagnostics by @dyc3 in #2922
- feat(biome_graphql_parser): parse scalar extension by @vohoanglong0107 in #2927
- refactor(lint/useTopLevelRegex): ignore regular expressions with the
g
and/ory
flags by @lucasweng in #2926 - chore(git): ignore more generated files by @Conaclos in #2938
- feat(biome_graphql_parser): parse object extension by @vohoanglong0107 in #2928
- feat(lsp): pull diagnostics for CSS files by @ematipico in #2937
- chore(linter): rename
noCssEmptyBlock
->noEmptyBlock
by @togami2864 in #2945 - feat(biome_js_analyzer): useAdjacentOverloadSignatures by @chansuke in #2508
New Contributors
- @mechairoi made their first contribution in #2778
- @Netail made their first contribution in #2839
- @abidjappie made their first contribution in #2837
- @NicholasLYang made their first contribution in #2857
- @iOnline247 made their first contribution in #2878
- @MacFJA made their first contribution in #2875
- @mrazauskas made their first contribution in #2895
Full Changelog: cli/v1.7.3...js-api/v0.6.0-nightly.af70ac2