Files
payload/packages/translations/scripts/translateNewKeys/sortKeys.ts
Elliot DeNolf 142616e6ad chore(eslint): curly [skip-lint] (#7959)
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.
2024-08-29 10:15:36 -04:00

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
}