useSimplifiedLogicExpression
このコンテンツはまだ日本語訳がありません。
Summary
Section titled “Summary”- Rule available since: 
v1.0.0 - Diagnostic Category: 
lint/complexity/useSimplifiedLogicExpression - This rule has a safe fix.
 - The default severity of this rule is information.
 
How to configure
Section titled “How to configure”{  "linter": {    "rules": {      "complexity": {        "useSimplifiedLogicExpression": "error"      }    }  }}Description
Section titled “Description”Discard redundant terms from logical expressions.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”const boolExp = true;const r = true && boolExp;code-block.js:2:11 lint/complexity/useSimplifiedLogicExpression  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━
  ℹ Logical expression contains unnecessary complexity.
  
    1 │ const boolExp = true;
  > 2 │ const r = true && boolExp;
      │           ^^^^^^^^^^^^^^^
    3 │ 
  
  ℹ Safe fix: Discard redundant terms from the logical expression.
  
    2 │ const·r·=·true·&&·boolExp;
      │           --------        
const boolExp2 = true;const r2 = boolExp || true;code-block.js:2:12 lint/complexity/useSimplifiedLogicExpression  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━
  ℹ Logical expression contains unnecessary complexity.
  
    1 │ const boolExp2 = true;
  > 2 │ const r2 = boolExp || true;
      │            ^^^^^^^^^^^^^^^
    3 │ 
  
  ℹ Safe fix: Discard redundant terms from the logical expression.
  
    2 │ const·r2·=·boolExp·||·true;
      │            -----------     
const nonNullExp = 123;const r3 = null ?? nonNullExp;code-block.js:2:12 lint/complexity/useSimplifiedLogicExpression  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━
  ℹ Logical expression contains unnecessary complexity.
  
    1 │ const nonNullExp = 123;
  > 2 │ const r3 = null ?? nonNullExp;
      │            ^^^^^^^^^^^^^^^^^^
    3 │ 
  
  ℹ Safe fix: Discard redundant terms from the logical expression.
  
    2 │ const·r3·=·null·??·nonNullExp;
      │            --------           
const boolExpr1 = true;const boolExpr2 = false;const r4 = !boolExpr1 || !boolExpr2;code-block.js:3:12 lint/complexity/useSimplifiedLogicExpression  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━
  ℹ Logical expression contains unnecessary complexity.
  
    1 │ const boolExpr1 = true;
    2 │ const boolExpr2 = false;
  > 3 │ const r4 = !boolExpr1 || !boolExpr2;
      │            ^^^^^^^^^^^^^^^^^^^^^^^^
    4 │ 
  
  ℹ Safe fix: Reduce the complexity of the logical expression.
  
    1 1 │   const boolExpr1 = true;
    2 2 │   const boolExpr2 = false;
    3   │ - const·r4·=·!boolExpr1·||·!boolExpr2;
      3 │ + const·r4·=·!(boolExpr1·&&·boolExpr2);
    4 4 │   
  
const boolExpr3 = true;const boolExpr4 = false;const r5 = !(boolExpr1 && boolExpr2);const boolExpr5 = true;const boolExpr6 = false;Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.