{"id":21305,"library":"eslint-plugin-mobx","title":"eslint-plugin-mobx","description":"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.","status":"active","version":"0.0.14","language":"javascript","source_language":"en","source_url":"https://github.com/mobxjs/mobx","tags":["javascript","eslint","eslint-plugin","eslintplugin","mobx"],"install":[{"cmd":"npm install eslint-plugin-mobx","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-mobx","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-mobx","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency, required to run the plugin","package":"eslint","optional":false},{"reason":"recommended parser for TypeScript support","package":"@typescript-eslint/parser","optional":true}],"imports":[{"note":"ESM-only since version 0.0.12; CJS require not supported with flat config","wrong":"const pluginMobx = require('eslint-plugin-mobx')","symbol":"default (pluginMobx)","correct":"import pluginMobx from 'eslint-plugin-mobx'"},{"note":"Named export for accessing individual rules; also ESM-only","wrong":"const { rules } = require('eslint-plugin-mobx')","symbol":"rules","correct":"import { rules } from 'eslint-plugin-mobx'"},{"note":"Flat config available since v0.0.12; requires ESLint >=9 and ESM module system","wrong":null,"symbol":"flatConfigs","correct":"import pluginMobx from 'eslint-plugin-mobx'; pluginMobx.flatConfigs.recommended"}],"quickstart":{"code":"// Install: npm install --save-dev eslint @typescript-eslint/parser eslint-plugin-mobx\n\n// .eslintrc.js (legacy)\nmodule.exports = {\n  parser: '@typescript-eslint/parser',\n  plugins: ['mobx'],\n  extends: 'plugin:mobx/recommended',\n  rules: {\n    'mobx/exhaustive-make-observable': 'warn',\n    'mobx/missing-make-observable': 'error',\n    'mobx/missing-observer': 'warn'\n  }\n};\n\n// eslint.config.js (flat config, ESLint >=9)\nimport pluginMobx from 'eslint-plugin-mobx';\nexport default [\n  pluginMobx.flatConfigs.recommended,\n  {\n    files: ['**/*.jsx'],\n    rules: {\n      'mobx/missing-observer': 'warn'\n    }\n  }\n];","lang":"javascript","description":"Shows both legacy (.eslintrc) and flat config (eslint.config.js) setups with recommended rules."},"warnings":[{"fix":"Use eslint.config.js with import syntax instead of .eslintrc.js with require.","message":"Flat config support requires ESLint >=9 and ESM module system; legacy .eslintrc config is not compatible.","severity":"breaking","affected_versions":">=0.0.12"},{"fix":"Manually annotate such fields in makeObservable or use makeAutoObservable.","message":"The exhaustive-make-observable rule does not support fields introduced by constructor (this.foo = 5) and may miss annotations.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Migrate to eslint.config.js with flat config syntax.","message":"Legacy config (plugin:mobx/recommended via extends) is deprecated in favor of flat config (pluginMobx.flatConfigs.recommended) for ESLint >=9.","severity":"deprecated","affected_versions":">=0.0.12"},{"fix":"Use overrides to limit rule to .jsx/.tsx files or adjust naming conventions.","message":"The missing-observer rule may produce false positives for non-component functions with capitalized names (e.g., helper functions).","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Run autofix with --rule='mobx/exhaustive-make-observable: [2, { autofixAnnotation: false }]' to annotate with false.","message":"Autofix for exhaustive-make-observable defaults to adding field:true; migrating projects may accidentally override existing behavior.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Add \"type\": \"module\" to package.json or rename file to .mjs.","cause":"Using flat config syntax with ESM in CommonJS project (package.json missing \"type\": \"module\").","error":"ESLint: Cannot read config file: .../eslint.config.js: Unexpected token 'export'"},{"fix":"Run npm install --save-dev eslint-plugin-mobx.","cause":"eslint-plugin-mobx not installed or not in node_modules.","error":"Error: Failed to load plugin 'mobx' declared in 'extends': Cannot find module 'eslint-plugin-mobx'"},{"fix":"Use require() for legacy config or switch to flat config with .mjs extension.","cause":"Using ESM import statements in a CommonJS file (.eslintrc.js without type:module).","error":"Parsing error: The keyword 'import' is reserved"},{"fix":"Add 'mobx' to plugins: ['mobx'] in .eslintrc.js.","cause":"Plugin not specified in plugins array in legacy config.","error":"Definition for rule 'mobx/exhaustive-make-observable' was not found"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}