Skip to content

Commit 3ff62fb

Browse files
authored
Switch to biome (#662)
1 parent 4abcfbc commit 3ff62fb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+291
-1861
lines changed

README.md

+24-5
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,11 @@ $ pnpm install
2323
We recommend the following setup for an optimal developer experience:
2424

2525
- [VS Code](https://code.visualstudio.com)
26-
- [VS Code ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
26+
- [VS Code Biome](https://marketplace.visualstudio.com/items?itemName=biomejs.biome)
2727
- [VS Code Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)
2828

2929
By default, the VS Code TypeScript extension only checks the types in open files. If you want your IDE to check types in the whole project, check `typescript.tsserver.experimental.enableProjectDiagnostics` in your VS Code preferences.
3030

31-
For better performance (and confort!), it's recommended to set:
32-
33-
- `eslint.run` to `"onSave"`.
34-
3531
## Linting
3632

3733
```console
@@ -44,6 +40,29 @@ You can also configure `lint-staged` as a pre-commit hook by running the followi
4440
$ pnpm configure-hooks
4541
```
4642

43+
### Ignore code
44+
45+
If you want to ignore a lint rule for a specific line of the code, you can add a suppression comment above the line that emits the lint diagnostic:
46+
47+
```ts
48+
// biome-ignore <rule>: <optional-explanation>
49+
```
50+
51+
For example:
52+
53+
```ts
54+
// biome-ignore lint/suspicious/noNamespace:
55+
namespace foo {}
56+
```
57+
58+
For `useExhaustiveDependencies` (equivalent of `react-hooks/exhaustive-deps`), you can even specify which dependencies are ignored, on multiple lines:
59+
60+
```ts
61+
// biome-ignore lint/correctness/useExhaustiveDependencies(fn):
62+
// biome-ignore lint/correctness/useExhaustiveDependencies(value):
63+
useEffect(fn, [fn, value]);
64+
```
65+
4766
## Generate Fluent icons
4867

4968
Add the name of the desired icon in `scripts/fluent-icons/icons.json` using the format `icon-name-{filled|regular}`, and run the following command:

biome.json

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
3+
"vcs": {
4+
"clientKind": "git",
5+
"enabled": false,
6+
"useIgnoreFile": false
7+
},
8+
"files": {
9+
"include": [
10+
"packages/*/__stories__/**/*.ts",
11+
"packages/*/__stories__/**/*.tsx",
12+
"packages/*/src/**/*.ts",
13+
"packages/*/src/**/*.tsx"
14+
],
15+
"ignoreUnknown": true,
16+
"ignore": ["**/*.d.ts"]
17+
},
18+
"formatter": {
19+
"enabled": false
20+
},
21+
"organizeImports": {
22+
"enabled": false
23+
},
24+
"linter": {
25+
"enabled": true,
26+
"rules": {
27+
"recommended": true,
28+
"a11y": {
29+
"noSvgWithoutTitle": "off",
30+
"useAltText": "off",
31+
"useIframeTitle": "off",
32+
"useSemanticElements": "off",
33+
"useValidAriaRole": "off"
34+
},
35+
"complexity": {
36+
"noForEach": "off",
37+
"useLiteralKeys": "off"
38+
},
39+
"correctness": {
40+
"noFlatMapIdentity": "off",
41+
"noUnusedVariables": "error",
42+
"noVoidTypeReturn": "off",
43+
"useArrayLiterals": "error",
44+
"useHookAtTopLevel": "warn",
45+
"useJsxKeyInIterable": "off"
46+
},
47+
"nursery": {
48+
"noCommonJs": "error"
49+
},
50+
"style": {
51+
"noImplicitBoolean": "error",
52+
"noNamespace": "error",
53+
"noUselessElse": "off",
54+
"useBlockStatements": "warn",
55+
"useImportType": "off",
56+
"useTemplate": "off"
57+
},
58+
"suspicious": {
59+
"noArrayIndexKey": "off",
60+
"noMisleadingCharacterClass": "off",
61+
"noConfusingVoidType": "off",
62+
"noShadowRestrictedNames": "off"
63+
}
64+
}
65+
}
66+
}

eslint.config.mjs

-106
This file was deleted.

package.json

+4-9
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"scripts": {
1616
"start": "storybook dev --port 6006",
1717
"typecheck": "tsc --noEmit",
18-
"lint": "eslint",
18+
"lint": "biome check",
1919
"build-storybook": "storybook build --output-dir dist",
2020
"test": "vitest run",
2121
"build": "tsc -p tsconfig.build.json",
@@ -36,9 +36,9 @@
3636
"configure-hooks": "git config --local core.hooksPath .hooks"
3737
},
3838
"lint-staged": {
39-
"packages/**/src/locales/*.json": "pnpm sort-locales",
4039
"*": "prettier --ignore-unknown --write",
41-
"**/*.{js,ts,tsx}": "eslint --fix"
40+
"packages/*/src/**/*.{ts,tsx}": "biome check",
41+
"packages/*/src/locales/*.json": "pnpm sort-locales"
4242
},
4343
"pnpm": {
4444
"peerDependencyRules": {
@@ -48,7 +48,7 @@
4848
}
4949
},
5050
"devDependencies": {
51-
"@eslint/js": "^9.17.0",
51+
"@biomejs/biome": "1.9.4",
5252
"@fluentui/svg-icons": "^1.1.271",
5353
"@localazy/cli": "^1.7.15",
5454
"@storybook/addon-essentials": "^8.4.7",
@@ -60,10 +60,6 @@
6060
"@types/semver": "^7.5.8",
6161
"@vitejs/plugin-react-swc": "^3.7.2",
6262
"dotenv": "^16.4.7",
63-
"eslint": "^9.17.0",
64-
"eslint-plugin-react": "^7.37.3",
65-
"eslint-plugin-react-hooks": "^5.1.0",
66-
"eslint-plugin-react-native": "^5.0.0",
6763
"fast-glob": "^3.3.3",
6864
"globals": "^15.14.0",
6965
"graphql": "^16.10.0",
@@ -84,7 +80,6 @@
8480
"tsx": "^4.19.2",
8581
"type-fest": "^4.31.0",
8682
"typescript": "^5.7.2",
87-
"typescript-eslint": "^8.19.1",
8883
"valienv": "^0.7.0",
8984
"vite": "^5.4.11",
9085
"vitest": "^2.1.8"

packages/lake/__stories__/Checkbox.stories.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const InteractiveCheckbox = ({
2929
const [value, setValue] = useState(defaultValue);
3030

3131
const toggle = () => {
32-
setValue(v => (v === true ? false : true));
32+
setValue(v => v !== true);
3333
};
3434

3535
return (
@@ -48,7 +48,7 @@ const InteractiveLabelledCheckbox = ({
4848
const [value, setValue] = useState(defaultValue);
4949

5050
const toggle = () => {
51-
setValue(v => (v === true ? false : true));
51+
setValue(v => v !== true);
5252
};
5353

5454
return (

packages/lake/__stories__/Stepper.stories.tsx

+6-8
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,12 @@ const steps: TopLevelStep[] = [
6767
},
6868
];
6969

70-
const stepIds = steps
71-
.map(step =>
72-
match(step)
73-
.with({ id: P.string }, ({ id }) => [id])
74-
.with({ children: P.array(P.any) }, ({ children }) => children.map(child => child.id))
75-
.exhaustive(),
76-
)
77-
.flat();
70+
const stepIds = steps.flatMap(step =>
71+
match(step)
72+
.with({ id: P.string }, ({ id }) => [id])
73+
.with({ children: P.array(P.any) }, ({ children }) => children.map(child => child.id))
74+
.exhaustive(),
75+
);
7876

7977
export const Interactive = () => {
8078
const [activeStepId, setActiveStepId] = useState("attach_the_documents_part_2");

packages/lake/__stories__/Tag.stories.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export const All = () => {
135135
icon="arrow-down-filled"
136136
style={styles.tag}
137137
color={color as ColorVariants}
138-
></Tag>
138+
/>
139139
))}
140140
</Box>
141141
</StoryPart>
@@ -149,7 +149,7 @@ export const All = () => {
149149
style={styles.tag}
150150
color={color as ColorVariants}
151151
size="large"
152-
></Tag>
152+
/>
153153
))}
154154
</Box>
155155
</StoryPart>

packages/lake/src/components/Breadcrumbs.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ const styles = StyleSheet.create({
7878
},
7979
horizontalLinkTextHovered: {
8080
color: colors.gray[900],
81-
boxShadow: `0 1px currentColor`,
81+
boxShadow: "0 1px currentColor",
8282
},
8383
activeHorizontalLinkText: {
8484
color: colors.gray[800],
@@ -201,6 +201,8 @@ export const BreadcrumbsRoot = ({ rootLevelCrumbs = emptyCrumbArray, children }:
201201
[crumbs],
202202
);
203203

204+
// biome-ignore lint/correctness/useExhaustiveDependencies(setCrumbs):
205+
// biome-ignore lint/correctness/useExhaustiveDependencies(currentIndexRef):
204206
const value = useMemo(
205207
() => [rootCrumbs, orderedCrumbs, setCrumbs, currentIndexRef] as const,
206208
[rootCrumbs, orderedCrumbs, setCrumbs, currentIndexRef],

packages/lake/src/components/Cells.tsx

-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { LakeTooltip } from "./LakeTooltip";
1414
import { Pressable } from "./Pressable";
1515
import { Space } from "./Space";
1616

17-
/* eslint-disable react-native/no-unused-styles */
1817
const directionStyles = StyleSheet.create({
1918
column: { flexDirection: "column" },
2019
row: { flexDirection: "row" },
@@ -31,7 +30,6 @@ const justifyContentStyles = StyleSheet.create({
3130
center: { justifyContent: "center" },
3231
right: { justifyContent: "flex-end" },
3332
});
34-
/* eslint-enable react-native/no-unused-styles */
3533

3634
const fadeOnLeftMask = `linear-gradient(to right, ${invariantColors.transparent}, ${invariantColors.black} ${spacings[8]})`;
3735
const fadeOnRightMask = `linear-gradient(to left, ${invariantColors.transparent}, ${invariantColors.black} ${spacings[8]})`;
@@ -78,7 +76,6 @@ const styles = StyleSheet.create({
7876
headerUnderlineActive: {
7977
backgroundColor: colors.current[500],
8078
},
81-
// eslint-disable-next-line react-native/no-color-literals
8279
buttonUnderline: {
8380
position: "absolute",
8481
bottom: 0,

packages/lake/src/components/FlatList.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ const FlatListWithRef = <T,>(
6666
? { top: 0, width: onEndReachedThresholdPx }
6767
: { left: 0, height: onEndReachedThresholdPx };
6868

69+
// biome-ignore lint/correctness/useExhaustiveDependencies(onEndReached):
70+
// biome-ignore lint/correctness/useExhaustiveDependencies(data.length):
6971
useEffect(() => {
7072
const element = scrollTrackerRef.current as unknown as HTMLElement;
7173

@@ -85,7 +87,7 @@ const FlatListWithRef = <T,>(
8587
};
8688
}
8789
// re-create an observer only on list length change
88-
}, [data.length]); // eslint-disable-line react-hooks/exhaustive-deps
90+
}, [data.length]);
8991

9092
return (
9193
<ScrollView

packages/lake/src/components/FocusTrap.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ export const FocusTrap = forwardRef<FocusTrapRef, Props>(
4141
const hasFocusedOutside = useRef(false);
4242

4343
useImperativeHandle(ref, () => ({
44-
setInitiallyFocusedElement: element => (previouslyFocusedRef.current = element),
44+
setInitiallyFocusedElement: element => {
45+
previouslyFocusedRef.current = element;
46+
},
4547
}));
4648

4749
const [initialEscapeListenerCount] = useState(escapeListenerCount);

0 commit comments

Comments
 (0)