forked from phoedos/pmd
add jdestructure assigments test
This commit is contained in:
@ -224,13 +224,13 @@ be misleading. Considering removing this unnecessary Block.
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
//Block[not(parent::FunctionNode or parent::IfStatement or parent::ForLoop or parent::ForInLoop
|
||||
or parent::WhileLoop or parent::DoLoop or parent::TryStatement or parent::CatchClause)
|
||||
and not(ancestor::VariableDeclarator) and not(ancestor::ImportDeclaration)]
|
||||
//Block[not(parent::FunctionNode or parent::IfStatement or parent::ForLoop or parent::ForInLoop or parent::ForOfLoop
|
||||
or parent::WhileLoop or parent::DoLoop or parent::TryStatement or parent::CatchClause
|
||||
or parent::VariableDeclarator or parent::ImportDeclaration)]
|
||||
|
|
||||
//Scope[not(parent::FunctionNode or parent::IfStatement or parent::ForLoop or parent::ForInLoop
|
||||
or parent::WhileLoop or parent::DoLoop or parent::TryStatement or parent::CatchClause)
|
||||
and not(ancestor::VariableDeclarator) and not(ancestor::ImportDeclaration)]
|
||||
//Scope[not(parent::FunctionNode or parent::IfStatement or parent::ForLoop or parent::ForInLoop or parent::ForOfLoop
|
||||
or parent::WhileLoop or parent::DoLoop or parent::TryStatement or parent::CatchClause
|
||||
or parent::VariableDeclarator or parent::ImportDeclaration)]
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
|
@ -42,6 +42,15 @@ for (var i in obj) {
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>Ok, for of</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
for (let value of obj) {
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>Ok, while</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
@ -192,4 +201,44 @@ try {
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>Ok, destructure assigments</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
import {foo} from 'bar'
|
||||
|
||||
const [a, b] = array;
|
||||
const [a, , b] = array;
|
||||
const [a = aDefault, b] = array;
|
||||
const [a, b, ...rest] = array;
|
||||
const [a, , b, ...rest] = array;
|
||||
const [a, b, ...{ pop, push }] = array;
|
||||
const [a, b, ...[c, d]] = array;
|
||||
|
||||
const { a, b } = obj;
|
||||
const { a: a1, b: b1 } = obj;
|
||||
const { a: a1 = aDefault, b = bDefault } = obj;
|
||||
const { a, b, ...rest } = obj;
|
||||
const { a: a1, b: b1, ...rest } = obj;
|
||||
const { [key]: a } = obj;
|
||||
|
||||
let a, b, a1, b1, c, d, rest, pop, push;
|
||||
[a, b] = array;
|
||||
[a, , b] = array;
|
||||
[a = aDefault, b] = array;
|
||||
[a, b, ...rest] = array;
|
||||
[a, , b, ...rest] = array;
|
||||
[a, b, ...{ pop, push }] = array;
|
||||
[a, b, ...[c, d]] = array;
|
||||
|
||||
({ a, b } = obj); // parentheses are required
|
||||
({ a: a1, b: b1 } = obj);
|
||||
({ a: a1 = aDefault, b = bDefault } = obj);
|
||||
({ a, b, ...rest } = obj);
|
||||
({ a: a1, b: b1, ...rest } = obj);
|
||||
|
||||
function fn( ({arg}) ){ return arg}
|
||||
]]></code>
|
||||
</test-code>
|
||||
</test-data>
|
||||
|
Reference in New Issue
Block a user