Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

relative-url-prefix errors on any relative links that are not at the same depth #816

Open
benjamincharity opened this issue Apr 23, 2019 · 2 comments
Labels

Comments

@benjamincharity
Copy link

Describe the bug

When the rule relative-url-prefix is enabled it considers deep relative URLs to not be prefixed correctly.

// Codelyzer considers valid:
'./foo.ts'

// Codelyzer considers invalid:
'./../foo.ts'

While this seems like a bug to me since ./../foo.ts is a relative URL, this library is explicitly testing for this behavior so it may not be considered a bug by the maintainer(s). Reference:

it("should fail when a relative URL isn't prefixed by ./", () => {
const source = `
@Component({
styleUrls: ['./../foobar.css']
~~~~~~~~~~~~~~~~~
})
class Test {}
`;
assertAnnotated({
ruleName,
message: Rule.FAILURE_STRING,
source
});
});

Context and configuration

Please share:

  • Which rule is causing the problem
    • relative-url-prefix
  • What's the content of your tsconfig.json
    • see below
  • What's the content of ~/.codelyzer.js (if applicable)
    • n/a
TSConfig.json Contents
{
  "angularCompilerOptions": {
    "fullTemplateTypeCheck": true,
    "preserveWhitespaces": false
  },
  "compileOnSave": false,
  "compilerOptions": {
    "allowJs": true,
    "alwaysStrict": true,
    "baseUrl": "demo",
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "es2016",
      "es2015",
      "dom"
    ],
    "moduleResolution": "node",
    "noImplicitAny": false,
    "outDir": "./dist/out-tsc",
    "plugins": [
      {
        "name": "typescript-tslint-plugin"
      }
    ],
    "skipLibCheck": true,
    "sourceMap": true,
    "strict": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ]
  }
}

To Reproduce

Steps to reproduce the behavior.

Expected behavior

I would expect the following to raise the lint error:

'foo.ts'
'../foo.ts'
'@my/lib/foo.ts'

I would not expect the following to raise a lint error:

'./foo.ts'
'./../foo.ts'

Code

Share the code which will let us reproduce the problem

Examples above will reproduce the issue.

Environment

  • Version [e.g. 22] 5.0.0
  • OS: [e.g. iOS] 10.14.4
  • Node.js version 11.9.0
  • Package manager (yarn/npm) version yarn 1.15.2
  • Angular version 7.2.2
  • tslint version 5.14.0

Additional context

Add any other context about the problem here.

@rafaelss95
Copy link
Collaborator

cc @wKoza

@wKoza
Copy link
Collaborator

wKoza commented Nov 28, 2020

Hi,
It seems to be a bug. We only need to have a relative url. Whatever we do after that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants