relative-url-prefix errors on any relative links that are not at the same depth
- Dominant language
- TypeScript
- Stars
- 2.5k
- Forks
- 232
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
When the rule `relative-url-prefix` is enabled it considers deep relative URLs to **not** be prefixed correctly.
```TypeScript
// 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: https://github.com/mgechev/codelyzer/blob/f12f27b699187bbb443a0400ab678b8ec911eb26/test/relativeUrlPrefixRule.spec.ts#L48-L61
**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.
Contributor guide
Research direction
Start with test/relativeUrlPrefixRule.spec.ts, especially the cases around lines 48-61, and run that rule's tests to confirm the current behavior. Update the rule and its tests so ./../foo.ts is accepted while foo.ts and ../foo.ts still raise the lint error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100