[sort-package-json] always ensure 2-space indent is used

This commit is contained in:
spalger 2023-01-10 10:39:48 -07:00
parent d35296ea3b
commit 72bd23b740
No known key found for this signature in database

View file

@ -13,29 +13,33 @@ import sorter from 'sort-package-json';
* @returns
*/
export function sortPackageJson(json) {
return sorter(typeof json === 'string' ? json : JSON.stringify(json, null, 2), {
// top level keys in the order they were written when this was implemented
sortOrder: [
'name',
'description',
'keywords',
'private',
'version',
'branch',
'main',
'browser',
'types',
'tsdocMetadata',
'build',
'homepage',
'bugs',
'license',
'kibana',
'author',
'scripts',
'repository',
'engines',
'resolutions',
],
});
return sorter(
// always parse and stringify the json to make sure it's using 2 space indentation
JSON.stringify(typeof json === 'string' ? JSON.parse(json) : json, null, 2),
{
// top level keys in the order they were written when this was implemented
sortOrder: [
'name',
'description',
'keywords',
'private',
'version',
'branch',
'main',
'browser',
'types',
'tsdocMetadata',
'build',
'homepage',
'bugs',
'license',
'kibana',
'author',
'scripts',
'repository',
'engines',
'resolutions',
],
}
);
}