Skip to content

Commit

Permalink
docs(website): portuguese translation (#1068)
Browse files Browse the repository at this point in the history
Co-authored-by: Victor <[email protected]>
  • Loading branch information
hknsh and victor-teles authored Dec 6, 2023
1 parent d7071e2 commit 9c3ace3
Show file tree
Hide file tree
Showing 19 changed files with 1,785 additions and 0 deletions.
4 changes: 4 additions & 0 deletions website/astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ export default defineConfig({
label: "简体中文",
lang: "zh-CN",
},
"pt-br": {
label: "Português",
lang: "pt-BR",
},
},
sidebar: [
{ label: "Home", link: "/", translations: { ja: "ホーム" } },
Expand Down
8 changes: 8 additions & 0 deletions website/src/content/docs/pt-br/404.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: "404"
template: splash
editUrl: false
hero:
title: "404"
tagline: Biome não encontrado. Verifique a URL ou tente usar a barra de pesquisa.
---
133 changes: 133 additions & 0 deletions website/src/content/docs/pt-br/analyzer/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
---
title: Analyzer
description: What the Biome analyzer provides
---

Biome's analyzer provides a series of features that users can leverage.

## Imports Sorting

Biome allows to sort import statement using [natural ordering](https://en.wikipedia.org/wiki/Natural_sort_order).

This feature is enabled by default but can be opted-out via configuration:

```json title="biome.json"
{
"organizeImports": {
"enabled": false
}
}
```

### How imports are sorted

Import statements are sorted by "distance". Modules that are "farther" from the user are put on the top, modules "closer" to the user are put on the bottom:

1. modules imported via `bun:` protocol. This is applicable when writing code run by Bun;
2. built-in Node.js modules that are explicitly imported using the `node:` protocol and common Node built-ins such as `assert`;
3. modules imported via `npm:` protocol. This is applicable when writing code run by Deno;
4. modules imported via URL;
5. modules imported from libraries;
6. modules imported via absolute imports;
7. modules imported from a name prefixed by `#`. This is applicable when using [Node's subpath imports](https://nodejs.org/api/packages.html#subpath-imports);
8. modules imported via relative imports;
9. modules that couldn't be identified by the previous criteria;

For example, given the following code:

```ts title="example.ts"
import uncle from "../uncle";
import sibling from "./sibling";
import express from "npm:express";
import imageUrl from "url:./image.png";
import assert from "node:assert";
import aunt from "../aunt";
import { VERSION } from "https://deno.land/std/version.ts";
import { mock, test } from "node:test";
import { expect } from "bun:test";
import { internal } from "#internal";
import { secret } from "/absolute/path";
import React from "react";
```

They will be sorted like this:

```ts title="example.ts"
import { expect } from "bun:test";
import assert from "node:assert";
import { mock, test } from "node:test";
import express from "npm:express";
import { VERSION } from "https://deno.land/std/version.ts";
import React from "react";
import { secret } from "/absolute/path";
import { internal } from "#internal";
import aunt from "../aunt";
import uncle from "../uncle";
import sibling from "./sibling";
import imageUrl from "url:./image.png";
```

You can apply the sorting in two ways: via [CLI](#import-sorting-via-cli) or [VSCode extension](#import-sorting-via-vscode-extension).

### Grouped imports

It's widespread to have import statements in a certain order, primarily when you work on a frontend project, and you import CSS files:

```js title="example.js"
import "../styles/reset.css";
import "../styles/layout.css";
import { Grid } from "../components/Grid.jsx";
```

Another common case is import polyfills or shim files, that needs to stay at the top file:

```js title="example.js"
import "../polyfills/array/flatMap";
import { functionThatUsesFlatMap } from "./utils.js";
```

In these cases, Biome will sort all these three imports, and it might happen that the order will **break** your application.

To avoid this, create a "group" of imports. You create a "group" by adding a **new line** to separate the groups.

By doing so, Biome will limit the sorting only to the import statements that belong to the same group:

```js title="example.js"
// group 1, only these two files will be sorted
import "../styles/reset.css";
import "../styles/layout.css";

// group 2, only this one is sorted
import { Grid } from "../components/Grid.jsx";
```

```js title="example.js"
// group 1, the polyfill/shim
import "../polyfills/array/flatMap";

// group 2, the files tha require the polyfill/shim
import { functionThatUsesFlatMap } from "./utils.js";
```

### Import sorting via CLI

Using the command `check`, with the option `--apply`.

```shell
biome check --apply ./path/to/src
```

### Import sorting via VSCode extension

The Biome VS Code extension supports imports sorting through the "Organize Imports" code action.
By default, this action can be run using the <kbd title="Shift">⇧</kbd>+<kbd>Alt</kbd>+<kbd>O</kbd> keyboard shortcut, or is accessible through the _Command Palette_ (<kbd>Ctrl</kbd>/<kbd title="Cmd">⌘</kbd>+<kbd title="Shift">⇧</kbd>+<kbd>P</kbd>) by selecting _Organize Imports_.

You can add the following to your editor configuration if you want the action to run automatically on save instead of calling it manually:

```json title="biome.json"
{
"editor.codeActionsOnSave":{
"source.organizeImports.biome": true
}
}
```
Loading

0 comments on commit 9c3ace3

Please sign in to comment.