Skip to content

chore: add ESLint linting to the project#84

Merged
watson merged 11 commits intomainfrom
watson/eslint
Mar 3, 2026
Merged

chore: add ESLint linting to the project#84
watson merged 11 commits intomainfrom
watson/eslint

Conversation

@watson
Copy link
Copy Markdown
Contributor

@watson watson commented Mar 3, 2026

Summary

Add ESLint to the project with a comprehensive set of plugins to enforce code quality, consistency, and best practices across all JavaScript files. A dedicated lint CI job is added as well.

Plugins

  • @eslint/js -- ESLint recommended rules as the baseline
  • @stylistic/eslint-plugin -- Formatting rules (no semicolons, single quotes, trailing commas, 2-space indent, 1tbs brace style)
  • eslint-plugin-n -- Node.js-specific rules (supported features, proper module usage)
  • eslint-plugin-unicorn -- Additional best-practice rules (with CommonJS-incompatible rules like prefer-module disabled)
  • eslint-plugin-import-x -- Import/require ordering and validation

Codebase changes

All existing files have been auto-fixed or manually updated to comply with the new rules. Notable changes include:

  • Consistent formatting (semicolons removed, single quotes, trailing commas, etc.)
  • node: protocol prefix added to all built-in module imports
  • Files renamed from snake_case to kebab-case (test_utils.js, process_discovery.js, test_wasm.js)
  • Minor code improvements caught by the linter (undeclared variable, .includes() over .find(), Math.trunc() over | 0, for...of over .forEach())

Review tip

This PR is best reviewed commit-by-commit. Each commit adds one plugin or addresses one concern, making it easier to see what changed and why.

Copy link
Copy Markdown
Contributor Author

watson commented Mar 3, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

watson added 8 commits March 3, 2026 17:06
Set up ESLint with flat config using the recommended ruleset and Node.js
globals. A dedicated lint job is added to the CI workflow so it runs
once per PR.

Fix an undeclared variable in the library_config WASM test that was
caught by the new linter.
Add stylistic rules to enforce consistent code formatting across the
codebase. Auto-fix all existing files to comply with the new rules.
Add Node.js-specific linting rules via the eslint-plugin-n recommended
config.
Add unicorn recommended rules and fix all violations. Rules incompatible
with CommonJS are disabled.
Enforce the unicorn/filename-case rule by renaming files that used
underscores to kebab-case and updating all references.
Replace null usages with undefined/implicit returns so the rule can be
enforced.
Suppress the rule inline for the one intentional async IIFE in the
crashtracker test instead of disabling it globally.
Enforce import ordering, grouping with newlines between sections, no
unnecessary extensions, and other import best practices across the
codebase.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 3, 2026

Overall package size

Self size: 37.36 MB
Deduped: 37.36 MB
No deduping: 37.36 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------|

🤖 This report was automatically generated by heaviest-objects-in-the-universe

watson added 3 commits March 3, 2026 17:15
Enforce `const` for variables that are never reassigned and fix
all existing violations across test files.
The prebuildify Docker images for linuxglibc use Node.js 12
which doesn't support the node: protocol prefix in require
calls. This was causing CI failures during the build step.
ESLint devDependencies require Node ^20.19.0 || ^22.13.0 ||
>=24, which breaks `yarn install` on older Node versions used
by the prebuildify test matrix. Add `.yarnrc` with
`--ignore-engines true` to skip engine checks.

Also move `yarn install` for test subdirectories from
`test/crashtracker/index.js` into `scripts/test.sh` so
dependencies are installed before Node loads the test file.
@watson watson marked this pull request as ready for review March 3, 2026 16:51
@watson watson requested review from a team as code owners March 3, 2026 16:51
@watson watson merged commit 8ea1cff into main Mar 3, 2026
46 checks passed
@watson watson deleted the watson/eslint branch March 4, 2026 06:59
tlhunter pushed a commit that referenced this pull request Mar 19, 2026
Set up ESLint with @eslint/js, @stylistic/eslint-plugin, eslint-plugin-n,
eslint-plugin-unicorn, and eslint-plugin-import-x. Add an eslint.config.js
with project-specific overrides (CJS mode, Node.js >=18, 1tbs brace style,
kebab-case filenames, prefer-const, import ordering, etc.) and a lint CI
job in the build workflow.

Apply all auto-fixable and manual lint fixes across the codebase:
- Use node: protocol for built-in requires
- Replace var/let with const where appropriate
- Add trailing commas, remove semicolons, fix spacing
- Rename files to kebab-case (test_utils.js -> test-utils.js,
  test_wasm.js -> test-wasm.js, process_discovery.js -> process-discovery.js)
- Replace .find() equality checks with .includes()
- Remove unused catch bindings
- Use top-level await where applicable
- Auto-install test subdirectory dependencies in test.sh
tlhunter pushed a commit that referenced this pull request Mar 20, 2026
Set up ESLint with @eslint/js, @stylistic/eslint-plugin, eslint-plugin-n,
eslint-plugin-unicorn, and eslint-plugin-import-x. Add an eslint.config.js
with project-specific overrides (CJS mode, Node.js >=18, 1tbs brace style,
kebab-case filenames, prefer-const, import ordering, etc.) and a lint CI
job in the build workflow.

Apply all auto-fixable and manual lint fixes across the codebase:
- Use node: protocol for built-in requires
- Replace var/let with const where appropriate
- Add trailing commas, remove semicolons, fix spacing
- Rename files to kebab-case (test_utils.js -> test-utils.js,
  test_wasm.js -> test-wasm.js, process_discovery.js -> process-discovery.js)
- Replace .find() equality checks with .includes()
- Remove unused catch bindings
- Use top-level await where applicable
- Auto-install test subdirectory dependencies in test.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants