-
Notifications
You must be signed in to change notification settings - Fork 887
global tslint throws error if extends
config option references local package
#1171
Comments
extends
config option is used with a locally installed package and absolute path to config fileextends
config option references local package
I expect this is because, when run globally, |
There is a workaround of using a relative or absolute path to the config file to extend, instead of a module ID. This obviously means you have to rely on the config file in the package not changing location in the package. |
This is known behavior and I had originally thought it was okay to have things work like this, but I'm glad you made this issue for discussion. This issue is pretty confusing behavior for end users, and changing it would be a big improvement. Perhaps the best solution here is to use a 3rd-party require/resolve library that lets you "start" from a different starting location? So modules could be resolved relative to the location of the config file and also as they are now. |
A package like resolve should do the job. I'm happy to create a pull request, if you're happy with this as a solution. |
Sure, a PR would be great! Thanks @janslow |
…files (#1172) * Add `resolve` dependency (and custom typings) * Use resolve instead of require in resolveConfigurationPaths Fixes #1171 * Simplify resolveConfigurationPath `resolve` can handle relative and absolute links. * path-is-absolute is no longer needed. * Install test packages in subdirectory, so they aren't in the scope of the main tslint binary * Run `npm install` in test config directory to install test packages. * Fix code style issue * Add dev dependency on npm for grunt run:installTestDeps task * Revert "Add dev dependency on npm for grunt run:installTestDeps task" This reverts commit fa0b947. * Replace run:installTestDeps task with npm-command:test * Fix lint errors in Gruntfile * Resolve config file relative to the cwd if it can't be found relative to the parent config * Make rules in tslint-test-custom-rules package valid rules (copied from noFailRule) * Add CLI test with a relative extend config * Add test config package And install it as a dev dependency * Add CLI test for extending a package which is installed in tslint. * Make test packages private * Fix entry point of test packages * Simplify non-relative test package * Add unit test for loadConfigurationFromPath with configs outside of the tslint require path.
…files (palantir#1172) * Add `resolve` dependency (and custom typings) * Use resolve instead of require in resolveConfigurationPaths Fixes palantir#1171 * Simplify resolveConfigurationPath `resolve` can handle relative and absolute links. * path-is-absolute is no longer needed. * Install test packages in subdirectory, so they aren't in the scope of the main tslint binary * Run `npm install` in test config directory to install test packages. * Fix code style issue * Add dev dependency on npm for grunt run:installTestDeps task * Revert "Add dev dependency on npm for grunt run:installTestDeps task" This reverts commit fa0b947. * Replace run:installTestDeps task with npm-command:test * Fix lint errors in Gruntfile * Resolve config file relative to the cwd if it can't be found relative to the parent config * Make rules in tslint-test-custom-rules package valid rules (copied from noFailRule) * Add CLI test with a relative extend config * Add test config package And install it as a dev dependency * Add CLI test for extending a package which is installed in tslint. * Make test packages private * Fix entry point of test packages * Simplify non-relative test package * Add unit test for loadConfigurationFromPath with configs outside of the tslint require path.
Bug Report
3.8.1
1.8.10
TypeScript code being linted
tslint.json
:(where
shared-tslint-config
is a locally installed NPM package providing a tslint config)Actual behavior
(when using a globally installed
tslint
)Expected behavior
tslint should resolve configuration file from locally installed package
shared-tslint-config
The text was updated successfully, but these errors were encountered: