-
-
Notifications
You must be signed in to change notification settings - Fork 939
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
infra(unicorn): prefer-string-slice #2814
Conversation
✅ Deploy Preview for fakerjs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## next #2814 +/- ##
==========================================
- Coverage 99.96% 99.96% -0.01%
==========================================
Files 2977 2977
Lines 215422 215424 +2
Branches 950 952 +2
==========================================
- Hits 215351 215342 -9
- Misses 71 82 +11
|
Please pay extra attention when reviewing the files changed by f48dfe4 because I had to convert them by hand and I don't know why. |
From the docs:
Have to disagree on the |
I can also disable the rule permanently. |
While I have some doubts about the previously explained statement, this rule would at least unify the way string slicing would be performed in the project. This might be a DX improvement (for faker developers) in itself because one has not wondered why X is used in one place while Y is used in another. |
My personal rules:
Examples: - filePath.substring(pathLocales.length + 1, filePath.length - 3)
+ filePath.slice(pathLocales.length + 1, -3) this is a really good change, and I like it - fileContent.substring(0, compareIndex)
+ fileContent.slice(0, Math.max(0, compareIndex)) this is not so good, because it complexifies the code by using TBH I personally like use |
This only really makes sense if we manually go through cases like this and remove the ugly Math.max in places where we know compareIndex must be positive.
|
Ref: #2439
Enables the
unicorn/prefer-string-slice
lint rule.