egs-cm / template-lint

Sanity check of Aurelia-flavor template HTML
Apache License 2.0
0 stars 0 forks source link

Skip unexported class when scanning for attributes #10

Closed egs-cm closed 1 year ago

egs-cm commented 1 year ago

If the first class in the view model file is not exported, it is scanned nevertheless. Unexported classes are not used as view models by Aurelia and should be skipped.

  it("will reject access in unexported class", (done) => {
    let viewmodel = `
    class Foo{
      invalid:string;
    }`;
    let view = `
    <template>
      <input type="text" value.bind="invalid">
    </template>`;
    let reflection = new Reflection();
    let rule = new BindingRule(reflection, new AureliaReflection());
    let linter = new Linter([rule]);
    reflection.add("./foo.ts", viewmodel);
    linter.lint(view, "./foo.html")
      .then((issues) => {
        expect(issues.length).toBe(1);
        expect(issues[0].message).toBe("cannot find 'invalid' in type 'Foo'");
        done();
      });
  });