eslint-plugin-de-morgan
raw JSON → 2.1.1 verified Sat Apr 25 auth: no javascript
ESLint plugin that enforces De Morgan's laws to transform negated boolean expressions into clearer equivalents. Current stable version 2.1.1, released monthly. Ships TypeScript types. Supports ESLint 8, 9, and 10. Key differentiator: auto-fixes negated conjunctions and disjunctions in code, reducing logical errors. ESM-only since v2.0.0, requires Node.js 20+ or 22+.
Common errors
error Error [ERR_REQUIRE_ESM]: require() of ES Module not supported ↓
cause Using require() with plugin v2+ which is ESM-only.
fix
Change to 'import deMorgan from 'eslint-plugin-de-morgan'' and ensure package.json has 'type': 'module'.
error Configuration for rule 'de-morgan/no-negated-conjunction' is invalid ↓
cause Misconfigured rule severity or options in legacy config.
fix
Ensure rule is defined under 'rules' object: 'de-morgan/no-negated-conjunction': 'error'.
error Cannot find module 'eslint-plugin-de-morgan' ↓
cause Plugin not installed or missing from package.json.
fix
Run 'npm install --save-dev eslint-plugin-de-morgan'.
Warnings
breaking v2.0.0 dropped CommonJS support; require() fails. ↓
fix Use ESM imports (import deMorgan from 'eslint-plugin-de-morgan').
breaking v2.0.0 dropped Node.js 18 support. ↓
fix Upgrade to Node.js 20 or 22.
breaking v2.0.0 removed legacy getSourceCode() function. ↓
fix Use context.sourceCode or sourceCode property from rule context.
gotcha Legacy config must use 'plugin:de-morgan/recommended-legacy' instead of 'plugin:de-morgan/recommended'. ↓
fix Use 'recommended-legacy' in .eslintrc.js extends array.
gotcha Flat config users must not mix legacy extends; only use deMorgan.configs.recommended. ↓
fix Use deMorgan.configs.recommended in eslint.config.js.
Install
npm install eslint-plugin-de-morgan yarn add eslint-plugin-de-morgan pnpm add eslint-plugin-de-morgan Imports
- plugin wrong
const deMorgan = require('eslint-plugin-de-morgan')correctimport deMorgan from 'eslint-plugin-de-morgan' - recommended config wrong
module.exports = { extends: ['plugin:de-morgan/recommended'] }correctimport deMorgan from 'eslint-plugin-de-morgan'; export default [deMorgan.configs.recommended] - rules wrong
const rules = require('eslint-plugin-de-morgan').rules.no-negated-conjunctioncorrectimport deMorgan from 'eslint-plugin-de-morgan'; const rules = deMorgan.rules['no-negated-conjunction']
Quickstart
import deMorgan from 'eslint-plugin-de-morgan';
export default [
deMorgan.configs.recommended,
{
plugins: {
'de-morgan': deMorgan
},
rules: {
'de-morgan/no-negated-conjunction': 'warn',
'de-morgan/no-negated-disjunction': 'error'
}
}
];