Skip to content
This repository was archived by the owner on Sep 6, 2018. It is now read-only.

Multiple call to import #14

Merged
merged 12 commits into from
Dec 26, 2017
Merged

Conversation

carloslancha
Copy link
Contributor

@carloslancha carloslancha commented Dec 22, 2017

This resolves #13

This pr has two parts:

  • Update the callToImport API to support multiple configs
  • Include the import specifiers into the importPaths to check to support named exports

Btw, first time with Typescript so... be gentle 😛

Copy link
Collaborator

@mthadley mthadley left a 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 = {
Copy link
Collaborator

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++) {
Copy link
Collaborator

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'));
Copy link
Collaborator

Choose a reason for hiding this comment

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

💯

.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++) {
Copy link
Collaborator

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.

@jbalsas
Copy link
Contributor

jbalsas commented Dec 26, 2017

Nice job, @carloslancha!

/cc @mthadley, since he might not be aware of your latest changes!

@mthadley mthadley merged commit d19b4d4 into deprecate:master Dec 26, 2017
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.

Multiple soyToImport configs
3 participants