mirror of
https://github.com/github/codeql-action.git
synced 2025-12-28 02:00:12 +08:00
Co-authored-by: Andrew Eisenberg <aeisenberg@github.com> Co-authored-by: Henry Mercer <henrymercer@github.com>
62 lines
2.2 KiB
TypeScript
62 lines
2.2 KiB
TypeScript
import { Node } from './Node';
|
|
import { Options } from 'prettier';
|
|
/** Options for `toStringWithImports`, i.e. for the top-level, per-file output. */
|
|
export interface ToStringOpts {
|
|
/** The intended file name of this code; used to know whether we can skip import statements that would be from our own file. */
|
|
path?: string;
|
|
/** Modules to use a CommonJS-in-ESM destructure fix for. */
|
|
forceDefaultImport?: string[];
|
|
/** Modules to use a CommonJS-in-ESM destructure fix for. */
|
|
forceModuleImport?: string[];
|
|
/** A top-of-file prefix, i.e. eslint disable. */
|
|
prefix?: string;
|
|
/** Optional per-file overrides for the prettier config, i.e. to use longer-than-normal line lengths. */
|
|
prettierOverrides?: Options;
|
|
/** optional importMappings */
|
|
importMappings?: {
|
|
[key: string]: string;
|
|
};
|
|
}
|
|
export declare class Code extends Node {
|
|
private literals;
|
|
private placeholders;
|
|
trim: boolean;
|
|
private oneline;
|
|
constructor(literals: TemplateStringsArray, placeholders: any[]);
|
|
/**
|
|
* Returns the code with any necessary import statements prefixed.
|
|
*
|
|
* This method will also use any local `.prettierrc` settings, hence needs
|
|
* to return a `Promise<String>`.
|
|
*/
|
|
toStringWithImports(opts?: ToStringOpts): Promise<string>;
|
|
/**
|
|
* Returns the formatted code, without any imports.
|
|
*
|
|
* Note that we don't use `.prettierrc` b/c that requires async I/O to resolve.
|
|
*/
|
|
toString(): string;
|
|
asOneline(): Code;
|
|
get childNodes(): unknown[];
|
|
toCodeString(): string;
|
|
private deepFindImports;
|
|
private deepFindDefs;
|
|
private deepConditionalOutput;
|
|
private deepReplaceNamedImports;
|
|
private generateCode;
|
|
}
|
|
export declare function deepGenerate(object: unknown): string;
|
|
/**
|
|
* Represents a symbol defined in the current file.
|
|
*
|
|
* We use this to know if a symbol imported from a different file is going to
|
|
* have a namespace collision.
|
|
*/
|
|
export declare class Def extends Node {
|
|
symbol: string;
|
|
constructor(symbol: string);
|
|
toCodeString(): string;
|
|
/** Any potentially string/SymbolSpec/Code nested nodes within us. */
|
|
get childNodes(): Node[];
|
|
}
|