Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure the initializer of a destructuring declaration is always inclu…
…ded if the id is included.
- Loading branch information
1 parent
8a2949e
commit 250c2b2
Showing
3 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const assert = require('assert'); | ||
|
||
module.exports = { | ||
description: 'includes for-loop parameters', | ||
exports({ checkObject, checkArray }) { | ||
assert.strictEqual(checkObject({ foo: 1 }), 1, 'object'); | ||
assert.strictEqual(checkArray([2]), 2, 'array'); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export function checkObject(p) { | ||
return getFromObjectInLoop(p); | ||
} | ||
|
||
export function checkArray(p) { | ||
return getFromArrayInLoop(p); | ||
} | ||
|
||
function getFromObjectInLoop(path) { | ||
for (let { foo } = path;;) { | ||
return foo; | ||
} | ||
} | ||
|
||
function getFromArrayInLoop(path) { | ||
for (let [ foo ] = path;;) { | ||
return foo; | ||
} | ||
} |