Skip to content

Commit

Permalink
Simplify biome config to required rules
Browse files Browse the repository at this point in the history
  • Loading branch information
ilovepixelart committed Oct 6, 2024
1 parent d1bf328 commit ecf033b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 122 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ jobs:
uses: rhysd/changelog-from-release/action@v3
with:
file: CHANGELOG.md
github_token: ${{ secrets.GITHUB_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
26 changes: 15 additions & 11 deletions .github/workflows/pr-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ on:
- feature*

pull_request:
types: [opened, synchronize, reopened]
types: [opened, synchronize, reopened]

jobs:
tests:
name: Coverage
Expand All @@ -36,20 +36,25 @@ jobs:
strategy:
matrix:
node-version: [18.x, 20.x]
mongoose-version: [[mongoose@6.12.8, bson@^4.7.2], [mongoose@7.6.11, bson@^5.5.0], [mongoose@latest, bson@^6.5.0]]
mongoose-version:
[
[mongoose@6.12.8, bson@^4.7.2],
[mongoose@7.6.11, bson@^5.5.0],
[mongoose@latest, bson@^6.5.0],
]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm

- name: Installing dependencies
run: npm ci

Expand All @@ -63,9 +68,9 @@ jobs:
REDIS_HOST: localhost
# The default Redis port
REDIS_PORT: 6379

sonar:
name: Coverage & Sonar
name: Biome, Coverage & Sonar
runs-on: ubuntu-latest

# Service containers to run with `container-job`
Expand All @@ -83,7 +88,7 @@ jobs:
ports:
# Maps port 6379 on service container to the host
- 6379:6379

strategy:
matrix:
node-version: [22.x]
Expand All @@ -103,8 +108,8 @@ jobs:
- name: Installing dependencies
run: npm ci

- name: Lint
run: npm run lint
- name: Biome
run: npm run biome

- name: Coverage
run: npm run test
Expand All @@ -130,4 +135,3 @@ jobs:
-Dsonar.tests=tests
-Dsonar.test.exclusions=tests/**
-Dsonar.coverage.exclusions=tests/**
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"nosql",
"npmignore",
"parens",
"rhysd",
"setex",
"singleline",
"sonarcloud",
Expand Down
111 changes: 8 additions & 103 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,76 +1,21 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.3/schema.json",
"vcs": { "enabled": false, "clientKind": "git", "useIgnoreFile": false },
"files": { "ignoreUnknown": false, "ignore": [] },
"files": {
"ignoreUnknown": false,
"ignore": ["node_modules", "dist", "coverage"]
},
"formatter": { "enabled": true, "indentStyle": "space", "indentWidth": 2 },
"organizeImports": { "enabled": true },
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"complexity": {
"noExcessiveCognitiveComplexity": "error",
"noExtraBooleanCast": "error",
"noMultipleSpacesInRegularExpressionLiterals": "error",
"noUselessCatch": "error",
"noWith": "error"
},
"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"
},
"style": { "useConsistentArrayType": "error", "useWhile": "error" },
"suspicious": {
"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",
"noSparseArray": "error",
"noUnsafeNegation": "error",
"useGetterReturn": "error",
"useValidTypeof": "error"
}
},
"ignore": ["**/node_modules", "**/dist", "**/coverage", "**/.env"]
"recommended": true
}
},
"javascript": {
"formatter": {
"trailingCommas": "all",
"quoteStyle": "single",
"semicolons": "asNeeded",
"lineWidth": 320
Expand All @@ -81,45 +26,5 @@
"formatter": {
"trailingCommas": "none"
}
},
"overrides": [
{ "include": ["tests/**/*.test.ts"], "linter": { "rules": {} } },
{
"include": ["src/**/*.ts"],
"linter": { "rules": { "style": { "useEnumInitializers": "error" } } }
},
{
"include": ["*.ts", "*.tsx", "*.mts", "*.cts"],
"linter": {
"rules": {
"correctness": {
"noConstAssign": "off",
"noGlobalObjectCalls": "off",
"noInvalidBuiltinInstantiation": "off",
"noInvalidConstructorSuper": "off",
"noNewSymbol": "off",
"noSetterReturn": "off",
"noUndeclaredVariables": "off",
"noUnreachable": "off",
"noUnreachableSuper": "off"
},
"style": {
"noArguments": "error",
"noVar": "error",
"useConst": "error"
},
"suspicious": {
"noDuplicateClassMembers": "off",
"noDuplicateObjectKeys": "off",
"noDuplicateParameters": "off",
"noFunctionAssign": "off",
"noImportAssign": "off",
"noRedeclare": "off",
"noUnsafeNegation": "off",
"useGetterReturn": "off"
}
}
}
}
]
}
}
10 changes: 3 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,15 @@
"module": "dist/esm/plugin.js",
"types": "dist/cjs/types/plugin.d.ts",
"scripts": {
"lint": "npx @biomejs/biome lint",
"lint:fix": "npx @biomejs/biome lint --write ./",
"check": "npx @biomejs/biome check",
"check:fix": "npx @biomejs/biome check --write ./",
"format": "npx @biomejs/biome format",
"format:fix": "npx @biomejs/biome format --write ./",
"biome": "npx @biomejs/biome check",
"biome:fix": "npx @biomejs/biome check --write .",
"test": "jest --config jest.config.ts --detectOpenHandles --coverage",
"test:open": "npm run test && open-cli coverage/lcov-report/index.html",
"clean": "rm -rf ./dist",
"build": "npm run clean && npm run build:cjs && npm run build:esm",
"build:cjs": "tsc -p config/tsconfig.cjs.json",
"build:esm": "tsc -p config/tsconfig.esm.json && bash/esm.sh",
"release": "npm run lint && npm run build && np"
"release": "npm run biome && npm run build && np"
},
"dependencies": {
"ioredis": "5.4.1",
Expand Down

0 comments on commit ecf033b

Please # to comment.