-
Notifications
You must be signed in to change notification settings - Fork 4
Multiple call to import #14
Multiple call to import #14
Conversation
0b3b1c0
to
5501400
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@carloslancha These changes are really nice! 👍
Just a few style nitpicks and I think it should be good to go.
src/config.ts
Outdated
@@ -7,29 +8,40 @@ const CONFIG_FILE_NAMES = [ | |||
'.soycriticrc.json', | |||
]; | |||
|
|||
type CallToImportConfig = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally, it's better to prefer interfaces over type alias for this kind of thing.
src/config.ts
Outdated
} | ||
|
||
if (!isRegex(config.callToImportReplace)) { | ||
throw new Error('callToImportReplace is not a valid replace string.'); | ||
for (let i=0; i < config.callToImport.length; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer for of
over c-style loops:
for (const item of config.callToImport) {
/* ... */
}
} | ||
]; | ||
|
||
console.log(chalk.yellow('CONFIG API HAS CHANGED, PLEASE UPDATE\n')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
src/validate-call-imports.ts
Outdated
.filter(name => { | ||
name = transform(name, config.callToImportRegex, config.callToImportReplace); | ||
return !importNames.find(importName => importName.includes(name)); | ||
for (let i=0; i < config.callToImport.length; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, try using a for of
instead.
Nice job, @carloslancha! /cc @mthadley, since he might not be aware of your latest changes! |
This resolves #13
This pr has two parts:
Btw, first time with Typescript so... be gentle 😛