Skip to content

Commit 68c6a9f

Browse files
onairmarcEncoreBot
andauthored
Fix Improper Indentation (#2)
Co-authored-by: EncoreBot <ghbot@encoredigitalgroup.com>
1 parent 87378c7 commit 68c6a9f

File tree

7 files changed

+63
-51
lines changed

7 files changed

+63
-51
lines changed

dist/shared/types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ export interface SortOptions {
44
filePath?: string;
55
dryRun?: boolean;
66
}
7+
export declare const DefaultSortOptions: SortOptions;

dist/shared/types.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,28 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.DefaultSortOptions = void 0;
4+
exports.DefaultSortOptions = {
5+
customSortOrder: [
6+
"name",
7+
"type",
8+
"author",
9+
"version",
10+
"description",
11+
"publishConfig",
12+
"keywords",
13+
"homepage",
14+
"engines",
15+
"dependencies",
16+
"devDependencies",
17+
"scripts",
18+
"types",
19+
"main",
20+
"module",
21+
"exports",
22+
"files",
23+
"repository",
24+
"bugs",
25+
],
26+
indentation: 4,
27+
dryRun: false,
28+
};

dist/sortPackage.js

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
66
exports.sortPackageJson = sortPackageJson;
77
exports.sortPackageFile = sortPackageFile;
88
const package_1 = require("./formatters/package");
9+
const types_1 = require("./shared/types");
910
const fs_1 = __importDefault(require("fs"));
1011
const path_1 = __importDefault(require("path"));
1112
const sort_package_json_1 = require("sort-package-json");
12-
const defaultSortOrder = [
13-
"name",
14-
"type",
15-
"author",
16-
"version",
17-
"description",
18-
"publishConfig",
19-
"keywords",
20-
"homepage",
21-
"engines",
22-
"dependencies",
23-
"devDependencies",
24-
"scripts",
25-
"types",
26-
"main",
27-
"module",
28-
"exports",
29-
"files",
30-
"repository",
31-
"bugs",
32-
];
3313
function sortPackageJson(packageObj, options = {}) {
34-
const sortOrder = options.customSortOrder || defaultSortOrder;
14+
const sortOrder = options.customSortOrder || types_1.DefaultSortOptions.customSortOrder;
3515
let sortedPackage = (0, sort_package_json_1.sortPackageJson)(packageObj, {
3616
sortOrder,
3717
});
@@ -42,7 +22,7 @@ function sortPackageJson(packageObj, options = {}) {
4222
}
4323
function sortPackageFile(filePath, options = {}) {
4424
const packagePath = filePath || path_1.default.join(process.cwd(), "package.json");
45-
const indentation = options.indentation || 2;
25+
const indentation = options.indentation || types_1.DefaultSortOptions.indentation;
4626
try {
4727
const packageJson = JSON.parse(fs_1.default.readFileSync(packagePath, "utf8"));
4828
const sortedPackageJson = sortPackageJson(packageJson, options);

dist/sortTSConfig.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
55
Object.defineProperty(exports, "__esModule", { value: true });
66
exports.sortTsConfig = sortTsConfig;
77
exports.sortTsConfigFile = sortTsConfigFile;
8+
const types_1 = require("./shared/types");
89
const fs_1 = __importDefault(require("fs"));
910
const path_1 = __importDefault(require("path"));
1011
function sortObjectKeysAlphabetically(obj) {
@@ -23,7 +24,7 @@ function sortTsConfig(tsConfig) {
2324
}
2425
function sortTsConfigFile(filePath, options = {}) {
2526
const tsConfigPath = filePath || path_1.default.join(process.cwd(), "tsconfig.json");
26-
const indentation = options.indentation || 2;
27+
const indentation = options.indentation || types_1.DefaultSortOptions.indentation;
2728
try {
2829
const tsConfig = JSON.parse(fs_1.default.readFileSync(tsConfigPath, "utf8"));
2930
const sortedTsConfig = sortTsConfig(tsConfig);

src/shared/types.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,29 @@ export interface SortOptions {
99
filePath?: string;
1010
dryRun?: boolean;
1111
}
12+
13+
export const DefaultSortOptions: SortOptions = {
14+
customSortOrder: [
15+
"name",
16+
"type",
17+
"author",
18+
"version",
19+
"description",
20+
"publishConfig",
21+
"keywords",
22+
"homepage",
23+
"engines",
24+
"dependencies",
25+
"devDependencies",
26+
"scripts",
27+
"types",
28+
"main",
29+
"module",
30+
"exports",
31+
"files",
32+
"repository",
33+
"bugs",
34+
],
35+
indentation: 4,
36+
dryRun: false,
37+
};

src/sortPackage.ts

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,13 @@
33
* All Rights Reserved.
44
*/
55
import {sortExportsKeys} from "./formatters/package";
6-
import {SortOptions} from "./shared/types";
6+
import {SortOptions, DefaultSortOptions} from "./shared/types";
77
import fs from "fs";
88
import path from "path";
99
import {sortPackageJson as baseSortPackageJson} from "sort-package-json";
1010

11-
const defaultSortOrder = [
12-
"name",
13-
"type",
14-
"author",
15-
"version",
16-
"description",
17-
"publishConfig",
18-
"keywords",
19-
"homepage",
20-
"engines",
21-
"dependencies",
22-
"devDependencies",
23-
"scripts",
24-
"types",
25-
"main",
26-
"module",
27-
"exports",
28-
"files",
29-
"repository",
30-
"bugs",
31-
];
32-
3311
export function sortPackageJson(packageObj: Record<string, any>, options: SortOptions = {}): Record<string, any> {
34-
const sortOrder = options.customSortOrder || defaultSortOrder;
12+
const sortOrder = options.customSortOrder || DefaultSortOptions.customSortOrder;
3513

3614
// Sort using the base library first
3715
let sortedPackage = baseSortPackageJson(packageObj, {
@@ -47,7 +25,7 @@ export function sortPackageJson(packageObj: Record<string, any>, options: SortOp
4725

4826
export function sortPackageFile(filePath?: string, options: SortOptions = {}): Record<string, any> {
4927
const packagePath = filePath || path.join(process.cwd(), "package.json");
50-
const indentation = options.indentation || 2;
28+
const indentation = options.indentation || (DefaultSortOptions.indentation as number);
5129

5230
try {
5331
const packageJson = JSON.parse(fs.readFileSync(packagePath, "utf8"));

src/sortTSConfig.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright (c) 2025. Encore Digital Group.
33
* All Rights Reserved.
44
*/
5-
import {SortOptions} from "./shared/types";
5+
import {DefaultSortOptions, SortOptions} from "./shared/types";
66
import fs from "fs";
77
import path from "path";
88

@@ -28,7 +28,7 @@ export function sortTsConfig(tsConfig: Record<string, any>): Record<string, any>
2828

2929
export function sortTsConfigFile(filePath?: string, options: SortOptions = {}): Record<string, any> {
3030
const tsConfigPath = filePath || path.join(process.cwd(), "tsconfig.json");
31-
const indentation = options.indentation || 2;
31+
const indentation = options.indentation || (DefaultSortOptions.indentation as number);
3232

3333
try {
3434
const tsConfig = JSON.parse(fs.readFileSync(tsConfigPath, "utf8"));

0 commit comments

Comments
 (0)