Skip to content

Commit b51c272

Browse files
committed
chore: replace eslint with biomejs (#2189)
**TLDR; Replace eslint and prettier (except css) for linting and formatting.** After doing some testing, debugging and fighting with getting eslint to work in #2175, I made this to test biomejs as a replacement. Either way we had to do big config changes for eslint 9.x so might aswell try biomejs. In general a positive experience having tested biomejs. - Linting is now done for the whole repo, except "ignores". - Seperated gh workflows. - Linting is now done in a separate workflow for the whole repo. - Building and testing the individual packages or apps i their own workflow. (will do more renames here after merging into `next`) - New recommended vscode extension for biomejs. - Biomejs lints, formats and sorts import order in <1s, while eslint 8.x uses >40s for only linting. - Linting when coding is also noticeably faster - Biomejs is still limited in what can be configured, but most of its current features set is good enough for our needs. - Biomejs is only 1 dependency, opposed to 11 dependencies from eslint - No more hassle upgrading dependencies hopefully - Biomejs lacks: - CSS formatting, ([but its being worked on](https://biomejs.dev/internals/language-support/)), so we are still using prettier for this. - Typed-linting? (i think) - No way of defining our own import order ([RFC](biomejs/biome#3015)) - No plugin support [but its planned](https://biomejs.dev/blog/roadmap-2024/) - Biomejs also has some new good linting rules we fixed - https://biomejs.dev/linter/rules/no-for-each/ - https://biomejs.dev/linter/rules/no-comma-operator/ - https://biomejs.dev/linter/rules/no-shadow-restricted-names/ - https://biomejs.dev/linter/rules/no-useless-else/ - https://biomejs.dev/linter/rules/no-assign-in-expressions/ - https://biomejs.dev/linter/rules/no-accumulating-spread/ - https://biomejs.dev/linter/rules/no-implicit-any-let/
1 parent f044266 commit b51c272

File tree

304 files changed

+1873
-5498
lines changed

Some content is hidden

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

304 files changed

+1873
-5498
lines changed

.changeset/tender-ties-swim.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@digdir/designsystemet-react': patch
3+
'@digdir/designsystemet': patch
4+
---
5+
6+
Changed linter and formatter from eslint to biomejs

.eslintignore

-7
This file was deleted.

.eslintrc.cjs

-99
This file was deleted.
+3-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
name: Checks Storefront
1+
name: Build Storefront
22
on:
33
workflow_dispatch:
44
pull_request:
55
paths:
66
- 'apps/storefront/**'
7-
push:
8-
paths:
9-
- 'apps/storefront/**'
107
jobs:
118
checks:
12-
name: Builds, lints and tests code
9+
name: Build & test
1310
runs-on: ubuntu-latest
1411
steps:
1512
- name: Checkout repository
@@ -27,9 +24,4 @@ jobs:
2724
run: yarn build:storefront
2825
- name: Types
2926
run: yarn types:storefront
30-
- name: Lint Code
31-
run: yarn lint ./apps/storefront
32-
- name: Lint CSS
33-
run: yarn lint-style ./apps/storefront/**/*.css
34-
- name: Test
35-
run: yarn test
27+

.github/workflows/checks-packages.yml

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
name: Checks Packages
1+
name: Build Packages
22
on:
33
workflow_dispatch:
44
pull_request:
55
paths:
66
- 'packages/**'
7-
- '*.*js'
8-
push:
9-
paths:
10-
- 'packages/**'
117
jobs:
128
checks:
13-
name: Builds, lints and tests code
9+
name: Build & test
1410
runs-on: ubuntu-latest
1511
steps:
1612
- uses: actions/checkout@v4
@@ -19,9 +15,5 @@ jobs:
1915
run: yarn build
2016
- name: Types
2117
run: yarn types:react
22-
- name: Lint Code
23-
run: yarn lint:all
24-
- name: Lint CSS
25-
run: yarn lint-style
2618
- name: Test
2719
run: yarn test

.github/workflows/checks.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Checks
2+
on:
3+
workflow_dispatch:
4+
pull_request:
5+
paths:
6+
- 'packages/**'
7+
- 'apps/**'
8+
- 'biome.jsonc'
9+
jobs:
10+
checks:
11+
name: Lint
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: ./.github/actions/gh-setup
16+
- name: Biome CI
17+
run: yarn biome ci .
18+
- name: Lint CSS
19+
run: yarn lint-style
20+

.vscode/extensions.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"recommendations": [
3-
"dbaeumer.vscode-eslint",
43
"esbenp.prettier-vscode",
54
"unifiedjs.vscode-mdx",
65
"christian-kohler.npm-intellisense",
@@ -22,6 +21,7 @@
2221
"editorconfig.editorconfig",
2322
"zignd.html-css-class-completion",
2423
"streetsidesoftware.code-spell-checker",
25-
"streetsidesoftware.code-spell-checker-norwegian-bokmal"
24+
"streetsidesoftware.code-spell-checker-norwegian-bokmal",
25+
"biomejs.biome"
2626
]
2727
}

.vscode/settings.json

+9-19
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
{
22
"git.rebaseWhenSync": true,
33
"git.autofetch": true,
4-
"editor.defaultFormatter": "esbenp.prettier-vscode",
54
"editor.formatOnSave": true,
5+
"editor.codeActionsOnSave": {
6+
"quickfix.biome": "explicit",
7+
"source.organizeImports.biome": "explicit"
8+
},
9+
"editor.defaultFormatter": "biomejs.biome",
10+
"[css]": {
11+
"editor.defaultFormatter": "esbenp.prettier-vscode"
12+
},
613
"prettier.prettierPath": "./node_modules/prettier",
714
"typescript.tsdk": "node_modules/typescript/lib",
815
"typescript.enablePromptUseWorkspaceTsdk": true,
@@ -11,22 +18,5 @@
1118
"packages/theme/brand/digdir/typography/primary.css",
1219
"packages/theme/brand/digdir/semantic.css"
1320
],
14-
"[ignore]": {
15-
"editor.defaultFormatter": "foxundermoon.shell-format"
16-
},
17-
"eslint.probe": [
18-
"javascript",
19-
"javascriptreact",
20-
"typescript",
21-
"typescriptreact",
22-
"html",
23-
"vue",
24-
"markdown",
25-
"mdx"
26-
],
27-
"html-css-class-completion.includeGlobPattern": "packages/css/**/*.{css,html}",
28-
"cSpell.words": ["altinn", "brreg", "designsystemet", "digdir"],
29-
"cSpell.language": "en,nb",
30-
"cSpell.ignorePaths": ["**/node_modules/**", "**/package.json", "yarn.lock"],
31-
"cSpell.enabledLanguageIds": ["markdown", "plaintext"]
21+
"html-css-class-completion.includeGlobPattern": "packages/css/**/*.{css,html}"
3222
}

apps/_components/src/ClipboardButton/ClipboardButton.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client';
2-
import { useState } from 'react';
2+
import { Button, Tooltip } from '@digdir/designsystemet-react';
33
import { ClipboardIcon } from '@navikt/aksel-icons';
4-
import { Tooltip, Button } from '@digdir/designsystemet-react';
4+
import { useState } from 'react';
55

66
import classes from './ClipboardButton.module.css';
77

apps/_components/src/CodeSnippet/CodeSnippet.tsx

+8-11
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
'use client';
22

3-
import { useEffect, useState } from 'react';
3+
import { Button, Tooltip } from '@digdir/designsystemet-react';
44
import { FilesIcon } from '@navikt/aksel-icons';
5-
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
6-
import { format } from 'prettier/standalone.js';
7-
import * as prettierMarkdown from 'prettier/plugins/markdown.js';
5+
import * as prettierBabel from 'prettier/parser-babel';
6+
import * as prettierEstree from 'prettier/plugins/estree';
87
import * as prettierHtml from 'prettier/plugins/html.js';
8+
import * as prettierMarkdown from 'prettier/plugins/markdown.js';
99
import * as prettierCSS from 'prettier/plugins/postcss.js';
1010
import * as prettierTypescript from 'prettier/plugins/typescript.js';
11-
import * as prettierEstree from 'prettier/plugins/estree';
12-
import * as prettierBabel from 'prettier/parser-babel';
11+
import { format } from 'prettier/standalone.js';
12+
import { useEffect, useState } from 'react';
13+
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
1314
import { nightOwl } from 'react-syntax-highlighter/dist/esm/styles/prism';
14-
import { Button, Tooltip } from '@digdir/designsystemet-react';
1515

1616
import classes from './CodeSnippet.module.css';
1717

@@ -67,10 +67,7 @@ const CodeSnippet = ({
6767
};
6868

6969
return (
70-
<div
71-
className={classes.codeSnippet}
72-
data-ds-color-mode='dark'
73-
>
70+
<div className={classes.codeSnippet} data-ds-color-mode='dark'>
7471
{snippet && (
7572
<>
7673
<Tooltip content={toolTipText}>

apps/_components/src/ColorModal/ColorModal.tsx

+5-18
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Paragraph, Modal } from '@digdir/designsystemet-react';
1+
import { Modal, Paragraph } from '@digdir/designsystemet-react';
22
import type { ColorNumber } from '@digdir/designsystemet/color';
33
import {
44
getColorNameFromNumber,
@@ -26,17 +26,11 @@ const Field = ({
2626
return (
2727
<div className={classes.field}>
2828
{label && (
29-
<Paragraph
30-
size='sm'
31-
className={classes.label}
32-
>
29+
<Paragraph size='sm' className={classes.label}>
3330
{label}
3431
</Paragraph>
3532
)}
36-
<Paragraph
37-
size='sm'
38-
className={classes.value}
39-
>
33+
<Paragraph size='sm' className={classes.value}>
4034
{value}
4135
</Paragraph>
4236
{copyBtn && <ClipboardButton value={value} />}
@@ -78,11 +72,7 @@ export const ColorModal = ({
7872
</div>
7973
<div className={classes.container}>
8074
<div className={classes.left}>
81-
<Field
82-
label='Hexkode:'
83-
value={hex}
84-
copyBtn
85-
/>
75+
<Field label='Hexkode:' value={hex} copyBtn />
8676
<Field
8777
label='HSLuv:'
8878
value={
@@ -105,10 +95,7 @@ export const ColorModal = ({
10595
value={getColorCombinations(weight)}
10696
/>
10797
)}
108-
<Field
109-
label=''
110-
value='Mer informasjon om fargen kommer.'
111-
/>
98+
<Field label='' value='Mer informasjon om fargen kommer.' />
11299
</div>
113100
<div
114101
className={classes.right}

apps/_components/src/ColorModal/colorModalUtils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
2-
getColorNameFromNumber,
32
type ColorNumber,
3+
getColorNameFromNumber,
44
} from '@digdir/designsystemet/color';
55

66
export const capitalizeFirstLetter = (str: string) => {

0 commit comments

Comments
 (0)