Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dist/build-plugins/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./transformGenericsPlugin";
4 changes: 4 additions & 0 deletions dist/build-plugins/transformGenericsPlugin.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export declare function transformGenericsPlugin(): {
name: string;
generateBundle(options: any, bundle: any): void;
};
1 change: 1 addition & 0 deletions dist/cli.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "reflect-metadata";
16 changes: 16 additions & 0 deletions dist/core/ast/ASTAnalyzer.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import * as ts from "typescript";
export interface ReferenceInfo {
identifiers: Set<string>;
thisReferences: Set<string>;
directCalls: Set<string>;
}
export declare class ASTAnalyzer {
static extractReferences(node: ts.Node, scopeFilter?: (name: string) => boolean): ReferenceInfo;
static extractClassMemberReferences(member: ts.ClassElement, availableMembers: Set<string>): Set<string>;
static extractFileDeclarationReferences(declaration: ts.Statement, availableDeclarations: Set<string>): Set<string>;
static getClassMemberName(member: ts.ClassElement): string;
static getDeclarationName(declaration: ts.Statement): string;
static hasModifier(node: ts.Node, kind: ts.SyntaxKind): boolean;
static isDefaultExport(node: ts.Statement): boolean;
static isExported(node: ts.Statement): boolean;
}
9 changes: 9 additions & 0 deletions dist/core/ast/ASTTransformer.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as ts from "typescript";
export declare class ASTTransformer {
static createSourceFile(source: string, filePath: string): ts.SourceFile;
static printNode(node: ts.Node, sourceFile: ts.SourceFile, removeComments?: boolean): string;
static printSourceFile(sourceFile: ts.SourceFile): string;
static reorderClassMembers(classNode: ts.ClassDeclaration, orderedMembers: ts.ClassElement[]): ts.ClassDeclaration;
static reorderSourceFileStatements(sourceFile: ts.SourceFile, orderedStatements: ts.Statement[]): ts.SourceFile;
static transformSourceFile(sourceFile: ts.SourceFile, visitor: (node: ts.Node) => ts.Node | undefined): ts.SourceFile;
}
16 changes: 16 additions & 0 deletions dist/core/ast/DependencyResolver.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export interface DependencyNode {
name: string;
dependencies: Set<string>;
originalIndex: number;
sortedIndex: number;
}
export interface DependencyGraph {
nodes: Map<string, DependencyNode>;
circularGroups: Set<string>[];
}
export declare class DependencyResolver {
private static findStronglyConnectedComponents;
static buildGraph<T>(items: T[], getName: (item: T) => string, getDependencies: (item: T) => Set<string>): DependencyGraph;
static topologicalSort(graph: DependencyGraph, sortedNames: string[]): string[];
static reorderWithDependencies<T>(items: T[], getName: (item: T) => string): T[];
}
3 changes: 3 additions & 0 deletions dist/core/ast/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./ASTAnalyzer";
export * from "./ASTTransformer";
export * from "./DependencyResolver";
82 changes: 82 additions & 0 deletions dist/core/config/ConfigDefaults.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import { CoreConfig, FormatterOrder } from "./ConfigTypes";
export declare class ConfigDefaults {
static readonly DEFAULT_EXCLUDE_PATTERNS: readonly ["node_modules/**", "dist/**", "vendor/**", "bin/**"];
static readonly DEFAULT_INDEX_DIRECTORIES: readonly ["src/", "packages/"];
static readonly DEFAULT_JS_INCLUDE_PATTERNS: readonly ["**/*.{js,ts,jsx,tsx}"];
static readonly DEFAULT_TS_INCLUDE_PATTERNS: readonly ["**/*.{ts,tsx}"];
static getDefaultCodeStyleConfig(): {
enabled: boolean;
quoteStyle: "double";
semicolons: "always";
bracketSpacing: boolean;
indentStyle: "space";
indentWidth: number;
lineWidth: number;
trailingCommas: "all";
arrowParens: "avoid";
};
static getDefaultIndexDirectories(): string[];
static getDefaultIndexGenerationConfig(): {
enabled: boolean;
directories: string[];
options: {
fileExtension: string;
indexFileName: string;
recursive: boolean;
};
updateMainIndex: boolean;
};
static getDefaultImportConfig(): {
enabled: boolean;
sortImports: boolean;
removeUnused: boolean;
removeSideEffects: boolean;
groupImports: boolean;
groupOrder: string[];
separateGroups: boolean;
};
static getDefaultIncludePatterns(): string[];
static getDefaultExcludePatterns(): string[];
static getDefaultSortingConfig(): {
enabled: boolean;
classMembers: {
enabled: boolean;
order: import("../").MemberType[];
groupByVisibility: boolean;
respectDependencies: boolean;
};
reactComponents: {
enabled: boolean;
order: import("../").MemberType[];
groupByVisibility: boolean;
respectDependencies: boolean;
};
fileDeclarations: {
enabled: boolean;
order: import("../").DeclarationType[];
respectDependencies: boolean;
};
include: string[];
exclude: string[];
};
static getDefaultSpacingConfig(): {
enabled: boolean;
betweenDeclarations: boolean;
beforeReturns: boolean;
betweenStatementTypes: boolean;
};
static getDefaultPackageJsonConfig(): {
enabled: boolean;
customSortOrder: string[] | undefined;
indentation: number;
};
static getDefaultTsConfigConfig(): {
enabled: boolean;
indentation: number;
};
static getDefaultFormatterOrder(): FormatterOrder[];
static getDefaultConfig(): CoreConfig;
static getDefaultJavaScriptIncludePatterns(): string[];
static getDisabledConfig(): CoreConfig;
static getMinimalConfig(): CoreConfig;
}
20 changes: 20 additions & 0 deletions dist/core/config/ConfigLoader.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { CoreConfig } from "./ConfigTypes";
export declare class ConfigLoader {
static readonly CONFIG_FILE_NAME = "tsfmt.config.ts";
private static configCache;
static clearCache(): void;
static getConfigFilePath(projectRoot?: string): string;
static createSampleConfig(projectRoot?: string, overwrite?: boolean): void;
static getCacheStats(): {
size: number;
keys: string[];
};
private static getFileModTime;
static hasConfigFile(projectRoot?: string): boolean;
private static transpileTypeScript;
private static loadTypeScriptConfig;
private static loadConfigWithCache;
static loadConfig(projectRoot?: string, validate?: boolean): CoreConfig;
static loadConfigWithoutValidation(projectRoot?: string): CoreConfig;
static reloadConfig(projectRoot?: string): CoreConfig;
}
6 changes: 6 additions & 0 deletions dist/core/config/ConfigMerger.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { CoreConfig } from "./ConfigTypes";
export declare class ConfigMerger {
private static deepMerge;
static merge(userConfig: Partial<CoreConfig>): CoreConfig;
static mergeMultiple(...configs: Partial<CoreConfig>[]): CoreConfig;
}
97 changes: 97 additions & 0 deletions dist/core/config/ConfigTypes.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import { MemberType } from "../";
import { DeclarationType } from "../";
import { IndexGenerationConfig } from "../";
export interface ClassMemberConfig {
enabled?: boolean;
order?: MemberType[];
groupByVisibility?: boolean;
respectDependencies?: boolean;
}
export interface CodeStyleConfig {
enabled?: boolean;
quoteStyle?: "single" | "double";
semicolons?: "always" | "never";
bracketSpacing?: boolean;
indentStyle?: "tab" | "space";
indentWidth?: number;
lineWidth?: number;
trailingCommas?: "none" | "es5" | "all";
arrowParens?: "always" | "avoid";
}
export interface ImportConfig {
enabled?: boolean;
sortImports?: boolean;
removeUnused?: boolean;
removeSideEffects?: boolean;
groupImports?: boolean;
groupOrder?: string[];
separateGroups?: boolean;
}
export interface ReactComponentConfig {
enabled?: boolean;
order?: MemberType[];
groupByVisibility?: boolean;
respectDependencies?: boolean;
}
export interface FileDeclarationConfig {
enabled?: boolean;
order?: DeclarationType[];
respectDependencies?: boolean;
}
export interface SortingConfig {
enabled?: boolean;
classMembers?: ClassMemberConfig;
reactComponents?: ReactComponentConfig;
fileDeclarations?: FileDeclarationConfig;
include?: string[];
exclude?: string[];
}
export interface SpacingConfig {
enabled?: boolean;
betweenDeclarations?: boolean;
beforeReturns?: boolean;
betweenStatementTypes?: boolean;
}
export interface PackageJsonConfig {
enabled?: boolean;
customSortOrder?: string[];
indentation?: number;
}
export interface TsConfigConfig {
enabled?: boolean;
indentation?: number;
}
export declare enum FormatterOrder {
IndexGeneration = "IndexGeneration",
CodeStyle = "CodeStyle",
ImportOrganization = "ImportOrganization",
ASTTransformation = "ASTTransformation",
Spacing = "Spacing"
}
export interface CoreConfig {
indexGeneration?: IndexGenerationConfig;
codeStyle?: CodeStyleConfig;
imports?: ImportConfig;
sorting?: SortingConfig;
spacing?: SpacingConfig;
packageJson?: PackageJsonConfig;
tsConfig?: TsConfigConfig;
formatterOrder?: FormatterOrder[];
skipReactFiles?: boolean;
}
export declare class ConfigTypes {
static getArrowParenOptions(): Array<"always" | "avoid">;
static getFormatterOrderOptions(): FormatterOrder[];
static getImportGroupOptions(): string[];
static getIndentStyleOptions(): Array<"tab" | "space">;
static getQuoteStyleOptions(): Array<"single" | "double">;
static getSemicolonOptions(): Array<"always" | "never">;
static getTrailingCommaOptions(): Array<"none" | "es5" | "all">;
static isRecommendedLineWidth(width: number): boolean;
static isValidArrowParenOption(option: string): option is "always" | "avoid";
static isValidIndentStyle(style: string): style is "tab" | "space";
static isValidIndentWidth(width: number): boolean;
static isValidQuoteStyle(style: string): style is "single" | "double";
static isValidSemicolonOption(option: string): option is "always" | "never";
static isValidTrailingCommaOption(option: string): option is "none" | "es5" | "all";
}
10 changes: 10 additions & 0 deletions dist/core/config/ConfigValidator.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { CoreConfig } from "./ConfigTypes";
export interface ValidationResult {
valid: boolean;
errors: string[];
warnings: string[];
}
export declare class ConfigValidator {
static validate(config: CoreConfig): ValidationResult;
static validateOrThrow(config: CoreConfig): void;
}
5 changes: 5 additions & 0 deletions dist/core/config/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export * from "./ConfigDefaults";
export * from "./ConfigLoader";
export * from "./ConfigMerger";
export * from "./ConfigTypes";
export * from "./ConfigValidator";
17 changes: 17 additions & 0 deletions dist/core/di/Container.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import "reflect-metadata";
export declare class Container {
private factories;
private services;
private singletons;
static inject(...dependencies: string[]): (target: any) => any;
clear(): void;
private extractGenericTypeName;
private extractGenericTypeNameForRegistration;
has(name: string): boolean;
private isConstructorFunction;
register<T>(name: string, instance: T): void;
private resolveByKey;
resolve<T>(name?: string): T;
private resolveDependencies;
singleton<T>(nameOrInstanceOrConstructor: string | T | (() => T) | (new (...args: any[]) => T), instance?: T | (() => T)): void;
}
5 changes: 5 additions & 0 deletions dist/core/di/ServiceRegistration.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { CoreConfig } from "../config";
import { Container } from "./Container";
export declare class ServiceRegistration {
static registerServices(container: Container, config: CoreConfig): void;
}
2 changes: 2 additions & 0 deletions dist/core/di/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./Container";
export * from "./ServiceRegistration";
16 changes: 16 additions & 0 deletions dist/core/formatters/BaseFormattingRule.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { CoreConfig } from "../config";
import { Container } from "../di";
import { IFormattingRule } from "./IFormattingRule";
export declare abstract class BaseFormattingRule implements IFormattingRule {
protected readonly container: Container;
protected readonly config: CoreConfig;
abstract readonly name: string;
constructor(container: Container, config?: CoreConfig);
abstract apply(source: string, filePath?: string): string;
protected getConfig(): CoreConfig;
protected getCodeStyleConfig(): import("../config").CodeStyleConfig | undefined;
protected getImportsConfig(): import("../config").ImportConfig | undefined;
protected getIndexGenerationConfig(): import("./rules").IndexGenerationConfig | undefined;
protected getSortingConfig(): import("../config").SortingConfig | undefined;
protected getSpacingConfig(): import("../config").SpacingConfig | undefined;
}
4 changes: 4 additions & 0 deletions dist/core/formatters/IFormattingRule.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface IFormattingRule {
readonly name: string;
apply(source: string, filePath?: string): string;
}
3 changes: 3 additions & 0 deletions dist/core/formatters/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./BaseFormattingRule";
export * from "./IFormattingRule";
export * from "./rules";
34 changes: 34 additions & 0 deletions dist/core/formatters/rules/ast/ClassMemberSortingRule.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import * as ts from "typescript";
import { BaseFormattingRule } from "../../BaseFormattingRule";
export declare enum MemberType {
StaticProperty = "static_property",
InstanceProperty = "instance_property",
Constructor = "constructor",
StaticMethod = "static_method",
InstanceMethod = "instance_method",
GetAccessor = "get_accessor",
SetAccessor = "set_accessor"
}
export interface ClassMember {
node: ts.ClassElement;
type: MemberType;
name: string;
isPublic: boolean;
isProtected: boolean;
isPrivate: boolean;
isStatic: boolean;
hasDecorator: boolean;
text: string;
dependencies?: Set<string>;
originalIndex?: number;
}
export declare const DEFAULT_CLASS_ORDER: MemberType[];
export declare class ClassMemberSortingRule extends BaseFormattingRule {
readonly name = "ClassMemberSortingRule";
private getMemberType;
private analyzeClassMember;
private createSourceFile;
private compareMembers;
private sortClassMembers;
apply(source: string, filePath?: string): string;
}
Loading