-
Notifications
You must be signed in to change notification settings - Fork 49
Bun experiment #1418
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: dev
Are you sure you want to change the base?
Bun experiment #1418
Conversation
9bb7eb7
to
37de7f6
Compare
78cf43e
to
a296bb8
Compare
|
WalkthroughThe changes encompass updates to configuration files and package management within a TypeScript project. Key modifications include the expansion of ignored files and directories in ESLint and Prettier configurations, enhancements to the Hardhat configuration with new plugins, and adjustments to scripts and dependencies in the Changes
Sequence Diagram(s)sequenceDiagram
participant Developer
participant ESLint
participant Prettier
participant Hardhat
participant TypeScript
Developer->>ESLint: Run linting
ESLint->>Developer: Return linting results
Developer->>Prettier: Run formatting
Prettier->>Developer: Return formatting results
Developer->>Hardhat: Deploy contracts
Hardhat->>Developer: Confirm deployment
Developer->>TypeScript: Compile code
TypeScript->>Developer: Return compilation results
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
Outside diff range and nitpick comments (1)
eslint-config/.eslintrc.js (1)
54-54
: LGTM!Turning off the
@typescript-eslint/no-inferrable-types
rule allows for more flexibility in type declarations, especially in scenarios where explicit type annotations are preferred for clarity or consistency.Consider adding a comment to explain the rationale behind turning off this rule, as it may deviate from the default recommended settings. This can help maintain consistency and clarity for future contributors.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (2)
bun.lockb
is excluded by!**/bun.lockb
yarn.lock
is excluded by!**/yarn.lock
,!**/*.lock
Files selected for processing (8)
- contracts/.eslintignore (1 hunks)
- contracts/.prettierignore (1 hunks)
- contracts/hardhat.config.ts (1 hunks)
- contracts/package.json (3 hunks)
- eslint-config/.eslintrc.js (3 hunks)
- package.json (1 hunks)
- prettier-config/index.js (3 hunks)
- tsconfig/base.json (1 hunks)
Additional comments not posted (29)
contracts/.prettierignore (1)
1-23
: LGTM!The additions to the
.prettierignore
file are logically grouped and cover common directories and files that do not need to be formatted by Prettier. This will help streamline the development process by preventing unnecessary formatting checks on files that do not require it.The changes are unlikely to have any negative impact on the project.
contracts/.eslintignore (1)
1-23
: LGTM!The additions to the
.eslintignore
file are appropriate and align with common practices for TypeScript projects. Ignoring build artifacts, coverage reports, and lock files helps keep the linting process focused on the source code.tsconfig/base.json (6)
2-2
: LGTM!The comment provides useful context about the origin of the configuration.
6-8
: LGTM!Including the
es2020
library ensures that the TypeScript compiler recognizes the appropriate standard library features.
12-14
: LGTM!Including the
bun-types
ensures that the TypeScript compiler recognizes the Bun runtime environment types.
18-18
: LGTM!Enabling the
declarationMap
option allows for better debugging by mapping declarations back to their original source files.
24-24
: Verify the usage of decorators in the project.The
emitDecoratorMetadata
option is essential for projects using decorators. If the project is not using decorators, this option can be safely removed.Run the following script to search for decorator usage:
5-5
: Verify compatibility with the es2020 target.Ensure that the codebase does not use any features introduced after es2020, as they may not be supported with this target.
Run the following script to search for potential incompatible features:
Verification successful
Changing the target to ES2020 is consistent with existing configurations
The modification of the "target" to "es2020" in the base tsconfig.json file aligns with the existing configuration in the web project. The web/tsconfig.json already specifies "target": "es2020", and the project uses Parcel for building, which can handle modern JavaScript features and perform necessary transpilation.
While some ES2021 features (like the 'at()' method) were found in the web code, this is not a concern because:
- The web project has its own TypeScript configuration targeting ES2020.
- Parcel, the build tool used in the web project, can transpile newer features for browser compatibility.
This change in the base configuration actually improves consistency across the project.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Search for potential es2021 features in .ts files. # Test: Search for es2021 features. Expect: No occurrences of es2021 features. rg --type ts -e 'replaceAll|at\('Length of output: 3904
Script:
#!/bin/bash # Description: Search for additional ES2021 features and check for separate tsconfig files # Search for other ES2021 features echo "Searching for additional ES2021 features:" rg --type ts -e 'Promise\.any|AggregateError|WeakRef|FinalizationRegistry|Intl\.ListFormat|Intl\.Segmenter' # Check for separate tsconfig files echo -e "\nChecking for separate tsconfig files:" fd tsconfig.json # Look for build scripts echo -e "\nSearching for build scripts:" rg --type yaml -e 'build:|compile:' package.jsonLength of output: 501
Script:
#!/bin/bash # Description: Examine TypeScript configurations and build scripts # Check the contents of web/tsconfig.json echo "Contents of web/tsconfig.json:" cat web/tsconfig.json # Look for package.json in the web directory echo -e "\nContents of web/package.json (if exists):" cat web/package.json 2>/dev/null || echo "web/package.json not found" # Verify the contents of the base tsconfig.json echo -e "\nContents of tsconfig/base.json:" cat tsconfig/base.jsonLength of output: 6460
prettier-config/index.js (4)
4-4
: Trailing comma option updated to enforce consistency.The
trailingComma
option has been updated from"es5"
to"all"
, which will enforce trailing commas wherever possible in the codebase, including function parameters and calls. This change promotes consistency in code formatting across the project.Note that this may introduce trailing commas in places where they were not present before, so be prepared for a significant number of formatting changes in the codebase.
16-17
: Solidity formatting options updated for compatibility.The Prettier configuration for Solidity files (
.sol
) has been updated with two new options:
compiler: "0.8.18"
: This option specifies the Solidity compiler version to use for formatting Solidity files, ensuring compatibility with the latest features and syntax.
parser: "solidity-parse"
: This option specifies the parser to use for Solidity files, which is necessary for proper formatting.These changes will improve the formatting of Solidity files and maintain compatibility with the latest Solidity version.
26-35
: New override added for TypeScript files.A new override has been introduced for TypeScript files (
.ts
) with the following options:
parser: "typescript"
: This option specifies the parser to use for TypeScript files, ensuring proper formatting.
importOrder: ["<THIRD_PARTY_MODULES>", "^[./]"]
: This option defines the order in which import statements should be organized. Third-party modules will be placed first, followed by local imports.
importOrderParserPlugins: ["typescript"]
: This option specifies the parser plugins to use for organizing import statements in TypeScript files.
importOrderSeparation: true
: This option adds a separator between import groups, improving readability.
importOrderSortSpecifiers: true
: This option sorts the imported symbols within each import statement alphabetically.These options work together to maintain a structured and organized import statement format in TypeScript files, enhancing code readability and maintainability.
Line range hint
1-38
: Overall, the changes in this Prettier configuration file are excellent!The updates made to the Prettier configuration file are focused on improving formatting consistency and compatibility across different file types, including JSON, Solidity, and TypeScript. The changes include:
- Updating the
trailingComma
option to enforce consistency in code formatting.- Adding Solidity-specific options to ensure compatibility with the latest Solidity features and syntax.
- Introducing a new override for TypeScript files to maintain a structured and organized import statement format.
These changes will enhance the overall code quality and maintainability of the project. Great job!
eslint-config/.eslintrc.js (4)
2-7
: LGTM!Extending the ESLint configuration with recommended settings from various plugins is a good practice to enable a comprehensive set of linting rules for a TypeScript project.
10-10
: LGTM!Specifying the project configuration file in
parserOptions
is essential for TypeScript projects to enable type-checking and other features in ESLint. This ensures that ESLint can leverage TypeScript's type information for more accurate linting.
24-25
: LGTM!Simplifying the
varsIgnorePattern
andargsIgnorePattern
rules forno-unused-vars
to only ignore variables and arguments that start with an underscore is a good practice. This streamlines the linting process by reducing false positives for intentionally unused variables and arguments.
47-53
: LGTM!Introducing the
@typescript-eslint/no-floating-promises
rule to enforce handling of promises is a good practice. It helps prevent potential unhandled promise rejections and improves the overall reliability of the codebase. The rule options to ignore IIFE and void expressions allow for flexibility in certain scenarios where the promise handling is intentional.package.json (2)
Line range hint
17-23
: Verify the impact of removing thebots
andkleros-sdk
workspaces.The
"bots"
and"kleros-sdk"
entries have been removed from theworkspaces
array. This change suggests a potential restructuring or simplification of the project's workspace organization.Please ensure that the removal of these workspaces doesn't break any dependencies or workflows within the project. You can run the following script to check for any broken dependencies or workflows:
If there are no errors, then the removal of the
bots
andkleros-sdk
workspaces hasn't broken any dependencies or workflows.Verification successful
Removal of
bots
andkleros-sdk
workspaces appears to be safe.Based on the analysis of the codebase:
- No references to 'bots' or 'kleros-sdk' were found in .js, .ts, or .json files.
- No dependencies on 'bots' or 'kleros-sdk' were found in the package.json files of the remaining workspaces.
These findings suggest that the removal of these workspaces is unlikely to break any dependencies or workflows within the project. The change appears to be a safe simplification of the project's workspace organization.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Navigate to the root of the monorepo cd "$(git rev-parse --show-toplevel)" # Install dependencies yarn install # Check for any broken dependencies yarn workspaces info # Check for any broken imports yarn workspaces foreach -ptv run tsc --noEmitLength of output: 359
Script:
#!/bin/bash # Check if npm is available if command -v npm &> /dev/null; then echo "npm is available" npm list --depth=0 npm list --depth=1 bots kleros-sdk else echo "npm is not available" fi # Search for references to bots and kleros-sdk in the codebase echo "Searching for 'bots' references:" grep -R --include="*.js" --include="*.ts" --include="*.json" "bots" . echo "Searching for 'kleros-sdk' references:" grep -R --include="*.js" --include="*.ts" --include="*.json" "kleros-sdk" . # Inspect package.json files in other workspaces for dependencies echo "Checking dependencies in workspace package.json files:" find . -name "package.json" -not -path "*/node_modules/*" -exec sh -c 'echo "File: {}"; grep -E "\"(bots|kleros-sdk)\":" {}' \;Length of output: 876
33-34
: Verify compatibility of the updated commitlint packages.The
@commitlint/cli
and@commitlint/config-conventional
packages have been updated to version^18.4.2
. This update can bring bug fixes, performance improvements, and new features.Please ensure that the updated versions are compatible with the project's existing configuration and dependencies. You can run the following script to verify that the commitlint setup is working as expected:
If there are no errors, then the updated commitlint packages are compatible with the project.
contracts/package.json (7)
25-25
: Verify the testing process after simplifying thetest
script.The change simplifies the testing command by removing the
TS_NODE_TRANSPILE_ONLY=1
prefix, which can improve the developer experience.Please ensure that removing the prefix does not introduce any unintended consequences or break the testing process. Consider running the following verification steps:
- Execute the simplified
test
script and ensure that all tests pass successfully.- Verify that the TypeScript transpilation process during testing remains unaffected by the change.
- Confirm that the test coverage and results are consistent with the previous configuration.
If any issues arise during the verification process, please investigate and address them accordingly.
32-35
: Monitor theviem
generation process for relevant warnings.The change removes the
NODE_NO_WARNINGS=1
prefix from theviem
generation scripts, which may allow warnings to be displayed during the generation process.Please consider the following:
- Run the
viem
generation scripts and observe any warnings that are displayed.- Assess the relevance and impact of the warnings on the generated output and the development process.
- If any critical warnings are encountered, investigate and address them appropriately.
- Consider documenting any notable warnings and their implications in the project's documentation or release notes.
Monitoring the warnings during the
viem
generation process can provide valuable insights and help maintain the quality of the generated code.
39-39
: Verify the compatibility and functionality of theviem:test
script with the Bun runtime.The change updates the
viem:test
script to usebun run
instead ofNODE_OPTIONS=--experimental-fetch ts-node
, indicating a transition to the Bun runtime for executing the script.Please consider the following verification steps:
- Ensure that all required dependencies for the
viem:test
script are compatible with the Bun runtime.- Execute the
viem:test
script usingbun run
and verify that it runs successfully without any errors or compatibility issues.- Compare the execution time and performance of the script using the Bun runtime against the previous Node.js configuration to assess any improvements or regressions.
- Verify that the script's functionality and output remain consistent with the expected behavior.
If any compatibility issues or discrepancies are encountered during the verification process, please investigate and address them accordingly to ensure a smooth transition to the Bun runtime.
40-44
: Verify the execution of the bot scripts using the updatedhardhat run
command.The change updates the bot scripts to use
hardhat run
instead ofyarn hardhat run
, suggesting a shift from using Yarn to directly invoking Hardhat for running the scripts.Please consider the following verification steps:
- Ensure that all required dependencies and configurations are properly set up for running the bot scripts with Hardhat.
- Execute each bot script using the updated
hardhat run
command and verify that they run successfully without any errors or issues.- Compare the execution behavior and output of the bot scripts using the updated command against the previous Yarn-based configuration to ensure consistency.
- Verify that the bot scripts' functionality and interactions with the relevant networks and contracts remain unaffected by the change.
If any issues or discrepancies are encountered during the verification process, please investigate and address them accordingly to ensure a smooth transition to using
hardhat run
for executing the bot scripts.
71-71
: Verify the impact of downgrading the@types/node
package version.The change downgrades the
@types/node
package version from^20.11.3
to^18.0.0
, which may affect compatibility with certain Node.js features and APIs.Please consider the following verification steps:
- Review the project's codebase and identify any usage of Node.js features or APIs that may be affected by the downgrade.
- Ensure that all required Node.js functionality is still available and properly typed with the downgraded
@types/node
version.- Run the project's test suite and verify that there are no type-related errors or compatibility issues arising from the downgrade.
- Consider documenting any notable changes or limitations introduced by the downgrade in the project's documentation or release notes.
If any compatibility issues or breaking changes are identified during the verification process, please assess the impact and consider updating the codebase or exploring alternative solutions to ensure the project's stability and functionality.
74-74
: Verify the integration of Bun and the usage of thebun-types
package.The addition of the
bun-types
package suggests that the project is introducing support for the Bun runtime, which can offer performance improvements and additional functionality.Please consider the following verification steps:
- Ensure that the project's codebase is compatible with the Bun runtime and that any necessary adaptations are made to leverage Bun's features effectively.
- Verify that the
bun-types
package is properly installed and that the TypeScript compiler can access the Bun-specific type definitions.- Review the project's code and identify areas where Bun-specific APIs or features are being used, ensuring that they are properly typed and utilized.
- Run the project's test suite and verify that there are no type-related errors or compatibility issues related to the integration of Bun.
- Consider documenting the integration of Bun and any notable changes or benefits it brings to the project in the project's documentation or release notes.
If any issues or incompatibilities are identified during the verification process, please investigate and address them accordingly to ensure a smooth integration of Bun into the project.
83-84
: Monitor thehardhat-deploy
andhardhat-deploy-ethers
packages for critical updates and security patches.The change in version specifications from caret (
^
) to exact versions forhardhat-deploy
andhardhat-deploy-ethers
suggests a stricter dependency management approach, ensuring more predictable and reproducible builds.Please consider the following:
- Regularly monitor the release notes and changelogs of the
hardhat-deploy
andhardhat-deploy-ethers
packages for any critical updates, bug fixes, or security patches.- Assess the impact and relevance of any updates to the project's requirements and functionality.
- If any critical updates or security patches are released, consider updating the exact versions of the packages in the project's dependencies to incorporate the necessary changes.
- Thoroughly test the project after updating the package versions to ensure compatibility and stability.
By actively monitoring the packages and selectively updating to incorporate critical updates and security patches, the project can maintain a balance between stability and staying up to date with important fixes and enhancements.
contracts/hardhat.config.ts (4)
2-2
: LGTM!Adding an empty line improves readability by separating import statements from the rest of the code.
6-7
: LGTM!The changes introduce two new imports:
- The
dotenv
package is imported to load environment variables from a.env
file, which is a common practice for managing configuration.- The
hardhat-contract-sizer
plugin is imported to analyze contract sizes, which can be useful for optimizing gas usage.
10-16
: LGTM!The changes introduce several new Hardhat plugins and rearrange the import statements:
hardhat-deploy-tenderly
for deploying contracts to Tenderly.hardhat-docgen
for generating documentation.hardhat-gas-reporter
for reporting gas usage.hardhat-tracer
for tracing Solidity function calls.hardhat-watcher
for watching and recompiling contracts.solidity-coverage
for Solidity code coverage.The
HardhatUserConfig
type is also imported fromhardhat/config
.These plugins can enhance the development workflow and provide useful features for testing, deployment, and documentation.
17-18
: LGTM!The changes add an empty line for readability and import simulation tasks from a local file.
https://bun.sh
PR-Codex overview
This PR focuses on updating dependencies and configuration files.
Detailed summary
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Chores