Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

No-relative-imports - allow-siblings flag not working #778

Closed
robgraeber opened this issue Jan 8, 2019 · 4 comments
Closed

No-relative-imports - allow-siblings flag not working #778

robgraeber opened this issue Jan 8, 2019 · 4 comments
Labels
External Issues that should be addressed in other repositories. Type: Bug
Milestone

Comments

@robgraeber
Copy link

Bug Report

  • tslint-microsoft-contrib: 6.0.0
  • TSLint version: 5.12.0
  • TypeScript version: 3.2.2
  • Running TSLint via: CLI + VSCode

TypeScript code being linted

import { chunkArray } from './Utils';

chunkArray([1, 2, 3], 1);

with tslint.json configuration:

"no-relative-imports": [true, "allow-siblings"],

Actual behavior

It's throwing an error for no-relative-imports.

Expected behavior

It would respect the "allow-siblings" flag and not be an error.

The weird thing about this is that it seemed to work correctly for me for a day, then the next day it stopped respecting the allow-siblings flag. I verified my node_modules were up to date. This is a very stripped down version of my project that seems to have the issue, run npm install && npm test and I get:
ERROR: /Users/bobby/Code/test-proj/src/Example.ts:1:1 - Imported module is being loaded from a relative path. Please use an absolute path: import { chunkArray } from './Utils';

test-proj.zip

@IllusionMH
Copy link
Contributor

@robgraeber thank you for raising issue. I will take a look on it.

@robgraeber
Copy link
Author

@IllusionMH now that I think about it, it could be an issue with tslint-config-airbnb since they're still on 5.2.1.

@robgraeber
Copy link
Author

I think tslint-config-airbnb was the culprit, apologies for the false alarm.

@JoshuaKGoldberg JoshuaKGoldberg added the External Issues that should be addressed in other repositories. label Jan 8, 2019
@IllusionMH IllusionMH added this to the 6.1.0-beta milestone Feb 19, 2019
@IllusionMH IllusionMH modified the milestones: 6.1.0-beta, None Mar 4, 2019
@tristan-mastrodicasa
Copy link

tristan-mastrodicasa commented Sep 18, 2019

Temporary Fix
If you want to use the allow-siblings flag right now with tslint-config-airbnb you can do what I did below

tslint.override.json
{ "rulesDirectory": ["node_modules/tslint-microsoft-contrib"], "rules": { "no-relative-imports": [true, "allow-siblings"] } }

tslint.json
{ "extends": ["./tslint.override.json", "tslint-config-airbnb"], "rules": { ... } }

Make sure the override is before the tslint-config-airbnb

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
External Issues that should be addressed in other repositories. Type: Bug
Projects
None yet
Development

No branches or pull requests

4 participants