Skip to content

Commit

Permalink
Vf 145 bytt linting og formattering til biomejs (#276)
Browse files Browse the repository at this point in the history
* feat: 🔧 change package manager to pnpm

* chore: 🔧 update linting rules

* style: 🎨 format code

* ci: 👷 update github actions

* ci: 💚 fix github actions

* revert: 🔥 remove build artifacts

* chore: 🔧 fix config

* fix: 🚨 fix lint

* fix: 🐛 fix import

* chore: 🔧 update package.json

remove package manager setting

* chore: ➕ add biome

* chore: 🔧 update biome config

import/migrate linting rules from eslint and formatting rules from prettier

* chore: 🔨 update scripts

replace eslint & prettier with biome in lint and format scripts. Add "check" script which both lints and formats. All scripts apply safe fixed

* style: 🚨 format and lint all files

* chore: 🔧 move scope settings to biome config

* style: 🎨 format config files

* chore: ✏️ fix script

* fix: 🚨 fix lint errors

* ci: 👷 update github actions

Optimize biome job

* chore: ➖ remove eslint & prettier
  • Loading branch information
phibkro authored May 1, 2024
1 parent 3563f09 commit ab7a467
Show file tree
Hide file tree
Showing 43 changed files with 1,306 additions and 1,327 deletions.
33 changes: 0 additions & 33 deletions .eslintrc.js

This file was deleted.

36 changes: 16 additions & 20 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,44 +15,40 @@ on:
jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v3
- name: Checkout code
uses: actions/checkout@v3
- name: Setup PNPM
uses: pnpm/action-setup@v3
with:
version: 8
- name: Use Node.js ${{ env.NODE_VERSION }}
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{env.NODE_VERSION}}
cache: "pnpm"
- name: Install dependencies
run: |
run:
pnpm install
pnpm build
- name: Build
run: pnpm build
- name: store build artifact
uses: actions/upload-artifact@v3
with:
name: build
path: build

lint:
code-quality:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v3
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Biome
uses: biomejs/setup-biome@v2
with:
version: 8
- name: Lint with eslint
uses: actions/setup-node@v3
with:
node-version: ${{env.NODE_VERSION}}
cache: "pnpm"
- name: pnpm lint
run: |
pnpm install
pnpm lint
version: 1.7.1
- name: Run Biome
run: biome ci .

vitest_tests:
needs: build
Expand Down
37 changes: 37 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"$schema": "https://biomejs.dev/schemas/1.7.1/schema.json",
"files": {
"include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx", "**/*.json"],
"ignore": ["node_modules", "build"]
},
"formatter": {
"enabled": true,
"formatWithErrors": false,
"indentStyle": "space",
"indentWidth": 2,
"lineEnding": "lf",
"lineWidth": 80,
"attributePosition": "auto"
},
"organizeImports": { "enabled": true },
"linter": {
"enabled": true,
"rules": {
"recommended": true
},
"ignore": ["/*", "!/src"]
},
"javascript": {
"formatter": {
"jsxQuoteStyle": "double",
"quoteProperties": "asNeeded",
"trailingComma": "all",
"semicolons": "always",
"arrowParentheses": "always",
"bracketSpacing": true,
"bracketSameLine": false,
"quoteStyle": "double",
"attributePosition": "auto"
}
}
}
26 changes: 5 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,9 @@
"@types/node": "^16.18.96",
"@types/react": "^17.0.80",
"@types/react-dom": "^17.0.25",
"@typescript-eslint/eslint-plugin": "latest",
"@typescript-eslint/parser": "^5.62.0",
"autoprefixer": "^10.4.19",
"daisyui": "^2.52.0",
"dayjs": "^1.11.10",
"eslint-plugin": "latest",
"eslint-plugin-import": "latest",
"eslint-plugin-jsx-a11y": "latest",
"eslint-plugin-react": "latest",
"eslint-plugin-react-hooks": "latest",
"norwegian-utils": "^0.4.1",
"postcss": "^8.4.38",
"postcss-import": "^15.1.0",
Expand All @@ -44,35 +37,26 @@
"test:cypress:firefox": "cypress run --browser firefox",
"test:vitest": "vitest run",
"test:vitest:watch": "vitest watch",
"lint": "eslint \"src/**/*.{js,ts,tsx}\"",
"lint:fix": "eslint --fix \"src/**/*.{js,ts,tsx}\"",
"format": "prettier --write './**/*.{js,jsx,ts,tsx,css,md,json}' --config ./.prettierrc"
"check": "biome check ./ --apply",
"lint": "biome lint ./ --apply",
"format": "biome format ./ --apply"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"production": [">0.2%", "not dead", "not op_mini all"],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@biomejs/biome": "1.7.1",
"@testing-library/dom": "^9.3.4",
"@testing-library/react": "^14.3.1",
"@testing-library/user-event": "^14.5.2",
"@types/jest": "^29.5.12",
"@vitejs/plugin-react": "^3.1.0",
"cypress": "12.8.1",
"eslint": "^7.11.0",
"eslint-config-airbnb": "^19.0.0",
"eslint-config-airbnb-typescript": "^14.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"prettier": "^3.2.5",
"vite": "^3.1.0",
"vite-plugin-svgr": "^2.2.1",
"vite-tsconfig-paths": "^3.5.0",
Expand Down
Loading

0 comments on commit ab7a467

Please sign in to comment.