Closed fsmaia closed 3 years ago
Currently, we are sending dummy.${extension} as the file path to import-sort.
dummy.${extension}
This may lead to bugs when an import-sort style relies on the filename for something, like in the following example:
export default (styleApi: IStyleAPI, file: string): IStyleItem[] => { const { isInstalledModule } = styleApi; console.log(isInstalledModule(file)); // should be the actual file instead of `dummy.${ext}` };
The file path is available in the prettier preprocess options:
preprocess(text, options) { console.log(options.filepath); }
Type reference took from: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/prettier/index.d.ts:
export interface ParserOptions<T = any> extends RequiredOptions { locStart: (node: T) => number; locEnd: (node: T) => number; originalText: string; } export interface RequiredOptions extends doc.printer.Options { //... /** * Specify the input filepath. This will be used to do parser inference. */ filepath: string;
Currently, we are sending
dummy.${extension}
as the file path to import-sort.This may lead to bugs when an import-sort style relies on the filename for something, like in the following example:
The file path is available in the prettier preprocess options:
Type reference took from: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/prettier/index.d.ts: