In the code below I get a circular conflict:
prefer-else-if suggests else if
- Following the suggestion from 1 => triggers
no-useless-else, which wants to
remove else => back to 1
Issue did not occur in 68.0; noticed after upgrading to 72.0
unicorn/prefer-else-if and unicorn/no-useless-else
// package.json
{
"devDependencies": {
"eslint": "^10.7.0",
"eslint-plugin-unicorn": "^72.0.0"
},
"type": "module"
}
// eslint.config.js
import unicorn from 'eslint-plugin-unicorn'
import { defineConfig } from 'eslint/config'
export default defineConfig([{
extends: ['unicorn/recommended'],
plugins: { unicorn },
rules: { 'unicorn/no-process-exit': 0 }
}])
// test.js
function handleSignal(signal) {
if (signal === 'SIGINT') {
process.exit(130)
}
// 'prefer-else-if' wants this to become `else if`
// but making it `else if` triggers 'no-useless-else'
if (signal === 'SIGTERM' || signal === 'SIGHUP') {
process.exit(1)
}
}
npx envinfo --system --binaries --npmPackages
System:
OS: macOS 15.7.7
CPU: (10) arm64 Apple M1 Pro
Memory: 1.22 GB / 32.00 GB
Shell: 5.9.999.3 - /opt/homebrew/bin/zsh
Binaries:
Node: 26.5.0 - /opt/homebrew/bin/node
npm: 12.0.1 - /opt/homebrew/bin/npm
bun: 1.3.14 - /opt/homebrew/bin/bun
Deno: 2.9.3 - /opt/homebrew/bin/deno
npmPackages:
eslint: ^10.7.0 => 10.7.0
eslint-plugin-unicorn: ^72.0.0 => 72.0.0
In the code below I get a circular conflict:
prefer-else-ifsuggestselse ifno-useless-else, which wants toremove
else=> back to 1Issue did not occur in 68.0; noticed after upgrading to 72.0
unicorn/prefer-else-ifandunicorn/no-useless-elsenpx envinfo --system --binaries --npmPackages System: OS: macOS 15.7.7 CPU: (10) arm64 Apple M1 Pro Memory: 1.22 GB / 32.00 GB Shell: 5.9.999.3 - /opt/homebrew/bin/zsh Binaries: Node: 26.5.0 - /opt/homebrew/bin/node npm: 12.0.1 - /opt/homebrew/bin/npm bun: 1.3.14 - /opt/homebrew/bin/bun Deno: 2.9.3 - /opt/homebrew/bin/deno npmPackages: eslint: ^10.7.0 => 10.7.0 eslint-plugin-unicorn: ^72.0.0 => 72.0.0