noYodaExpression
Ta treść nie jest jeszcze dostępna w Twoim języku.
Summary
Section titled “Summary”- Rule available since: 
v1.8.0 - Diagnostic Category: 
lint/style/noYodaExpression - This rule has a safe fix.
 - The default severity of this rule is information.
 - Sources:
- Same as 
yoda 
 - Same as 
 
How to configure
Section titled “How to configure”{  "linter": {    "rules": {      "style": {        "noYodaExpression": "error"      }    }  }}Description
Section titled “Description”Disallow the use of yoda expressions.
A Yoda expression is a programming style where, given a binary operation, the “static” part of the binary operation is placed on the left-hand side. This rule forbids the use of Yoda expressions and enforces the placing of the “static” part of the binary operations on the right-hand side.
Exceptions
Section titled “Exceptions”Range expressions like 0 < value && value < 1 or value <= 0 || 1 < value are allowed.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”if ("red" == value) {}code-block.js:1:5 lint/style/noYodaExpression  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ℹ Avoid the use of yoda expressions.
  
  > 1 │ if (“red” == value) {}
      │     ^^^^^^^^^^^^^^
    2 │ 
  
  ℹ Yoda expressions can be confusing to some people, invert the expression operands for better readability.
  
  ℹ Safe fix: Flip the operators of the expression.
  
    1   │ - if·(“red”·==·value)·{}
      1 │ + if·(value·==·“red”)·{}
    2 2 │   
  
if (true === value) {}code-block.js:1:5 lint/style/noYodaExpression  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ℹ Avoid the use of yoda expressions.
  
  > 1 │ if (true === value) {}
      │     ^^^^^^^^^^^^^^
    2 │ 
  
  ℹ Yoda expressions can be confusing to some people, invert the expression operands for better readability.
  
  ℹ Safe fix: Flip the operators of the expression.
  
    1   │ - if·(true·===·value)·{}
      1 │ + if·(value·===·true)·{}
    2 2 │   
  
if (5 != value) {}code-block.js:1:5 lint/style/noYodaExpression  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ℹ Avoid the use of yoda expressions.
  
  > 1 │ if (5 != value) {}
      │     ^^^^^^^^^^
    2 │ 
  
  ℹ Yoda expressions can be confusing to some people, invert the expression operands for better readability.
  
  ℹ Safe fix: Flip the operators of the expression.
  
    1   │ - if·(5·!=·value)·{}
      1 │ + if·(value·!=·5)·{}
    2 2 │   
  
if (value === "red") {}if (value === value) {}if (value != 5) {}if (0 < value && value < 1) {}Resources
Section titled “Resources”Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.