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

no-submodule-imports: consider exact matches as whitelisted #3129

Merged
merged 2 commits into from Aug 17, 2017
Merged

no-submodule-imports: consider exact matches as whitelisted #3129

merged 2 commits into from Aug 17, 2017

Conversation

ajafff
Copy link
Contributor

@ajafff ajafff commented Aug 14, 2017

PR checklist

  • Addresses an existing issue: #0000
  • New feature, bugfix, or enhancement
    • Includes tests
  • Documentation update

Overview of change:

Today I wanted to use the new no-submodule-imports rule. I need to whitelist @angular/core/testing for example, but doing that will check if the import starts with @angular/core/testing/ (note the trailing slash).
This PR also tests for exact matches, allowing me to whitelist @angular/core/testing instead of @angular/core

Is there anything you'd like reviewers to focus on?

CHANGELOG.md entry:

[enhancement] no-submodule-imports allows whitelisting of submodules like @angular/core/testing

@@ -102,10 +99,6 @@ class NoSubmoduleImportsWalker extends Lint.AbstractWalker<string[]> {
}
}

function isAbsoluteOrRelativePath(path: string): boolean {
return /^(..?(\/|$)|\/)/.test(path);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one was actually wrong. it needed \. instead of just .
Anyways, we now use a typescript function which also check for C:\foo\bar as of typescript@2.5.0

Copy link
Contributor

@adidahiya adidahiya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, thanks

@adidahiya adidahiya merged commit 03c4886 into palantir:master Aug 17, 2017
@adidahiya adidahiya added this to the TSLint v5.7 milestone Aug 17, 2017
HyphnKnight pushed a commit to HyphnKnight/tslint that referenced this pull request Apr 9, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants