Enforce ES module syntax using import-x module-system rules
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Overview
Enable the import-x module-system rules (no-commonjs, no-amd, no-import-module-exports) in packages/kolibri-format/eslint.config.mjs to enforce ES module syntax across the Kolibri codebase, and remediate the pre-existing violations. The Node.js packages under packages/ (e.g. kolibri-format, eslint-plugin-kolibri, kolibri-build, browserslist-config-kolibri) remain on CommonJS for now and need an override carve-out — non-Node packages in packages/ (frontend/browser code) are still expected to comply. Includes a minor version bump of kolibri-format.
Complexity: Medium Target branch: develop
Context
The kolibri-format package provides the shared ESLint config consumed by the Kolibri repo and external projects. The root eslint.config.mjs in Kolibri simply re-exports it:
export { default } from 'kolibri-format/eslint.config.mjs';
Several packages in packages/ are Node-only dev/build tooling and still use CommonJS. Until they migrate to ESM, they need to be exempted from the new rules via an override in the top-level Kolibri eslint.config.mjs (not in kolibri-format itself, so that external consumers of kolibri-format get the rules enforced by default).
Node.js-only packages to exempt:
packages/browserslist-config-kolibri/packages/eslint-plugin-kolibri/packages/kolibri-build/packages/kolibri-format/packages/kolibri-glob/packages/kolibri-i18n/packages/kolibri-jest-config/packages/kolibri-logging/packages/kolibri-tools/packages/build_kolibri_package.js(top-level script)
Frontend/browser packages (e.g. kolibri, kolibri-common, kolibri-module, kolibri-viewer, kolibri-zip, kolibri-app, kolibri-sandbox, kolibri-plugin-data) are expected to comply, though some may contain individual CJS files (e.g. webpack configs) that need file-level overrides rather than package-level.
Most violations will be in the main Kolibri source outside packages/.
The Change
In packages/kolibri-format/eslint.config.mjs, enable:
import-x/no-commonjsimport-x/no-amdimport-x/no-import-module-exports
In the top-level Kolibri eslint.config.mjs, add an override that disables those three rules for the Node.js-only packages listed in Context, so that only ESM-compliant code is linted against them.
Remediate the resulting violations across the Kolibri codebase — primarily in the main source tree outside packages/. Where an individual file inside a frontend package is a legitimate CommonJS boundary (e.g. a webpack config), add a narrow file-level override rather than exempting the whole package.
Bump kolibri-format to a new minor version.
How to Get There
After adding the rules, run the fix command from the repo root to see and autofix violations:
pnpm run lint-frontend:format
import-x/no-commonjs and import-x/no-amd have no autofix, so remaining violations need manual conversion to ESM. import-x/no-import-module-exports will flag files that mix import and module.exports — resolve by committing to one module system per file.
Out of Scope
- Converting the Node.js packages in
packages/(listed in Context) to ESM. They remain CommonJS with an override exemption. - Enabling other
import-xrules beyond the three above. - Enabling
import-x/unambiguous(flags any file without an import/export; typically noisy without corresponding benefit onceno-commonjsis enforced).
Acceptance Criteria
- [ ]
import-x/no-commonjs,import-x/no-amd, andimport-x/no-import-module-exportsare enabled as errors inpackages/kolibri-format/eslint.config.mjs - [ ] Top-level
eslint.config.mjscarves out the Node.js-only packages listed in Context so they continue to lint clean - [ ]
pnpm run lint-frontendpasses with no new violations across the repo - [ ] Any legitimate CJS files inside frontend packages have a narrow file-level override rather than a blanket package exemption
- [ ]
kolibri-formathas a minor version bump in itspackage.json - [ ]
pnpm-lock.yamlis updated for the version bump
References
eslint-plugin-import-xmodule systems rulesimport-x/no-commonjsimport-x/no-amdimport-x/no-import-module-exports
AI usage
Used Claude Code to draft this issue iteratively. I provided direction on scope (which rules to enable, which packages to carve out, remediation approach) and reviewed each section before it was committed. Claude scanned packages/ to enumerate which packages use CommonJS and help identify the exemption list.
Which should I do?
@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly
How was this generated?
- Implemented code following the pre-approved plan using test-driven development (red-green-refactor)
- Ran the project's full test suite and linter before committing
- For UI changes: captured live screenshots to verify rendering
- For backend changes: verified with example API/CLI output