dprint-plugin-typescript
dprint-plugin-typescript copied to clipboard
Alphabetical ordering of interfaces, classes, properties and methods
Request: Add an option to sort interfaces, classes, types, and their properties and methods in an alphabetical order
Related issues: #561 #585
Configuration options: Expose an option to order each set individually, e.g. "sortProperties": "caseSensitive", similar to module.sortImportDeclarations
Example: Given file:
class Z {
constructor();
weights: Record<string, number>;
longString: string;
}
interface A {
someKey: boolean;
aProperty: number;
zeroCount(): number;
doSomething(): void;
}
Should become:
interface A {
aProperty: number;
someKey: boolean;
doSomething(): void;
zeroCount(): number;
}
class Z {
constructor();
longString: string;
weights: Record<string, number>;
}
Apologies if this issue is too broad in scope. I have already implemented a (very bad) way to do this using ts-morph, but my implementation leaves much to be desired.