Skip to content

Commit 9e24cd9

Browse files
authored
Merge pull request #310 from knockout/modern-tooling/phase-4-biome
Replace ESLint + Prettier with Biome
2 parents 203236f + 0ef4f53 commit 9e24cd9

146 files changed

Lines changed: 18519 additions & 17088 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/lint-and-typecheck.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,8 @@ jobs:
2121
- name: Install dependencies
2222
run: bun install --frozen-lockfile
2323

24-
- name: Check Prettier
25-
run: bun run format
26-
27-
- name: Check ESLint
28-
run: bun run lint
24+
- name: Check Biome (lint + format)
25+
run: bunx @biomejs/biome ci .
2926

3027
- name: Build (required for tsc)
3128
run: bun run build

.prettierignore

Lines changed: 0 additions & 16 deletions
This file was deleted.

.prettierrc

Lines changed: 0 additions & 10 deletions
This file was deleted.

AGENTS.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ All commands use Bun. Run from the repo root:
3838
bun install # Install all dependencies (uses Bun workspaces)
3939
bun run build # Build all packages (ESM, CommonJS, MJS, browser)
4040
bun run test # Run all tests (Vitest, headless Chromium via Playwright)
41-
bun run lint # Run ESLint
42-
bun run lint:fix # Run ESLint with auto-fix
43-
bun run format # Check Prettier formatting
44-
bun run format:fix # Fix Prettier formatting
41+
bun run check # Run Biome (lint + format)
42+
bun run lint # Run Biome lint only
43+
bun run lint:fix # Run Biome lint with auto-fix
44+
bun run format # Check Biome formatting
45+
bun run format:fix # Fix Biome formatting
4546
bun run tsc # TypeScript type-check (no emit)
4647
bun run dts # Generate TypeScript declaration files
4748
bun run clean # Clean dist/ and coverage/ dirs
@@ -62,12 +63,11 @@ because TKO does low-level DOM manipulation, MutationObserver, and event handlin
6263

6364
## Code Style
6465

65-
- **Formatter**: Prettier — no semicolons, single quotes, trailing commas: none, 120 char width
66-
- **Linter**: ESLint with typescript-eslint (flat config)
67-
- **Editor**: 2-space indentation for JS/TS, LF line endings
68-
- See `.prettierrc` and `eslint.config.js` for full config
66+
- **Linter + Formatter**: Biome — single Rust-native tool replacing ESLint + Prettier
67+
- **Style**: no semicolons, single quotes, trailing commas: none, 120 char width, 2-space indent, LF line endings
68+
- See `biome.json` for full config
6969

70-
Run `bun run format:fix && bun run lint:fix` before committing.
70+
Run `bun run lint:fix` before committing.
7171

7272
## TypeScript
7373

@@ -102,7 +102,7 @@ GitHub Actions workflows (`.github/workflows/`):
102102
|----------|---------|---------|
103103
| `main-build.yml` | Push to main | Build + audit + headless test |
104104
| `test-headless.yml` | PRs | Matrix test (Chrome, Firefox, jQuery) |
105-
| `lint-and-typecheck.yml` | PRs | Prettier + ESLint + tsc (combined) |
105+
| `lint-and-typecheck.yml` | PRs | Biome + tsc (lint, format, typecheck) |
106106
| `publish-check.yml` | PRs | Verify packages are publishable |
107107
| `release.yml` | Tag push (`v*`) | Changeset version PRs + npm publish + GitHub release creation |
108108
| `github-release.yml` | Manual fallback | Backfill a GitHub release/tag for a published `main` commit if automatic release creation needs a retry |

biome.json

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/2.4.11/schema.json",
3+
"vcs": { "enabled": true, "clientKind": "git", "useIgnoreFile": true },
4+
"files": {
5+
"ignoreUnknown": true,
6+
"includes": ["packages/**", "builds/**", "tools/**", "global.d.ts", "vitest.config.ts"]
7+
},
8+
"formatter": {
9+
"enabled": true,
10+
"indentStyle": "space",
11+
"indentWidth": 2,
12+
"lineWidth": 120,
13+
"lineEnding": "lf"
14+
},
15+
"linter": {
16+
"enabled": true,
17+
"includes": ["**/*.ts"],
18+
"rules": {
19+
"recommended": true,
20+
"complexity": {
21+
"noUselessEscapeInRegex": "off",
22+
"noArguments": "off",
23+
"noBannedTypes": "off",
24+
"useArrowFunction": "off",
25+
"noThisInStatic": "off"
26+
},
27+
"correctness": {
28+
"noUnusedVariables": "warn",
29+
"noUnusedImports": "warn",
30+
"noUnusedFunctionParameters": "warn"
31+
},
32+
"style": {
33+
"useConst": "off",
34+
"useArrayLiterals": "off",
35+
"noNamespace": "off",
36+
"noNonNullAssertion": "off"
37+
},
38+
"suspicious": {
39+
"noExplicitAny": "off",
40+
"noAssignInExpressions": "off",
41+
"noMisleadingCharacterClass": "off",
42+
"noDoubleEquals": "off",
43+
"noRedeclare": "error",
44+
"noShadowRestrictedNames": "off",
45+
"noControlCharactersInRegex": "off",
46+
"noEmptyBlockStatements": "off",
47+
"noPrototypeBuiltins": "off",
48+
"noFallthroughSwitchClause": "error",
49+
"noImplicitAnyLet": "off",
50+
"noTemplateCurlyInString": "off",
51+
"useIterableCallbackReturn": "off",
52+
"noGlobalIsNan": "off",
53+
"noGlobalIsFinite": "off",
54+
"noThenProperty": "off",
55+
"useGetterReturn": "error"
56+
},
57+
"performance": {
58+
"noDelete": "off"
59+
},
60+
"security": {
61+
"noGlobalEval": "off"
62+
}
63+
}
64+
},
65+
"javascript": {
66+
"formatter": {
67+
"semicolons": "asNeeded",
68+
"trailingCommas": "none",
69+
"quoteStyle": "single",
70+
"arrowParentheses": "asNeeded"
71+
}
72+
},
73+
"assist": {
74+
"enabled": false
75+
}
76+
}

builds/knockout/helpers/mocha-test-helpers.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,14 @@ function detectIEVersion() {
4949
const div = document.createElement('div')
5050
const iElems = div.getElementsByTagName('i')
5151

52-
while ((div.innerHTML = '<!--[if gt IE ' + ++version + ']><i></i><![endif]-->'), iElems[0]) {}
52+
while (((div.innerHTML = '<!--[if gt IE ' + ++version + ']><i></i><![endif]-->'), iElems[0])) {}
5353
return version > 4 ? version : undefined
5454
}
5555

5656
function expectEqualOneOf(actual, expectedPossibilities) {
57-
const matches = expectedPossibilities.some(function (expected) { return chai.util.eql(actual, expected) })
57+
const matches = expectedPossibilities.some(function (expected) {
58+
return chai.util.eql(actual, expected)
59+
})
5860
expect(matches, 'expected value to deeply equal one of the provided possibilities').to.equal(true)
5961
}
6062

@@ -93,18 +95,31 @@ function expectHaveTexts(actual, expectedTexts) {
9395
}
9496

9597
function expectHaveValues(actual, expectedValues) {
96-
const values = ko.utils.arrayFilter(ko.utils.arrayMap(actual.childNodes, function (node) { return node.value }), function (value) { return value !== undefined })
98+
const values = ko.utils.arrayFilter(
99+
ko.utils.arrayMap(actual.childNodes, function (node) {
100+
return node.value
101+
}),
102+
function (value) {
103+
return value !== undefined
104+
}
105+
)
97106
expect(values).to.deep.equal(expectedValues)
98107
}
99108

100109
function expectHaveCheckedStates(actual, expectedValues) {
101-
const values = ko.utils.arrayMap(actual.childNodes, function (node) { return node.checked })
110+
const values = ko.utils.arrayMap(actual.childNodes, function (node) {
111+
return node.checked
112+
})
102113
expect(values).to.deep.equal(expectedValues)
103114
}
104115

105116
function expectHaveSelectedValues(actual, expectedValues) {
106-
const selectedNodes = ko.utils.arrayFilter(actual.childNodes, function (node) { return node.selected })
107-
const selectedValues = ko.utils.arrayMap(selectedNodes, function (node) { return ko.selectExtensions.readValue(node) })
117+
const selectedNodes = ko.utils.arrayFilter(actual.childNodes, function (node) {
118+
return node.selected
119+
})
120+
const selectedValues = ko.utils.arrayMap(selectedNodes, function (node) {
121+
return ko.selectExtensions.readValue(node)
122+
})
108123
expect(selectedValues).to.deep.equal(expectedValues)
109124
}
110125

0 commit comments

Comments
 (0)