-
Notifications
You must be signed in to change notification settings - Fork 198
Add an importNameRule option to ignore npm modules #541
Comments
I might be way wrong here, but can't you just do, |
I tried it
` |
Hey @lonyele, thanks for posting this! Agreed that it would be nice to have an option for the rule to ignore npm modules. The // tslint.json
{
"rules": {
"import-name": [true, {
"styled-components": "styled"
}]
}
} You can try that kind of configuration until the option is added. Since the rule already takes in a general object as that mapping, maybe it should also be able to take a string // tslint.json
{
"rules": {
"import-name": [true, "ignore-modules"]
}
} As for your error message, that looks like a TypeScript complaint, not TSLint. Maybe it's this? https://stackoverflow.com/questions/32236163/when-to-use-import-as-foo-versus-import-foo |
@JoshuaKGoldberg It sounds nice. I have other things to do right now so I can't make a PR(Actually, I already saw the codebase, but I couldn't really understand all of it to make a useful PR) |
#569) * Make more arguments can be passed to options by using index flag and make more state for the later * Extract checking replacements logic to function for more checking for the later * Extract ignoredList from third argument * Make "isImportNameValid()" return true when ignoredList has moduleName that is currently in a validation process Add "es7" to "lib" at tsconfig.json for using Array.includes() with string[] type * Extra config from fourth argument * Ignore if isExternalLibraryImport flag is true from runtime node object * Add Tests that can be tested with "grunt all" - Need Help I want to write a test about ignoring node_moduels feature, but "node" object is only given at runtime. I don't know how to write a test of it. * for.. of doesn't support Map at es5 target. It just changes to for loop and silently doesn't go into for loop. I changed it to forEach. Now It's working. * 1. Remove "es7" from tsconfig 2. Without es7 support, Array.includes doesnt work. I changed it using filter function. (This is the reason why I added es7 support) I think Array.includes() is not that 'absolutely needed' I just removed it. * comment added? * comment for interfaces * Add optionExamples * Change optionsExamples --> naming of previous one can be confusing.
I've used "tslint-config-airbnb" and it uses this library. I think ImportNameRule can be useful when It checks users code, not npm installed module's code.
I recently tested with my new project setting and
import styled from "styled-components"
and got tslint warning "Misnamed import. Import should be named 'styledComponents' but found styled"I made this rule to be false, and it is all find. Just curious about this result
The text was updated successfully, but these errors were encountered: