本文整理汇总了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`);
});