Skip to content
New issue

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

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

Already on GitHub? # to your account

feat: add support for import-alias-naming rule #881

Merged
merged 5 commits into from
Aug 28, 2023

Conversation

denisvmedia
Copy link
Collaborator

Closes #880.

@denisvmedia
Copy link
Collaborator Author

denisvmedia commented Aug 28, 2023

@chavacava I'm thinking of making it an array of rules instead of a single rule. This will let users submitting multiple regexes that will be combined as logical AND (so that every rule must match). What do you think?

upd: to be clear, the idea is clarity of the configuration. The first regex can be the main, positive, match. Other subsequent regexes may be used to imply negative matches. E.g. to exclude v1 the user will provide a negative match ^(?!v1$).*. However, it is possible to do in a single regex, the readability will suffer, I'm afraid.

Copy link
Collaborator

@chavacava chavacava left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I've left some comments.

rule/import-naming.go Outdated Show resolved Hide resolved
RULES_DESCRIPTIONS.md Outdated Show resolved Hide resolved
rule/import-naming.go Outdated Show resolved Hide resolved
rule/import-naming.go Outdated Show resolved Hide resolved
rule/import-naming.go Outdated Show resolved Hide resolved
@chavacava
Copy link
Collaborator

@chavacava I'm thinking of making it an array of rules instead of a single rule. This will let users submitting multiple regexes that will be combined as logical AND (so that every rule must match). What do you think?
upd: to be clear, the idea is clarity of the configuration. The first regex can be the main, positive, match. Other subsequent regexes may be used to imply negative matches. E.g. to exclude v1 the user will provide a negative match ^(?!v1$).*. However, it is possible to do in a single regex, the readability will suffer, I'm afraid.

I personally prefer a single argument. That way there is no need to explain (and understand) how multiple regex are combined (AND or OR?). Yes it can lead to a complex regex but... if you are playing with a regex you know what are you doing :)

@denisvmedia
Copy link
Collaborator Author

I personally prefer a single argument. That way there is no need to explain (and understand) how multiple regex are combined (AND or OR?). Yes it can lead to a complex regex but... if you are playing with a regex you know what are you doing :)

OK, let it be a single regex.

@chavacava chavacava changed the title feat: add support for import-naming rule feat: add support for import-alias-naming rule Aug 28, 2023
@chavacava chavacava merged commit f900b6c into mgechev:master Aug 28, 2023
@denisvmedia denisvmedia deleted the feature/import-naming-rule branch August 28, 2023 13:33
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Linter rule to check against import alias naming restrictions
2 participants