Skip to content

refactor(eslint-plugin-mobx): rewrite in TypeScript and type flat/legacy configs - #4699

Open
rakleed wants to merge 2 commits into
mobxjs:mainfrom
rakleed:eslint-plugin-mobx-flat-config-types
Open

refactor(eslint-plugin-mobx): rewrite in TypeScript and type flat/legacy configs#4699
rakleed wants to merge 2 commits into
mobxjs:mainfrom
rakleed:eslint-plugin-mobx-flat-config-types

Conversation

@rakleed

@rakleed rakleed commented Aug 19, 2026

Copy link
Copy Markdown

Rewrites eslint-plugin-mobx in TypeScript so mobx.flatConfigs.recommended and mobx.configs.recommended are typed when consumed from a TypeScript eslint.config.ts, per @kubk's suggestion:

  • Source files renamed to .ts.
  • Rollup now compiles src/index.ts with rollup-plugin-typescript2 (already used by the other packages in this monorepo). Babel still runs afterwards (via the existing .babelrc.js) so the shipped bundle is downleveled the same way it was before this change.
  • Declarations are generated into dist/index.d.ts and "types" points there, so the declaration can no longer drift from the implementation the way a hand-written one could. The generated export default is patched to export = after the build to match the actual module.exports = <value> CommonJS runtime shape regardless of the consumer's esModuleInterop setting, and the standalone .d.ts rollup-plugin-typescript2 emits per compiled module is removed since dist/index.d.ts is fully self-contained.
  • @types/eslint moved to dependencies (it's referenced by the generated declaration, so it needs to be installed for consumers too), and @types/estree is pinned to ^1.0.0 as a direct dependency, since @types/eslint's own dependency on it is unconstrained.

Closes #4545.

Code change checklist

  • Added/updated unit tests
  • Updated /docs. For new functionality, at least API.md should be updated
  • Verified that there is no significant performance drop (npm -w mobx run test:performance)

@changeset-bot

changeset-bot Bot commented Aug 19, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4971f60

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
eslint-plugin-mobx Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kubk

kubk commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Hi @rakleed Thank you for the PR

the issue I see here is that we need to maintain JSDoc + a handwritten declaration file. Thoughts on rewriting the eslint plugin to TS?

the eslint plugin is already bundled with rollup. Possible plan:

  1. Rename the source files to .ts
  2. Change the Rollup input to src/index.ts
  3. Add rollup-plugin-typescript2, which the monorepo already uses
  4. Generate declarations into dist
  5. Set "types": "dist/index.d.ts"

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Public type dependencies and generated declaration behavior are not packaged or tested correctly, and the implementation contradicts the stated scope.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds typings for the ESLint plugin’s legacy and flat recommended configurations by migrating its implementation to TypeScript and generating declarations during Rollup builds.

Changes:

  • Types plugin rules and recommended configurations.
  • Replaces JavaScript sources with TypeScript and updates build/test configuration.
  • Adds package metadata and release notes for declarations.
File summaries
File Description
.changeset/eslint-plugin-mobx-flat-config-types.md Records the typing enhancement.
package-lock.json Locks the ESLint type dependency.
packages/eslint-plugin-mobx/package.json Declares typings and type-check scripts.
packages/eslint-plugin-mobx/rollup.config.js Switches the build to TypeScript.
packages/eslint-plugin-mobx/tsconfig.json Configures source type-checking.
packages/eslint-plugin-mobx/src/index.ts Types and exports plugin configurations.
packages/eslint-plugin-mobx/src/index.js Removes the previous JavaScript entry point.
packages/eslint-plugin-mobx/src/utils.ts Migrates shared utilities to TypeScript.
packages/eslint-plugin-mobx/src/utils.js Removes the JavaScript utilities.
packages/eslint-plugin-mobx/src/exhaustive-make-observable.ts Types the exhaustive rule.
packages/eslint-plugin-mobx/src/missing-make-observable.ts Migrates and types the rule.
packages/eslint-plugin-mobx/src/missing-make-observable.js Removes the JavaScript rule.
packages/eslint-plugin-mobx/src/missing-observer.ts Types the observer rule.
packages/eslint-plugin-mobx/src/no-anonymous-observer.ts Types the anonymous-observer rule.
packages/eslint-plugin-mobx/src/unconditional-make-observable.ts Migrates and types the rule.
packages/eslint-plugin-mobx/src/unconditional-make-observable.js Removes the JavaScript rule.
packages/eslint-plugin-mobx/__tests__/exhaustive-make-observable.js Updates TypeScript source imports.
packages/eslint-plugin-mobx/__tests__/missing-make-observable.js Updates imports and formatting.
packages/eslint-plugin-mobx/__tests__/missing-observer.js Updates the rule import.
packages/eslint-plugin-mobx/__tests__/no-anonymous-observer.js Updates the rule import.
packages/eslint-plugin-mobx/__tests__/unconditional-make-observable.js Updates imports and formatting.
Review details

Suppressed comments (1)

packages/eslint-plugin-mobx/src/exhaustive-make-observable.ts:121

  • “Listen” is the wrong form here; the fields are being “listed.”
  • Files reviewed: 20/21 changed files
  • Comments generated: 4
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/eslint-plugin-mobx/package.json
Comment thread packages/eslint-plugin-mobx/package.json
Comment thread packages/eslint-plugin-mobx/rollup.config.js Outdated
Comment thread packages/eslint-plugin-mobx/src/unconditional-make-observable.ts Outdated
@rakleed rakleed changed the title feat(eslint-plugin-mobx): add types for flat/legacy configs refactor(eslint-plugin-mobx): rewrite in TypeScript and type flat/legacy configs Sep 5, 2026
@rakleed
rakleed force-pushed the eslint-plugin-mobx-flat-config-types branch 3 times, most recently from a721761 to c4948ff Compare September 5, 2026 16:14
@kubk

kubk commented Sep 5, 2026

Copy link
Copy Markdown
Collaborator

@rakleed Thank you! could you please use git mv so git doesn't re-create files from scratch and we can see what really changed?

image

Same for missing-make-observable

Rewrites the plugin in TypeScript so mobx.flatConfigs.recommended and
mobx.configs.recommended are typed when consumed from a TypeScript
eslint.config.ts, per @kubk's suggestion on the PR:

- source files renamed to .ts
- rollup compiles src/index.ts with rollup-plugin-typescript2 (already
  used by the other packages in this monorepo), with Babel still
  running afterwards (via the existing .babelrc.js) to downlevel the
  output the same way the pre-TypeScript build did
- declarations are generated into dist/index.d.ts and "types" points
  there, so the declaration can no longer drift from the implementation
  the way a hand-written one could
- the generated declaration's `export default` is patched to `export =`
  after the build, to match the actual module.exports = <value> runtime
  shape regardless of the consumer's esModuleInterop setting
- the standalone .d.ts rollup-plugin-typescript2 emits for every
  compiled module (not just the bundled entry point) is removed after
  the build, since dist/index.d.ts is fully self-contained
- @types/eslint moved to dependencies, since the generated declaration
  references it and it isn't installed transitively as a devDependency;
  @types/estree is pinned to ^1.0.0 as a direct dependency too, since
  @types/eslint's own dependency on it is unconstrained and this repo
  already has an incompatible 0.0.39 hoisted at the root

Closes mobxjs#4545.
@rakleed
rakleed force-pushed the eslint-plugin-mobx-flat-config-types branch from c4948ff to 2184c46 Compare September 5, 2026 21:26
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.

3 participants