本文整理匯總了TypeScript中prettier.resolveConfig類的典型用法代碼示例。如果您正苦於以下問題:TypeScript resolveConfig類的具體用法?TypeScript resolveConfig怎麽用?TypeScript resolveConfig使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了resolveConfig類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: minimatch
filesToCheck.forEach(filePath => {
const matchesPattern = minimatch(filePath, prettierPattern, {
matchBase: true,
})
if (!matchesPattern) return
const fileInfo = getFileInfo.sync(filePath)
if (fileInfo.ignored) return
if (!fileInfo.inferredParser) return
const source = readFileSync(filePath, 'utf8')
const config = resolveConfig.sync(filePath)
const options = { ...config, parser: fileInfo.inferredParser }
if (!check(source, options)) {
fail(`${filePath} is not formatted using Prettier.`)
prettierFailed = true
}
})
示例2: Error
});
if (prettier.getFileInfo.sync('./tsconfig.json').inferredParser !== 'json') {
throw new Error('Bad parser');
}
prettier.getFileInfo('./tsconfig.json').then(result => {
if (result.inferredParser !== 'json') {
throw new Error('Bad parser');
}
});
// $ExpectError
prettier.resolveConfig();
const options = prettier.resolveConfig.sync('path/to/somewhere');
if (options !== null) {
const formatted = prettier.format('hello world', options);
}
prettier.clearConfigCache();
const currentSupportInfo = prettier.getSupportInfo();
const specificSupportInfo = prettier.getSupportInfo('1.8.0');
prettierStandalone.formatWithCursor(' 1', { cursorOffset: 2, parser: 'babel' });
prettierStandalone.format(' 1', { parser: 'babel' });
prettierStandalone.check(' console.log(b)');
typescriptParser.parsers.typescript.parse; // $ExpectType (text: string, parsers: { [parserName: string]: Parser; }, options: ParserOptions) => any