當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript template-lint.Linter類代碼示例

本文整理匯總了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(); }
      });
  });
開發者ID:MeirionHughes,項目名稱:aurelia-template-lint,代碼行數:29,代碼來源:binding.spec.ts

示例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(); }
      })
  });
開發者ID:atsu85,項目名稱:aurelia-template-lint,代碼行數:32,代碼來源:binding.spec.ts

示例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();
       }
     });
 });
開發者ID:MeirionHughes,項目名稱:aurelia-template-lint,代碼行數:34,代碼來源:binding.spec.ts


注:本文中的template-lint.Linter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。