Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Accept whitelist for no-implicit-dependencies #3839

Closed
wata727 opened this issue Apr 17, 2018 · 5 comments
Closed

Accept whitelist for no-implicit-dependencies #3839

wata727 opened this issue Apr 17, 2018 · 5 comments

Comments

@wata727
Copy link

wata727 commented Apr 17, 2018

I would like to specify whitelists for no-implicit-dependencies because of webpack externals options.

TypeScript code being linted

import * as i18n from 'i18n-js' // Module 'i18n-js' is not listed as dependency in package.json

// ...

webpack.config.js:

module.exports = {
  // ...

  externals: {
    'i18n-js': 'I18n',
  },

  // ...
}

I guess this rule should accept whitelists as options. However, since the current option only accepts the type of dependencies, this is breaking change.
Is such a feature accepted?

@ghost
Copy link

ghost commented May 16, 2018

My use case is slightly different. Assume the following paths in the tsconfig.json:

"paths": {
    "@app/*": ["app/*"],
    "@config/*": ["app/_config/*"],
    "@environment/*": ["environments/*"],
    "@shared/*": ["app/_shared/*"],
    "@helpers/*": ["helpers/*"]
}

Although it won't be easy to parse the paths when linting I'd like to see the whitelist as a workaround which should be a lot easier to implement. no-submodule-imports has a similar whitelist that works for me. Here's hoping no-implicit-dependencies gets some love as well.

ajcrites added a commit to ajcrites/tslint that referenced this issue Jun 20, 2018
This allows you to specify a whitelist of modules that will not be part of package.json such as project-relative aliases
ajcrites added a commit to ajcrites/tslint that referenced this issue Jun 20, 2018
This allows you to specify a whitelist of modules that will not be part of package.json such as project-relative aliases
@suchanlee
Copy link
Contributor

i also find myself disabling no-implicit-dependencies when writing test code which imports from dev dependencies (e.g. enzyme)

ajcrites added a commit to ajcrites/tslint that referenced this issue Jun 28, 2018
Use Set for whitelist package name comparison instead of Array.
suchanlee pushed a commit that referenced this issue Jun 28, 2018
…3979)

* feature - no-implicit-dependencies - add whitelist (#3839)

This allows you to specify a whitelist of modules that will not be part of package.json such as project-relative aliases

* feature - no-implicit-dependencies - add whitelist (#3839)

Use Set for whitelist package name comparison instead of Array.
@ajcrites
Copy link
Contributor

The whitelist should fix this issue, however for @nearautomata it may still be a problem because the rule handles imports starting with @ differently: https://github.com/palantir/tslint/blob/master/src/rules/noImplicitDependenciesRule.ts#L115

@wata727
Copy link
Author

wata727 commented Jun 29, 2018

@ajcrites Thanks for your great works! I'm happy that this option has been added :)

pablobirukov pushed a commit to evolution-gaming/tslint that referenced this issue Jul 4, 2018
…r#3839) (palantir#3979)

* feature - no-implicit-dependencies - add whitelist (palantir#3839)

This allows you to specify a whitelist of modules that will not be part of package.json such as project-relative aliases

* feature - no-implicit-dependencies - add whitelist (palantir#3839)

Use Set for whitelist package name comparison instead of Array.
@johnwiseheart
Copy link
Contributor

I think the fix for this has been merged (and should be released shortly). Going to close this for now - feel free to reopen it if need be.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants