[−][src]Struct rslint_core::groups::errors::NoCondAssign
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]
Trait Implementations
impl Clone for NoCondAssign
[src]
fn clone(&self) -> NoCondAssign
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl CstRule for NoCondAssign
[src]
fn check_node(&self, node: &SyntaxNode, ctx: &mut RuleCtx) -> Option<()>
[src]
fn check_token(&self, token: &SyntaxToken, ctx: &mut RuleCtx) -> Option<()>
[src]
fn check_root(&self, root: &SyntaxNode, ctx: &mut RuleCtx) -> Option<()>
[src]
impl Debug for NoCondAssign
[src]
impl Default for NoCondAssign
[src]
impl<'de> Deserialize<'de> for NoCondAssign where
NoCondAssign: Default,
[src]
NoCondAssign: Default,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Rule for NoCondAssign
[src]
impl Serialize for NoCondAssign
[src]
Auto Trait Implementations
impl RefUnwindSafe for NoCondAssign
impl Send for NoCondAssign
impl Sync for NoCondAssign
impl Unpin for NoCondAssign
impl UnwindSafe for NoCondAssign
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> DynClone for T where
T: Clone,
[src]
T: Clone,
impl<T> Erasable for T
unsafe fn unerase(this: NonNull<Erased>) -> NonNull<T>
const ACK_1_1_0: bool
fn erase(this: NonNull<Self>) -> NonNull<Erased>
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Serialize for T where
T: Serialize + ?Sized,
[src]
T: Serialize + ?Sized,
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<Ok, Error>
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,