![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
eslint-plugin-de-morgan
Advanced tools
ESLint plugin for transforming negated boolean expressions via De Morgan’s laws
An ESLint plugin that enforces logical consistency by transforming negated boolean expressions according to De Morgan’s laws.
This plugin automatically rewrites negated conjunctions and disjunctions to improve code clarity and reduce potential logical errors.
In Boolean algebra, De Morgan’s laws are two transformation rules that are both valid rules of inference. They are named after Augustus De Morgan and are fundamental in the fields of mathematics, computer science, and digital logic. The laws state that:
First Law:
$\neg (A \land B) \equiv (\neg A) \lor (\neg B)$
Second Law:
$\neg (A \lor B) \equiv (\neg A) \land (\neg B)$
Using these principles, the plugin provides two ESLint rules:
These transformations are grounded in Boolean algebra and can help make the logic of your code more explicit and easier to understand.
De Morgan’s laws are a cornerstone of Boolean algebra and have several practical benefits in programming:
For example:
if (!(a && !b && c >= 10 && d !== e)) {
/* ... */
}
Becomes:
if (!a || b || c < 10 || d === e) {
/* ... */
}
Avoiding Logical Errors: When dealing with nested logical expressions, small mistakes in the placement of negations can lead to subtle bugs. By enforcing a consistent style based on well-known laws, the plugin helps reduce such errors.
Simplification: In some cases, the transformed expression may be simpler to evaluate and optimize, both for human readers and for compilers / interpreters.
You'll first need to install ESLint:
npm install --save-dev eslint
Next, install eslint-plugin-de-morgan
:
npm install --save-dev eslint-plugin-de-morgan
The easiest way to use eslint-plugin-de-morgan
is to use ready-made config.
eslint.config.js
)import deMorgan from 'eslint-plugin-de-morgan'
export default [
deMorgan.configs.recommended,
]
.eslintrc.js
)module.exports = {
extends: [
'plugin:de-morgan/recommended-legacy',
],
}
🔧 Automatically fixable by the --fix
CLI option.
Name | Description | 🔧 |
---|---|---|
no-negated-conjunction | Transforms the negation of a conjunction into the equivalent | 🔧 |
no-negated-disjunction | Transforms the negation of a disjunction into the equivalent | 🔧 |
This plugin is following Semantic Versioning and ESLint's Semantic Versioning Policy.
See Contributing Guide.
MIT © Azat S.
FAQs
ESLint plugin for transforming negated boolean expressions via De Morgan’s laws
The npm package eslint-plugin-de-morgan receives a total of 61 weekly downloads. As such, eslint-plugin-de-morgan popularity was classified as not popular.
We found that eslint-plugin-de-morgan demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.