LearnNewsExamplesServices
Frontmatter
id7078
titleCreate Node.js script to standardize and sort module imports
stateClosed
labels
enhancementstale
assignees[]
createdAtJul 17, 2025, 2:12 PM
updatedAtFeb 4, 2026, 4:41 AM
githubUrlhttps://github.com/neomjs/neo/issues/7078
authortobiu
commentsCount3
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtFeb 4, 2026, 4:41 AM

Create Node.js script to standardize and sort module imports

Closed v12.0.0 enhancementstale
tobiu
tobiu commented on Jul 17, 2025, 2:12 PM

Description

The project currently has hundreds of source files, and the order of top-level import statements is inconsistent. Manually sorting them is time-consuming and error-prone. A consistent import order improves code readability and maintainability.

This task is to create a Node.js script inside the /buildScripts directory to automate the sorting of ES module imports.

Requirements

  1. The script should be able to parse .mjs files.
  2. It should read all top-level import statements within a file.
  3. It must sort the imports alphabetically based on their file path (e.g., '../core/Base.mjs' comes before '../manager/Component.mjs').
  4. The script should then overwrite the original file with the newly sorted imports, leaving the rest of the file content unchanged.
  5. It should be designed to run across the entire /src directory or on specific sub-directories.

Future Enhancements

  • Integrate the script into a pre-commit hook to automatically format files.
  • Add the script to a CI/CD pipeline to enforce the standard.
tobiu added the enhancement label on Jul 17, 2025, 2:12 PM