Registry / testing / eslint-plugin-ternaries

eslint-plugin-ternaries

JSON →
library1.1.0jsnpmunverified

An ESLint plugin that provides rules specifically for controlling the use of ternary expressions in JavaScript. The current stable version is 1.1.0, which adds the no-empty-ternary rule to complement the existing no-null-ternary rule. This plugin is designed for teams that want to enforce coding standards around ternaries, such as disallowing null or empty string values in ternary branches. It is a lightweight plugin with no additional dependencies besides ESLint itself.

npm install eslint-plugin-ternaries
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-TERN
E
eslint-plugin-ternaries
testingjavascriptv1.1.0
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.

Plugin
// .eslintrc: { "plugins": ["ternaries"] }
// npm install eslint-plugin-ternaries --save-dev (forgetting to add to plugins)
The plugin is registered in ESLint config, not imported in code.
no-null-ternary
// .eslintrc: { "rules": { "ternaries/no-null-ternary": "error" } }
{ "rules": { "no-null-ternary": "error" } }
Rules must be prefixed with the plugin name 'ternaries/'.
no-empty-ternary
// .eslintrc: { "rules": { "ternaries/no-empty-ternary": "warn" } }
{ "rules": { "ternaries/no-empty-ternary": "error", "ternaries/no-null-ternary": 2 } }
Severity levels: 0=off, 1=warn, 2=error. Common mistake is using numbers or strings incorrectly.

Shows installation, configuration in .eslintrc, and example violations.

// Step 1: Install ESLint and the plugin npm install eslint --save-dev npm install eslint-plugin-ternaries --save-dev // Step 2: Create .eslintrc.json { "plugins": ["ternaries"], "rules": { "ternaries/no-null-ternary": "error", "ternaries/no-empty-ternary": "warn" } } // Step 3: Test with a file const x = condition ? null : 1; // Error: ternaries/no-null-ternary const y = condition ? '' : 2; // Warning: ternaries/no-empty-ternary
Debug
Known issues
gotchaRules must be prefixed with 'ternaries/' in ESLint configuration.
fix
Use 'ternaries/no-null-ternary' instead of just 'no-null-ternary'.
affects: >=0.0.0
breakingESLint required as peer dependency. Plugin will not work without ESLint.
fix
Ensure ESLint is installed in your project.
affects: >=1.0.0
gotchaSeverity values: 0 (off), 1 (warn), 2 (error) or strings 'off', 'warn', 'error'. Do not use other numbers.
fix
Use correct severity: 'error', 'warn', or 'off'.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Failed to load plugin 'ternaries': Cannot find module 'eslint-plugin-ternaries'
Plugin not installed in node_modules.
fix
Run 'npm install eslint-plugin-ternaries --save-dev'.
Error: Failed to load rule 'no-null-ternary'
Rule missing 'ternaries/' prefix in ESLint config.
fix
Use 'ternaries/no-null-ternary' instead of 'no-null-ternary'.
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
eslint-plugin-ternaries — npm install eslint-plugin-ternaries · libregistry