Registry / testing / eslint-plugin-math

eslint-plugin-math

JSON →
library0.13.1jsnpmunverified

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).

npm install eslint-plugin-math
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-MATH
E
eslint-plugin-math
testingjavascriptv0.13.1
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 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

default
import eslintPluginMath from 'eslint-plugin-math'
const eslintPluginMath = require('eslint-plugin-math')
ESM-only; CommonJS require not supported. Use dynamic import if needed in CJS.
configs
import { configs } from 'eslint-plugin-math'
import eslintPluginMath from 'eslint-plugin-math'; const configs = eslintPluginMath.configs
Named export 'configs' is available since v0.10.0. Using default and destructuring is fine but redundant.
rules
import { rules } from 'eslint-plugin-math'
const { rules } = require('eslint-plugin-math')
Named export 'rules' is available since v0.10.0.

Shows how to use the plugin with flat config, including recommended config and custom rules.

import eslintPluginMath from 'eslint-plugin-math'; export default [ eslintPluginMath.configs.recommended, { rules: { 'math/prefer-math-trunc': 'error', 'math/no-static-infinity-calculations': 'warn', }, }, ];
Debug
Known issues
breakingPlugin no longer supports ESLint <8.57.0 as of v0.10.0.
fix
Upgrade ESLint to >=8.57.0 or pin plugin to <0.10.0.
affects: >=0.10.0
breakingPlugin no longer supports Node <18 as of v0.10.0.
fix
Upgrade Node to ^18 or >=20 or pin plugin to <0.10.0.
affects: >=0.10.0
breakingLegacy config 'plugin:math/recommended' renamed to 'plugin:math/recommended-legacy' in v0.10.0.
fix
Use 'plugin:math/recommended-legacy' in .eslintrc files. Flat config users should use eslintPluginMath.configs.recommended.
affects: >=0.10.0
gotchaFlat config import must be default import; named exports 'configs' and 'rules' are also available but require destructuring.
fix
Use `import eslintPluginMath from 'eslint-plugin-math'` or `import { configs } from 'eslint-plugin-math'`.
affects: >=0.10.0
deprecatedOption `reportBitwise` in rule 'prefer-math-trunc' was deprecated in v0.9.0.
fix
Remove the option; behavior is now default.
affects: >=0.9.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module /node_modules/eslint-plugin-math/dist/index.js from /project/eslint.config.js not supported.
Plugin is ESM-only and cannot be required via CommonJS.
fix
Use `import eslintPluginMath from 'eslint-plugin-math'` in an ESM context or use dynamic import.
ESLint couldn't find the plugin "eslint-plugin-math". (Note: plugins are not resolved relative to the config file.)
Plugin not installed or not in node_modules, or ESLint cannot resolve it.
fix
Run `npm install --save-dev eslint-plugin-math eslint` and ensure config references the plugin correctly.
Configuration for rule "math/prefer-math-trunc" is invalid: Value "off" is the only valid severity for deprecated rules.
Rule 'math/prefer-math-trunc' might be deprecated in future version.
fix
Check rule docs and use 'error' or 'warn' if still supported; or use 'off' to disable.
Upgrade
Version history
0.13.1latest on npm
Audit
Dependencies
eslintrequiredpeer dependency to run ESLint plugin
Agent activity
2 hits · last 30 days
node
2
Resources
eslint-plugin-math — npm install eslint-plugin-math · libregistry