本文整理汇总了TypeScript中template-lint.Linter类的典型用法代码示例。如果您正苦于以下问题:TypeScript Linter类的具体用法?TypeScript Linter怎么用?TypeScript Linter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Linter类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it("supports delegate binding", (done) => {
let pageViewModel = `
export class Page {
value:number;
public submit() {
}
}`;
let pageView = `
<template>
\${value}
<form role="form" submit.delegate="submit()"></form>
<form role="form" submit.delegate="submt()"></form>
</template>`;
let reflection = new Reflection();
let rule = new BindingRule(reflection, new AureliaReflection(), { reportExceptions: true });
let linter = new Linter([rule]);
reflection.add("./page.ts", pageViewModel);
linter.lint(pageView, "./page.html")
.then((issues) => {
try {
expect(issues.length).toBe(1);
expect(issues[0].message).toBe("cannot find 'submt' in type 'Page'");
}
catch (err) { fail(err); }
finally { done(); }
});
});
示例2: it
it("supports getters", (done) => {
let item = `
export class Item{
value:string;
}`;
let viewmodel = `
import {Item} from './path/item
export class Foo{
get item(): Item {}
}`
let view = `
<template>
\${item}
\${item.value}
\${item.vale}
</template>`
let reflection = new Reflection();
let rule = new BindingRule(reflection);
let linter = new Linter([rule]);
reflection.add("./foo.ts", viewmodel);
reflection.add("./path/item", item);
linter.lint(view, "./foo.html")
.then((issues) => {
try {
expect(issues.length).toBe(1);
expect(issues[0].message).toBe("cannot find 'vale' in type 'Item'");
}
catch(err){fail(err);}
finally { done(); }
})
});
示例3: xit
xit("should detect invalid references", (done) => {
const viewmodel = `
export class Foo{
field1: number;
field2: number;
@computedFrom("field1", "missingField1", "field2", "missingField2")
get computedField(){
return this.field1 + this.field2;
}
}`;
const view = `
<template>
\${computedField}
</template>`;
const reflection = new Reflection();
const rule = new BindingRule(reflection, new AureliaReflection());
const linter = new Linter([rule]);
reflection.add("./foo.ts", viewmodel);
linter.lint(view, "./foo.html")
.then((issues) => {
try {
expect(issues.length).toBe(2);
expect(issues[0].message).toBe("cannot find 'missingField1' in type 'Foo'");
expect(issues[1].message).toBe("cannot find 'missingField2' in type 'Foo'");
}
catch (err) {
fail(err);
}
finally {
done();
}
});
});