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

tslint-config-prettier-check relative path on Windows #341

Open
PMExtra opened this issue Aug 7, 2019 · 3 comments
Open

tslint-config-prettier-check relative path on Windows #341

PMExtra opened this issue Aug 7, 2019 · 3 comments

Comments

@PMExtra
Copy link

PMExtra commented Aug 7, 2019

I just test it on Windows, but I think it may also occurs on other platform (Edited: It's because windows path separator \, so it won't occurs on other platform).

>.\node_modules\.bin\tslint-config-prettier-check tslint.json
Invalid "extends" configuration value - could not require "tslint.json". Review the Node lookup algorithm (https://nodejs.org/api/modules.html#modules_all_together) for the approximate method TSLint uses to find the referenced configuration file.        

>.\node_modules\.bin\tslint-config-prettier-check .\tslint.json
Invalid "extends" configuration value - could not require ".\tslint.json". Review the Node lookup algorithm (https://nodejs.org/api/modules.html#modules_all_together) for the approximate method TSLint uses to find the referenced configuration file.      

>.\node_modules\.bin\tslint-config-prettier-check %cd%\tslint.json
(no output, it works)

>.\node_modules\.bin\tslint-config-prettier-check ..\..\..\tslint.json
(no output, it works)

%cd% is equivalent to UNIX $(pwd) for Windows.

It seems because the check command calculate the relative path based node_modules/... instead the current work directory of shell.

@ikatyang
Copy link
Member

ikatyang commented Aug 7, 2019

Ref: https://github.com/palantir/tslint/blob/5.18.0/src/configuration.ts#L236-L245

We simply call loadConfigurationFromPath from TSLint to load configs, which uses the Node module resolution to find it. Since it uses Node resolution, you should pass ./tslint.json instead of .\tslint.json.

This does not look like a bug but something we could improve, PRs welcome.

@PMExtra
Copy link
Author

PMExtra commented Aug 7, 2019

@ikatyang Great! So it's only a trouble for Windows users.
It's awesome if we can simply replace the '' with '/' on Windows. I'm not familiar with this project. I think maybe you could add below code in place.

if (process.platform === "win32") {
  path = path.replace(/\\/g, '/')
}

@PMExtra
Copy link
Author

PMExtra commented Aug 7, 2019

I have checked.

> tslint-config-prettier-check ./tslint.json

> tslint-config-prettier-check C:/path/to/project/tslint.json

They are all works. So we can replace all the \ with / on Windows at ease.

@PMExtra PMExtra changed the title BUG: tslint-config-prettier-check relative path tslint-config-prettier-check relative path on Windows Aug 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants