Skip to content

Commit

Permalink
feat(scaffolding): replaced eslint with biome, set up pre-commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
jkomyno committed Sep 13, 2024
1 parent fb8c8b6 commit 95ff66c
Show file tree
Hide file tree
Showing 12 changed files with 489 additions and 1,593 deletions.
65 changes: 0 additions & 65 deletions .eslintrc.js

This file was deleted.

7 changes: 2 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,8 @@ jobs:
- name: Transpile TS to JS
run: pnpm build

- name: Run eslint
run: pnpm eslint-check

- name: Run prettier
run: pnpm prettier-check
- name: Lint code
run: pnpm lint:ci

- name: Run unit tests
run: pnpm test:unit
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm lint-staged
5 changes: 0 additions & 5 deletions .prettierrc.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

- `pnpm install`: install the dependencies needed for each package.
- `pnpm build`: transpile the local TypeScript packages to JavaScript.
- `pnpm eslint-check`: check that the code follows the `eslint` guidelines.
- `pnpm lint:ci`: check that the code follows the `eslint` guidelines.
- `pnpm prettier-check`: check that the code follows the `prettier` guidelines.
- `pnpm prettier-write`: override the code to follow the `prettier` guidelines.
- `pnpm test:unit`: run unit tests.
Expand Down
109 changes: 109 additions & 0 deletions biome.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
// Note: UNIX-like glob patterns {a,b,c} aren't supported yet.
"files": {
"ignore": ["./**/node_modules/**", "./public/**", "./build/**"],
"include": ["./app/**/", "./*.ts", "./*.js", "./*.json", "./*.jsonc"]
},
"organizeImports": { "enabled": true },
"formatter": {
"enabled": true,
"indentWidth": 2,
"indentStyle": "space",
"lineWidth": 120
},
"javascript": {
"globals": [
"React",

// We need to manually list every test global variable.
// See: https://github.com/biomejs/biome/discussions/283.
"describe",
"test",
"testIf",
"it",
"expect"
],
"linter": {
"enabled": true
},
"formatter": {
"quoteStyle": "single",
"semicolons": "asNeeded"
}
},
"css": {
"linter": {
"enabled": true
}
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"complexity": {
"noExtraBooleanCast": "error",
"noMultipleSpacesInRegularExpressionLiterals": "error",
"noUselessCatch": "error",
"noWith": "error"
},
"nursery": {
"useSortedClasses": "error"
},
"style": {
"noParameterAssign": "off",
"noNonNullAssertion": "off"
},
"correctness": {
"noConstAssign": "error",
"noConstantCondition": "error",
"noEmptyCharacterClassInRegex": "error",
"noEmptyPattern": "error",
"noGlobalObjectCalls": "error",
"noInnerDeclarations": "error",
"noInvalidConstructorSuper": "error",
"noNewSymbol": "error",
"noNonoctalDecimalEscape": "error",
"noPrecisionLoss": "error",
"noSelfAssign": "error",
"noSetterReturn": "error",
"noSwitchDeclarations": "error",
"noUndeclaredVariables": "error",
"noUnreachable": "error",
"noUnreachableSuper": "error",
"noUnsafeFinally": "error",
"noUnsafeOptionalChaining": "error",
"noUnusedLabels": "error",
"noUnusedVariables": "error",
"useIsNan": "error",
"useValidForDirection": "error",
"useYield": "error"
},
"suspicious": {
"noApproximativeNumericConstant": "off",
"noAsyncPromiseExecutor": "error",
"noCatchAssign": "error",
"noClassAssign": "error",
"noCompareNegZero": "error",
"noControlCharactersInRegex": "error",
"noDebugger": "error",
"noDuplicateCase": "error",
"noDuplicateClassMembers": "error",
"noDuplicateObjectKeys": "error",
"noDuplicateParameters": "error",
"noEmptyBlockStatements": "error",
"noFallthroughSwitchClause": "error",
"noFunctionAssign": "error",
"noGlobalAssign": "error",
"noImportAssign": "error",
"noMisleadingCharacterClass": "error",
"noPrototypeBuiltins": "error",
"noRedeclare": "error",
"noShadowRestrictedNames": "error",
"noUnsafeNegation": "error",
"useGetterReturn": "error",
"useValidTypeof": "error"
}
}
}
}
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,34 @@
},
"scripts": {
"build": "turbo run build",
"clean": "turbo run clean",
"watch": "turbo run watch",
"prettier-check": "turbo run prettier-check",
"prettier-write": "turbo run prettier-write",
"typecheck": "turbo run typecheck",
"eslint-check": "turbo run eslint-check",
"prepare": "cd .. && husky install",
"lint-staged": "turbo run lint-staged --concurrency=1",
"lint:ci": "turbo run lint:ci",
"lint": "turbo run lint",
"test": "turbo run test",
"test:unit": "turbo run test:unit",
"test:integration": "turbo run test:integration",
"test:ci": "turbo run test:ci"
"test:ci": "turbo run test:ci",
"prepare": "husky"
},
"devDependencies": {
"@biomejs/biome": "^1.9.0",
"@types/jest": "^29.1.2",
"@types/node": "20.9.0",
"@typescript-eslint/eslint-plugin": "^5.21.0",
"@typescript-eslint/parser": "^5.21.0",
"eslint": "^8.25.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^26.1.5",
"husky": "^7.0.4",
"husky": "^9.1.6",
"jest": "^29.2.0",
"prettier": "^2.7.1",
"lint-staged": "^15.2.10",
"rimraf": "^3.0.2",
"ts-jest": "29.0.3",
"turbo": "^2.1.2",
"typescript": "^4.8.4"
},
"packageManager": "[email protected]"
"packageManager": "[email protected]",
"pre-commit": "lint-staged",
"lint-staged": {
"*.{js,ts,cjs,mjs,md,json,jsonc}": "biome ci"
}
}
2 changes: 1 addition & 1 deletion packages/common-utils/__tests__/unit/sum.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { sum } from '../../src'

describe(`sum`, () => {
describe('sum', () => {
it('sum([]) = 0', () => {
expect(sum([])).toBe(0)
})
Expand Down
8 changes: 3 additions & 5 deletions packages/common-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
"description": "Library that contains common utility functions",
"main": "./build/index.js",
"scripts": {
"clean": "rimraf lib",
"clean": "rimraf build",
"build": "pnpm clean && tsc",
"prettier-check": "prettier --parser=typescript \"src/**/*.{js,ts}\" --check",
"prettier-write": "prettier --parser=typescript \"src/**/*.{js,ts}\" --write",
"typecheck": "tsc",
"eslint-check": "eslint \"src/**/*.{js,ts}\"",
"lint-staged": "lint-staged",
"lint:ci": "biome ci",
"lint": "biome check --fix --unsafe",
"pretest": "jest --clearCache",
"test": "pnpm test:ci",
"test:unit": "JEST_LIB_UNDER_TEST=common-utils jest -c ../jest/jest.config.unit.mjs",
Expand Down
8 changes: 3 additions & 5 deletions packages/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
"description": "Example that imports a local package",
"main": "./build/index.js",
"scripts": {
"clean": "rimraf lib",
"clean": "rimraf build",
"build": "pnpm clean && tsc",
"prettier-check": "prettier --parser=typescript \"src/**/*.{js,ts}\" --check",
"prettier-write": "prettier --parser=typescript \"src/**/*.{js,ts}\" --write",
"typecheck": "tsc",
"eslint-check": "eslint \"src/**/*.{js,ts}\"",
"lint-staged": "lint-staged",
"lint:ci": "biome ci",
"lint": "biome check --fix --unsafe",
"pretest": "jest --clearCache"
},
"dependencies": {
Expand Down
Loading

0 comments on commit 95ff66c

Please sign in to comment.