Registry / testing / eslint-plugin-mobx

eslint-plugin-mobx

JSON →
library0.0.14jsnpmunverified

ESLint plugin providing MobX-specific linting rules for enforcing correct usage of makeObservable, makeAutoObservable, decorators, and observer in React components. Current stable version: 0.0.14. Supports ESLint 3–10 including flat config (ESLint 9+) and TypeScript via @typescript-eslint/parser. Key differentiator: catches common MobX footguns like missing makeObservable calls, non-exhaustive annotations, and missing observer wrappers, with autofix capabilities.

npm install eslint-plugin-mobx
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-MOBX
E
eslint-plugin-mobx
testingjavascriptv0.0.14
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (pluginMobx)
import pluginMobx from 'eslint-plugin-mobx'
const pluginMobx = require('eslint-plugin-mobx')
ESM-only since version 0.0.12; CJS require not supported with flat config
rules
import { rules } from 'eslint-plugin-mobx'
const { rules } = require('eslint-plugin-mobx')
Named export for accessing individual rules; also ESM-only
flatConfigs
import pluginMobx from 'eslint-plugin-mobx'; pluginMobx.flatConfigs.recommended
Flat config available since v0.0.12; requires ESLint >=9 and ESM module system

Shows both legacy (.eslintrc) and flat config (eslint.config.js) setups with recommended rules.

// Install: npm install --save-dev eslint @typescript-eslint/parser eslint-plugin-mobx // .eslintrc.js (legacy) module.exports = { parser: '@typescript-eslint/parser', plugins: ['mobx'], extends: 'plugin:mobx/recommended', rules: { 'mobx/exhaustive-make-observable': 'warn', 'mobx/missing-make-observable': 'error', 'mobx/missing-observer': 'warn' } }; // eslint.config.js (flat config, ESLint >=9) import pluginMobx from 'eslint-plugin-mobx'; export default [ pluginMobx.flatConfigs.recommended, { files: ['**/*.jsx'], rules: { 'mobx/missing-observer': 'warn' } } ];
Debug
Known issues
breakingFlat config support requires ESLint >=9 and ESM module system; legacy .eslintrc config is not compatible.
fix
Use eslint.config.js with import syntax instead of .eslintrc.js with require.
affects: >=0.0.12
gotchaThe exhaustive-make-observable rule does not support fields introduced by constructor (this.foo = 5) and may miss annotations.
fix
Manually annotate such fields in makeObservable or use makeAutoObservable.
affects: >=0.0.0
deprecatedLegacy config (plugin:mobx/recommended via extends) is deprecated in favor of flat config (pluginMobx.flatConfigs.recommended) for ESLint >=9.
fix
Migrate to eslint.config.js with flat config syntax.
affects: >=0.0.12
gotchaThe missing-observer rule may produce false positives for non-component functions with capitalized names (e.g., helper functions).
fix
Use overrides to limit rule to .jsx/.tsx files or adjust naming conventions.
affects: >=0.0.0
gotchaAutofix for exhaustive-make-observable defaults to adding field:true; migrating projects may accidentally override existing behavior.
fix
Run autofix with --rule='mobx/exhaustive-make-observable: [2, { autofixAnnotation: false }]' to annotate with false.
affects: >=0.0.0
Errors
Common errors & fixes
ESLint: Cannot read config file: .../eslint.config.js: Unexpected token 'export'
Using flat config syntax with ESM in CommonJS project (package.json missing "type": "module").
fix
Add "type": "module" to package.json or rename file to .mjs.
Error: Failed to load plugin 'mobx' declared in 'extends': Cannot find module 'eslint-plugin-mobx'
eslint-plugin-mobx not installed or not in node_modules.
fix
Run npm install --save-dev eslint-plugin-mobx.
Parsing error: The keyword 'import' is reserved
Using ESM import statements in a CommonJS file (.eslintrc.js without type:module).
fix
Use require() for legacy config or switch to flat config with .mjs extension.
Definition for rule 'mobx/exhaustive-make-observable' was not found
Plugin not specified in plugins array in legacy config.
fix
Add 'mobx' to plugins: ['mobx'] in .eslintrc.js.
Upgrade
Version history
0.0.14latest on npm
Audit
Dependencies
eslintrequiredpeer dependency, required to run the plugin
@typescript-eslint/parseroptionalrecommended parser for TypeScript support
Agent activity
4 hits · last 30 days
node
4
Resources
eslint-plugin-mobx — npm install eslint-plugin-mobx · libregistry