[−][src]Struct rslint_core::groups::errors::GetterReturn
Disallow getter properties which do not always return a value.
Getters are special properties introduced in ES5 which call a function when a property is accessed. The value returned will be the value returned for the property access:
let obj = {
// Using object literal syntax
get foo() {
return 5;
}
}
// Using the defineProperty function
Object.defineProperty(obj, "foo", {
get: function() {
return 5;
}
})
Getters are expected to return a value, it is a bad practice to use getters to run some function without a return. This rule makes sure that does not happen and enforces a getter always returns a value.
Incorrect code examples
// The getter does not always return a value, it would not return anything
// if bar is falsey
let obj = {
get foo() {
if (bar) {
return foo;
}
}
}
Correct code examples
// The getter always returns a value
let obj = {
get foo() {
if (bar) {
return foo;
} else {
return bar;
}
}
}
Fields
allow_implicit: bool
Whether to allow implicitly returning undefined with return;
.
true
by default.
Implementations
impl GetterReturn
[src]
Trait Implementations
impl Clone for GetterReturn
[src]
fn clone(&self) -> GetterReturn
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl CstRule for GetterReturn
[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 GetterReturn
[src]
impl Default for GetterReturn
[src]
fn default() -> GetterReturn
[src]
impl<'de> Deserialize<'de> for GetterReturn
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Rule for GetterReturn
[src]
impl Serialize for GetterReturn
[src]
Auto Trait Implementations
impl RefUnwindSafe for GetterReturn
impl Send for GetterReturn
impl Sync for GetterReturn
impl Unpin for GetterReturn
impl UnwindSafe for GetterReturn
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>,