-
Notifications
You must be signed in to change notification settings - Fork 516
chore(eslint): Add stricter ESLint rules for RegExp usage #805
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
base: master
Are you sure you want to change the base?
chore(eslint): Add stricter ESLint rules for RegExp usage #805
Conversation
|
@rogaldh is attempting to deploy a commit to the Solana Foundation Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Caution
Changes requested ❌
Reviewed everything up to f911236 in 4 minutes and 16 seconds. Click for details.
- Reviewed
606lines of code in47files - Skipped
1files when reviewing. - Skipped posting
41draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. .eslintrc.json:1
- Draft comment:
ESLint configuration now includes stricter RegExp rules and a custom plugin for ESLint comments. Ensure documentation and team guidelines explain when and how to disable these rules. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
2. app/api/metadata/proxy/feature/errors.ts:37
- Draft comment:
The regex pattern /over limit:/ in error.message.match is appropriately used to detect specific error cases. The inline disable is justified. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
3. app/api/metadata/proxy/feature/processors.ts:60
- Draft comment:
Normalization of line endings via text.trim().replace(/\r\n/g, '\n') is clear and well-commented with an inline disable. No changes required. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
4. app/components/SearchBar.tsx:351
- Draft comment:
The regex /^0\w/ is used to filter out hex or binary prefixed numbers before BigInt parsing. Ensure it does not mistakenly reject valid inputs. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
5. app/components/account/TokenAccountSection.tsx:57
- Draft comment:
The regex to extract an Ethereum address from a URL is justified with an inline disable comment. Ensure that the rationale for this pattern is documented. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
6. app/components/account/__tests__/TokenExtensionRow.spec.tsx:1
- Draft comment:
Test file disables no-restricted-syntax and no-restricted-globals for regex pattern matching. Ensure consistency with project guidelines. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
7. app/components/account/nftoken/isNFTokenAccount.ts:38
- Draft comment:
The replacement using .replace(/\0/g, '') to remove null bytes is clear and well-commented. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
8. app/components/common/__tests__/BaseInstructionCard.spec.tsx:1
- Draft comment:
Test file disables regex restrictions for assertions. Ensure tests cover edge cases along with regex usage. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
9. app/components/common/__tests__/VerifiedProgramBadge.spec.tsx:1
- Draft comment:
Tests for VerifiedProgramBadge properly mock hooks; consider adding tests for cases with missing metadata. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
10. app/components/common/stories/TokenExtensionBadge.stories.tsx:1
- Draft comment:
Storybook story for CustomToast is well-structured with play functions validating UI elements. Inline disable for regex is appropriately used. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
11. app/components/inspector/RawInputCard.tsx:68
- Draft comment:
The inline disable for regex used in splitting text is properly documented. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
12. app/components/inspector/__tests__/AccountsCard.spec.tsx:1
- Draft comment:
AccountsCard tests are clear; verify that deserialization mocks accurately simulate production data. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
13. app/components/inspector/__tests__/AssociatedTokenDetailsCard.spec.tsx:1
- Draft comment:
Tests for AssociatedTokenDetailsCard using intoParsedInstruction and intoParsedTransaction are thorough. Ensure stability when IDL schemas change. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
14. app/components/inspector/__tests__/InspectorPage-SystemProgram.spec.tsx:1
- Draft comment:
Tests for SystemProgram instructions effectively use waitForTimeout to handle asynchronous rendering. The helper function expectAllColumnsNotNull is a good approach. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
15. app/components/instruction/__tests__/TokenDetailsCard.spec.tsx:1
- Draft comment:
TokenDetailsCard tests cover Transfer and TransferChecked instructions. Ensure that transaction message mocks remain realistic. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
16. app/components/shared/ui/sonner/custom.stories.tsx:1
- Draft comment:
CustomToast Storybook stories validate various toast types and use play functions to ensure UI reliability. Ensure visual consistency. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
17. app/components/stories/SearchBar.stories.tsx:1
- Draft comment:
SearchBar stories verify mobile touch target sizes and functional input behavior. Input width and focus tests are well implemented. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
18. app/entities/idl/mocks/codama/simplified/minimalMock.ts:1
- Draft comment:
Mock data file minimalMock.ts disables ESLint as it's mock data. Ensure the mock conforms to the expected IDL format. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
19. app/entities/idl/mocks/codama/simplified/programMock1.ts:1
- Draft comment:
programMock1 contains comprehensive mock data including error codes. Verify that types and error messages remain consistent with production contracts. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
20. app/entities/idl/mocks/codama/simplified/programMock2.ts:1
- Draft comment:
programMock2 mock data includes detailed PDA configuration. Ensure that seeds and PDA derivation logic match on-chain specifications. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
21. app/entities/idl/mocks/codama/simplified/programMock3.ts:1
- Draft comment:
programMock3 contains complete mock data with version and instructions. Keep it aligned with any changes in the on-chain program. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
22. app/entities/idl/mocks/codama/simplified/programMock4.ts:1
- Draft comment:
programMock4 defines a larger structure with array fields. Ensure mock definitions remain comprehensive and in sync with production data. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
23. app/entities/idl/model/converters/type-handlers/leaf-tuple-type-handler.spec.ts:1
- Draft comment:
Tests cover multiple edge cases for parsing leaf tuples with arrays. The error messages and expects ensure robust parser implementation. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
24. app/entities/idl/model/interactive-idl.ts:8
- Draft comment:
The function isInteractiveIdlSupported performs semantic version checking clearly. Consider adding tests for borderline version strings. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
25. app/entities/instruction-card/ui/stories/ProgramField.stories.tsx:1
- Draft comment:
ProgramField story validates standard and extended information for system and token programs; the use of decorators is well structured. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
26. app/feature-gates/page-client.tsx:14
- Draft comment:
FeatureGatesPageClient correctly maps feature activation epochs by cluster. Verify that filtering logic distinguishes features appropriately based on activation epochs. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
27. app/features/idl/interactive-idl/model/account-autocomplete/const.ts:32
- Draft comment:
Helper functions stripProgramSuffix, stripSysvarPrefix, and stripPrecompileSuffix are clearly documented with inline disables. The recordToAutocompleteItems function is reusable and clear. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
28. app/features/idl/interactive-idl/ui/ArgumentInput.tsx:44
- Draft comment:
ArgumentInput component delegates to SingleArgumentInput or ArrayArgumentInput based on arg type. Inline disables for regex are justified; consider adding tests for multiple input scenarios. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
29. app/entities/idl/ui/__tests__/IdlCard.spec.tsx:1
- Draft comment:
IdlCard tests properly mock next/navigation and differentiate between Anchor and Program Metadata IDLs, ensuring correct tab rendering. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
30. app/features/security-txt/ui/__tests__/SecurityCard.spec.tsx:1
- Draft comment:
SecurityCard tests verify error messaging when Security.txt is missing or absent. The use of helper functions to mock account data is effective. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
31. app/features/security-txt/ui/__tests__/SecurityTXTBadge.spec.tsx:1
- Draft comment:
SecurityTXTBadge tests cover various states (error, included, etc.) and effectively use mocked hooks. Ensure all security.txt cases are handled. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
32. app/features/token-extensions/use-token-extension-navigation.ts:29
- Draft comment:
The useTokenExtensionNavigation hook correctly constructs navigation URIs and sanitizes components. Confirm that using globalThis does not break SSR. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
33. app/features/verified-programs/__tests__/api.spec.ts:1
- Draft comment:
The fetchProgramsPage tests are comprehensive, covering successful responses, partial metadata, and error handling including network failures. Good use of mocked fetch and Logger calls. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
34. app/providers/accounts/index.tsx:1
- Draft comment:
AccountsProvider and related context setup are clear. Consider adding more type-level tests around account parsing and error handling for edge cases. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
35. app/providers/scroll-anchor.tsx:1
- Draft comment:
ScrollAnchorProvider implements dynamic scrolling efficiently using WeakRef, with fallback for unsupported environments. Verify behavior across browsers. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
36. app/shared/lib/triggerDownload.ts:1
- Draft comment:
The triggerDownload function validates and decodes base64 data securely, preventing DoS via large files. The inline comments regarding MIME type handling are informative. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
37. app/utils/anchor.tsx:1
- Draft comment:
The anchor utility functions correctly decode events and instructions, including handling custom short discriminators. Ensure test coverage for new IDL versions. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
38. bench/BUILD.md:1
- Draft comment:
The build information table reflects updated sizes in many routes. Verify that these metrics match current build performance post-optimizations. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
39. package.json:1
- Draft comment:
The package.json explicitly pins dependency versions and includes thorough scripts. Confirm that React version "18.3.1" is intentional and consider regular vulnerability audits. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
40. .eslintrc.json:22
- Draft comment:
Typo: Change "explaint" to "explain". - Reason this comment was not posted:
Marked as duplicate.
41. app/components/SearchBar.tsx:353
- Draft comment:
Typographical suggestion: Consider changing "eg" to "e.g." for clarity and standard abbreviation formatting. - Reason this comment was not posted:
Comment was on unchanged code.
Workflow ID: wflow_yi5blvf1neldq97P
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
Description
PR provides better config for RegExps usage.
It also adds reasoning for the current usage of RegExps.
Type of change
Screenshots
n/a
Testing
CI tests should pass
Related Issues
n/a
Checklist
build:infoscript to update build informationImportant
Introduce stricter ESLint rules for RegExp usage, requiring justification for its use and updating various files to comply with these rules.
@eslint-community/eslint-plugin-eslint-commentsto plugins in.eslintrc.json.no-restricted-globalsrule to restrictRegExp.no-restricted-syntaxrule to restrictLiteral[regex]andRegExpLiteralwith a message to justify usage.eslint-disable-next-line no-restricted-syntaxcomments inerrors.ts,processors.ts,SearchBar.tsx,TokenAccountSection.tsx,RawInputCard.tsx,isNFTokenAccount.ts, and 8 other files to justify RegExp usage.eslint-disablecomments inTokenExtensionRow.spec.tsx,BaseInstructionCard.spec.tsx,VerifiedProgramBadge.spec.tsx, and 10 other test files to allow RegExp usage for pattern matching.@eslint-community/eslint-plugin-eslint-commentstodevDependenciesinpackage.json.This description was created by
for f911236. You can customize this summary. It will automatically update as commits are pushed.