Skip to content

Commit

Permalink
chore: Replace prettier with biome
Browse files Browse the repository at this point in the history
  • Loading branch information
maxmilton committed Feb 3, 2024
1 parent 0ec14f2 commit 0095bd2
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 28 deletions.
14 changes: 9 additions & 5 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,32 @@ module.exports = {
'plugin:@typescript-eslint/strict-type-checked',
'plugin:@typescript-eslint/stylistic-type-checked',
'plugin:unicorn/recommended',
'prettier',
],
plugins: ['prettier'],
rules: {
'@typescript-eslint/explicit-module-boundary-types': ERROR,
// TODO: Would prefer a warning rather than disabling this but auto-fix is
// undesirable (adds unnecessary braces leading to byte bloat).
// '@typescript-eslint/no-confusing-void-expression': WARN,
'@typescript-eslint/no-non-null-assertion': WARN,
'@typescript-eslint/no-use-before-define': WARN,
'import/order': OFF, // broken with prettier
'import/prefer-default-export': OFF,
'no-restricted-syntax': OFF,
'no-void': OFF,
'prettier/prettier': WARN,
'unicorn/filename-case': OFF,
'unicorn/no-abusive-eslint-disable': WARN,
'unicorn/no-null': OFF,
'unicorn/prefer-module': WARN,
'unicorn/prefer-top-level-await': WARN,
'unicorn/prevent-abbreviations': OFF,

/* Covered by biome formatter */
'@typescript-eslint/indent': OFF,
'function-paren-newline': OFF,
'implicit-arrow-linebreak': OFF,
'max-len': OFF,
'object-curly-newline': OFF,
'operator-linebreak': OFF,

/* Performance and byte savings */
// byte savings
'@typescript-eslint/no-confusing-void-expression': OFF,
Expand All @@ -54,7 +58,7 @@ module.exports = {
// byte savings + faster
'unicorn/explicit-length-check': OFF,
'unicorn/no-array-callback-reference': OFF,
// forEach is often faster (in Chrome and Firefox but not Safari)
// forEach is often faster (in Chrome and Bun but not Firefox)
'unicorn/no-array-for-each': OFF,
'unicorn/no-await-expression-member': OFF,
// indexOf is faster (in Chrome)
Expand Down
14 changes: 0 additions & 14 deletions .prettierrc

This file was deleted.

2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"recommendations": [
"biomejs.biome",
"oven.bun-vscode",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"stylelint.vscode-stylelint"
]
}
11 changes: 7 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"editor.codeActionsOnSave": {
"source.fixAll": "explicit"
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": false,
Expand All @@ -13,14 +12,18 @@
},
"git.branchProtection": ["master", "next"],
"js/ts.implicitProjectConfig.checkJs": true,
"prettier.ignorePath": ".gitignore",
"prettier.enable": false, // use biome instead
"scss.validate": false,
"stylelint.validate": ["css", "scss"],
"typescript.tsdk": "node_modules/typescript/lib",
"[css][html][json][jsonc][markdown][scss]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[javascript][typescript]": {
"editor.codeActionsOnSave": {
"source.sortImports": "explicit",
"source.fixAll": "explicit"
}
"source.fixAll": "explicit",
},
"editor.defaultFormatter": "biomejs.biome"
}
}
91 changes: 91 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"organizeImports": {
"enabled": false
},
"formatter": {
"formatWithErrors": true,
"indentStyle": "space",
"indentWidth": 2,
"lineEnding": "lf",
"lineWidth": 80
},
"javascript": {
"globals": ["chrome"],
"formatter": {
"semicolons": "always",
"trailingComma": "all",
"quoteStyle": "single"
}
},
"linter": {
"rules": {
"recommended": true,
"complexity": {
"noForEach": "off",
"useSimplifiedLogicExpression": "warn"
},
"style": {
"noNamespace": "error",
"noNegationElse": "error",
"noNonNullAssertion": "off",
"noParameterProperties": "error",
"noRestrictedGlobals": "error",
"noShoutyConstants": "error",
"useCollapsedElseIf": "error",
"useNamingConvention": {
"level": "error",
"options": { "strictCase": false }
},
"useShorthandArrayType": "error",
"useShorthandAssign": "error",
"useSingleCaseStatement": "error",
"useTemplate": "off"
},
"suspicious": {
"noApproximativeNumericConstant": "error",
"noAssignInExpressions": "off",
"noConfusingVoidType": "off",
"noConsoleLog": "warn",
"noConstEnum": "off",
"noExplicitAny": "off",
"noMisrefactoredShorthandAssign": "error"
}
}
},
"overrides": [
{
"include": [".vscode/**"],
"json": {
"parser": {
"allowComments": true,
"allowTrailingCommas": true
}
}
},
{
"include": ["**/*.spec.ts", "**/*.test.ts", "test/**/*.ts"],
"formatter": {
"lineWidth": 100
}
},
{
"include": ["build.ts", "manifest.config.ts"],
"linter": {
"rules": {
"style": {
"useNamingConvention": "off"
},
"suspicious": {
"noConsoleLog": "off"
}
}
}
}
]
}
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
"scripts": {
"build": "NODE_ENV=production bun build.ts",
"dev": "NODE_ENV=development bun build.ts",
"lint": "bun run lint:css && bun run lint:js && bun run lint:ts",
"lint": "bun run lint:fmt && bun run lint:css && bun run lint:js && bun run lint:ts",
"lint:css": "stylelint --ignore-path .gitignore '**/*.{css,xcss}'",
"lint:fmt": "biome format .",
"lint:js": "eslint --ignore-path .gitignore --ext .ts,.mjs,.js,.cjs .",
"lint:ts": "tsc --noEmit",
"prebuild": "rm -rf dist; cp -r static dist",
Expand All @@ -25,6 +26,7 @@
"stage1": "0.8.0-next.7"
},
"devDependencies": {
"@biomejs/biome": "1.5.3",
"@ekscss/plugin-import": "0.0.12",
"@maxmilton/stylelint-config": "0.0.15",
"@playwright/test": "1.41.0",
Expand All @@ -36,13 +38,10 @@
"eslint": "8.56.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-config-airbnb-typescript": "17.1.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-prettier": "5.1.3",
"eslint-plugin-unicorn": "50.0.1",
"happy-dom": "13.1.4",
"lightningcss": "1.23.0",
"prettier": "3.2.4",
"stylelint": "16.1.0",
"stylelint-config-standard": "36.0.0",
"terser": "5.27.0",
Expand Down

0 comments on commit 0095bd2

Please sign in to comment.