template-lint icon indicating copy to clipboard operation
template-lint copied to clipboard

Support baseURL compiler option

Open RomkeVdMeulen opened this issue 8 years ago • 4 comments

resolution:

original:

Not very common, but sometimes I have something like: src/components/my-widget.ts:

import {Toggle} from "src/components/toggle";

export class MyWidget extends Toggle {
  myProp = "Lorem Ipsum";
}

src/components/toggle.ts:

export class Toggle {
  toggled = false;

  toggle() {
    this.toggled = !this.toggled;
  }
}

src/components/my-widget.html:

<template>
  <button click.trigger="toggle()">Toggle me</button>
  <p if.bind="toggled">${myProp}</p>
</template>

In which case the linter should not report WARNING: cannot find 'toggle' in type 'MyWidget' Ln 2 Col 3 my-widget.html or WARNING: cannot find 'toggled' in type 'MyWidget' Ln 3 Col 3 my-widget.html.

RomkeVdMeulen avatar Feb 17 '17 09:02 RomkeVdMeulen

Its possible your import statement is the problem as inheritance should be supported: https://github.com/MeirionHughes/aurelia-template-lint/commit/7f941b9f05b8b3dd458d98f20594f11342883dc5

MeirionHughes avatar Feb 17 '17 11:02 MeirionHughes

That could be it: I'm not importing with a relative path. I have updated my original post to show how I import Toggle.

RomkeVdMeulen avatar Feb 17 '17 11:02 RomkeVdMeulen

Yes, that's it. I think you'll need to use relative paths. Unless I'm mistaken "src/components/toggle" means /components/toggle from within src module. If this is what you're trying doing then support for modules at the moment is done via setting the typings path - not tested with node_modules/@types though.

MeirionHughes avatar Feb 17 '17 12:02 MeirionHughes

Using relative paths isn't a good option for my project. src isn't an external module in my case, it refers to code under the src dir in my codebase. I'm using the TypeScript baseURL compiler option to make this work.

In this case the module path I'm importing from matches what I passed to reflectionOpts.sourceFileGlob. Which is:

config.reflectionOpts.sourceFileGlob = "src/**/*.ts";

I can understand that following complex module resolution logic is a bit out of scope for a template linter. But perhaps it might be a useful feature to try to resolve non-relative imports that match the sourceFileGlob?

RomkeVdMeulen avatar Feb 17 '17 14:02 RomkeVdMeulen