cli/v1.8.0
版本发布时间: 2024-06-04 19:45:55
biomejs/biome最新发布版本:js-api/v0.7.1(2024-10-02 00:17:16)
Analyzer
New features
- Allow suppression comments to suppress individual instances of rules. This is
used for the lint rule
useExhaustiveDependencies
, which is now able to suppress specific dependencies. Fixes #2509. Contributed by @arendjr
Enhancements
- Assume
Astro
object is always a global when processing.astro
files. Contributed by @minht11 - Assume Vue compiler macros are globals when processing
.vue
files. (#2771) Contributed by @dyc3
CLI
New features
-
New
clean
command. Use this new command to clean after thebiome-logs
directory, and remove all the log files.biome clean
-
Add two new options
--only
and--skip
to the commandbiome lint
(#58).The
--only
option allows you to run a given rule or rule group, For example, the following command runs only thestyle/useNamingConvention
andstyle/noInferrableTypes
rules. If the rule is disabled in the configuration, then its severity level is set toerror
for a recommended rule orwarn
otherwise.biome lint --only=style/useNamingConvention --only=style/noInferrableTypes
Passing a group does not change the severity level of the rules in the group. All the disabled rules in the group will remain disabled. To ensure that the group is run, the
recommended
field of the group is enabled. Thenursery
group cannot be passed, as no rules are enabled by default in the nursery group.The
--skip
option allows you to skip the execution of a given group or a given rule. For example, the following command skips thestyle
group and thesuspicious/noExplicitAny
rule.biome lint --skip=style --skip=suspicious/noExplicitAny
You can also use
--only
and--skip
together.--skip
oevrrides--only
. The following command executes only the rules from thestyle
group, but thestyle/useNamingConvention
rule.biome lint --only=style --skip=style/useNamingConvention
These options are compatible with other options such as
--write
(previously--apply
), 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 -
Add a new
--reporter
calledgithub
. This reporter will print diagnostics using GitHub workflow commands:::error title=lint/suspicious/noDoubleEquals,file=main.ts,line=4,endLine=4,col=3,endColumn=5::Use === instead of == ::error title=lint/suspicious/noDebugger,file=main.ts,line=6,endLine=6,col=1,endColumn=9::This is an unexpected use of the debugger statement. ::error title=lint/nursery/noEvolvingAny,file=main.ts,line=8,endLine=8,col=5,endColumn=6::This variable's type is not allowed to evolve implicitly, leading to potential any types.
Contributed by @ematipico
-
Add a new
--reporter
calledjunit
. This reporter will print diagnostics using GitHub workflow commands:<?xml version="1.0" encoding="UTF-8"?> <testsuites name="Biome" tests="16" failures="16" errors="20" time="<TIME>"> <testsuite name="main.ts" tests="1" disabled="0" errors="0" failures="1" package="org.biome"> <testcase name="org.biome.lint.suspicious.noDoubleEquals" line="4" column="3"> <failure message="Use === instead of ==. == is only allowed when comparing against `null`">line 3, col 2, Use === instead of ==. == is only allowed when comparing against `null`</failure> </testcase> </testsuite> <testsuite name="main.ts" tests="1" disabled="0" errors="0" failures="1" package="org.biome"> <testcase name="org.biome.lint.suspicious.noDebugger" line="6" column="1"> <failure message="This is an unexpected use of the debugger statement.">line 5, col 0, This is an unexpected use of the debugger statement.</failure> </testcase> </testsuite> <testsuite name="main.ts" tests="1" disabled="0" errors="0" failures="1" package="org.biome"> <testcase name="org.biome.lint.nursery.noEvolvingAny" line="8" column="5"> <failure message="This variable's type is not allowed to evolve implicitly, leading to potential any types.">line 7, col 4, This variable's type is not allowed to evolve implicitly, leading to potential any types.</failure> </testcase> </testsuite> </testsuites>
Contributed by @ematipico
Bug fixes
- Fix #3024, where running
biome init
would createbiome.json
even ifbiome.jsonc
already exists. Contributed by @minht11
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 the
fix
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 -
You can now change the severity of lint rules down to
"info"
. The"info"
severity doesn't emit error codes, and it isn't affected by other options like--error-on-warnings
:{ "linter": { "rules": { "suspicious": { "noDebugger": "info" } } } }
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
Bug fixes
- Fix a bug where if the formatter was disabled at the language level, it could be erroneously enabled by an override that did not specify the formatter section #2924. Contributed by @dyc3
- Fix #2990, now Biome doesn't add a trailing comma when formatting
biome.json
. Contributed by @dyc3
Editors
New features
- Add support for LSP Workspaces
Enhancements
- The LSP doesn't crash anymore when the configuration file contains errors. If the configuration contains errors, Biome now shows a pop-up to the user, and it will only parse files using the default configuration. Formatting and linting is disabled until the configuration file is fixed. Contributed by @ematipico
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
- Fix [https://github.com/biomejs/biome/issues/2877] by correctly handling line terminators in JSX string. Contributed by @ah-yu
JavaScript APIs
Linter
Promoted rules
New rules are incubated in the nursery group. Once stable, we promote them to a stable group. The following rules are promoted:
New features
-
Add nursery/useDateNow. Contributed by @minht11
-
Add nursery/useErrorMessage. Contributed by @minht11
-
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
-
Add nursery/noUnusedFunctionParameters Contributed by @printfn
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
-
Improve code action for nursery/noUselessUndefinedInitialization to handle comments.
The rule now places inline comments after the declaration statement, instead of removing them. The code action is now safe to apply.
Contributed by @lutaok
-
Make useExhaustiveDependencies report duplicate dependencies. Contributed by @tunamaguro
-
Rename
noEvolvingAny
intonoEvolvingTypes
(#48). 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 correctly handle ambient computed member names (#2975).
A constant can be imported as a type and used in a computed member name of a member signature. Previously, Biome was unable to bind the value imported as a type to the computed member name.
import type { NAME } from "./constants.js"; type X = { [NAME]: number };
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 /> } }
Contributed by @printfn and @Conaclos
-
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('');
-
noEmptyBlockStatements
no longer reports empty constructors using typescript parameter properties. #3005 Contributed by @dyc3 -
noEmptyBlockStatements
no longer reports empty private or protected constructors. Contributed by @dyc3 -
noExportsInTest rule no longer treats files with in-source testing as test files https://github.com/biomejs/biome/issues/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
-
noUndeclaredVariables no logger alerts on
arguments
object in a function scope. Contributed by @ah-yu
Parser
Enhancements
-
lang="tsx"
is now supported in Vue Single File Components. #2765 Contributed by @dyc3
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
- ci: create workflow to enable CD for
@biomejs/wasm-web
by @ematipico in https://github.com/biomejs/biome/pull/2954 - refactor: make suppression action generic via trait by @ematipico in https://github.com/biomejs/biome/pull/2955
- release(crates): biome_deserialize and biome_deserialize_macros by @Conaclos in https://github.com/biomejs/biome/pull/2979
- feat(css_parser): add parsing css modules @value at rule by @denbezrukov in https://github.com/biomejs/biome/pull/2985
- chore(deps): update rust crate schemars to 0.8.21 by @renovate in https://github.com/biomejs/biome/pull/2997
- chore(deps): update rust crate proc-macro2 to 1.0.84 by @renovate in https://github.com/biomejs/biome/pull/2996
- chore(deps): update rust crate serde to 1.0.203 by @renovate in https://github.com/biomejs/biome/pull/2998
- chore(deps): update actions/setup-node action to v4.0.2 by @renovate in https://github.com/biomejs/biome/pull/2993
- chore(deps): update rust crate anyhow to 1.0.86 by @renovate in https://github.com/biomejs/biome/pull/2995
- feat(biome_graphql_parser): parse interface type extension by @vohoanglong0107 in https://github.com/biomejs/biome/pull/2942
- docs(noUselessConstructor): update outdated link to external docs by @dyc3 in https://github.com/biomejs/biome/pull/3008
- refactor(biome_js_analyze): use rustc_hash::FxHashSet; and reduce allocation by @chansuke in https://github.com/biomejs/biome/pull/3004
- feat(configuration): add support for
{a,b}
glob patterns, gated behind an internal flag by @dyc3 in https://github.com/biomejs/biome/pull/2989 - fix(formatter): never format biome.json with trailing commas by @dyc3 in https://github.com/biomejs/biome/pull/3007
- feat(css_parser): add :local and :global pseudo class. #3011 by @denbezrukov in https://github.com/biomejs/biome/pull/3012
- feat(lsp): improve DX when the configuration has syntax errors by @ematipico in https://github.com/biomejs/biome/pull/2982
- feat(biome_graphql_parser): parse union extension by @vohoanglong0107 in https://github.com/biomejs/biome/pull/3010
- feat(cli): rage now prints all enabled rules by @ematipico in https://github.com/biomejs/biome/pull/2946
- ci: move wasm build to dispatch by @ematipico in https://github.com/biomejs/biome/pull/3018
- feat(css_parser): css modules composes by @denbezrukov in https://github.com/biomejs/biome/pull/3017
- docs(bench): update docs of benchmark by @chansuke in https://github.com/biomejs/biome/pull/3022
- feat: add
noLabelWithoutControl
rule by @michellocana in https://github.com/biomejs/biome/pull/2987 - fix(lint/useJsxKeyInIterable): fix a false positive when key is in the return statement, but not any variable declarations by @dyc3 in https://github.com/biomejs/biome/pull/3031
- chore(deps): update docker/login-action action to v3.2.0 by @renovate in https://github.com/biomejs/biome/pull/3045
- chore(deps): update dependency eslint to v9.4.0 by @renovate in https://github.com/biomejs/biome/pull/3043
- chore(deps): update rust crate proc-macro2 to 1.0.85 by @renovate in https://github.com/biomejs/biome/pull/3040
- chore(deps): update rust crate smallvec to 1.13.2 by @renovate in https://github.com/biomejs/biome/pull/3048
- chore(deps): update rust crate insta to 1.39.0 by @renovate in https://github.com/biomejs/biome/pull/3046
- chore(deps): update rust crate oxc_resolver to 1.8.1 by @renovate in https://github.com/biomejs/biome/pull/3047
- refactor(noUnusedTemplateLiteral): remove rule sources by @Conaclos in https://github.com/biomejs/biome/pull/3052
- refactor(useThrowOnlyError): fix sources by @Conaclos in https://github.com/biomejs/biome/pull/3053
- chore: remove git modules for better internal experience by @ematipico in https://github.com/biomejs/biome/pull/3054
New Contributors
- @tunamaguro made their first contribution in https://github.com/biomejs/biome/pull/2991
Full Changelog: https://github.com/biomejs/biome/compare/cli/v1.7.4-nightly.125f34b...cli/v1.8.0
1、 biome-darwin-arm64 19.53MB
2、 biome-darwin-x64 21.06MB
3、 biome-linux-arm64 20.93MB
4、 biome-linux-arm64-musl 18.49MB
5、 biome-linux-x64 23.74MB
6、 biome-linux-x64-musl 23.01MB
7、 biome-win32-arm64.exe 22.4MB
8、 biome-win32-x64.exe 26.67MB