Struct rslint_core::groups::errors::NoUnexpectedMultiline [−][src]
pub struct NoUnexpectedMultiline {}
Expand description
Disallow confusing newlines in expressions.
JavaScript has automatic semicolon insertion, where newlines end statements, however, expressions can often span across newlines, therefore it can become a bit confusing at times and ambiguous. Take the following as an example:
let foo = bar
/bar/g.test("foo");
you would expect this to be a variable declaration and then a regex test, however, it is actually a division expression as such: `(bar / bar) / (g.test(“foo”)). This rule is aimed at preventing ambiguous and buggy expressions such like these. It disallows ambiguous tagged templates, property accesses, function calls, and division expressions.
Invalid Code Examples
var foo = bar
(1 || 2).baz();
var foo = 'bar'
[1, 2, 3].forEach(addNumber);
let x = function() {}
`foo`
let x = function() {}
x
`bar`
let x = foo
/regex/g.test(bar)
Correct Code Examples
var foo = bar;
(1 || 2).baz();
var foo = 'bar';
[1, 2, 3].forEach(addNumber);
let x = function() {};
`foo`
let x = function() {};
x;
`bar`
let x = foo;
/regex/g.test(bar)
Implementations
Trait Implementations
Check an individual node in the syntax tree.
You can use the match_ast
macro to make matching a node to an ast node easier.
The reason this uses nodes and not a visitor is because nodes are more flexible,
converting them to an AST node has zero cost and you can easily traverse surrounding nodes.
Defaults to doing nothing. Read more
Check an individual token in the syntax tree. Defaults to doing nothing. Read more
Check the root of the tree one time.
This method is guaranteed to only be called once.
The root’s kind will be either SCRIPT
or MODULE
.
Defaults to doing nothing. Read more
Returns the “default value” for a type. Read more
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
A list of tags present on this rule. Empty by default.
Whether this rule is recommended, this is a simple helper around Self::tags
.
Auto Trait Implementations
impl RefUnwindSafe for NoUnexpectedMultiline
impl Send for NoUnexpectedMultiline
impl Sync for NoUnexpectedMultiline
impl Unpin for NoUnexpectedMultiline
impl UnwindSafe for NoUnexpectedMultiline
Blanket Implementations
Mutably borrows from an owned value. Read more
Whether this implementor has acknowledged the 1.1.0 update to
unerase
’s documented implementation requirements. Read more