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

[schematics/angular] Use module resolution for codelyzer in tslint.json #13100

Closed
toupeira opened this issue Nov 30, 2018 · 5 comments · Fixed by #13101
Closed

[schematics/angular] Use module resolution for codelyzer in tslint.json #13100

toupeira opened this issue Nov 30, 2018 · 5 comments · Fixed by #13101

Comments

@toupeira
Copy link

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [x] feature request

Command (mark with an x)

- [x] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Versions

$node --version
v8.13.0
$ npm --version
6.4.1
$ ng --version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 7.0.3
Node: 8.13.0
OS: linux x64
Angular: 7.0.1
... animations, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic, router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.10.3
@angular-devkit/build-angular      0.10.3
@angular-devkit/build-ng-packagr   0.10.4
@angular-devkit/build-optimizer    0.10.3
@angular-devkit/build-webpack      0.10.3
@angular-devkit/core               7.0.3
@angular-devkit/schematics         7.0.3
@angular/cli                       7.0.3
@ngtools/json-schema               1.1.0
@ngtools/webpack                   7.0.3
@schematics/angular                7.0.3
@schematics/update                 0.10.3
ng-packagr                         4.4.0
rxjs                               6.3.3
typescript                         3.1.3
webpack                            4.19.1

Repro steps

I'd like to extend my tslint.json with the defaults from Angular's schematics, using this syntax:

{
  "extends": "@schematics/angular/workspace/files/tslint.json"
}

The log given by the failure

ng lint and tslint -p . both fail with this error:

Failed to load [...]/tslint.json: Could not find custom rule directory: node_modules/codelyzer

The problem seems to be that relative paths in rulesDirectory are resolved from the location of the extended tslint.json inside node_modules/, rather than the tslint.json in my project's root.

Desired functionality

The tslint.json template in @schematics/angular should just use module resolution ("rulesDirectory": ["codelyzer"]), this seems to work here without any issues.

@alan-agius4
Copy link
Collaborator

Hi, thanks for reporting this, but this issue is not caused by Angular CLI.

extends In general always uses relative paths. What you are requesting is not supported by tslint. The feature request should be opened in their issue tracker.

Thanks.

@toupeira
Copy link
Author

@alan-agius4 that's not true, tslint does support module resolution:

This value is handled using node module resolution semantics. For example, a value of "tslint-config" would tell TSLint to try and load the main file of a module named “tslint-config” as a configuration file. Specific files inside node modules can also be specified, eg. "tslint-config/path/to/submodule". Relative paths to JSON files or JS modules are also supported, e.g. "./tslint-config".

And as I mentioned in the original issue, I tested this and it works :)

@alan-agius4
Copy link
Collaborator

alan-agius4 commented Nov 30, 2018

HI, you are right.

Sorry about, re-opening.

That said it is important to highlight that deep linking to our tslint.json is not something that we support and might break in the future.

@toupeira
Copy link
Author

@alan-agius4 thanks! 👍

That said it is important to highlight that deep linking to our tslint.json is not something that we support and might break in the future.

Sure, that's fine by me since tslint will error out when an extended file can't be found.

But generally, wouldn't it be better if ng new just generated a minimal tslint.json which extends the configuration from one of the Angular packages? Sounds more maintainable to me ;-)

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants