Skip to content

Commit 956747f

Browse files
josephfrazierslevithan
authored andcommitted
ESLint: Enforce array destructuring
This is a follow-up to #237
1 parent cc11a5d commit 956747f

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ module.exports = {
248248
"prefer-destructuring": [
249249
"error",
250250
{
251-
"array": false,
251+
"array": true,
252252
"object": true
253253
}
254254
],

src/xregexp.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ function XRegExp(pattern, flags) {
602602
pos += (result.matchLength || 1);
603603
} else {
604604
// Get the native token at the current position
605-
const token = XRegExp.exec(appliedPattern, nativeTokens[scope], pos, 'sticky')[0];
605+
const [token] = XRegExp.exec(appliedPattern, nativeTokens[scope], pos, 'sticky');
606606
output += token;
607607
pos += token.length;
608608
if (token === '[' && scope === defaultScope) {
@@ -1525,7 +1525,7 @@ fixed.replace = function(search, replacement) {
15251525
// Change the `args[0]` string primitive to a `String` object that can store
15261526
// properties. This really does need to use `String` as a constructor
15271527
args[0] = new String(args[0]);
1528-
groupsObject = args[0];
1528+
[groupsObject] = args;
15291529
}
15301530

15311531
// Store named backreferences

tools/scripts/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ const createBmpRange = (r, {addBrackets} = {addBrackets: true}) => {
8080
if (r.length === 0) {return '';}
8181

8282
const buf = [];
83-
let start = r[0];
84-
let end = r[0];
83+
let [start] = r;
84+
let [end] = r;
8585
let predict = start + 1;
8686
r = r.slice(1);
8787

0 commit comments

Comments
 (0)