[][src]Struct rslint_core::groups::errors::NoCondAssign

pub struct NoCondAssign {
    pub allow_parens: bool,
}

Forbid the use of assignment expressions in conditions which may yield unwanted behavior.

Assignment expressions return the value assigned:

let foo = 5;

console.log(foo = 8); // 8
console.log(foo += 4) // foo + 4 (12 in this case)

Users often make a typo and end up using = instead of == or === in conditions in statements like if, while, do_while, and for. This is erroneous and is most likely unwanted behavior since the condition used will actually be the value assigned.

Incorrect Code Examples

let foo = 5;

if (foo = 6) {
//      ^^^ assignments return the value assigned, therefore the condition checks `6`
//          `6` is always truthy, therefore the if statement always runs even if we dont want it to.

} else {}
//^^^^ it makes this else unreachable

foo // 6

Fields

allow_parens: bool

Allow an assignment if they are enclosed in parentheses to allow things like reassigning a variable.

Implementations

impl NoCondAssign[src]

pub fn new() -> Self[src]

Trait Implementations

impl Clone for NoCondAssign[src]

impl CstRule for NoCondAssign[src]

impl Debug for NoCondAssign[src]

impl Default for NoCondAssign[src]

impl<'de> Deserialize<'de> for NoCondAssign where
    NoCondAssign: Default
[src]

impl Rule for NoCondAssign[src]

impl Serialize for NoCondAssign[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> DynClone for T where
    T: Clone
[src]

impl<T> Erasable for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Serialize for T where
    T: Serialize + ?Sized
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.