[dx] use Biome instead of Prettier, part 2 (#2731)

Biome seems to be MUCH faster than Prettier. Unfortunately, it
introduces some formatting changes around the ternary operator, so we
have to update files in the repo. To make revert easier if we need it,
the change is split into two PRs. This PR introduces a Biome CI check
and reformats all files accordingly.

## Change Type
- [x] `minor` — New feature
This commit is contained in:
Dan Groshev 2024-02-05 17:54:02 +00:00 committed by GitHub
parent 826433751c
commit e6e4e7f6cb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
56 changed files with 286 additions and 264 deletions

View file

@ -41,8 +41,8 @@ jobs:
- name: Setup Biome CLI - name: Setup Biome CLI
uses: biomejs/setup-biome@v2 uses: biomejs/setup-biome@v2
# - name: Run Biome - name: Run Biome
# run: biome ci --formatter-enabled=true --linter-enabled=false --organize-imports-enabled=false . run: biome ci --formatter-enabled=true --linter-enabled=false --organize-imports-enabled=false .
- name: Typecheck - name: Typecheck
run: yarn build-types run: yarn build-types

View file

@ -109,7 +109,9 @@ export async function GET(req: NextRequest) {
} }
}) })
Object.keys(results).forEach((section: string) => results[section as keyof Data['results']].sort((a, b) => b.score - a.score)) Object.keys(results).forEach((section: string) =>
results[section as keyof Data['results']].sort((a, b) => b.score - a.score)
)
results.articles.sort( results.articles.sort(
(a, b) => (b.type === 'heading' ? -1 : 1) - (a.type === 'heading' ? -1 : 1) (a, b) => (b.type === 'heading' ? -1 : 1) - (a.type === 'heading' ? -1 : 1)

View file

@ -3,9 +3,11 @@ import { AlarmScheduler } from './AlarmScheduler'
jest.useFakeTimers() jest.useFakeTimers()
function makeMockAlarmScheduler<Key extends string>(alarms: { function makeMockAlarmScheduler<Key extends string>(
alarms: {
[K in Key]: jest.Mock<Promise<void>, []> [K in Key]: jest.Mock<Promise<void>, []>
}) { }
) {
const data = new Map<string, number>() const data = new Map<string, number>()
let scheduledAlarm: number | null = null let scheduledAlarm: number | null = null

View file

@ -10,7 +10,6 @@ export function LocalMigration() {
useEffect(() => { useEffect(() => {
let didCancel = false let didCancel = false
;(async () => { ;(async () => {
if (!isEditorEmpty(editor)) return if (!isEditorEmpty(editor)) return

View file

@ -97,7 +97,6 @@ const InsideOfEditorContext = () => {
return null return null
} }
/* /*
Introduction: Introduction:

View file

@ -1,5 +1,8 @@
[ [
["functions", ["atom-1", "computed-1", "react", "reactor-1", "transact", "transaction"]], [
"functions",
["atom-1", "computed-1", "react", "reactor-1", "transact", "transaction"]
],
["classes"], ["classes"],
["interfaces", ["Signal"]] ["interfaces", ["Signal"]]
] ]

View file

@ -91,11 +91,16 @@ const CurrentState = track(function CurrentState() {
const shape = path === 'select.idle' || !path.includes('select.') ? hoverShape : selectedShape const shape = path === 'select.idle' || !path.includes('select.') ? hoverShape : selectedShape
const shapeInfo = const shapeInfo =
shape && path.includes('select.') shape && path.includes('select.')
? ` / ${shape.type || ''}${'geo' in shape.props ? ' / ' + shape.props.geo : ''} / [${Vec.ToFixed(editor.getPointInShapeSpace(shape, editor.inputs.currentPagePoint), 0)}]` ? ` / ${shape.type || ''}${
'geo' in shape.props ? ' / ' + shape.props.geo : ''
} / [${Vec.ToFixed(editor.getPointInShapeSpace(shape, editor.inputs.currentPagePoint), 0)}]`
: '' : ''
const ruler = const ruler =
path.startsWith('select.') && !path.includes('.idle') path.startsWith('select.') && !path.includes('.idle')
? ` / [${Vec.ToFixed(editor.inputs.originPagePoint, 0)}] → [${Vec.ToFixed(editor.inputs.currentPagePoint, 0)}] = ${Vec.Dist(editor.inputs.originPagePoint, editor.inputs.currentPagePoint).toFixed(0)}` ? ` / [${Vec.ToFixed(editor.inputs.originPagePoint, 0)}] → [${Vec.ToFixed(
editor.inputs.currentPagePoint,
0
)}] = ${Vec.Dist(editor.inputs.originPagePoint, editor.inputs.currentPagePoint).toFixed(0)}`
: '' : ''
return <div className="tlui-debug-panel__current-state">{`${path}${shapeInfo}${ruler}`}</div> return <div className="tlui-debug-panel__current-state">{`${path}${shapeInfo}${ruler}`}</div>

View file

@ -50,8 +50,10 @@ type DefaultHelpers = ReturnType<typeof useDefaultHelpers>
export type TLUiOverride<Type, Helpers> = (editor: Editor, schema: Type, helpers: Helpers) => Type export type TLUiOverride<Type, Helpers> = (editor: Editor, schema: Type, helpers: Helpers) => Type
type WithDefaultHelpers<T extends TLUiOverride<any, any>> = type WithDefaultHelpers<T extends TLUiOverride<any, any>> = T extends TLUiOverride<
T extends TLUiOverride<infer Type, infer Helpers> infer Type,
infer Helpers
>
? TLUiOverride<Type, Helpers extends undefined ? DefaultHelpers : Helpers & DefaultHelpers> ? TLUiOverride<Type, Helpers extends undefined ? DefaultHelpers : Helpers & DefaultHelpers>
: never : never

View file

@ -58,9 +58,11 @@ export function deepCopy<T = unknown>(obj: T): T {
* *
* @internal * @internal
*/ */
export function objectMapKeys<Key extends string>(object: { export function objectMapKeys<Key extends string>(
object: {
readonly [K in Key]: unknown readonly [K in Key]: unknown
}): Array<Key> { }
): Array<Key> {
return Object.keys(object) as Key[] return Object.keys(object) as Key[]
} }
@ -70,9 +72,11 @@ export function objectMapKeys<Key extends string>(object: {
* *
* @internal * @internal
*/ */
export function objectMapValues<Key extends string, Value>(object: { export function objectMapValues<Key extends string, Value>(
object: {
[K in Key]: Value [K in Key]: Value
}): Array<Value> { }
): Array<Value> {
return Object.values(object) as Value[] return Object.values(object) as Value[]
} }
@ -82,9 +86,11 @@ export function objectMapValues<Key extends string, Value>(object: {
* *
* @internal * @internal
*/ */
export function objectMapEntries<Key extends string, Value>(object: { export function objectMapEntries<Key extends string, Value>(
object: {
[K in Key]: Value [K in Key]: Value
}): Array<[Key, Value]> { }
): Array<[Key, Value]> {
return Object.entries(object) as [Key, Value][] return Object.entries(object) as [Key, Value][]
} }

View file

@ -242,9 +242,11 @@ export class ObjectValidator<Shape extends object> extends Validator<Shape> {
* }) * })
* ``` * ```
*/ */
extend<Extension extends Record<string, unknown>>(extension: { extend<Extension extends Record<string, unknown>>(
extension: {
readonly [K in keyof Extension]: Validatable<Extension[K]> readonly [K in keyof Extension]: Validatable<Extension[K]>
}): ObjectValidator<Shape & Extension> { }
): ObjectValidator<Shape & Extension> {
return new ObjectValidator({ ...this.config, ...extension }) as ObjectValidator< return new ObjectValidator({ ...this.config, ...extension }) as ObjectValidator<
Shape & Extension Shape & Extension
> >
@ -470,9 +472,11 @@ export const unknownObject = new Validator<Record<string, unknown>>((value) => {
* *
* @public * @public
*/ */
export function object<Shape extends object>(config: { export function object<Shape extends object>(
config: {
readonly [K in keyof Shape]: Validatable<Shape[K]> readonly [K in keyof Shape]: Validatable<Shape[K]>
}): ObjectValidator<Shape> { }
): ObjectValidator<Shape> {
return new ObjectValidator(config) return new ObjectValidator(config)
} }