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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update: Add exceptionPatterns to id-length rule (fixes #13094) #13576

Merged
merged 14 commits into from Aug 29, 2020

Conversation

sodaMelon
Copy link
Contributor

@sodaMelon sodaMelon commented Aug 17, 2020

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[X] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[x] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:

issue #113094

What changes did you make? (Give an overview)

I continued the PR #13099

to quote from #13099

I added an option named exceptionPatterns to id-length, which takes as value an array of the allowed patterns.
If the option is not defined it takes an empty array as default value.
Then I declared a boolean matchesExceptions that gets true if one of the patterns tests the name.
And added that boolean to the condition.


Based on comments in #13099, I modified some codes about it.

  • Unnecessary 'parserOption' was removed from id-length.js(test)

  • Two valid tests were added. They test with multiple exception patterns.

  • Two invalid tests were added, too. They test with an identifier that doesn't match configured pattern.
    (One tests tooLongError, another tests tooShrotError. )

  • To avoid creating new RegExp in "return value", I exatracted a function.

  • docs/rules/id-length.md was updated about exceptionPatterns

Is there anything you'd like reviewers to focus on?

I want know how these test-cases are suitable.
I thought them in my own way.........馃 but not sure.. 馃槀

@jsf-clabot
Copy link

jsf-clabot commented Aug 17, 2020

CLA assistant check
All committers have signed the CLA.

@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Aug 17, 2020
@yeonjuan
Copy link
Member

yeonjuan commented Aug 17, 2020

@sodaMelon Would you mind sign CLA ?

@sodaMelon
Copy link
Contributor Author

sodaMelon commented Aug 18, 2020

@sodaMelon Would you mind sign CLA ?

Ok, I did it now.

@yeonjuan yeonjuan added accepted There is consensus among the team that this change meets the criteria for inclusion enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules and removed triage An ESLint team member will look at this issue soon labels Aug 18, 2020
Copy link
Member

@yeonjuan yeonjuan 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 working on this 馃憤 I left some comments

lib/rules/id-length.js Outdated Show resolved Hide resolved
docs/rules/id-length.md Outdated Show resolved Hide resolved
@sodaMelon
Copy link
Contributor Author

I modified codes related with comments. Please check them whenever you have enough time.

Copy link
Member

@yeonjuan yeonjuan left a comment

Choose a reason for hiding this comment

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

LGTM!

lib/rules/id-length.js Outdated Show resolved Hide resolved
@sodaMelon
Copy link
Contributor Author

sodaMelon commented Aug 22, 2020

Modification is complete.
Please check this when you are not busy. 馃槑

Copy link
Member

@yeonjuan yeonjuan left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks :)

@mdjermanovic mdjermanovic linked an issue Aug 26, 2020 that may be closed by this pull request
Copy link
Member

@mdjermanovic mdjermanovic 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 working on this! Looks great, I have just a few small suggestions.

docs/rules/id-length.md Outdated Show resolved Hide resolved
lib/rules/id-length.js Outdated Show resolved Hide resolved
tests/lib/rules/id-length.js Outdated Show resolved Hide resolved
sodaMelon and others added 2 commits August 29, 2020 01:28
Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
@sodaMelon
Copy link
Contributor Author

sodaMelon commented Aug 28, 2020

I modified the function name to matchesExceptionPattern.
And I added a valid test that doesn't match with the first pattern. (that matches with the second.)

While making this test, I thought "Z*" of the test case from the above test not look good. So I changed it to "^Z".
(maybe it will be clearer!)

Thanks for your suggestions.馃憤鉂

Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

Copy link
Member

@kaicataldo kaicataldo left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for contributing!

@kaicataldo kaicataldo merged commit 96b11a0 into eslint:master Aug 29, 2020
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Mar 18, 2021
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Mar 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

id-length exceptions pattern
5 participants