Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle import aliases #445

Merged
merged 3 commits into from
Jul 23, 2024
Merged

fix: handle import aliases #445

merged 3 commits into from
Jul 23, 2024

Conversation

cristiand391
Copy link
Member

@cristiand391 cristiand391 commented Jul 23, 2024

Fixes: #444

This PR updates the extendsSfCommand util to account SfCommand being imported with an alias.

Before

commands extending SfCommand directly but using import aliases would get a warn from the new rules:
Screenshot 2024-07-23 at 3 31 45 PM

After:

rules are aware of how SfCommand is imported.

@W-16300123@

@cristiand391 cristiand391 marked this pull request as ready for review July 23, 2024 18:18
@@ -95,10 +95,12 @@ module.exports = {
| [no-unnecessary-aliases](docs/rules/no-unnecessary-aliases.md) | Mark when an alias is unnecessary because its only an order permutation, not really a different name | ✈️ ✅ | | | 🔧 | |
| [no-unnecessary-properties](docs/rules/no-unnecessary-properties.md) | Boolean properties are false by default, so they should not be set to false | | ✈️ ✅ | | 🔧 | |
| [no-username-properties](docs/rules/no-username-properties.md) | Convert requiresUsername and supportusername to username flags | ✈️ | | | 🔧 | |
| [only-extend-SfCommand](docs/rules/only-extend-SfCommand.md) | Only allow commands that directly extend SfCommand | | ✈️ ✅ | | | |
Copy link
Member Author

@cristiand391 cristiand391 Jul 23, 2024

Choose a reason for hiding this comment

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

these are from Willie's PR

}
}

return node.superClass?.type === AST_NODE_TYPES.Identifier && (importedClasses.get(node.superClass.name) == 'SfCommand');
Copy link
Member Author

Choose a reason for hiding this comment

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

this file contains the most relevant changes, the rest were tests/changes required due to changed funcs signatures.

// Handle import aliases
else if (specifier.type === 'ImportSpecifier' && specifier.local.name !== specifier.imported.name) {
importedClasses.set(specifier.local.name, specifier.imported.name);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

@mshanemc mshanemc merged commit d89b38f into main Jul 23, 2024
44 checks passed
@mshanemc mshanemc deleted the cd/handle-import-aliases branch July 23, 2024 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lint rules don't cover import aliases
2 participants