diff --git a/.eslintrc.js b/.eslintrc.js index 3a2a0d9c..8f49f081 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -248,7 +248,7 @@ module.exports = { "prefer-destructuring": [ "error", { - "array": false, + "array": true, "object": true } ], diff --git a/src/xregexp.js b/src/xregexp.js index 13cebc10..fe64743a 100644 --- a/src/xregexp.js +++ b/src/xregexp.js @@ -602,7 +602,7 @@ function XRegExp(pattern, flags) { pos += (result.matchLength || 1); } else { // Get the native token at the current position - const token = XRegExp.exec(appliedPattern, nativeTokens[scope], pos, 'sticky')[0]; + const [token] = XRegExp.exec(appliedPattern, nativeTokens[scope], pos, 'sticky'); output += token; pos += token.length; if (token === '[' && scope === defaultScope) { @@ -1525,7 +1525,7 @@ fixed.replace = function(search, replacement) { // Change the `args[0]` string primitive to a `String` object that can store // properties. This really does need to use `String` as a constructor args[0] = new String(args[0]); - groupsObject = args[0]; + [groupsObject] = args; } // Store named backreferences diff --git a/tools/scripts/utils.js b/tools/scripts/utils.js index 11b5e5d7..77a15c3f 100644 --- a/tools/scripts/utils.js +++ b/tools/scripts/utils.js @@ -80,8 +80,8 @@ const createBmpRange = (r, {addBrackets} = {addBrackets: true}) => { if (r.length === 0) {return '';} const buf = []; - let start = r[0]; - let end = r[0]; + let [start] = r; + let [end] = r; let predict = start + 1; r = r.slice(1);