### Install Biome using bun Source: https://v1.biomejs.dev/guides/getting-started Installs Biome as a development dependency using bun. ```bash bun add --dev --exact @biomejs/biome ``` -------------------------------- ### Install Biome using deno Source: https://v1.biomejs.dev/guides/getting-started Installs Biome as a development dependency using deno. ```bash deno add --dev npm:@biomejs/biome ``` -------------------------------- ### Initialize Biome configuration using deno Source: https://v1.biomejs.dev/guides/getting-started Initializes a biome.json configuration file using deno. ```bash deno run -A npm:@biomejs/biome init ``` -------------------------------- ### Install Biome using npm Source: https://v1.biomejs.dev/guides/getting-started Installs Biome as a development dependency using npm. ```bash npm install --save-dev --save-exact @biomejs/biome ``` -------------------------------- ### Initialize Biome configuration using bun Source: https://v1.biomejs.dev/guides/getting-started Initializes a biome.json configuration file using bun. ```bash bunx biome init ``` -------------------------------- ### Initialize Biome configuration using npx Source: https://v1.biomejs.dev/guides/getting-started Initializes a biome.json configuration file using npx. ```bash npx @biomejs/biome init ``` -------------------------------- ### Install Biome using yarn Source: https://v1.biomejs.dev/guides/getting-started Installs Biome as a development dependency using yarn. ```bash yarn add --dev --exact @biomejs/biome ``` -------------------------------- ### Install Biome using pnpm Source: https://v1.biomejs.dev/guides/getting-started Installs Biome as a development dependency using pnpm. ```bash pnpm add --save-dev --save-exact @biomejs/biome ``` -------------------------------- ### Initialize Biome configuration using pnpm Source: https://v1.biomejs.dev/guides/getting-started Initializes a biome.json configuration file using pnpm. ```bash pnpm biome init ``` -------------------------------- ### Initialize Biome configuration using yarn Source: https://v1.biomejs.dev/guides/getting-started Initializes a biome.json configuration file using yarn. ```bash yarn biome init ``` -------------------------------- ### Format files using deno Source: https://v1.biomejs.dev/guides/getting-started Formats specified files or directories using the Biome CLI with deno. ```bash deno run -A npm:@biomejs/biome format --write ``` -------------------------------- ### Default Biome configuration file Source: https://v1.biomejs.dev/guides/getting-started Example of a default biome.json configuration file generated by the init command. ```json { "$schema": "https://biomejs.dev/schemas/1.9.4/schema.json", "vcs": { "enabled": false, "clientKind": "git", "useIgnoreFile": false }, "files": { "ignoreUnknown": false, "ignore": [] }, "formatter": { "enabled": true, "indentStyle": "tab" }, "organizeImports": { "enabled": true }, "linter": { "enabled": true, "rules": { "recommended": true } }, "javascript": { "formatter": { "quoteStyle": "double" } } } ``` -------------------------------- ### Format files using npx Source: https://v1.biomejs.dev/guides/getting-started Formats specified files or directories using the Biome CLI with npx. ```bash npx @biomejs/biome format --write ``` -------------------------------- ### Format files using bun Source: https://v1.biomejs.dev/guides/getting-started Formats specified files or directories using the Biome CLI with bun. ```bash bunx biome format --write ``` -------------------------------- ### Configuration example Source: https://v1.biomejs.dev/linter/rules/use-trim-start-end Example of how to configure the useTrimStartEnd rule. ```json { "linter": { "rules": { "nursery": { "useTrimStartEnd": "error" } } } } ``` -------------------------------- ### Format files using yarn Source: https://v1.biomejs.dev/guides/getting-started Formats specified files or directories using the Biome CLI with yarn. ```bash yarn biome format --write ``` -------------------------------- ### Check files using deno Source: https://v1.biomejs.dev/guides/getting-started Runs format, lint, and organize imports on specified files or directories using the Biome CLI with deno. ```bash deno run -A npm:@biomejs/biome check --write ``` -------------------------------- ### Format files using pnpm Source: https://v1.biomejs.dev/guides/getting-started Formats specified files or directories using the Biome CLI with pnpm. ```bash pnpm biome format --write ``` -------------------------------- ### Check files using bun Source: https://v1.biomejs.dev/guides/getting-started Runs format, lint, and organize imports on specified files or directories using the Biome CLI with bun. ```bash bunx biome check --write ``` -------------------------------- ### Check files using npx Source: https://v1.biomejs.dev/guides/getting-started Runs format, lint, and organize imports on specified files or directories using the Biome CLI with npx. ```bash npx @biomejs/biome check --write ``` -------------------------------- ### Check files using pnpm Source: https://v1.biomejs.dev/guides/getting-started Runs format, lint, and organize imports on specified files or directories using the Biome CLI with pnpm. ```bash pnpm biome check --write ``` -------------------------------- ### Configuration example Source: https://v1.biomejs.dev/linter/rules/use-is-nan This is an example of how to configure the useIsNan rule. ```json { "linter": { "rules": { "correctness": { "useIsNan": "error" } } } } ``` -------------------------------- ### Check files using yarn Source: https://v1.biomejs.dev/guides/getting-started Runs format, lint, and organize imports on specified files or directories using the Biome CLI with yarn. ```bash yarn biome check --write ``` -------------------------------- ### Configuration example Source: https://v1.biomejs.dev/linter/rules/use-alt-text Example of how to configure the `useAltText` rule in Biome. ```json { "linter": { "rules": { "a11y": { "useAltText": "error" } } } } ``` -------------------------------- ### Configuration example Source: https://v1.biomejs.dev/linter/rules/use-nodejs-import-protocol Example of how to configure the 'useNodejsImportProtocol' rule in biome.json. ```json { "linter": { "rules": { "style": { "useNodejsImportProtocol": "error" } } } } ``` -------------------------------- ### Configuration example Source: https://v1.biomejs.dev/linter/rules/no-useless-undefined-initialization This is an example of how to configure the noUselessUndefinedInitialization rule in the linter configuration. ```json { "linter": { "rules": { "complexity": { "noUselessUndefinedInitialization": "error" } } } } ``` -------------------------------- ### Formatter Example Source: https://v1.biomejs.dev/playground?code=YQAgAD0AIAB7AAoAIAAgAFsAeAAgAD0AIAAwAF0AOgAgADEALAAKAH0ACgAKAGMAbABhAHMAcwAgAEMAIAB7AAoAIAAgACAAIABbAHgAIAA9ACAAMABdACAAPQAgADEACgB9AAoA&enabledLinting=false An example demonstrating Biome's formatter output. ```javascript a = { [x = 0]: 1, } class C { [x = 0] = 1 } ``` -------------------------------- ### Docker Image Usage Source: https://v1.biomejs.dev/guides/manual-installation Examples of using Biome's official Docker images for linting and formatting files. The default working directory in the container is /code. ```bash # Lint files docker run -v $(pwd):/code ghcr.io/biomejs/biome lint docker run -v $(pwd):/code ghcr.io/biomejs/biome lint --write # Format files docker run -v $(pwd):/code ghcr.io/biomejs/biome format docker run -v $(pwd):/code ghcr.io/biomejs/biome format --write ``` -------------------------------- ### Configuration example Source: https://v1.biomejs.dev/linter/rules/no-positive-tabindex This is an example of how to configure the `noPositiveTabindex` rule. ```json { "linter": { "rules": { "a11y": { "noPositiveTabindex": "error" } } } } ``` -------------------------------- ### Lint and fix files using bun Source: https://v1.biomejs.dev/guides/getting-started Lints specified files or directories and applies safe fixes using the Biome CLI with bun. ```bash bunx biome lint --write ``` -------------------------------- ### Configuration example Source: https://v1.biomejs.dev/linter/rules/use-iframe-title Example of how to configure the `useIframeTitle` rule in the Biome configuration. ```json { "linter": { "rules": { "a11y": { "useIframeTitle": "error" } } } } ``` -------------------------------- ### Configuration Example Source: https://v1.biomejs.dev/linter/rules/no-duplicate-at-import-rules Example of how to configure the noDuplicateAtImportRules in biome.json. ```json { "linter": { "rules": { "suspicious": { "noDuplicateAtImportRules": "error" } } } } ``` -------------------------------- ### Lint and fix files using deno Source: https://v1.biomejs.dev/guides/getting-started Lints specified files or directories and applies safe fixes using the Biome CLI with deno. ```bash deno run -A npm:@biomejs/biome lint --write ``` -------------------------------- ### Lint and fix files using npx Source: https://v1.biomejs.dev/guides/getting-started Lints specified files or directories and applies safe fixes using the Biome CLI with npx. ```bash npx @biomejs/biome lint --write ``` -------------------------------- ### Configuration example Source: https://v1.biomejs.dev/linter/rules/no-useless-switch-case Example of how to configure the noUselessSwitchCase rule in a biome.json file. ```json { "linter": { "rules": { "complexity": { "noUselessSwitchCase": "error" } } } } ``` -------------------------------- ### Homebrew Installation Source: https://v1.biomejs.dev/guides/manual-installation Installs Biome using the Homebrew package manager on macOS and Linux. ```bash brew install biome ``` -------------------------------- ### Configuration example Source: https://v1.biomejs.dev/linter/rules/no-substr Example of how to configure the noSubstr rule in biome.json. ```json { "linter": { "rules": { "nursery": { "noSubstr": "error" } } } } ``` -------------------------------- ### organizeImports.include example Source: https://v1.biomejs.dev/reference/configuration Example configuration for including files for import sorting. ```json { "organizeImports": { "include": ["scripts/*.js"] } } ``` -------------------------------- ### Configuration Example Source: https://v1.biomejs.dev/linter/rules/use-key-with-click-events Example of how to configure the useKeyWithClickEvents rule in Biome. ```json { "linter": { "rules": { "a11y": { "useKeyWithClickEvents": "error" } } } } ``` -------------------------------- ### Configuration example Source: https://v1.biomejs.dev/linter/rules/no-self-assign Example of how to configure the noSelfAssign rule in the Biome configuration. ```json { "linter": { "rules": { "correctness": { "noSelfAssign": "error" } } } } ``` -------------------------------- ### Valid Example Source: https://v1.biomejs.dev/linter/rules/use-jsx-key-in-iterable This example shows valid usage with key props. ```jsx [, , ]; data.map((x) => {x}); ``` -------------------------------- ### Configuration example Source: https://v1.biomejs.dev/linter/rules/no-class-assign Example of how to configure the noClassAssign rule in biome.json. ```json { "linter": { "rules": { "suspicious": { "noClassAssign": "error" } } } } ``` -------------------------------- ### Configuration example Source: https://v1.biomejs.dev/linter/rules/use-heading-content This is an example of how to configure the useHeadingContent rule in the linter configuration. ```json { "linter": { "rules": { "a11y": { "useHeadingContent": "error" } } } } ``` -------------------------------- ### Example ESLint configuration Source: https://v1.biomejs.dev/guides/migrate-eslint-prettier An example ESLint configuration file. ```json { "extends": ["plugin:unicorn/recommended"], "plugins": ["unicorn"], "ignore_patterns": ["dist/**"], "globals": { "Global1": "readonly" }, "rules": { "eqeqeq": "error" }, "overrides": [ { "files": ["tests/**"], "rules": { "eqeqeq": "off" } } ] } ``` -------------------------------- ### Configuration example Source: https://v1.biomejs.dev/linter/rules/no-duplicate-else-if This example shows how to configure the noDuplicateElseIf rule. ```json { "linter": { "rules": { "nursery": { "noDuplicateElseIf": "error" } } } } ``` -------------------------------- ### Simplified private class member convention Source: https://v1.biomejs.dev/linter/rules/use-naming-convention Example of configuring a convention for private class members to start with an underscore. ```json { // ... "options": { "conventions": [ { "selector": { "kind": "classMember", "modifiers": ["private"] }, "match": "_(.+)" // We don't need to specify `formats` because the capture is forwarded to the next conventions. } // default conventions ] } } ``` -------------------------------- ### Configuration example Source: https://v1.biomejs.dev/linter/rules/no-constant-condition Example of how to configure the noConstantCondition rule in biome.json. ```json { "linter": { "rules": { "correctness": { "noConstantCondition": "error" } } } } ``` -------------------------------- ### How to configure Source: https://v1.biomejs.dev/linter/rules/use-filenaming-convention Example of how to configure the rule. ```json { "linter": { "rules": { "style": { "useFilenamingConvention": "error" } } } } ``` -------------------------------- ### noUndeclaredDependencies now recognizes imports of subpath exports Source: https://v1.biomejs.dev/internals/changelog Example import statements that no longer report errors if @mui/material and tailwindcss are installed as dependencies. ```typescript import Button from "@mui/material/Button"; import { fontFamily } from "tailwindcss/defaultTheme"; ``` -------------------------------- ### Windows (x86_64) Binary Installation Source: https://v1.biomejs.dev/guides/manual-installation Downloads the Biome executable for Windows x86_64 architecture. ```powershell # Windows (x86_64, Powershell) Invoke-WebRequest -Uri "https://github.com/biomejs/biome/releases/download/cli%2Fv/biome-win32-x64.exe" -OutFile "biome.exe" ``` -------------------------------- ### Configuration example Source: https://v1.biomejs.dev/linter/rules/no-catch-assign This is an example of how to configure the noCatchAssign rule in a biome.json file. ```json { "linter": { "rules": { "suspicious": { "noCatchAssign": "error" } } } } ``` -------------------------------- ### Configuration example Source: https://v1.biomejs.dev/linter/rules/no-self-compare Example of how to configure the noSelfCompare rule in Biome. ```json { "linter": { "rules": { "suspicious": { "noSelfCompare": "error" } } } } ``` -------------------------------- ### Using 'extends' to resolve shared configuration Source: https://v1.biomejs.dev/blog/biome-v1-6 Example of how to use the 'extends' property in biome.json to reference a shared configuration from an installed dependency. ```json { "extends": ["@shared-configs/biome"] } ``` -------------------------------- ### Options Source: https://v1.biomejs.dev/linter/rules/use-filenaming-convention Example of how to configure the rule options. ```json { "//": "...", "options": { "strictCase": false, "requireAscii": true, "filenameCases": ["camelCase", "export"] } } ``` -------------------------------- ### Enforce naming conventions for private class members Source: https://v1.biomejs.dev/linter/rules/use-naming-convention Example of enforcing that private class members start with `_` and the captured name is in `camelCase`. ```json { "//": "...", "options": { "conventions": [ { "selector": { "kind": "classMember", "modifiers": ["private"] }, "match": "_(.+)", "formats": ["camelCase"] } ] } } ``` -------------------------------- ### Husky: Prepare script for automatic hook setup Source: https://v1.biomejs.dev/recipes/git-hooks This `package.json` script automatically sets up Husky hooks upon package installation. ```json { "scripts": { "prepare": "husky" } } ``` -------------------------------- ### Linux (x86_64) Binary Installation Source: https://v1.biomejs.dev/guides/manual-installation Downloads and makes the Biome executable for Linux x86_64 architecture executable. ```bash # Linux (x86_64) curl -L https://github.com/biomejs/biome/releases/download/cli%2Fv/biome-linux-x64 -o biome chmod +x biome ``` -------------------------------- ### Invalid example 2 with fix Source: https://v1.biomejs.dev/linter/rules/no-blank-target The same invalid example with the suggested fix. ```jsx child ``` -------------------------------- ### Prettier Configuration Source: https://v1.biomejs.dev/guides/migrate-eslint-prettier An example of a Prettier configuration file. ```json { "useTabs": false, "singleQuote": true, "overrides": [ { "files": ["*.json"], "options": { "tabWidth": 2 } } ] } ``` -------------------------------- ### Configuration example Source: https://v1.biomejs.dev/linter/rules/use-guard-for-in Configuration to enable the useGuardForIn rule. ```json { "linter": { "rules": { "nursery": { "useGuardForIn": "error" } } } } ``` -------------------------------- ### Lint and fix files using pnpm Source: https://v1.biomejs.dev/guides/getting-started Lints specified files or directories and applies safe fixes using the Biome CLI with pnpm. ```bash pnpm biome lint --write ``` -------------------------------- ### Lint and fix files using yarn Source: https://v1.biomejs.dev/guides/getting-started Lints specified files or directories and applies safe fixes using the Biome CLI with yarn. ```bash yarn biome lint --write ``` -------------------------------- ### $schema - Local path Source: https://v1.biomejs.dev/reference/configuration Allows to pass a path to a JSON schema file. This example shows how to specify a relative path to the schema if @biomejs/biome is installed in node_modules. ```json { "$schema": "./node_modules/@biomejs/biome/configuration_schema.json" } ``` -------------------------------- ### biome init usage Source: https://v1.biomejs.dev/reference/cli Initializes a new Biome project by creating a configuration file with default settings. ```bash biome init [--jsonc] ``` -------------------------------- ### Invalid for loop with incorrect condition direction Source: https://v1.biomejs.dev/linter/rules/use-valid-for-direction This example shows an invalid for loop where the counter `i` is incremented (`i++`) but the condition requires `i` to be greater than 10, which will never be met if `i` starts at 0. ```javascript for (var i = 0; i > 10; i++) { } ``` -------------------------------- ### Search command output example Source: https://v1.biomejs.dev/blog Example output from the `biome search` command, showing matched lines. ```text ./benchmark/bench.js:38:3 search ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ **38 │ console.info(`\n⌛ repository: ${name}`);** ./packages/@biomejs/js-api/scripts/update-nightly-version.mjs:27:1 search ━━━━━━━━━━━━━━ **27 │ console.log(`version=${version}`);** Searched 67 files in 1034ms. Found 2 matches. ``` -------------------------------- ### Configuration Example Source: https://v1.biomejs.dev/linter/rules/use-top-level-regex This is an example of how to configure the 'useTopLevelRegex' rule in the Biome configuration file. ```json { "linter": { "rules": { "performance": { "useTopLevelRegex": "error" } } } } ``` -------------------------------- ### biome start usage Source: https://v1.biomejs.dev/reference/cli Starts the Biome daemon server process. ```bash biome start [--config-path=PATH] ``` -------------------------------- ### Valid code example Source: https://v1.biomejs.dev/linter/rules/no-empty-pattern These code examples are valid because they create new bindings, unlike the invalid examples. ```javascript var {a = {}} = foo; var {a, b = {}} = foo; var {a = []} = foo; function foo({a = {}}) {} function foo({a = []}) {} var [a] = foo; ``` -------------------------------- ### Ignore code example Source: https://v1.biomejs.dev/formatter Example: ```javascript const expr = // biome-ignore format: the array should not be formatted [ (2 * n) / (r - l), 0, (r + l) / (r - l), 0, 0, (2 * n) / (t - b), (t + b) / (t - b), 0, 0, 0, -(f + n) / (f - n), -(2 * f * n) / (f - n), 0, 0, -1, 0, ]; ``` -------------------------------- ### Configuration example Source: https://v1.biomejs.dev/linter/rules/use-is-array This code snippet shows how to configure the `useIsArray` rule. ```json { "linter": { "rules": { "suspicious": { "useIsArray": "error" } } } } ``` -------------------------------- ### Configuration example Source: https://v1.biomejs.dev/linter/rules/no-control-characters-in-regex This is an example of how to configure the noControlCharactersInRegex rule. ```json { "linter": { "rules": { "suspicious": { "noControlCharactersInRegex": "error" } } } } ``` -------------------------------- ### noConstantCondition example Source: https://v1.biomejs.dev/internals/changelog Example of `while(true)` now allowed by noConstantCondition. ```typescript while (true) { if (cond) { break; } } ``` -------------------------------- ### React Component Example Source: https://v1.biomejs.dev/ A React component demonstrating formatting and basic logic. ```jsx function HelloWorld({greeting = "hello", greeted = '"World"', silent = false, onMouseOver,}) { if(!greeting){return null}; // TODO: Don't use random in render let num = Math.floor (Math.random() * 1E+7).toString().replace(/.d+/ig, "") return
{ greeting.slice( 0, 1 ).toUpperCase() + greeting.slice(1).toLowerCase() } {greeting.endsWith(",") ? " " : ", " } { greeted } { (silent) ? "." : "!"}
; } ``` -------------------------------- ### noConsoleLog example Source: https://v1.biomejs.dev/internals/changelog Example of code now reported by noConsoleLog. ```typescript globalThis.console.log("log") ``` -------------------------------- ### Custom configuration for lsp-proxy and start commands Source: https://v1.biomejs.dev/blog/biome-wins-prettier-challenge Pass a custom configuration to the `lsp-proxy` and `start` commands using the `--config-path` option. ```bash biome --config-path=../path/where/config/is lsp-proxy biome --config-path=../path/where/config/is start ``` -------------------------------- ### Formatter overrides example Source: https://v1.biomejs.dev/reference/configuration Example demonstrating how to override formatter settings like `lineWidth` and `indentStyle` for specific file globs. ```json { "formatter": { "lineWidth": 100 }, "overrides": [ { "include": ["generated/**"], "formatter": { "lineWidth": 160, "indentStyle": "space" } } ] } ``` -------------------------------- ### Configuration Example Source: https://v1.biomejs.dev/linter/rules/use-jsx-key-in-iterable Configuration for the useJsxKeyInIterable rule. ```json { "linter": { "rules": { "correctness": { "useJsxKeyInIterable": "error" } } } } ``` -------------------------------- ### Example Source: https://v1.biomejs.dev/linter/rules/use-exhaustive-dependencies Configuration example for hooks with stable results. ```json { "//": "...", "options": { "hooks": [ { "name": "useDispatch", "stableResult": true } ] } } ``` -------------------------------- ### Example Source: https://v1.biomejs.dev/linter/rules/use-exhaustive-dependencies Example of using hooks with the specified configuration. ```javascript function Foo() { const location = useLocation(() => {}, []); const query = useQuery([], () => {}); } ``` -------------------------------- ### Configuration example for rules without options Source: https://v1.biomejs.dev/internals/changelog This example shows how to configure a rule without options, where the `options` field is no longer required. ```json { "linter": { "rules": { "style": { "noDefaultExport": { "level": "off" } } } } } ``` -------------------------------- ### Example Source: https://v1.biomejs.dev/linter/rules/use-exhaustive-dependencies Configuration example for validating hook dependencies. ```json { "//": "...", "options": { "hooks": [ { "name": "useLocation", "closureIndex": 0, "dependenciesIndex": 1}, { "name": "useQuery", "closureIndex": 1, "dependenciesIndex": 0} ] } } ``` -------------------------------- ### Biome configuration file example Source: https://v1.biomejs.dev/guides/configure-biome An example Biome configuration file demonstrating the use of 'files.include' and 'files.ignore' for global file processing rules, and 'linter.ignore' for tool-specific rules. ```json { "files": { "include": ["src/**/*.js", "test/**/*.js"], "ignore": ["**/*.min.js"], }, "linter": { "ignore": ["test"] } } ``` -------------------------------- ### Configuration example Source: https://v1.biomejs.dev/linter/rules/use-exponentiation-operator Example of how to configure the `useExponentiationOperator` rule in biome.json. ```json { "linter": { "rules": { "style": { "useExponentiationOperator": "error" } } } } ``` -------------------------------- ### New 'using' syntax Source: https://v1.biomejs.dev/internals/changelog Example of the new 'using' syntax. ```javascript const using = resource.lock(); ``` -------------------------------- ### Configuration path flag example Source: https://v1.biomejs.dev/internals/changelog Example of using the `--config-path` flag to specify a configuration file. ```bash biome format --config-path=../biome.json ./src ``` -------------------------------- ### Configuration Example Source: https://v1.biomejs.dev/linter/rules/no-useless-string-raw Example of how to configure the noUselessStringRaw rule in biome.json. ```json { "linter": { "rules": { "nursery": { "noUselessStringRaw": "error" } } } } ``` -------------------------------- ### Invalid Fragment Example 4 Source: https://v1.biomejs.dev/linter/rules/no-useless-fragments An example of an empty fragment. ```jsx <> ``` ```text code-block.jsx:1:1 lint/complexity/noUselessFragments ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ✖ Avoid using unnecessary Fragment. > 1 │ <> ** │ ****^****^****^****^****^** 2 │ ℹ A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment. ``` -------------------------------- ### Configuration example Source: https://v1.biomejs.dev/linter/rules/no-unsafe-negation Example of how to configure the noUnsafeNegation rule. ```json { "linter": { "rules": { "suspicious": { "noUnsafeNegation": "error" } } } } ``` -------------------------------- ### Example ESLint Configuration Source: https://v1.biomejs.dev/blog/biome-v1-7 An example of a legacy ESLint configuration file. ```json { "extends": [ "plugin:unicorn/recommended" ], "plugins": [ "unicorn" ], "ignore_patterns": [ "dist/**" ], "globals": { "Global1": "readonly" }, "rules": { "eqeqeq": "error" }, "overrides": [ { "files": [ "tests/**" ], "rules": { "eqeqeq": "off" } } ] } ``` -------------------------------- ### Configuration example Source: https://v1.biomejs.dev/linter/rules/no-unmatchable-anb-selector Example of how to configure the noUnmatchableAnbSelector rule in biome.json. ```json { "linter": { "rules": { "correctness": { "noUnmatchableAnbSelector": "error" } } } } ``` -------------------------------- ### Valid trimStart Source: https://v1.biomejs.dev/linter/rules/use-trim-start-end Example of valid code using trimStart. ```javascript const foo = bar.trimStart(); ``` -------------------------------- ### Configuration example Source: https://v1.biomejs.dev/linter/rules/no-unknown-pseudo-element Example of how to configure the noUnknownPseudoElement rule in biome.json. ```json { "linter": { "rules": { "nursery": { "noUnknownPseudoElement": "error" } } } } ``` -------------------------------- ### Configuration Source: https://v1.biomejs.dev/linter/rules/no-delete Example of how to configure the noDelete rule. ```json { "linter": { "rules": { "performance": { "noDelete": "error" } } } } ``` -------------------------------- ### Invalid array example Source: https://v1.biomejs.dev/linter/rules/no-sparse-array An example of an invalid sparse array. ```javascript [1,,2] ``` -------------------------------- ### Valid examples Source: https://v1.biomejs.dev/linter/rules/no-misleading-character-class These examples show valid regular expressions. ```javascript /^[abc]$/; ``` ```javascript /^[👍]$/u; ``` ```javascript /^["q{👶🏻}]$/v; ``` -------------------------------- ### Configuration Example Source: https://v1.biomejs.dev/linter/rules/no-irregular-whitespace This is an example of how to configure the noIrregularWhitespace rule. ```json { "linter": { "rules": { "nursery": { "noIrregularWhitespace": "error" } } } } ``` -------------------------------- ### Configuration example Source: https://v1.biomejs.dev/linter/rules/no-focused-tests This is an example of how to configure the `noFocusedTests` rule. ```json { "linter": { "rules": { "suspicious": { "noFocusedTests": "error" } } } } ``` -------------------------------- ### JSON parser overrides example Source: https://v1.biomejs.dev/reference/configuration Example demonstrating how to enable JSON parsing features like `allowComments` and `allowTrailingCommas` for files within a specific directory. ```json { "linter": { "enabled": true, "rules": { "recommended": true } }, "overrides": [ { "include": [".vscode/**"], "json": { "parser": { "allowComments": true, "allowTrailingCommas": true } } } ] } ``` -------------------------------- ### Configuration example Source: https://v1.biomejs.dev/linter/rules/no-duplicate-class-members Example of how to configure the noDuplicateClassMembers rule in biome.json. ```json { "linter": { "rules": { "suspicious": { "noDuplicateClassMembers": "error" } } } } ``` -------------------------------- ### macOS arm (M1 or newer) Binary Installation Source: https://v1.biomejs.dev/guides/manual-installation Downloads and makes the Biome executable for macOS arm64 architecture executable. ```bash # macOS arm (M1 or newer) curl -L https://github.com/biomejs/biome/releases/download/cli%2Fv/biome-darwin-arm64 -o biome chmod +x biome ``` -------------------------------- ### Configuration example Source: https://v1.biomejs.dev/linter/rules/no-confusing-void-type Example of how to configure the `noConfusingVoidType` rule in biome.json. ```json { "linter": { "rules": { "suspicious": { "noConfusingVoidType": "error" } } } } ``` -------------------------------- ### Configuration example Source: https://v1.biomejs.dev/linter/rules/use-as-const-assertion This JSON object shows how to configure the `useAsConstAssertion` rule in the Biome linter. ```json { "linter": { "rules": { "style": { "useAsConstAssertion": "error" } } } } ``` -------------------------------- ### How to configure Source: https://v1.biomejs.dev/linter/rules/use-optional-chain Configuration for the `useOptionalChain` rule. ```json { "linter": { "rules": { "complexity": { "useOptionalChain": "error" } } } } ``` -------------------------------- ### useOptionalChain example Source: https://v1.biomejs.dev/internals/changelog Example of correctly handling logical and chains with methods of the same name. ```typescript tags && tags.includes('a') && tags.includes('b') tags?.includes('a') && tags.includes('b') ``` -------------------------------- ### Valid examples Source: https://v1.biomejs.dev/linter/rules/no-async-promise-executor Examples of valid Promise executor usage. ```javascript new Promise((resolve, reject) => {}) new Promise((resolve, reject) => {}, async function unrelated() {}) new Foo(async (resolve, reject) => {}) new Foo((( (resolve, reject) => {} ))) ``` -------------------------------- ### Compact log example Source: https://v1.biomejs.dev/internals/changelog Example of a compact log message. ```log 2023-10-05T08:29:04.864247Z INFO biome::worker_2 Process check:Processes linting:Pulling diagnostics: crates/biome_service/src/file_handlers/javascript.rs: Analyze file ./website/src/playground/components/Resizable.tsx path="./website/src/playground/components/Resizable.tsx" path="./website/src/playground/components/Resizable.tsx" categories=RuleCategories(LINT) 2023-10-05T08:29:04.864290Z INFO biome::worker_7 Process check:Processes formatting: crates/biome_service/src/file_handlers/javascript.rs: Format file ./website/src/playground/components/Tabs.tsx path="./website/src/playground/components/Tabs.tsx" path="./website/src/playground/components/Tabs.tsx" 2023-10-05T08:29:04.879332Z INFO biome::worker_2 Process check:Processes formatting:Pulling diagnostics: crates/biome_service/src/file_handlers/javascript.rs: Analyze file ./website/src/playground/components/Resizable.tsx path="./website/src/playground/components/Resizable.tsx" path="./website/src/playground/components/Resizable.tsx" categories=RuleCategories(SYNTAX) 2023-10-05T08:29:04.879383Z INFO biome::worker_2 Process check:Processes formatting: crates/biome_service/src/file_handlers/javascript.rs: Format file ./website/src/playground/components/Resizable.tsx path="./website/src/playground/components/Resizable.tsx" path="./website/src/playground/components/Resizable.tsx" ``` -------------------------------- ### Configuration example Source: https://v1.biomejs.dev/linter/rules/use-while Example of how to configure the `useWhile` rule in Biome. ```json { "linter": { "rules": { "style": { "useWhile": "error" } } } } ``` -------------------------------- ### Configure formatter options Source: https://v1.biomejs.dev/guides/configure-biome Example demonstrating general formatter options, JavaScript-specific formatter options, and disabling the formatter for JSON. ```json { "formatter": { "indentStyle": "space", // default is `tab` "lineWidth": 100 // default is `80` }, "javascript": { "formatter": { "quoteStyle": "single", // default is `double` "lineWidth": 120 // override `formatter.lineWidth` } }, "json": { "formatter": { "enabled": false } } } ``` -------------------------------- ### Configuration example Source: https://v1.biomejs.dev/linter/rules/use-self-closing-elements Example of how to configure the `useSelfClosingElements` rule in Biome. ```json { "linter": { "rules": { "style": { "useSelfClosingElements": "error" } } } } ``` -------------------------------- ### Configuration example Source: https://v1.biomejs.dev/linter/rules/use-single-var-declarator Example of how to configure the useSingleVarDeclarator rule in biome.json. ```json { "linter": { "rules": { "style": { "useSingleVarDeclarator": "error" } } } } ``` -------------------------------- ### Glob example Source: https://v1.biomejs.dev/formatter The command accepts a list of files and directories. If you pass a glob as a parameter, your shell will expand it. The result of the expansion depends on your shell. For example, some shells don’t support the recursive glob `**` or the alternation `{}` in the following command: ```bash biome format ./src/**/*.test.{js,ts} ``` -------------------------------- ### Valid code example 1 Source: https://v1.biomejs.dev/linter/rules/no-useless-undefined-initialization This example shows a valid initialization of a variable. ```javascript var a = 1; ``` -------------------------------- ### Configuration example Source: https://v1.biomejs.dev/linter/rules/use-throw-new-error Example of how to configure the `useThrowNewError` rule in Biome. ```json { "linter": { "rules": { "style": { "useThrowNewError": "error" } } } } ``` -------------------------------- ### Valid example Source: https://v1.biomejs.dev/linter/rules/use-simplified-logic-expression This example shows a valid and simplified logical expression. ```javascript const boolExpr3 = true; const boolExpr4 = false; const r5 = !(boolExpr1 && boolExpr2); const boolExpr5 = true; const boolExpr6 = false; ``` -------------------------------- ### Prettier Configuration Example Source: https://v1.biomejs.dev/blog/biome-v1-6 An example of a Prettier configuration file that Biome can migrate. ```json { "useTabs": false, "semi": true, "singleQuote": true } ``` -------------------------------- ### Configuration example Source: https://v1.biomejs.dev/linter/rules/no-setter-return Configuration for the noSetterReturn rule. ```json { "linter": { "rules": { "correctness": { "noSetterReturn": "error" } } } } ```