Now enforcing curly brackets on all if statements. Includes auto-fixer. ```ts // ❌ Bad if (foo) foo++; // ✅ Good if (foo) { foo++; } ``` Note: this did not lint the `drizzle` package or any `db-*` packages. This will be done in the future.
19 lines
366 B
TypeScript
19 lines
366 B
TypeScript
export function sortKeys(obj: any): any {
|
|
if (typeof obj !== 'object' || obj === null) {
|
|
return obj
|
|
}
|
|
|
|
if (Array.isArray(obj)) {
|
|
return obj.map(sortKeys)
|
|
}
|
|
|
|
const sortedKeys = Object.keys(obj).sort()
|
|
const sortedObj: { [key: string]: any } = {}
|
|
|
|
for (const key of sortedKeys) {
|
|
sortedObj[key] = sortKeys(obj[key])
|
|
}
|
|
|
|
return sortedObj
|
|
}
|