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

pub struct ValidTypeof {
    pub require_string_literals: bool,
}

Enforce the use of valid string literals in a typeof comparison.

typeof can only return a small set of strings, undefined, object, boolean, number, string or function, and if you provide an invalid value, it's most likely a typo, and the comparison will always return false. This behaviour will be denied by this rule.

Invalid Code Examples

typeof foo === "strnig"
typeof foo == "undefimed"
typeof bar != "nunber"
typeof bar !== "fucntion"

Fields

require_string_literals: bool

If this option is true, typeof expression can only be compared to valid string literals, or other typeof expressions, but can not be compared to any other value.

Implementations

impl ValidTypeof[src]

pub fn new() -> Self[src]

Trait Implementations

impl Clone for ValidTypeof[src]

impl CstRule for ValidTypeof[src]

impl Debug for ValidTypeof[src]

impl Default for ValidTypeof[src]

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

impl Rule for ValidTypeof[src]

impl Serialize for ValidTypeof[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.