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

[quality] Implement a custom tslint rule to check imports #467

Closed
akosyakov opened this issue Sep 7, 2017 · 10 comments
Closed

[quality] Implement a custom tslint rule to check imports #467

akosyakov opened this issue Sep 7, 2017 · 10 comments
Labels
help wanted issues meant to be picked up, require help quality issues related to code and application quality

Comments

@akosyakov
Copy link
Member

Because of hoisting, any package can access any dependency declared in another package. We should check that imports only access packages declared in package.json or transitive dependencies.

@akosyakov
Copy link
Member Author

An alternative is to move lerna root to another folder, but we've rejected it because of the not standard project setup: #423 (comment)

@hexa00
Copy link

hexa00 commented Sep 7, 2017

I'm wondering how that can be done ? but that would be good indeed.

@akosyakov
Copy link
Member Author

There is such check for ESlint: https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md

I wonder whether we can leverage eslint. It supports ES6 modules.
If we cannot we should implement custom tslint rule with https://palantir.github.io/tslint/develop/custom-rules/

@hexa00
Copy link

hexa00 commented Sep 7, 2017

OK thx for the pointers...
I have a feeling eslint may have a problem with our lerna hoisted dep stuff, but worth a try.

@svenefftinge
Copy link
Contributor

Currently, it is really painful for me, because vs code is creating all sorts of wrong imports and I don't see them through watch. So I always run yarn build to see if I have any issues. Would be cool to have vscode telling me that the imports are wrong.

@svenefftinge
Copy link
Contributor

palantir/tslint#3235

@akosyakov akosyakov added the quality issues related to code and application quality label Jan 29, 2018
@akosyakov akosyakov added the help wanted issues meant to be picked up, require help label Feb 6, 2018
@akosyakov
Copy link
Member Author

I wish someone start working on it, it is exhausting to catch them manually.

@benoitf
Copy link
Contributor

benoitf commented Feb 6, 2018

using option

"no-implicit-dependencies": [true, "dev"]

will report issues around test dependencies and import from the current module in tests

[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/browser/endpoint.spec.ts[8, 23]: Module 'chai' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/browser/endpoint.spec.ts[9, 26]: Module '@theia/core' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/browser/label-parser.spec.ts[10, 24]: Module 'chai' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/browser/label-provider.spec.ts[8, 24]: Module 'chai' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/browser/menu/browser-menu-plugin.ts[10, 60]: Module '@phosphor/commands' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/browser/saveable.ts[9, 25]: Module '@phosphor/messaging' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/browser/shell/application-shell.ts[9, 41]: Module '@phosphor/algorithm' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/browser/shell/application-shell.ts[10, 24]: Module '@phosphor/signaling' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/browser/shell/side-panel-handler.ts[9, 32]: Module '@phosphor/algorithm' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/browser/shell/tab-bars.ts[10, 35]: Module '@phosphor/virtualdom' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/browser/status-bar/status-bar.ts[10, 19]: Module '@phosphor/virtualdom' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/browser/storage-service.spec.ts[10, 24]: Module 'chai' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/browser/storage-service.spec.ts[13, 24]: Module 'sinon' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/browser/test/jsdom.ts[8, 23]: Module 'jsdom' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/browser/tree/tree-widget.ts[9, 25]: Module '@phosphor/messaging' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/browser/tree/tree-widget.ts[10, 28]: Module '@phosphor/domutils' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/browser/tree/tree-widget.ts[11, 53]: Module '@phosphor/virtualdom' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/browser/widget-manager.spec.ts[8, 24]: Module 'chai' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/browser/widget-manager.spec.ts[11, 24]: Module '@phosphor/signaling' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/browser/widgets/virtual-renderer.ts[8, 57]: Module '@phosphor/virtualdom' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/browser/widgets/virtual-widget.ts[9, 19]: Module '@phosphor/virtualdom' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/browser/widgets/widget.ts[10, 25]: Module '@phosphor/messaging' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/browser/widgets/widget.ts[17, 15]: Module '@phosphor/messaging' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/common/keybinding.spec.ts[22, 23]: Module 'chai' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/common/keybinding.spec.ts[23, 24]: Module 'sinon' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/common/logger.spec.ts[8, 24]: Module 'chai' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/common/menu.spec.ts[10, 8]: Module 'mocha' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/common/menu.spec.ts[11, 23]: Module 'chai' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/common/menu.spec.ts[12, 33]: Module 'chai-as-promised' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/common/messaging/connection-error-handler.ts[8, 25]: Module 'vscode-jsonrpc' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/common/messaging/handler.ts[8, 35]: Module 'vscode-jsonrpc' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/common/messaging/proxy-factory.spec.ts[8, 8]: Module 'mocha' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/common/messaging/proxy-factory.spec.ts[9, 23]: Module 'chai' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/common/messaging/proxy-factory.spec.ts[10, 33]: Module 'chai-as-promised' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/common/messaging/proxy-factory.spec.ts[13, 41]: Module 'vscode-jsonrpc' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/common/messaging/proxy-factory.ts[8, 50]: Module 'vscode-jsonrpc' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/common/selection-service.spec.ts[9, 8]: Module 'mocha' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/common/selection-service.spec.ts[10, 23]: Module 'chai' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/common/selection-service.spec.ts[11, 33]: Module 'chai-as-promised' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/common/uri.spec.ts[8, 23]: Module 'chai' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/node/backend-application.ts[17, 21]: Module 'fs-extra' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/node/cli.spec.ts[9, 23]: Module 'chai' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/node/cluster/worker-connection.ts[11, 68]: Module 'vscode-jsonrpc' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/node/file-uri.spec.ts[10, 23]: Module 'chai' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/node/messaging/connection.ts[13, 35]: Module 'vscode-jsonrpc' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/node/messaging/ipc-bootstrap.ts[10, 84]: Module 'vscode-jsonrpc' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/node/messaging/ipc-connection-provider.ts[11, 112]: Module 'vscode-jsonrpc' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/node/messaging/ipc-protocol.ts[9, 35]: Module 'vscode-jsonrpc' is not listed as dependency in package.json
[lint] ERROR: /Users/benoitf/Documents/git/theia/packages/core/src/node/messaging/logger.ts[8, 24]: Module 'vscode-jsonrpc' is not listed as dependency in package.json

@akosyakov akosyakov mentioned this issue Feb 8, 2018
6 tasks
@akosyakov
Copy link
Member Author

no-implicit-dependencies will force us to duplicate dependencies everywhere which is bad because then we should check that we use the same versions across of all packages. We need something like that but it should respect transitive dependencies and allow to exclude dev dependencies.

@kittaakos
Copy link
Contributor

no-implicit-dependencies

#3044

we should check that we use the same versions across of all packages

#2994

Can we close this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted issues meant to be picked up, require help quality issues related to code and application quality
Projects
None yet
Development

No branches or pull requests

5 participants