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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce Import Order #47

Merged
merged 2 commits into from
Sep 16, 2024
Merged

Enforce Import Order #47

merged 2 commits into from
Sep 16, 2024

Conversation

bh2smith
Copy link
Collaborator

@bh2smith bh2smith commented Sep 16, 2024

PR Type

enhancement, configuration changes


Description

  • Enforced import order across multiple TypeScript files for consistency.
  • Added eslint-plugin-import to enforce import order and configured its rules in eslint.config.cjs.
  • Added missing return type to the remove0x function in src/lib/multisend.ts.
  • Added newlines at the end of .prettierrc and package.json for formatting consistency.

Changes walkthrough 📝

Relevant files
Enhancement
8 files
cli.ts
Enforce import order in CLI example                                           

examples/cli.ts

  • Added a newline for import order consistency.
+1/-0     
send-tx.ts
Enforce import order in send-tx example                                   

examples/send-tx.ts

  • Reordered imports to enforce import order.
+2/-1     
bundler.ts
Enforce import order in bundler library                                   

src/lib/bundler.ts

  • Reordered imports to enforce import order.
+2/-1     
multisend.ts
Enforce import order and add type in multisend library     

src/lib/multisend.ts

  • Added a newline for import order consistency.
  • Added return type to remove0x function.
  • +2/-1     
    safe.ts
    Enforce import order in safe library                                         

    src/lib/safe.ts

    • Reordered imports to enforce import order.
    +4/-3     
    tx-manager.ts
    Enforce import order in transaction manager                           

    src/tx-manager.ts

    • Reordered imports to enforce import order.
    +6/-5     
    util.ts
    Enforce import order in utility functions                               

    src/util.ts

    • Reordered imports to enforce import order.
    +2/-1     
    utils.spec.ts
    Enforce import order in utility tests                                       

    tests/utils.spec.ts

    • Added a newline for import order consistency.
    +2/-1     
    Formatting
    1 files
    .prettierrc
    Add newline at end of Prettier configuration file               

    .prettierrc

    • Added newline at end of file.
    +1/-1     
    Configuration changes
    1 files
    eslint.config.cjs
    Add and configure eslint-plugin-import for import order   

    eslint.config.cjs

  • Added eslint-plugin-import to enforce import order.
  • Configured import order rules.
  • +14/-0   
    Dependencies
    1 files
    package.json
    Add eslint-plugin-import to dependencies                                 

    package.json

  • Added eslint-plugin-import to dependencies.
  • Added newline at end of file.
  • +2/-1     

    💡 PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    Base automatically changed from moar-viem to main September 16, 2024 12:33
    @mintbase-codium-pr-agent
    Copy link

    PR Reviewer Guide 🔍

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Key issues to review

    Function Typing
    The remove0x function now includes a return type. Ensure that this change is reflected across all usages and that the return type aligns with the expected data handling in the application.

    @mintbase-codium-pr-agent
    Copy link

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Maintainability
    Group and separate different types of imports for better readability

    To maintain consistency and readability, consider grouping and separating different
    types of imports. Here, UserOptions is a local import and should be grouped with
    other local imports, separated by a newline from external imports.

    examples/cli.ts [1-4]

     import yargs from "yargs";
     import { hideBin } from "yargs/helpers";
    +
     import { UserOptions } from "../src";
     
    Suggestion importance[1-10]: 8

    Why: The suggestion improves code readability and maintainability by grouping local imports separately from external imports, which is a common best practice.

    8
    Best practice
    Add newlines between different groups in import order configuration for better readability

    To ensure that the import order is enforced consistently, consider adding a newline
    between different groups of imports in the configuration. This makes the
    configuration easier to read and maintain.

    eslint.config.cjs [35-45]

     "import/order": [
       "error",
       {
         "groups": [
           ["builtin", "external"],
    +
           ["internal", "parent", "sibling", "index"]
         ],
         "newlines-between": "always",
         "alphabetize": { "order": "asc", "caseInsensitive": true }
       }
     ],
     
    Suggestion importance[1-10]: 7

    Why: The suggestion enhances the readability and maintainability of the ESLint configuration by clearly separating different import groups.

    7
    Use consistent arrow function syntax for better readability

    To enhance readability and maintainability, consider using arrow function syntax
    consistently across your codebase. Here, the remove0x function can be converted to
    an arrow function to match the style used elsewhere.

    src/lib/multisend.ts [35]

    -const remove0x = (hexString: Hex): string => hexString.slice(2);
    +const remove0x = (hexString: Hex) => hexString.slice(2);
     
    Suggestion importance[1-10]: 5

    Why: The suggestion promotes consistency in the codebase, but the change is minor and does not significantly impact functionality or readability.

    5

    @bh2smith bh2smith merged commit 5107b3c into main Sep 16, 2024
    1 check passed
    @bh2smith bh2smith deleted the import-order branch September 16, 2024 12:41
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    1 participant