Skip to content

Commit

Permalink
chore(lint): move to biome instead of eslint (opennextjs#538)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxmorozoff committed Nov 6, 2024
1 parent 44f3678 commit 4da249a
Show file tree
Hide file tree
Showing 9 changed files with 222 additions and 1,989 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
trim_trailing_whitespace = true
indent_style = space
tab_width = 2
insert_final_newline = true
end_of_line = lf
46 changes: 0 additions & 46 deletions .eslintrc.cjs

This file was deleted.

11 changes: 7 additions & 4 deletions .github/actions/lint/action.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
name: Lint codebase
description: Run eslint to lint codebase and ensure code quality
description: Run biome to lint codebase and ensure code quality

runs:
using: 'composite'
using: "composite"
steps:
- name: Install dependencies
run: pnpm install
shell: bash

- name: Run eslint
run: pnpm lint
- name: Setup Biome CLI
uses: biomejs/[email protected]

- name: Run biome
run: biome ci --reporter=github
shell: bash
7 changes: 1 addition & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@ jobs:
uses: actions/checkout@v4

- uses: ./.github/actions/pnpm-setup

- name: Install dependencies
run: pnpm install

- name: Check codestyle
run: pnpm lint
- uses: ./.github/actions/lint

- name: Create Release Pull Request or Publish to npm
id: changesets
Expand Down
96 changes: 96 additions & 0 deletions biome.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"vcs": { "enabled": true, "clientKind": "git", "useIgnoreFile": true },
"files": {
"ignoreUnknown": true
},
"organizeImports": { "enabled": true },
"formatter": { "enabled": true, "useEditorconfig": true },
"css": { "formatter": { "quoteStyle": "single" } },
"linter": {
"enabled": true,
"rules": {
"suspicious": {
"noExplicitAny": "info",
"noGlobalIsNan": "warn",
"noImplicitAnyLet": "warn",
"noAssignInExpressions": "warn",
"noConfusingVoidType": "warn",
"useNamespaceKeyword": "warn" // safe fix
},
"style": {
"noUnusedTemplateLiteral": "warn",
"noInferrableTypes": "warn", // safe fix
"noUselessElse": "warn",
"useNodejsImportProtocol": "warn",
"useTemplate": "warn",
"useNumberNamespace": "warn", // safe fix
"noNonNullAssertion": "warn",
"useImportType": "warn",
"noParameterAssign": "warn",
"useDefaultParameterLast": "warn",
"noCommaOperator": "warn",
"useConst": "warn",
"useSingleVarDeclarator": "warn",
"noVar": "warn",
"useShorthandFunctionType": "warn" // safe fix
},
"correctness": {
"noSwitchDeclarations": "warn",
"noUnnecessaryContinue": "warn",
"noInnerDeclarations": "warn"
},
"complexity": {
"useLiteralKeys": "warn",
"noForEach": "off",
"noUselessSwitchCase": "warn",
"noUselessConstructor": "warn",
"noBannedTypes": "warn",
"noUselessTernary": "warn",
"useArrowFunction": "warn", // safe fix
"noExtraBooleanCast": "warn",
"useOptionalChain": "warn"
},
"performance": {
"noDelete": "warn",
"noAccumulatingSpread": "warn"
}
}
},
"overrides": [
{
"include": ["packages/tests-unit/**", "packages/tests-e2e/**"],
"linter": {
"rules": {
"suspicious": {
"noRedeclare": "warn"
}
}
}
},
{
"include": ["examples/**/*"],
"linter": {
"rules": {
"style": {
"useSelfClosingElements": "warn"
},
"a11y": {
"useIframeTitle": "warn",
"useButtonType": "warn",
"useAltText": "warn",
"useKeyWithClickEvents": "warn"
},
"correctness": {
"useJsxKeyInIterable": "warn",
"useExhaustiveDependencies": "warn"
},
"suspicious": {
"noArrayIndexKey": "warn",
"noRedeclare": "warn"
}
}
}
}
]
}
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,18 @@
"dev": "turbo run dev",
"build": "turbo run build",
"clean": "turbo run clean && rm -rf node_modules pnpm-lock.yaml",
"lint": "eslint --ext .js,.ts,.tsx .",
"lint:fix": "eslint --fix --ext .js,.ts,.tsx .",
"lint": "biome lint",
"lint:fix": "biome lint --fix",
"test": "turbo run test",
"e2e:test": "turbo run e2e:test",
"version": "./.changeset/version",
"release": "./.changeset/release",
"release-snapshot": "./.changeset/snapshot"
},
"devDependencies": {
"@biomejs/biome": "1.9.4",
"@changesets/changelog-github": "^0.4.4",
"@changesets/cli": "^2.22.0",
"@sladg/eslint-config-base": "1.4.1",
"eslint": "^8.47.0",
"pkg-pr-new": "^0.0.29",
"turbo": "1.10.12"
},
Expand Down
1 change: 0 additions & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"scripts": {
"build": "tsup ./src/*.ts --format cjs --dts",
"dev": "tsup ./src/*.ts --format cjs --dts --watch",
"lint": "TIMING=1 eslint \"**/*.ts*\"",
"clean": "rm -rf .turbo && rm -rf node_modules"
},
"dependencies": {},
Expand Down
Loading

0 comments on commit 4da249a

Please sign in to comment.