{"id":19830,"library":"eslint-plugin-math","title":"eslint-plugin-math","description":"ESLint plugin for Math object and Number linting. Current version 0.13.1, peer dependency ESLint >=8.57.0, requires Node ^18 or >=20. Provides ~30 rules including prefer-math-trunc, prefer-math-pow, prefer-number-is-finite. Supports flat config (eslint.config.js) and legacy .eslintrc. Offers a recommended config and fixable suggestions. Built on eslint-type-tracer for efficient type detection. Designed to catch common Math/Number anti-patterns and promote modern alternatives. Notable for its focus on correctness (e.g., prefer-math-sum-precise for floating point).","status":"active","version":"0.13.1","language":"javascript","source_language":"en","source_url":"https://github.com/ota-meshi/eslint-plugin-math","tags":["javascript","eslint","eslintplugin","eslint-plugin","math","number","lint","typescript"],"install":[{"cmd":"npm install eslint-plugin-math","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-math","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-math","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency to run ESLint plugin","package":"eslint","optional":false}],"imports":[{"note":"ESM-only; CommonJS require not supported. Use dynamic import if needed in CJS.","wrong":"const eslintPluginMath = require('eslint-plugin-math')","symbol":"default","correct":"import eslintPluginMath from 'eslint-plugin-math'"},{"note":"Named export 'configs' is available since v0.10.0. Using default and destructuring is fine but redundant.","wrong":"import eslintPluginMath from 'eslint-plugin-math'; const configs = eslintPluginMath.configs","symbol":"configs","correct":"import { configs } from 'eslint-plugin-math'"},{"note":"Named export 'rules' is available since v0.10.0.","wrong":"const { rules } = require('eslint-plugin-math')","symbol":"rules","correct":"import { rules } from 'eslint-plugin-math'"}],"quickstart":{"code":"import eslintPluginMath from 'eslint-plugin-math';\n\nexport default [\n  eslintPluginMath.configs.recommended,\n  {\n    rules: {\n      'math/prefer-math-trunc': 'error',\n      'math/no-static-infinity-calculations': 'warn',\n    },\n  },\n];","lang":"javascript","description":"Shows how to use the plugin with flat config, including recommended config and custom rules."},"warnings":[{"fix":"Upgrade ESLint to >=8.57.0 or pin plugin to <0.10.0.","message":"Plugin no longer supports ESLint <8.57.0 as of v0.10.0.","severity":"breaking","affected_versions":">=0.10.0"},{"fix":"Upgrade Node to ^18 or >=20 or pin plugin to <0.10.0.","message":"Plugin no longer supports Node <18 as of v0.10.0.","severity":"breaking","affected_versions":">=0.10.0"},{"fix":"Use 'plugin:math/recommended-legacy' in .eslintrc files. Flat config users should use eslintPluginMath.configs.recommended.","message":"Legacy config 'plugin:math/recommended' renamed to 'plugin:math/recommended-legacy' in v0.10.0.","severity":"breaking","affected_versions":">=0.10.0"},{"fix":"Use `import eslintPluginMath from 'eslint-plugin-math'` or `import { configs } from 'eslint-plugin-math'`.","message":"Flat config import must be default import; named exports 'configs' and 'rules' are also available but require destructuring.","severity":"gotcha","affected_versions":">=0.10.0"},{"fix":"Remove the option; behavior is now default.","message":"Option `reportBitwise` in rule 'prefer-math-trunc' was deprecated in v0.9.0.","severity":"deprecated","affected_versions":">=0.9.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use `import eslintPluginMath from 'eslint-plugin-math'` in an ESM context or use dynamic import.","cause":"Plugin is ESM-only and cannot be required via CommonJS.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module /node_modules/eslint-plugin-math/dist/index.js from /project/eslint.config.js not supported."},{"fix":"Run `npm install --save-dev eslint-plugin-math eslint` and ensure config references the plugin correctly.","cause":"Plugin not installed or not in node_modules, or ESLint cannot resolve it.","error":"ESLint couldn't find the plugin \"eslint-plugin-math\". (Note: plugins are not resolved relative to the config file.)"},{"fix":"Check rule docs and use 'error' or 'warn' if still supported; or use 'off' to disable.","cause":"Rule 'math/prefer-math-trunc' might be deprecated in future version.","error":"Configuration for rule \"math/prefer-math-trunc\" is invalid: Value \"off\" is the only valid severity for deprecated rules."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}