本文整理匯總了TypeScript中polymer-analyzer.makeParseLoader函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript makeParseLoader函數的具體用法?TypeScript makeParseLoader怎麽用?TypeScript makeParseLoader使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了makeParseLoader函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: test
test('applies automatic-safe fixes', async() => {
const warnings = await linter.lint([`${ruleId}/before-fixes.html`]);
const edits = warnings.filter((w) => w.fix).map((w) => w.fix!);
const loader = makeParseLoader(analyzer, warnings.analysis);
const result = await applyEdits(edits, loader);
assert.deepEqual(
result.editedFiles.get(`${ruleId}/before-fixes.html`),
(await loader(`${ruleId}/after-fixes.html`)).contents);
});
示例2: assertFileChanges
async function assertFileChanges(inputFile: string, outputFile: string) {
const warnings = await linter.lint([inputFile]);
const edits = warnings.filter((w) => w.fix).map((w) => w.fix!);
const loader = makeParseLoader(analyzer);
const result = await applyEdits(edits, loader);
const inputFileContent = result.editedFiles.get(inputFile)
const outputFileContent = (await loader(outputFile)).contents;
assert.deepEqual(inputFileContent, outputFileContent);
}
示例3: test
test('adds missing import by inferring the base path', async() => {
const warnings =
await linter.lint([`${ruleId}/forgot-import-before-fixes.html`]);
const edits = warnings.filter((w) => w.fix).map((w) => w.fix!);
const loader = makeParseLoader(analyzer, warnings.analysis);
const result = await applyEdits(edits, loader);
assert.deepEqual(
result.editedFiles.get(`${ruleId}/forgot-import-before-fixes.html`),
(await loader(`${ruleId}/forgot-import-after-fixes.html`)).contents);
});
示例4: assertExpectedFixes
export async function assertExpectedFixes(
linter: Linter, analyzer: Analyzer, inputFile: string, goldenFile: string) {
const {warnings} = await linter.lint([inputFile]);
const edits = warnings.filter((w) => w.fix).map((w) => w.fix!);
const loader = makeParseLoader(analyzer);
const {editedFiles, incompatibleEdits} = await applyEdits(edits, loader);
assert.deepEqual(incompatibleEdits, []);
const inputFileContent = editedFiles.get(analyzer.resolveUrl(inputFile)!);
const outputFileContent =
(await loader(analyzer.resolveUrl(goldenFile)!)).contents;
assert.deepEqual(inputFileContent, outputFileContent);
}
示例5: test
test('applies automatic-safe fixes', async() => {
const warnings = await linter.lint(
['deprecated-css-custom-property-syntax/before-fixes.html']);
const edits = warnings.filter((w) => w.fix).map((w) => w.fix!);
const loader = makeParseLoader(analyzer, warnings.analysis);
const result = await applyEdits(edits, loader);
assert.deepEqual(
result.editedFiles.get(
'deprecated-css-custom-property-syntax/before-fixes.html'),
(await loader('deprecated-css-custom-property-syntax/after-fixes.html'))
.contents);
assert.deepEqual(result.incompatibleEdits, []);
});
示例6: test
test('applies fixes and edit actions', async () => {
const {warnings, analysis} =
await linter.lint([`${ruleId}/before-fixes.html`]);
const edits = [];
for (const warning of warnings) {
if (warning.fix) {
edits.push(warning.fix);
}
for (const action of warning.actions || []) {
if (action.kind === 'edit') {
edits.push(action.edit);
}
}
}
const loader = makeParseLoader(analyzer, analysis);
const result = await applyEdits(edits, loader);
await assertFileEdited(
analyzer,
result,
`${ruleId}/before-fixes.html`,
`${ruleId}/after-edits.html`);
});