eslint-linter-browserify 8.45.0 → 8.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. package/linter.cjs +1170 -345
  2. package/linter.js +1170 -345
  3. package/linter.min.js +3 -3
  4. package/linter.mjs +1170 -345
  5. package/package.json +4 -4
package/linter.cjs CHANGED
@@ -6823,7 +6823,7 @@ function requireEslintScope () {
6823
6823
 
6824
6824
  /* vim: set sw=4 ts=4 et tw=80 : */
6825
6825
 
6826
- const version = "7.2.0";
6826
+ const version = "7.2.2";
6827
6827
 
6828
6828
  /*
6829
6829
  Copyright (C) 2012-2014 Yusuke Suzuki <utatane.tea@gmail.com>
@@ -14140,7 +14140,6 @@ function requireEspree () {
14140
14140
  * @fileoverview Translates tokens between Acorn format and Esprima format.
14141
14141
  * @author Nicholas C. Zakas
14142
14142
  */
14143
- /* eslint no-underscore-dangle: 0 */
14144
14143
 
14145
14144
  //------------------------------------------------------------------------------
14146
14145
  // Requirements
@@ -14318,8 +14317,7 @@ function requireEspree () {
14318
14317
  */
14319
14318
  onToken(token, extra) {
14320
14319
 
14321
- const that = this,
14322
- tt = this._acornTokTypes,
14320
+ const tt = this._acornTokTypes,
14323
14321
  tokens = extra.tokens,
14324
14322
  templateTokens = this._tokens;
14325
14323
 
@@ -14329,10 +14327,10 @@ function requireEspree () {
14329
14327
  * @returns {void}
14330
14328
  * @private
14331
14329
  */
14332
- function translateTemplateTokens() {
14333
- tokens.push(convertTemplatePart(that._tokens, that._code));
14334
- that._tokens = [];
14335
- }
14330
+ const translateTemplateTokens = () => {
14331
+ tokens.push(convertTemplatePart(this._tokens, this._code));
14332
+ this._tokens = [];
14333
+ };
14336
14334
 
14337
14335
  if (token.type === tt.eof) {
14338
14336
 
@@ -14520,7 +14518,7 @@ function requireEspree () {
14520
14518
  });
14521
14519
  }
14522
14520
 
14523
- /* eslint-disable no-param-reassign*/
14521
+ /* eslint no-param-reassign: 0 -- stylistic choice */
14524
14522
 
14525
14523
 
14526
14524
  const STATE = Symbol("espree's internal state");
@@ -14629,7 +14627,7 @@ function requireEspree () {
14629
14627
  allowReturnOutsideFunction: options.allowReturnOutsideFunction,
14630
14628
 
14631
14629
  // Collect tokens
14632
- onToken: token => {
14630
+ onToken(token) {
14633
14631
  if (tokenTranslator) {
14634
14632
 
14635
14633
  // Use `tokens`, `ecmaVersion`, and `jsxAttrValueToken` in the state.
@@ -14641,7 +14639,7 @@ function requireEspree () {
14641
14639
  },
14642
14640
 
14643
14641
  // Collect comments
14644
- onComment: (block, text, start, end, startLoc, endLoc) => {
14642
+ onComment(block, text, start, end, startLoc, endLoc) {
14645
14643
  if (state.comments) {
14646
14644
  const comment = convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc, code);
14647
14645
 
@@ -14834,7 +14832,7 @@ function requireEspree () {
14834
14832
  * on extra so that when tokens are converted, the next token will be switched
14835
14833
  * to JSXText via onToken.
14836
14834
  */
14837
- jsx_readString(quote) { // eslint-disable-line camelcase
14835
+ jsx_readString(quote) { // eslint-disable-line camelcase -- required by API
14838
14836
  const result = super.jsx_readString(quote);
14839
14837
 
14840
14838
  if (this.type === tokTypes.string) {
@@ -14867,64 +14865,9 @@ function requireEspree () {
14867
14865
  };
14868
14866
  };
14869
14867
 
14870
- const version$1 = "9.6.0";
14868
+ const version$1 = "9.6.1";
14871
14869
 
14872
- /**
14873
- * @fileoverview Main Espree file that converts Acorn into Esprima output.
14874
- *
14875
- * This file contains code from the following MIT-licensed projects:
14876
- * 1. Acorn
14877
- * 2. Babylon
14878
- * 3. Babel-ESLint
14879
- *
14880
- * This file also contains code from Esprima, which is BSD licensed.
14881
- *
14882
- * Acorn is Copyright 2012-2015 Acorn Contributors (https://github.com/marijnh/acorn/blob/master/AUTHORS)
14883
- * Babylon is Copyright 2014-2015 various contributors (https://github.com/babel/babel/blob/master/packages/babylon/AUTHORS)
14884
- * Babel-ESLint is Copyright 2014-2015 Sebastian McKenzie <sebmck@gmail.com>
14885
- *
14886
- * Redistribution and use in source and binary forms, with or without
14887
- * modification, are permitted provided that the following conditions are met:
14888
- *
14889
- * * Redistributions of source code must retain the above copyright
14890
- * notice, this list of conditions and the following disclaimer.
14891
- * * Redistributions in binary form must reproduce the above copyright
14892
- * notice, this list of conditions and the following disclaimer in the
14893
- * documentation and/or other materials provided with the distribution.
14894
- *
14895
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14896
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14897
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
14898
- * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
14899
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
14900
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
14901
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
14902
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
14903
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
14904
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14905
- *
14906
- * Esprima is Copyright (c) jQuery Foundation, Inc. and Contributors, All Rights Reserved.
14907
- *
14908
- * Redistribution and use in source and binary forms, with or without
14909
- * modification, are permitted provided that the following conditions are met:
14910
- *
14911
- * * Redistributions of source code must retain the above copyright
14912
- * notice, this list of conditions and the following disclaimer.
14913
- * * Redistributions in binary form must reproduce the above copyright
14914
- * notice, this list of conditions and the following disclaimer in the
14915
- * documentation and/or other materials provided with the distribution.
14916
- *
14917
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14918
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14919
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
14920
- * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
14921
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
14922
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
14923
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
14924
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
14925
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
14926
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14927
- */
14870
+ /* eslint-disable jsdoc/no-multi-asterisks -- needed to preserve original formatting of licences */
14928
14871
 
14929
14872
 
14930
14873
  // To initialize lazily.
@@ -14974,7 +14917,7 @@ function requireEspree () {
14974
14917
 
14975
14918
  // Ensure to collect tokens.
14976
14919
  if (!options || options.tokens !== true) {
14977
- options = Object.assign({}, options, { tokens: true }); // eslint-disable-line no-param-reassign
14920
+ options = Object.assign({}, options, { tokens: true }); // eslint-disable-line no-param-reassign -- stylistic choice
14978
14921
  }
14979
14922
 
14980
14923
  return new Parser(options, code).tokenize();
@@ -17038,7 +16981,7 @@ function requireLodash_merge () {
17038
16981
  }
17039
16982
 
17040
16983
  var name$1 = "eslint";
17041
- var version$1 = "8.45.0";
16984
+ var version$1 = "8.46.0";
17042
16985
  var author = "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>";
17043
16986
  var description$3 = "An AST-based pattern checker for JavaScript.";
17044
16987
  var bin = {
@@ -17086,21 +17029,21 @@ var homepage$1 = "https://eslint.org";
17086
17029
  var bugs = "https://github.com/eslint/eslint/issues/";
17087
17030
  var dependencies$3 = {
17088
17031
  "@eslint-community/eslint-utils": "^4.2.0",
17089
- "@eslint-community/regexpp": "^4.4.0",
17090
- "@eslint/eslintrc": "^2.1.0",
17091
- "@eslint/js": "8.44.0",
17032
+ "@eslint-community/regexpp": "^4.6.1",
17033
+ "@eslint/eslintrc": "^2.1.1",
17034
+ "@eslint/js": "^8.46.0",
17092
17035
  "@humanwhocodes/config-array": "^0.11.10",
17093
17036
  "@humanwhocodes/module-importer": "^1.0.1",
17094
17037
  "@nodelib/fs.walk": "^1.2.8",
17095
- ajv: "^6.10.0",
17038
+ ajv: "^6.12.4",
17096
17039
  chalk: "^4.0.0",
17097
17040
  "cross-spawn": "^7.0.2",
17098
17041
  debug: "^4.3.2",
17099
17042
  doctrine: "^3.0.0",
17100
17043
  "escape-string-regexp": "^4.0.0",
17101
- "eslint-scope": "^7.2.0",
17102
- "eslint-visitor-keys": "^3.4.1",
17103
- espree: "^9.6.0",
17044
+ "eslint-scope": "^7.2.2",
17045
+ "eslint-visitor-keys": "^3.4.2",
17046
+ espree: "^9.6.1",
17104
17047
  esquery: "^1.4.2",
17105
17048
  esutils: "^2.0.2",
17106
17049
  "fast-deep-equal": "^3.1.3",
@@ -77778,6 +77721,8 @@ function requireRegexpp () {
77778
77721
  __proto__: null
77779
77722
  });
77780
77723
 
77724
+ const latestEcmaVersion = 2024;
77725
+
77781
77726
  let largeIdStartRanges = undefined;
77782
77727
  let largeIdContinueRanges = undefined;
77783
77728
  function isIdStart(cp) {
@@ -77844,13 +77789,14 @@ function requireRegexpp () {
77844
77789
  }
77845
77790
 
77846
77791
  class DataSet {
77847
- constructor(raw2018, raw2019, raw2020, raw2021, raw2022, raw2023) {
77792
+ constructor(raw2018, raw2019, raw2020, raw2021, raw2022, raw2023, raw2024) {
77848
77793
  this._raw2018 = raw2018;
77849
77794
  this._raw2019 = raw2019;
77850
77795
  this._raw2020 = raw2020;
77851
77796
  this._raw2021 = raw2021;
77852
77797
  this._raw2022 = raw2022;
77853
77798
  this._raw2023 = raw2023;
77799
+ this._raw2024 = raw2024;
77854
77800
  }
77855
77801
  get es2018() {
77856
77802
  var _a;
@@ -77876,12 +77822,16 @@ function requireRegexpp () {
77876
77822
  var _a;
77877
77823
  return ((_a = this._set2023) !== null && _a !== void 0 ? _a : (this._set2023 = new Set(this._raw2023.split(" "))));
77878
77824
  }
77825
+ get es2024() {
77826
+ var _a;
77827
+ return ((_a = this._set2024) !== null && _a !== void 0 ? _a : (this._set2024 = new Set(this._raw2024.split(" "))));
77828
+ }
77879
77829
  }
77880
77830
  const gcNameSet = new Set(["General_Category", "gc"]);
77881
77831
  const scNameSet = new Set(["Script", "Script_Extensions", "sc", "scx"]);
77882
- const gcValueSets = new DataSet("C Cased_Letter Cc Cf Close_Punctuation Cn Co Combining_Mark Connector_Punctuation Control Cs Currency_Symbol Dash_Punctuation Decimal_Number Enclosing_Mark Final_Punctuation Format Initial_Punctuation L LC Letter Letter_Number Line_Separator Ll Lm Lo Lowercase_Letter Lt Lu M Mark Math_Symbol Mc Me Mn Modifier_Letter Modifier_Symbol N Nd Nl No Nonspacing_Mark Number Open_Punctuation Other Other_Letter Other_Number Other_Punctuation Other_Symbol P Paragraph_Separator Pc Pd Pe Pf Pi Po Private_Use Ps Punctuation S Sc Separator Sk Sm So Space_Separator Spacing_Mark Surrogate Symbol Titlecase_Letter Unassigned Uppercase_Letter Z Zl Zp Zs cntrl digit punct", "", "", "", "", "");
77883
- const scValueSets = new DataSet("Adlam Adlm Aghb Ahom Anatolian_Hieroglyphs Arab Arabic Armenian Armi Armn Avestan Avst Bali Balinese Bamu Bamum Bass Bassa_Vah Batak Batk Beng Bengali Bhaiksuki Bhks Bopo Bopomofo Brah Brahmi Brai Braille Bugi Buginese Buhd Buhid Cakm Canadian_Aboriginal Cans Cari Carian Caucasian_Albanian Chakma Cham Cher Cherokee Common Copt Coptic Cprt Cuneiform Cypriot Cyrillic Cyrl Deseret Deva Devanagari Dsrt Dupl Duployan Egyp Egyptian_Hieroglyphs Elba Elbasan Ethi Ethiopic Geor Georgian Glag Glagolitic Gonm Goth Gothic Gran Grantha Greek Grek Gujarati Gujr Gurmukhi Guru Han Hang Hangul Hani Hano Hanunoo Hatr Hatran Hebr Hebrew Hira Hiragana Hluw Hmng Hung Imperial_Aramaic Inherited Inscriptional_Pahlavi Inscriptional_Parthian Ital Java Javanese Kaithi Kali Kana Kannada Katakana Kayah_Li Khar Kharoshthi Khmer Khmr Khoj Khojki Khudawadi Knda Kthi Lana Lao Laoo Latin Latn Lepc Lepcha Limb Limbu Lina Linb Linear_A Linear_B Lisu Lyci Lycian Lydi Lydian Mahajani Mahj Malayalam Mand Mandaic Mani Manichaean Marc Marchen Masaram_Gondi Meetei_Mayek Mend Mende_Kikakui Merc Mero Meroitic_Cursive Meroitic_Hieroglyphs Miao Mlym Modi Mong Mongolian Mro Mroo Mtei Mult Multani Myanmar Mymr Nabataean Narb Nbat New_Tai_Lue Newa Nko Nkoo Nshu Nushu Ogam Ogham Ol_Chiki Olck Old_Hungarian Old_Italic Old_North_Arabian Old_Permic Old_Persian Old_South_Arabian Old_Turkic Oriya Orkh Orya Osage Osge Osma Osmanya Pahawh_Hmong Palm Palmyrene Pau_Cin_Hau Pauc Perm Phag Phags_Pa Phli Phlp Phnx Phoenician Plrd Prti Psalter_Pahlavi Qaac Qaai Rejang Rjng Runic Runr Samaritan Samr Sarb Saur Saurashtra Sgnw Sharada Shavian Shaw Shrd Sidd Siddham SignWriting Sind Sinh Sinhala Sora Sora_Sompeng Soyo Soyombo Sund Sundanese Sylo Syloti_Nagri Syrc Syriac Tagalog Tagb Tagbanwa Tai_Le Tai_Tham Tai_Viet Takr Takri Tale Talu Tamil Taml Tang Tangut Tavt Telu Telugu Tfng Tglg Thaa Thaana Thai Tibetan Tibt Tifinagh Tirh Tirhuta Ugar Ugaritic Vai Vaii Wara Warang_Citi Xpeo Xsux Yi Yiii Zanabazar_Square Zanb Zinh Zyyy", "Dogr Dogra Gong Gunjala_Gondi Hanifi_Rohingya Maka Makasar Medefaidrin Medf Old_Sogdian Rohg Sogd Sogdian Sogo", "Elym Elymaic Hmnp Nand Nandinagari Nyiakeng_Puachue_Hmong Wancho Wcho", "Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi", "Cpmn Cypro_Minoan Old_Uyghur Ougr Tangsa Tnsa Toto Vith Vithkuqi", "");
77884
- const binPropertySets = new DataSet("AHex ASCII ASCII_Hex_Digit Alpha Alphabetic Any Assigned Bidi_C Bidi_Control Bidi_M Bidi_Mirrored CI CWCF CWCM CWKCF CWL CWT CWU Case_Ignorable Cased Changes_When_Casefolded Changes_When_Casemapped Changes_When_Lowercased Changes_When_NFKC_Casefolded Changes_When_Titlecased Changes_When_Uppercased DI Dash Default_Ignorable_Code_Point Dep Deprecated Dia Diacritic Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Ext Extender Gr_Base Gr_Ext Grapheme_Base Grapheme_Extend Hex Hex_Digit IDC IDS IDSB IDST IDS_Binary_Operator IDS_Trinary_Operator ID_Continue ID_Start Ideo Ideographic Join_C Join_Control LOE Logical_Order_Exception Lower Lowercase Math NChar Noncharacter_Code_Point Pat_Syn Pat_WS Pattern_Syntax Pattern_White_Space QMark Quotation_Mark RI Radical Regional_Indicator SD STerm Sentence_Terminal Soft_Dotted Term Terminal_Punctuation UIdeo Unified_Ideograph Upper Uppercase VS Variation_Selector White_Space XIDC XIDS XID_Continue XID_Start space", "Extended_Pictographic", "", "EBase EComp EMod EPres ExtPict", "", "");
77832
+ const gcValueSets = new DataSet("C Cased_Letter Cc Cf Close_Punctuation Cn Co Combining_Mark Connector_Punctuation Control Cs Currency_Symbol Dash_Punctuation Decimal_Number Enclosing_Mark Final_Punctuation Format Initial_Punctuation L LC Letter Letter_Number Line_Separator Ll Lm Lo Lowercase_Letter Lt Lu M Mark Math_Symbol Mc Me Mn Modifier_Letter Modifier_Symbol N Nd Nl No Nonspacing_Mark Number Open_Punctuation Other Other_Letter Other_Number Other_Punctuation Other_Symbol P Paragraph_Separator Pc Pd Pe Pf Pi Po Private_Use Ps Punctuation S Sc Separator Sk Sm So Space_Separator Spacing_Mark Surrogate Symbol Titlecase_Letter Unassigned Uppercase_Letter Z Zl Zp Zs cntrl digit punct", "", "", "", "", "", "");
77833
+ const scValueSets = new DataSet("Adlam Adlm Aghb Ahom Anatolian_Hieroglyphs Arab Arabic Armenian Armi Armn Avestan Avst Bali Balinese Bamu Bamum Bass Bassa_Vah Batak Batk Beng Bengali Bhaiksuki Bhks Bopo Bopomofo Brah Brahmi Brai Braille Bugi Buginese Buhd Buhid Cakm Canadian_Aboriginal Cans Cari Carian Caucasian_Albanian Chakma Cham Cher Cherokee Common Copt Coptic Cprt Cuneiform Cypriot Cyrillic Cyrl Deseret Deva Devanagari Dsrt Dupl Duployan Egyp Egyptian_Hieroglyphs Elba Elbasan Ethi Ethiopic Geor Georgian Glag Glagolitic Gonm Goth Gothic Gran Grantha Greek Grek Gujarati Gujr Gurmukhi Guru Han Hang Hangul Hani Hano Hanunoo Hatr Hatran Hebr Hebrew Hira Hiragana Hluw Hmng Hung Imperial_Aramaic Inherited Inscriptional_Pahlavi Inscriptional_Parthian Ital Java Javanese Kaithi Kali Kana Kannada Katakana Kayah_Li Khar Kharoshthi Khmer Khmr Khoj Khojki Khudawadi Knda Kthi Lana Lao Laoo Latin Latn Lepc Lepcha Limb Limbu Lina Linb Linear_A Linear_B Lisu Lyci Lycian Lydi Lydian Mahajani Mahj Malayalam Mand Mandaic Mani Manichaean Marc Marchen Masaram_Gondi Meetei_Mayek Mend Mende_Kikakui Merc Mero Meroitic_Cursive Meroitic_Hieroglyphs Miao Mlym Modi Mong Mongolian Mro Mroo Mtei Mult Multani Myanmar Mymr Nabataean Narb Nbat New_Tai_Lue Newa Nko Nkoo Nshu Nushu Ogam Ogham Ol_Chiki Olck Old_Hungarian Old_Italic Old_North_Arabian Old_Permic Old_Persian Old_South_Arabian Old_Turkic Oriya Orkh Orya Osage Osge Osma Osmanya Pahawh_Hmong Palm Palmyrene Pau_Cin_Hau Pauc Perm Phag Phags_Pa Phli Phlp Phnx Phoenician Plrd Prti Psalter_Pahlavi Qaac Qaai Rejang Rjng Runic Runr Samaritan Samr Sarb Saur Saurashtra Sgnw Sharada Shavian Shaw Shrd Sidd Siddham SignWriting Sind Sinh Sinhala Sora Sora_Sompeng Soyo Soyombo Sund Sundanese Sylo Syloti_Nagri Syrc Syriac Tagalog Tagb Tagbanwa Tai_Le Tai_Tham Tai_Viet Takr Takri Tale Talu Tamil Taml Tang Tangut Tavt Telu Telugu Tfng Tglg Thaa Thaana Thai Tibetan Tibt Tifinagh Tirh Tirhuta Ugar Ugaritic Vai Vaii Wara Warang_Citi Xpeo Xsux Yi Yiii Zanabazar_Square Zanb Zinh Zyyy", "Dogr Dogra Gong Gunjala_Gondi Hanifi_Rohingya Maka Makasar Medefaidrin Medf Old_Sogdian Rohg Sogd Sogdian Sogo", "Elym Elymaic Hmnp Nand Nandinagari Nyiakeng_Puachue_Hmong Wancho Wcho", "Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi", "Cpmn Cypro_Minoan Old_Uyghur Ougr Tangsa Tnsa Toto Vith Vithkuqi", "Hrkt Katakana_Or_Hiragana Kawi Nag_Mundari Nagm Unknown Zzzz", "");
77834
+ const binPropertySets = new DataSet("AHex ASCII ASCII_Hex_Digit Alpha Alphabetic Any Assigned Bidi_C Bidi_Control Bidi_M Bidi_Mirrored CI CWCF CWCM CWKCF CWL CWT CWU Case_Ignorable Cased Changes_When_Casefolded Changes_When_Casemapped Changes_When_Lowercased Changes_When_NFKC_Casefolded Changes_When_Titlecased Changes_When_Uppercased DI Dash Default_Ignorable_Code_Point Dep Deprecated Dia Diacritic Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Ext Extender Gr_Base Gr_Ext Grapheme_Base Grapheme_Extend Hex Hex_Digit IDC IDS IDSB IDST IDS_Binary_Operator IDS_Trinary_Operator ID_Continue ID_Start Ideo Ideographic Join_C Join_Control LOE Logical_Order_Exception Lower Lowercase Math NChar Noncharacter_Code_Point Pat_Syn Pat_WS Pattern_Syntax Pattern_White_Space QMark Quotation_Mark RI Radical Regional_Indicator SD STerm Sentence_Terminal Soft_Dotted Term Terminal_Punctuation UIdeo Unified_Ideograph Upper Uppercase VS Variation_Selector White_Space XIDC XIDS XID_Continue XID_Start space", "Extended_Pictographic", "", "EBase EComp EMod EPres ExtPict", "", "", "");
77885
77835
  function isValidUnicodeProperty(version, name, value) {
77886
77836
  if (gcNameSet.has(name)) {
77887
77837
  return version >= 2018 && gcValueSets.es2018.has(value);
@@ -77891,7 +77841,8 @@ function requireRegexpp () {
77891
77841
  (version >= 2019 && scValueSets.es2019.has(value)) ||
77892
77842
  (version >= 2020 && scValueSets.es2020.has(value)) ||
77893
77843
  (version >= 2021 && scValueSets.es2021.has(value)) ||
77894
- (version >= 2022 && scValueSets.es2022.has(value)));
77844
+ (version >= 2022 && scValueSets.es2022.has(value)) ||
77845
+ (version >= 2023 && scValueSets.es2023.has(value)));
77895
77846
  }
77896
77847
  return false;
77897
77848
  }
@@ -77908,7 +77859,10 @@ function requireRegexpp () {
77908
77859
  const FORM_FEED = 0x0c;
77909
77860
  const CARRIAGE_RETURN = 0x0d;
77910
77861
  const EXCLAMATION_MARK = 0x21;
77862
+ const NUMBER_SIGN = 0x23;
77911
77863
  const DOLLAR_SIGN = 0x24;
77864
+ const PERCENT_SIGN = 0x25;
77865
+ const AMPERSAND = 0x26;
77912
77866
  const LEFT_PARENTHESIS = 0x28;
77913
77867
  const RIGHT_PARENTHESIS = 0x29;
77914
77868
  const ASTERISK = 0x2a;
@@ -77922,10 +77876,12 @@ function requireRegexpp () {
77922
77876
  const DIGIT_SEVEN = 0x37;
77923
77877
  const DIGIT_NINE = 0x39;
77924
77878
  const COLON = 0x3a;
77879
+ const SEMICOLON = 0x3b;
77925
77880
  const LESS_THAN_SIGN = 0x3c;
77926
77881
  const EQUALS_SIGN = 0x3d;
77927
77882
  const GREATER_THAN_SIGN = 0x3e;
77928
77883
  const QUESTION_MARK = 0x3f;
77884
+ const COMMERCIAL_AT = 0x40;
77929
77885
  const LATIN_CAPITAL_LETTER_A = 0x41;
77930
77886
  const LATIN_CAPITAL_LETTER_B = 0x42;
77931
77887
  const LATIN_CAPITAL_LETTER_D = 0x44;
@@ -77946,6 +77902,7 @@ function requireRegexpp () {
77946
77902
  const LATIN_SMALL_LETTER_M = 0x6d;
77947
77903
  const LATIN_SMALL_LETTER_N = 0x6e;
77948
77904
  const LATIN_SMALL_LETTER_P = 0x70;
77905
+ const LATIN_SMALL_LETTER_Q = 0x71;
77949
77906
  const LATIN_SMALL_LETTER_R = 0x72;
77950
77907
  const LATIN_SMALL_LETTER_S = 0x73;
77951
77908
  const LATIN_SMALL_LETTER_T = 0x74;
@@ -77959,9 +77916,11 @@ function requireRegexpp () {
77959
77916
  const REVERSE_SOLIDUS = 0x5c;
77960
77917
  const RIGHT_SQUARE_BRACKET = 0x5d;
77961
77918
  const CIRCUMFLEX_ACCENT = 0x5e;
77919
+ const GRAVE_ACCENT = 0x60;
77962
77920
  const LEFT_CURLY_BRACKET = 0x7b;
77963
77921
  const VERTICAL_LINE = 0x7c;
77964
77922
  const RIGHT_CURLY_BRACKET = 0x7d;
77923
+ const TILDE = 0x7e;
77965
77924
  const ZERO_WIDTH_NON_JOINER = 0x200c;
77966
77925
  const ZERO_WIDTH_JOINER = 0x200d;
77967
77926
  const LINE_SEPARATOR = 0x2028;
@@ -78116,41 +78075,120 @@ function requireRegexpp () {
78116
78075
  }
78117
78076
 
78118
78077
  class RegExpSyntaxError extends SyntaxError {
78119
- constructor(source, uFlag, index, message) {
78120
- if (source) {
78121
- if (!source.startsWith("/")) {
78122
- source = `/${source}/${uFlag ? "u" : ""}`;
78078
+ constructor(srcCtx, flags, index, message) {
78079
+ let source = "";
78080
+ if (srcCtx.kind === "literal") {
78081
+ const literal = srcCtx.source.slice(srcCtx.start, srcCtx.end);
78082
+ if (literal) {
78083
+ source = `: ${literal}`;
78123
78084
  }
78124
- source = `: ${source}`;
78085
+ }
78086
+ else if (srcCtx.kind === "pattern") {
78087
+ const pattern = srcCtx.source.slice(srcCtx.start, srcCtx.end);
78088
+ const flagsText = `${flags.unicode ? "u" : ""}${flags.unicodeSets ? "v" : ""}`;
78089
+ source = `: /${pattern}/${flagsText}`;
78125
78090
  }
78126
78091
  super(`Invalid regular expression${source}: ${message}`);
78127
78092
  this.index = index;
78128
78093
  }
78129
78094
  }
78130
78095
 
78096
+ const binPropertyOfStringSets = new Set([
78097
+ "Basic_Emoji",
78098
+ "Emoji_Keycap_Sequence",
78099
+ "RGI_Emoji_Modifier_Sequence",
78100
+ "RGI_Emoji_Flag_Sequence",
78101
+ "RGI_Emoji_Tag_Sequence",
78102
+ "RGI_Emoji_ZWJ_Sequence",
78103
+ "RGI_Emoji",
78104
+ ]);
78105
+ function isValidLoneUnicodePropertyOfString(version, value) {
78106
+ return version >= 2024 && binPropertyOfStringSets.has(value);
78107
+ }
78108
+
78109
+ const SYNTAX_CHARACTER = new Set([
78110
+ CIRCUMFLEX_ACCENT,
78111
+ DOLLAR_SIGN,
78112
+ REVERSE_SOLIDUS,
78113
+ FULL_STOP,
78114
+ ASTERISK,
78115
+ PLUS_SIGN,
78116
+ QUESTION_MARK,
78117
+ LEFT_PARENTHESIS,
78118
+ RIGHT_PARENTHESIS,
78119
+ LEFT_SQUARE_BRACKET,
78120
+ RIGHT_SQUARE_BRACKET,
78121
+ LEFT_CURLY_BRACKET,
78122
+ RIGHT_CURLY_BRACKET,
78123
+ VERTICAL_LINE,
78124
+ ]);
78125
+ const CLASS_SET_RESERVED_DOUBLE_PUNCTUATOR_CHARACTER = new Set([
78126
+ AMPERSAND,
78127
+ EXCLAMATION_MARK,
78128
+ NUMBER_SIGN,
78129
+ DOLLAR_SIGN,
78130
+ PERCENT_SIGN,
78131
+ ASTERISK,
78132
+ PLUS_SIGN,
78133
+ COMMA,
78134
+ FULL_STOP,
78135
+ COLON,
78136
+ SEMICOLON,
78137
+ LESS_THAN_SIGN,
78138
+ EQUALS_SIGN,
78139
+ GREATER_THAN_SIGN,
78140
+ QUESTION_MARK,
78141
+ COMMERCIAL_AT,
78142
+ CIRCUMFLEX_ACCENT,
78143
+ GRAVE_ACCENT,
78144
+ TILDE,
78145
+ ]);
78146
+ const CLASS_SET_SYNTAX_CHARACTER = new Set([
78147
+ LEFT_PARENTHESIS,
78148
+ RIGHT_PARENTHESIS,
78149
+ LEFT_SQUARE_BRACKET,
78150
+ RIGHT_SQUARE_BRACKET,
78151
+ LEFT_CURLY_BRACKET,
78152
+ RIGHT_CURLY_BRACKET,
78153
+ SOLIDUS,
78154
+ HYPHEN_MINUS,
78155
+ REVERSE_SOLIDUS,
78156
+ VERTICAL_LINE,
78157
+ ]);
78158
+ const CLASS_SET_RESERVED_PUNCTUATOR = new Set([
78159
+ AMPERSAND,
78160
+ HYPHEN_MINUS,
78161
+ EXCLAMATION_MARK,
78162
+ NUMBER_SIGN,
78163
+ PERCENT_SIGN,
78164
+ COMMA,
78165
+ COLON,
78166
+ SEMICOLON,
78167
+ LESS_THAN_SIGN,
78168
+ EQUALS_SIGN,
78169
+ GREATER_THAN_SIGN,
78170
+ COMMERCIAL_AT,
78171
+ GRAVE_ACCENT,
78172
+ TILDE,
78173
+ ]);
78131
78174
  function isSyntaxCharacter(cp) {
78132
- return (cp === CIRCUMFLEX_ACCENT ||
78133
- cp === DOLLAR_SIGN ||
78134
- cp === REVERSE_SOLIDUS ||
78135
- cp === FULL_STOP ||
78136
- cp === ASTERISK ||
78137
- cp === PLUS_SIGN ||
78138
- cp === QUESTION_MARK ||
78139
- cp === LEFT_PARENTHESIS ||
78140
- cp === RIGHT_PARENTHESIS ||
78141
- cp === LEFT_SQUARE_BRACKET ||
78142
- cp === RIGHT_SQUARE_BRACKET ||
78143
- cp === LEFT_CURLY_BRACKET ||
78144
- cp === RIGHT_CURLY_BRACKET ||
78145
- cp === VERTICAL_LINE);
78146
- }
78147
- function isRegExpIdentifierStart(cp) {
78175
+ return SYNTAX_CHARACTER.has(cp);
78176
+ }
78177
+ function isClassSetReservedDoublePunctuatorCharacter(cp) {
78178
+ return CLASS_SET_RESERVED_DOUBLE_PUNCTUATOR_CHARACTER.has(cp);
78179
+ }
78180
+ function isClassSetSyntaxCharacter(cp) {
78181
+ return CLASS_SET_SYNTAX_CHARACTER.has(cp);
78182
+ }
78183
+ function isClassSetReservedPunctuator(cp) {
78184
+ return CLASS_SET_RESERVED_PUNCTUATOR.has(cp);
78185
+ }
78186
+ function isIdentifierStartChar(cp) {
78148
78187
  return isIdStart(cp) || cp === DOLLAR_SIGN || cp === LOW_LINE;
78149
78188
  }
78150
- function isRegExpIdentifierPart(cp) {
78189
+ function isIdentifierPartChar(cp) {
78151
78190
  return (isIdContinue(cp) ||
78152
78191
  cp === DOLLAR_SIGN ||
78153
- cp === LOW_LINE ||
78154
78192
  cp === ZERO_WIDTH_NON_JOINER ||
78155
78193
  cp === ZERO_WIDTH_JOINER);
78156
78194
  }
@@ -78163,29 +78201,36 @@ function requireRegexpp () {
78163
78201
  class RegExpValidator {
78164
78202
  constructor(options) {
78165
78203
  this._reader = new Reader();
78166
- this._uFlag = false;
78204
+ this._unicodeMode = false;
78205
+ this._unicodeSetsMode = false;
78167
78206
  this._nFlag = false;
78168
78207
  this._lastIntValue = 0;
78169
- this._lastMinValue = 0;
78170
- this._lastMaxValue = 0;
78208
+ this._lastRange = {
78209
+ min: 0,
78210
+ max: Number.POSITIVE_INFINITY,
78211
+ };
78171
78212
  this._lastStrValue = "";
78172
- this._lastKeyValue = "";
78173
- this._lastValValue = "";
78174
78213
  this._lastAssertionIsQuantifiable = false;
78175
78214
  this._numCapturingParens = 0;
78176
78215
  this._groupNames = new Set();
78177
78216
  this._backreferenceNames = new Set();
78217
+ this._srcCtx = null;
78178
78218
  this._options = options !== null && options !== void 0 ? options : {};
78179
78219
  }
78180
78220
  validateLiteral(source, start = 0, end = source.length) {
78181
- this._uFlag = this._nFlag = false;
78221
+ this._srcCtx = { source, start, end, kind: "literal" };
78222
+ this._unicodeSetsMode = this._unicodeMode = this._nFlag = false;
78182
78223
  this.reset(source, start, end);
78183
78224
  this.onLiteralEnter(start);
78184
78225
  if (this.eat(SOLIDUS) && this.eatRegExpBody() && this.eat(SOLIDUS)) {
78185
78226
  const flagStart = this.index;
78186
- const uFlag = source.includes("u", flagStart);
78187
- this.validateFlags(source, flagStart, end);
78188
- this.validatePattern(source, start + 1, flagStart - 1, uFlag);
78227
+ const unicode = source.includes("u", flagStart);
78228
+ const unicodeSets = source.includes("v", flagStart);
78229
+ this.validateFlagsInternal(source, flagStart, end);
78230
+ this.validatePatternInternal(source, start + 1, flagStart - 1, {
78231
+ unicode,
78232
+ unicodeSets,
78233
+ });
78189
78234
  }
78190
78235
  else if (start >= end) {
78191
78236
  this.raise("Empty");
@@ -78197,6 +78242,29 @@ function requireRegexpp () {
78197
78242
  this.onLiteralLeave(start, end);
78198
78243
  }
78199
78244
  validateFlags(source, start = 0, end = source.length) {
78245
+ this._srcCtx = { source, start, end, kind: "flags" };
78246
+ this.validateFlagsInternal(source, start, end);
78247
+ }
78248
+ validatePattern(source, start = 0, end = source.length, uFlagOrFlags = undefined) {
78249
+ this._srcCtx = { source, start, end, kind: "pattern" };
78250
+ this.validatePatternInternal(source, start, end, uFlagOrFlags);
78251
+ }
78252
+ validatePatternInternal(source, start = 0, end = source.length, uFlagOrFlags = undefined) {
78253
+ const mode = this._parseFlagsOptionToMode(uFlagOrFlags, end);
78254
+ this._unicodeMode = mode.unicodeMode;
78255
+ this._nFlag = mode.nFlag;
78256
+ this._unicodeSetsMode = mode.unicodeSetsMode;
78257
+ this.reset(source, start, end);
78258
+ this.consumePattern();
78259
+ if (!this._nFlag &&
78260
+ this.ecmaVersion >= 2018 &&
78261
+ this._groupNames.size > 0) {
78262
+ this._nFlag = true;
78263
+ this.rewind(start);
78264
+ this.consumePattern();
78265
+ }
78266
+ }
78267
+ validateFlagsInternal(source, start, end) {
78200
78268
  const existingFlags = new Set();
78201
78269
  let global = false;
78202
78270
  let ignoreCase = false;
@@ -78205,10 +78273,11 @@ function requireRegexpp () {
78205
78273
  let unicode = false;
78206
78274
  let dotAll = false;
78207
78275
  let hasIndices = false;
78276
+ let unicodeSets = false;
78208
78277
  for (let i = start; i < end; ++i) {
78209
78278
  const flag = source.charCodeAt(i);
78210
78279
  if (existingFlags.has(flag)) {
78211
- this.raise(`Duplicated flag '${source[i]}'`);
78280
+ this.raise(`Duplicated flag '${source[i]}'`, { index: start });
78212
78281
  }
78213
78282
  existingFlags.add(flag);
78214
78283
  if (flag === LATIN_SMALL_LETTER_G) {
@@ -78236,8 +78305,12 @@ function requireRegexpp () {
78236
78305
  this.ecmaVersion >= 2022) {
78237
78306
  hasIndices = true;
78238
78307
  }
78308
+ else if (flag === LATIN_SMALL_LETTER_V &&
78309
+ this.ecmaVersion >= 2024) {
78310
+ unicodeSets = true;
78311
+ }
78239
78312
  else {
78240
- this.raise(`Invalid flag '${source[i]}'`);
78313
+ this.raise(`Invalid flag '${source[i]}'`, { index: start });
78241
78314
  }
78242
78315
  }
78243
78316
  this.onRegExpFlags(start, end, {
@@ -78248,27 +78321,43 @@ function requireRegexpp () {
78248
78321
  sticky,
78249
78322
  dotAll,
78250
78323
  hasIndices,
78324
+ unicodeSets,
78251
78325
  });
78252
78326
  }
78253
- validatePattern(source, start = 0, end = source.length, uFlag = false) {
78254
- this._uFlag = uFlag && this.ecmaVersion >= 2015;
78255
- this._nFlag = uFlag && this.ecmaVersion >= 2018;
78256
- this.reset(source, start, end);
78257
- this.consumePattern();
78258
- if (!this._nFlag &&
78259
- this.ecmaVersion >= 2018 &&
78260
- this._groupNames.size > 0) {
78261
- this._nFlag = true;
78262
- this.rewind(start);
78263
- this.consumePattern();
78327
+ _parseFlagsOptionToMode(uFlagOrFlags, sourceEnd) {
78328
+ let unicode = false;
78329
+ let unicodeSets = false;
78330
+ if (uFlagOrFlags && this.ecmaVersion >= 2015) {
78331
+ if (typeof uFlagOrFlags === "object") {
78332
+ unicode = Boolean(uFlagOrFlags.unicode);
78333
+ if (this.ecmaVersion >= 2024) {
78334
+ unicodeSets = Boolean(uFlagOrFlags.unicodeSets);
78335
+ }
78336
+ }
78337
+ else {
78338
+ unicode = uFlagOrFlags;
78339
+ }
78264
78340
  }
78341
+ if (unicode && unicodeSets) {
78342
+ this.raise("Invalid regular expression flags", {
78343
+ index: sourceEnd + 1,
78344
+ unicode,
78345
+ unicodeSets,
78346
+ });
78347
+ }
78348
+ const unicodeMode = unicode || unicodeSets;
78349
+ const nFlag = (unicode && this.ecmaVersion >= 2018) ||
78350
+ unicodeSets ||
78351
+ Boolean(this._options.strict && this.ecmaVersion >= 2023);
78352
+ const unicodeSetsMode = unicodeSets;
78353
+ return { unicodeMode, nFlag, unicodeSetsMode };
78265
78354
  }
78266
78355
  get strict() {
78267
- return Boolean(this._options.strict) || this._uFlag;
78356
+ return Boolean(this._options.strict) || this._unicodeMode;
78268
78357
  }
78269
78358
  get ecmaVersion() {
78270
78359
  var _a;
78271
- return (_a = this._options.ecmaVersion) !== null && _a !== void 0 ? _a : 2022;
78360
+ return (_a = this._options.ecmaVersion) !== null && _a !== void 0 ? _a : latestEcmaVersion;
78272
78361
  }
78273
78362
  onLiteralEnter(start) {
78274
78363
  if (this._options.onLiteralEnter) {
@@ -78373,9 +78462,9 @@ function requireRegexpp () {
78373
78462
  this._options.onEscapeCharacterSet(start, end, kind, negate);
78374
78463
  }
78375
78464
  }
78376
- onUnicodePropertyCharacterSet(start, end, kind, key, value, negate) {
78465
+ onUnicodePropertyCharacterSet(start, end, kind, key, value, negate, strings) {
78377
78466
  if (this._options.onUnicodePropertyCharacterSet) {
78378
- this._options.onUnicodePropertyCharacterSet(start, end, kind, key, value, negate);
78467
+ this._options.onUnicodePropertyCharacterSet(start, end, kind, key, value, negate, strings);
78379
78468
  }
78380
78469
  }
78381
78470
  onCharacter(start, end, value) {
@@ -78388,9 +78477,9 @@ function requireRegexpp () {
78388
78477
  this._options.onBackreference(start, end, ref);
78389
78478
  }
78390
78479
  }
78391
- onCharacterClassEnter(start, negate) {
78480
+ onCharacterClassEnter(start, negate, unicodeSets) {
78392
78481
  if (this._options.onCharacterClassEnter) {
78393
- this._options.onCharacterClassEnter(start, negate);
78482
+ this._options.onCharacterClassEnter(start, negate, unicodeSets);
78394
78483
  }
78395
78484
  }
78396
78485
  onCharacterClassLeave(start, end, negate) {
@@ -78403,8 +78492,35 @@ function requireRegexpp () {
78403
78492
  this._options.onCharacterClassRange(start, end, min, max);
78404
78493
  }
78405
78494
  }
78406
- get source() {
78407
- return this._reader.source;
78495
+ onClassIntersection(start, end) {
78496
+ if (this._options.onClassIntersection) {
78497
+ this._options.onClassIntersection(start, end);
78498
+ }
78499
+ }
78500
+ onClassSubtraction(start, end) {
78501
+ if (this._options.onClassSubtraction) {
78502
+ this._options.onClassSubtraction(start, end);
78503
+ }
78504
+ }
78505
+ onClassStringDisjunctionEnter(start) {
78506
+ if (this._options.onClassStringDisjunctionEnter) {
78507
+ this._options.onClassStringDisjunctionEnter(start);
78508
+ }
78509
+ }
78510
+ onClassStringDisjunctionLeave(start, end) {
78511
+ if (this._options.onClassStringDisjunctionLeave) {
78512
+ this._options.onClassStringDisjunctionLeave(start, end);
78513
+ }
78514
+ }
78515
+ onStringAlternativeEnter(start, index) {
78516
+ if (this._options.onStringAlternativeEnter) {
78517
+ this._options.onStringAlternativeEnter(start, index);
78518
+ }
78519
+ }
78520
+ onStringAlternativeLeave(start, end, index) {
78521
+ if (this._options.onStringAlternativeLeave) {
78522
+ this._options.onStringAlternativeLeave(start, end, index);
78523
+ }
78408
78524
  }
78409
78525
  get index() {
78410
78526
  return this._reader.index;
@@ -78422,7 +78538,7 @@ function requireRegexpp () {
78422
78538
  return this._reader.nextCodePoint3;
78423
78539
  }
78424
78540
  reset(source, start, end) {
78425
- this._reader.reset(source, start, end, this._uFlag);
78541
+ this._reader.reset(source, start, end, this._unicodeMode);
78426
78542
  }
78427
78543
  rewind(index) {
78428
78544
  this._reader.rewind(index);
@@ -78439,8 +78555,12 @@ function requireRegexpp () {
78439
78555
  eat3(cp1, cp2, cp3) {
78440
78556
  return this._reader.eat3(cp1, cp2, cp3);
78441
78557
  }
78442
- raise(message) {
78443
- throw new RegExpSyntaxError(this.source, this._uFlag, this.index, message);
78558
+ raise(message, context) {
78559
+ var _a, _b, _c;
78560
+ throw new RegExpSyntaxError(this._srcCtx, {
78561
+ unicode: (_a = context === null || context === void 0 ? void 0 : context.unicode) !== null && _a !== void 0 ? _a : (this._unicodeMode && !this._unicodeSetsMode),
78562
+ unicodeSets: (_b = context === null || context === void 0 ? void 0 : context.unicodeSets) !== null && _b !== void 0 ? _b : this._unicodeSetsMode,
78563
+ }, (_c = context === null || context === void 0 ? void 0 : context.index) !== null && _c !== void 0 ? _c : this.index, message);
78444
78564
  }
78445
78565
  eatRegExpBody() {
78446
78566
  const start = this.index;
@@ -78555,7 +78675,7 @@ function requireRegexpp () {
78555
78675
  this.onAlternativeLeave(start, this.index, i);
78556
78676
  }
78557
78677
  consumeTerm() {
78558
- if (this._uFlag || this.strict) {
78678
+ if (this._unicodeMode || this.strict) {
78559
78679
  return (this.consumeAssertion() ||
78560
78680
  (this.consumeAtom() && this.consumeOptionalQuantifier()));
78561
78681
  }
@@ -78624,8 +78744,7 @@ function requireRegexpp () {
78624
78744
  max = 1;
78625
78745
  }
78626
78746
  else if (this.eatBracedQuantifier(noConsume)) {
78627
- min = this._lastMinValue;
78628
- max = this._lastMaxValue;
78747
+ ({ min, max } = this._lastRange);
78629
78748
  }
78630
78749
  else {
78631
78750
  return false;
@@ -78639,23 +78758,23 @@ function requireRegexpp () {
78639
78758
  eatBracedQuantifier(noError) {
78640
78759
  const start = this.index;
78641
78760
  if (this.eat(LEFT_CURLY_BRACKET)) {
78642
- this._lastMinValue = 0;
78643
- this._lastMaxValue = Number.POSITIVE_INFINITY;
78644
78761
  if (this.eatDecimalDigits()) {
78645
- this._lastMinValue = this._lastMaxValue = this._lastIntValue;
78762
+ const min = this._lastIntValue;
78763
+ let max = min;
78646
78764
  if (this.eat(COMMA)) {
78647
- this._lastMaxValue = this.eatDecimalDigits()
78765
+ max = this.eatDecimalDigits()
78648
78766
  ? this._lastIntValue
78649
78767
  : Number.POSITIVE_INFINITY;
78650
78768
  }
78651
78769
  if (this.eat(RIGHT_CURLY_BRACKET)) {
78652
- if (!noError && this._lastMaxValue < this._lastMinValue) {
78770
+ if (!noError && max < min) {
78653
78771
  this.raise("numbers out of order in {} quantifier");
78654
78772
  }
78773
+ this._lastRange = { min, max };
78655
78774
  return true;
78656
78775
  }
78657
78776
  }
78658
- if (!noError && (this._uFlag || this.strict)) {
78777
+ if (!noError && (this._unicodeMode || this.strict)) {
78659
78778
  this.raise("Incomplete quantifier");
78660
78779
  }
78661
78780
  this.rewind(start);
@@ -78666,7 +78785,7 @@ function requireRegexpp () {
78666
78785
  return (this.consumePatternCharacter() ||
78667
78786
  this.consumeDot() ||
78668
78787
  this.consumeReverseSolidusAtomEscape() ||
78669
- this.consumeCharacterClass() ||
78788
+ Boolean(this.consumeCharacterClass()) ||
78670
78789
  this.consumeUncapturingGroup() ||
78671
78790
  this.consumeCapturingGroup());
78672
78791
  }
@@ -78726,7 +78845,7 @@ function requireRegexpp () {
78726
78845
  return (this.consumeDot() ||
78727
78846
  this.consumeReverseSolidusAtomEscape() ||
78728
78847
  this.consumeReverseSolidusFollowedByC() ||
78729
- this.consumeCharacterClass() ||
78848
+ Boolean(this.consumeCharacterClass()) ||
78730
78849
  this.consumeUncapturingGroup() ||
78731
78850
  this.consumeCapturingGroup() ||
78732
78851
  this.consumeInvalidBracedQuantifier() ||
@@ -78800,7 +78919,7 @@ function requireRegexpp () {
78800
78919
  (this._nFlag && this.consumeKGroupName())) {
78801
78920
  return true;
78802
78921
  }
78803
- if (this.strict || this._uFlag) {
78922
+ if (this.strict || this._unicodeMode) {
78804
78923
  this.raise("Invalid escape");
78805
78924
  }
78806
78925
  return false;
@@ -78813,7 +78932,7 @@ function requireRegexpp () {
78813
78932
  this.onBackreference(start - 1, this.index, n);
78814
78933
  return true;
78815
78934
  }
78816
- if (this.strict || this._uFlag) {
78935
+ if (this.strict || this._unicodeMode) {
78817
78936
  this.raise("Invalid escape");
78818
78937
  }
78819
78938
  this.rewind(start);
@@ -78821,52 +78940,57 @@ function requireRegexpp () {
78821
78940
  return false;
78822
78941
  }
78823
78942
  consumeCharacterClassEscape() {
78943
+ var _a;
78824
78944
  const start = this.index;
78825
78945
  if (this.eat(LATIN_SMALL_LETTER_D)) {
78826
78946
  this._lastIntValue = -1;
78827
78947
  this.onEscapeCharacterSet(start - 1, this.index, "digit", false);
78828
- return true;
78948
+ return {};
78829
78949
  }
78830
78950
  if (this.eat(LATIN_CAPITAL_LETTER_D)) {
78831
78951
  this._lastIntValue = -1;
78832
78952
  this.onEscapeCharacterSet(start - 1, this.index, "digit", true);
78833
- return true;
78953
+ return {};
78834
78954
  }
78835
78955
  if (this.eat(LATIN_SMALL_LETTER_S)) {
78836
78956
  this._lastIntValue = -1;
78837
78957
  this.onEscapeCharacterSet(start - 1, this.index, "space", false);
78838
- return true;
78958
+ return {};
78839
78959
  }
78840
78960
  if (this.eat(LATIN_CAPITAL_LETTER_S)) {
78841
78961
  this._lastIntValue = -1;
78842
78962
  this.onEscapeCharacterSet(start - 1, this.index, "space", true);
78843
- return true;
78963
+ return {};
78844
78964
  }
78845
78965
  if (this.eat(LATIN_SMALL_LETTER_W)) {
78846
78966
  this._lastIntValue = -1;
78847
78967
  this.onEscapeCharacterSet(start - 1, this.index, "word", false);
78848
- return true;
78968
+ return {};
78849
78969
  }
78850
78970
  if (this.eat(LATIN_CAPITAL_LETTER_W)) {
78851
78971
  this._lastIntValue = -1;
78852
78972
  this.onEscapeCharacterSet(start - 1, this.index, "word", true);
78853
- return true;
78973
+ return {};
78854
78974
  }
78855
78975
  let negate = false;
78856
- if (this._uFlag &&
78976
+ if (this._unicodeMode &&
78857
78977
  this.ecmaVersion >= 2018 &&
78858
78978
  (this.eat(LATIN_SMALL_LETTER_P) ||
78859
78979
  (negate = this.eat(LATIN_CAPITAL_LETTER_P)))) {
78860
78980
  this._lastIntValue = -1;
78981
+ let result = null;
78861
78982
  if (this.eat(LEFT_CURLY_BRACKET) &&
78862
- this.eatUnicodePropertyValueExpression() &&
78983
+ (result = this.eatUnicodePropertyValueExpression()) &&
78863
78984
  this.eat(RIGHT_CURLY_BRACKET)) {
78864
- this.onUnicodePropertyCharacterSet(start - 1, this.index, "property", this._lastKeyValue, this._lastValValue || null, negate);
78865
- return true;
78985
+ if (negate && result.strings) {
78986
+ this.raise("Invalid property name");
78987
+ }
78988
+ this.onUnicodePropertyCharacterSet(start - 1, this.index, "property", result.key, result.value, negate, (_a = result.strings) !== null && _a !== void 0 ? _a : false);
78989
+ return { mayContainStrings: result.strings };
78866
78990
  }
78867
78991
  this.raise("Invalid property name");
78868
78992
  }
78869
- return false;
78993
+ return null;
78870
78994
  }
78871
78995
  consumeCharacterEscape() {
78872
78996
  const start = this.index;
@@ -78876,7 +79000,7 @@ function requireRegexpp () {
78876
79000
  this.eatHexEscapeSequence() ||
78877
79001
  this.eatRegExpUnicodeEscapeSequence() ||
78878
79002
  (!this.strict &&
78879
- !this._uFlag &&
79003
+ !this._unicodeMode &&
78880
79004
  this.eatLegacyOctalEscapeSequence()) ||
78881
79005
  this.eatIdentityEscape()) {
78882
79006
  this.onCharacter(start - 1, this.index, this._lastIntValue);
@@ -78901,18 +79025,31 @@ function requireRegexpp () {
78901
79025
  const start = this.index;
78902
79026
  if (this.eat(LEFT_SQUARE_BRACKET)) {
78903
79027
  const negate = this.eat(CIRCUMFLEX_ACCENT);
78904
- this.onCharacterClassEnter(start, negate);
78905
- this.consumeClassRanges();
79028
+ this.onCharacterClassEnter(start, negate, this._unicodeSetsMode);
79029
+ const result = this.consumeClassContents();
78906
79030
  if (!this.eat(RIGHT_SQUARE_BRACKET)) {
78907
- this.raise("Unterminated character class");
79031
+ if (this.currentCodePoint === -1) {
79032
+ this.raise("Unterminated character class");
79033
+ }
79034
+ this.raise("Invalid character in character class");
79035
+ }
79036
+ if (negate && result.mayContainStrings) {
79037
+ this.raise("Negated character class may contain strings");
78908
79038
  }
78909
79039
  this.onCharacterClassLeave(start, this.index, negate);
78910
- return true;
79040
+ return result;
78911
79041
  }
78912
- return false;
79042
+ return null;
78913
79043
  }
78914
- consumeClassRanges() {
78915
- const strict = this.strict || this._uFlag;
79044
+ consumeClassContents() {
79045
+ if (this._unicodeSetsMode) {
79046
+ if (this.currentCodePoint === RIGHT_SQUARE_BRACKET) {
79047
+ return {};
79048
+ }
79049
+ const result = this.consumeClassSetExpression();
79050
+ return result;
79051
+ }
79052
+ const strict = this.strict || this._unicodeMode;
78916
79053
  for (;;) {
78917
79054
  const rangeStart = this.index;
78918
79055
  if (!this.consumeClassAtom()) {
@@ -78938,6 +79075,7 @@ function requireRegexpp () {
78938
79075
  }
78939
79076
  this.onCharacterClassRange(rangeStart, this.index, min, max);
78940
79077
  }
79078
+ return {};
78941
79079
  }
78942
79080
  consumeClassAtom() {
78943
79081
  const start = this.index;
@@ -78960,7 +79098,7 @@ function requireRegexpp () {
78960
79098
  this.onCharacter(start, this.index, this._lastIntValue);
78961
79099
  return true;
78962
79100
  }
78963
- if (this.strict || this._uFlag) {
79101
+ if (this.strict || this._unicodeMode) {
78964
79102
  this.raise("Invalid escape");
78965
79103
  }
78966
79104
  this.rewind(start);
@@ -78974,14 +79112,14 @@ function requireRegexpp () {
78974
79112
  this.onCharacter(start - 1, this.index, this._lastIntValue);
78975
79113
  return true;
78976
79114
  }
78977
- if (this._uFlag && this.eat(HYPHEN_MINUS)) {
79115
+ if (this._unicodeMode && this.eat(HYPHEN_MINUS)) {
78978
79116
  this._lastIntValue = HYPHEN_MINUS;
78979
79117
  this.onCharacter(start - 1, this.index, this._lastIntValue);
78980
79118
  return true;
78981
79119
  }
78982
79120
  let cp = 0;
78983
79121
  if (!this.strict &&
78984
- !this._uFlag &&
79122
+ !this._unicodeMode &&
78985
79123
  this.currentCodePoint === LATIN_SMALL_LETTER_C &&
78986
79124
  (isDecimalDigit((cp = this.nextCodePoint)) || cp === LOW_LINE)) {
78987
79125
  this.advance();
@@ -78990,7 +79128,196 @@ function requireRegexpp () {
78990
79128
  this.onCharacter(start - 1, this.index, this._lastIntValue);
78991
79129
  return true;
78992
79130
  }
78993
- return (this.consumeCharacterClassEscape() || this.consumeCharacterEscape());
79131
+ return (Boolean(this.consumeCharacterClassEscape()) ||
79132
+ this.consumeCharacterEscape());
79133
+ }
79134
+ consumeClassSetExpression() {
79135
+ const start = this.index;
79136
+ let mayContainStrings = false;
79137
+ let result = null;
79138
+ if (this.consumeClassSetCharacter()) {
79139
+ if (this.consumeClassSetRangeFromOperator(start)) {
79140
+ this.consumeClassUnionRight({});
79141
+ return {};
79142
+ }
79143
+ mayContainStrings = false;
79144
+ }
79145
+ else if ((result = this.consumeClassSetOperand())) {
79146
+ mayContainStrings = result.mayContainStrings;
79147
+ }
79148
+ else {
79149
+ const cp = this.currentCodePoint;
79150
+ if (cp === REVERSE_SOLIDUS) {
79151
+ this.advance();
79152
+ this.raise("Invalid escape");
79153
+ }
79154
+ if (cp === this.nextCodePoint &&
79155
+ isClassSetReservedDoublePunctuatorCharacter(cp)) {
79156
+ this.raise("Invalid set operation in character class");
79157
+ }
79158
+ this.raise("Invalid character in character class");
79159
+ }
79160
+ if (this.eat2(AMPERSAND, AMPERSAND)) {
79161
+ while (this.currentCodePoint !== AMPERSAND &&
79162
+ (result = this.consumeClassSetOperand())) {
79163
+ this.onClassIntersection(start, this.index);
79164
+ if (!result.mayContainStrings) {
79165
+ mayContainStrings = false;
79166
+ }
79167
+ if (this.eat2(AMPERSAND, AMPERSAND)) {
79168
+ continue;
79169
+ }
79170
+ return { mayContainStrings };
79171
+ }
79172
+ this.raise("Invalid character in character class");
79173
+ }
79174
+ if (this.eat2(HYPHEN_MINUS, HYPHEN_MINUS)) {
79175
+ while (this.consumeClassSetOperand()) {
79176
+ this.onClassSubtraction(start, this.index);
79177
+ if (this.eat2(HYPHEN_MINUS, HYPHEN_MINUS)) {
79178
+ continue;
79179
+ }
79180
+ return { mayContainStrings };
79181
+ }
79182
+ this.raise("Invalid character in character class");
79183
+ }
79184
+ return this.consumeClassUnionRight({ mayContainStrings });
79185
+ }
79186
+ consumeClassUnionRight(leftResult) {
79187
+ let mayContainStrings = leftResult.mayContainStrings;
79188
+ for (;;) {
79189
+ const start = this.index;
79190
+ if (this.consumeClassSetCharacter()) {
79191
+ this.consumeClassSetRangeFromOperator(start);
79192
+ continue;
79193
+ }
79194
+ const result = this.consumeClassSetOperand();
79195
+ if (result) {
79196
+ if (result.mayContainStrings) {
79197
+ mayContainStrings = true;
79198
+ }
79199
+ continue;
79200
+ }
79201
+ break;
79202
+ }
79203
+ return { mayContainStrings };
79204
+ }
79205
+ consumeClassSetRangeFromOperator(start) {
79206
+ const currentStart = this.index;
79207
+ const min = this._lastIntValue;
79208
+ if (this.eat(HYPHEN_MINUS)) {
79209
+ if (this.consumeClassSetCharacter()) {
79210
+ const max = this._lastIntValue;
79211
+ if (min === -1 || max === -1) {
79212
+ this.raise("Invalid character class");
79213
+ }
79214
+ if (min > max) {
79215
+ this.raise("Range out of order in character class");
79216
+ }
79217
+ this.onCharacterClassRange(start, this.index, min, max);
79218
+ return true;
79219
+ }
79220
+ this.rewind(currentStart);
79221
+ }
79222
+ return false;
79223
+ }
79224
+ consumeClassSetOperand() {
79225
+ let result = null;
79226
+ if ((result = this.consumeNestedClass())) {
79227
+ return result;
79228
+ }
79229
+ if ((result = this.consumeClassStringDisjunction())) {
79230
+ return result;
79231
+ }
79232
+ if (this.consumeClassSetCharacter()) {
79233
+ return {};
79234
+ }
79235
+ return null;
79236
+ }
79237
+ consumeNestedClass() {
79238
+ const start = this.index;
79239
+ if (this.eat(LEFT_SQUARE_BRACKET)) {
79240
+ const negate = this.eat(CIRCUMFLEX_ACCENT);
79241
+ this.onCharacterClassEnter(start, negate, true);
79242
+ const result = this.consumeClassContents();
79243
+ if (!this.eat(RIGHT_SQUARE_BRACKET)) {
79244
+ this.raise("Unterminated character class");
79245
+ }
79246
+ if (negate && result.mayContainStrings) {
79247
+ this.raise("Negated character class may contain strings");
79248
+ }
79249
+ this.onCharacterClassLeave(start, this.index, negate);
79250
+ return result;
79251
+ }
79252
+ if (this.eat(REVERSE_SOLIDUS)) {
79253
+ const result = this.consumeCharacterClassEscape();
79254
+ if (result) {
79255
+ return result;
79256
+ }
79257
+ this.rewind(start);
79258
+ }
79259
+ return null;
79260
+ }
79261
+ consumeClassStringDisjunction() {
79262
+ const start = this.index;
79263
+ if (this.eat3(REVERSE_SOLIDUS, LATIN_SMALL_LETTER_Q, LEFT_CURLY_BRACKET)) {
79264
+ this.onClassStringDisjunctionEnter(start);
79265
+ let i = 0;
79266
+ let mayContainStrings = false;
79267
+ do {
79268
+ if (this.consumeClassString(i++).mayContainStrings) {
79269
+ mayContainStrings = true;
79270
+ }
79271
+ } while (this.eat(VERTICAL_LINE));
79272
+ if (this.eat(RIGHT_CURLY_BRACKET)) {
79273
+ this.onClassStringDisjunctionLeave(start, this.index);
79274
+ return { mayContainStrings };
79275
+ }
79276
+ this.raise("Unterminated class string disjunction");
79277
+ }
79278
+ return null;
79279
+ }
79280
+ consumeClassString(i) {
79281
+ const start = this.index;
79282
+ let count = 0;
79283
+ this.onStringAlternativeEnter(start, i);
79284
+ while (this.currentCodePoint !== -1 &&
79285
+ this.consumeClassSetCharacter()) {
79286
+ count++;
79287
+ }
79288
+ this.onStringAlternativeLeave(start, this.index, i);
79289
+ return { mayContainStrings: count !== 1 };
79290
+ }
79291
+ consumeClassSetCharacter() {
79292
+ const start = this.index;
79293
+ const cp = this.currentCodePoint;
79294
+ if (cp !== this.nextCodePoint ||
79295
+ !isClassSetReservedDoublePunctuatorCharacter(cp)) {
79296
+ if (cp !== -1 && !isClassSetSyntaxCharacter(cp)) {
79297
+ this._lastIntValue = cp;
79298
+ this.advance();
79299
+ this.onCharacter(start, this.index, this._lastIntValue);
79300
+ return true;
79301
+ }
79302
+ }
79303
+ if (this.eat(REVERSE_SOLIDUS)) {
79304
+ if (this.consumeCharacterEscape()) {
79305
+ return true;
79306
+ }
79307
+ if (isClassSetReservedPunctuator(this.currentCodePoint)) {
79308
+ this._lastIntValue = this.currentCodePoint;
79309
+ this.advance();
79310
+ this.onCharacter(start, this.index, this._lastIntValue);
79311
+ return true;
79312
+ }
79313
+ if (this.eat(LATIN_SMALL_LETTER_B)) {
79314
+ this._lastIntValue = BACKSPACE;
79315
+ this.onCharacter(start, this.index, this._lastIntValue);
79316
+ return true;
79317
+ }
79318
+ this.rewind(start);
79319
+ }
79320
+ return false;
78994
79321
  }
78995
79322
  eatGroupName() {
78996
79323
  if (this.eat(LESS_THAN_SIGN)) {
@@ -79013,7 +79340,7 @@ function requireRegexpp () {
79013
79340
  }
79014
79341
  eatRegExpIdentifierStart() {
79015
79342
  const start = this.index;
79016
- const forceUFlag = !this._uFlag && this.ecmaVersion >= 2020;
79343
+ const forceUFlag = !this._unicodeMode && this.ecmaVersion >= 2020;
79017
79344
  let cp = this.currentCodePoint;
79018
79345
  this.advance();
79019
79346
  if (cp === REVERSE_SOLIDUS &&
@@ -79026,7 +79353,7 @@ function requireRegexpp () {
79026
79353
  cp = combineSurrogatePair(cp, this.currentCodePoint);
79027
79354
  this.advance();
79028
79355
  }
79029
- if (isRegExpIdentifierStart(cp)) {
79356
+ if (isIdentifierStartChar(cp)) {
79030
79357
  this._lastIntValue = cp;
79031
79358
  return true;
79032
79359
  }
@@ -79037,7 +79364,7 @@ function requireRegexpp () {
79037
79364
  }
79038
79365
  eatRegExpIdentifierPart() {
79039
79366
  const start = this.index;
79040
- const forceUFlag = !this._uFlag && this.ecmaVersion >= 2020;
79367
+ const forceUFlag = !this._unicodeMode && this.ecmaVersion >= 2020;
79041
79368
  let cp = this.currentCodePoint;
79042
79369
  this.advance();
79043
79370
  if (cp === REVERSE_SOLIDUS &&
@@ -79050,7 +79377,7 @@ function requireRegexpp () {
79050
79377
  cp = combineSurrogatePair(cp, this.currentCodePoint);
79051
79378
  this.advance();
79052
79379
  }
79053
- if (isRegExpIdentifierPart(cp)) {
79380
+ if (isIdentifierPartChar(cp)) {
79054
79381
  this._lastIntValue = cp;
79055
79382
  return true;
79056
79383
  }
@@ -79112,7 +79439,7 @@ function requireRegexpp () {
79112
79439
  }
79113
79440
  eatRegExpUnicodeEscapeSequence(forceUFlag = false) {
79114
79441
  const start = this.index;
79115
- const uFlag = forceUFlag || this._uFlag;
79442
+ const uFlag = forceUFlag || this._unicodeMode;
79116
79443
  if (this.eat(LATIN_SMALL_LETTER_U)) {
79117
79444
  if ((uFlag && this.eatRegExpUnicodeSurrogatePairEscape()) ||
79118
79445
  this.eatFixedHexDigits(4) ||
@@ -79168,7 +79495,7 @@ function requireRegexpp () {
79168
79495
  if (cp === -1) {
79169
79496
  return false;
79170
79497
  }
79171
- if (this._uFlag) {
79498
+ if (this._unicodeMode) {
79172
79499
  return isSyntaxCharacter(cp) || cp === SOLIDUS;
79173
79500
  }
79174
79501
  if (this.strict) {
@@ -79195,11 +79522,14 @@ function requireRegexpp () {
79195
79522
  eatUnicodePropertyValueExpression() {
79196
79523
  const start = this.index;
79197
79524
  if (this.eatUnicodePropertyName() && this.eat(EQUALS_SIGN)) {
79198
- this._lastKeyValue = this._lastStrValue;
79525
+ const key = this._lastStrValue;
79199
79526
  if (this.eatUnicodePropertyValue()) {
79200
- this._lastValValue = this._lastStrValue;
79201
- if (isValidUnicodeProperty(this.ecmaVersion, this._lastKeyValue, this._lastValValue)) {
79202
- return true;
79527
+ const value = this._lastStrValue;
79528
+ if (isValidUnicodeProperty(this.ecmaVersion, key, value)) {
79529
+ return {
79530
+ key,
79531
+ value: value || null,
79532
+ };
79203
79533
  }
79204
79534
  this.raise("Invalid property name");
79205
79535
  }
@@ -79208,18 +79538,28 @@ function requireRegexpp () {
79208
79538
  if (this.eatLoneUnicodePropertyNameOrValue()) {
79209
79539
  const nameOrValue = this._lastStrValue;
79210
79540
  if (isValidUnicodeProperty(this.ecmaVersion, "General_Category", nameOrValue)) {
79211
- this._lastKeyValue = "General_Category";
79212
- this._lastValValue = nameOrValue;
79213
- return true;
79541
+ return {
79542
+ key: "General_Category",
79543
+ value: nameOrValue || null,
79544
+ };
79214
79545
  }
79215
79546
  if (isValidLoneUnicodeProperty(this.ecmaVersion, nameOrValue)) {
79216
- this._lastKeyValue = nameOrValue;
79217
- this._lastValValue = "";
79218
- return true;
79547
+ return {
79548
+ key: nameOrValue,
79549
+ value: null,
79550
+ };
79551
+ }
79552
+ if (this._unicodeSetsMode &&
79553
+ isValidLoneUnicodePropertyOfString(this.ecmaVersion, nameOrValue)) {
79554
+ return {
79555
+ key: nameOrValue,
79556
+ value: null,
79557
+ strings: true,
79558
+ };
79219
79559
  }
79220
79560
  this.raise("Invalid property name");
79221
79561
  }
79222
- return false;
79562
+ return null;
79223
79563
  }
79224
79564
  eatUnicodePropertyName() {
79225
79565
  this._lastStrValue = "";
@@ -79246,7 +79586,7 @@ function requireRegexpp () {
79246
79586
  if (this.eatFixedHexDigits(2)) {
79247
79587
  return true;
79248
79588
  }
79249
- if (this._uFlag || this.strict) {
79589
+ if (this._unicodeMode || this.strict) {
79250
79590
  this.raise("Invalid escape");
79251
79591
  }
79252
79592
  this.rewind(start);
@@ -79321,16 +79661,24 @@ function requireRegexpp () {
79321
79661
  const DUMMY_PATTERN = {};
79322
79662
  const DUMMY_FLAGS = {};
79323
79663
  const DUMMY_CAPTURING_GROUP = {};
79664
+ function isClassSetOperand(node) {
79665
+ return (node.type === "Character" ||
79666
+ node.type === "CharacterSet" ||
79667
+ node.type === "CharacterClass" ||
79668
+ node.type === "ExpressionCharacterClass" ||
79669
+ node.type === "ClassStringDisjunction");
79670
+ }
79324
79671
  class RegExpParserState {
79325
79672
  constructor(options) {
79326
79673
  var _a;
79327
79674
  this._node = DUMMY_PATTERN;
79675
+ this._expressionBuffer = null;
79328
79676
  this._flags = DUMMY_FLAGS;
79329
79677
  this._backreferences = [];
79330
79678
  this._capturingGroups = [];
79331
79679
  this.source = "";
79332
79680
  this.strict = Boolean(options === null || options === void 0 ? void 0 : options.strict);
79333
- this.ecmaVersion = (_a = options === null || options === void 0 ? void 0 : options.ecmaVersion) !== null && _a !== void 0 ? _a : 2022;
79681
+ this.ecmaVersion = (_a = options === null || options === void 0 ? void 0 : options.ecmaVersion) !== null && _a !== void 0 ? _a : latestEcmaVersion;
79334
79682
  }
79335
79683
  get pattern() {
79336
79684
  if (this._node.type !== "Pattern") {
@@ -79344,7 +79692,7 @@ function requireRegexpp () {
79344
79692
  }
79345
79693
  return this._flags;
79346
79694
  }
79347
- onRegExpFlags(start, end, { global, ignoreCase, multiline, unicode, sticky, dotAll, hasIndices, }) {
79695
+ onRegExpFlags(start, end, { global, ignoreCase, multiline, unicode, sticky, dotAll, hasIndices, unicodeSets, }) {
79348
79696
  this._flags = {
79349
79697
  type: "Flags",
79350
79698
  parent: null,
@@ -79358,6 +79706,7 @@ function requireRegexpp () {
79358
79706
  sticky,
79359
79707
  dotAll,
79360
79708
  hasIndices,
79709
+ unicodeSets,
79361
79710
  };
79362
79711
  }
79363
79712
  onPatternEnter(start) {
@@ -79572,26 +79921,33 @@ function requireRegexpp () {
79572
79921
  negate,
79573
79922
  });
79574
79923
  }
79575
- onUnicodePropertyCharacterSet(start, end, kind, key, value, negate) {
79924
+ onUnicodePropertyCharacterSet(start, end, kind, key, value, negate, strings) {
79576
79925
  const parent = this._node;
79577
- if (parent.type !== "Alternative" && parent.type !== "CharacterClass") {
79926
+ if ((parent.type !== "Alternative" &&
79927
+ parent.type !== "CharacterClass") ||
79928
+ (strings && (negate || value))) {
79578
79929
  throw new Error("UnknownError");
79579
79930
  }
79580
- parent.elements.push({
79931
+ const base = {
79581
79932
  type: "CharacterSet",
79582
79933
  parent,
79583
79934
  start,
79584
79935
  end,
79585
79936
  raw: this.source.slice(start, end),
79586
79937
  kind,
79938
+ strings,
79587
79939
  key,
79588
- value,
79589
- negate,
79590
- });
79940
+ };
79941
+ const node = strings
79942
+ ? Object.assign(Object.assign({}, base), { value: null, negate: false, strings: true }) : Object.assign(Object.assign({}, base), { value,
79943
+ negate, strings: false });
79944
+ parent.elements.push(node);
79591
79945
  }
79592
79946
  onCharacter(start, end, value) {
79593
79947
  const parent = this._node;
79594
- if (parent.type !== "Alternative" && parent.type !== "CharacterClass") {
79948
+ if (parent.type !== "Alternative" &&
79949
+ parent.type !== "CharacterClass" &&
79950
+ parent.type !== "StringAlternative") {
79595
79951
  throw new Error("UnknownError");
79596
79952
  }
79597
79953
  parent.elements.push({
@@ -79620,31 +79976,66 @@ function requireRegexpp () {
79620
79976
  parent.elements.push(node);
79621
79977
  this._backreferences.push(node);
79622
79978
  }
79623
- onCharacterClassEnter(start, negate) {
79979
+ onCharacterClassEnter(start, negate, unicodeSets) {
79624
79980
  const parent = this._node;
79625
- if (parent.type !== "Alternative") {
79626
- throw new Error("UnknownError");
79627
- }
79628
- this._node = {
79981
+ const base = {
79629
79982
  type: "CharacterClass",
79630
79983
  parent,
79631
79984
  start,
79632
79985
  end: start,
79633
79986
  raw: "",
79987
+ unicodeSets,
79634
79988
  negate,
79635
79989
  elements: [],
79636
79990
  };
79637
- parent.elements.push(this._node);
79991
+ if (parent.type === "Alternative") {
79992
+ const node = Object.assign(Object.assign({}, base), { parent });
79993
+ this._node = node;
79994
+ parent.elements.push(node);
79995
+ }
79996
+ else if (parent.type === "CharacterClass" &&
79997
+ parent.unicodeSets &&
79998
+ unicodeSets) {
79999
+ const node = Object.assign(Object.assign({}, base), { parent,
80000
+ unicodeSets });
80001
+ this._node = node;
80002
+ parent.elements.push(node);
80003
+ }
80004
+ else {
80005
+ throw new Error("UnknownError");
80006
+ }
79638
80007
  }
79639
80008
  onCharacterClassLeave(start, end) {
79640
80009
  const node = this._node;
79641
80010
  if (node.type !== "CharacterClass" ||
79642
- node.parent.type !== "Alternative") {
80011
+ (node.parent.type !== "Alternative" &&
80012
+ node.parent.type !== "CharacterClass") ||
80013
+ (this._expressionBuffer && node.elements.length > 0)) {
79643
80014
  throw new Error("UnknownError");
79644
80015
  }
80016
+ const parent = node.parent;
79645
80017
  node.end = end;
79646
80018
  node.raw = this.source.slice(start, end);
79647
- this._node = node.parent;
80019
+ this._node = parent;
80020
+ const expression = this._expressionBuffer;
80021
+ this._expressionBuffer = null;
80022
+ if (!expression) {
80023
+ return;
80024
+ }
80025
+ const newNode = {
80026
+ type: "ExpressionCharacterClass",
80027
+ parent,
80028
+ start: node.start,
80029
+ end: node.end,
80030
+ raw: node.raw,
80031
+ negate: node.negate,
80032
+ expression,
80033
+ };
80034
+ expression.parent = newNode;
80035
+ if (node !== parent.elements.pop()) {
80036
+ throw new Error("UnknownError");
80037
+ }
80038
+ parent.elements.push(newNode);
79648
80039
  }
79649
80040
  onCharacterClassRange(start, end) {
79650
80041
  const parent = this._node;
@@ -79653,15 +80044,19 @@ function requireRegexpp () {
79653
80044
  }
79654
80045
  const elements = parent.elements;
79655
80046
  const max = elements.pop();
79656
- const hyphen = elements.pop();
80047
+ if (!max || max.type !== "Character") {
80048
+ throw new Error("UnknownError");
80049
+ }
80050
+ if (!parent.unicodeSets) {
80051
+ const hyphen = elements.pop();
80052
+ if (!hyphen ||
80053
+ hyphen.type !== "Character" ||
80054
+ hyphen.value !== HYPHEN_MINUS) {
80055
+ throw new Error("UnknownError");
80056
+ }
80057
+ }
79657
80058
  const min = elements.pop();
79658
- if (!min ||
79659
- !max ||
79660
- !hyphen ||
79661
- min.type !== "Character" ||
79662
- max.type !== "Character" ||
79663
- hyphen.type !== "Character" ||
79664
- hyphen.value !== HYPHEN_MINUS) {
80059
+ if (!min || min.type !== "Character") {
79665
80060
  throw new Error("UnknownError");
79666
80061
  }
79667
80062
  const node = {
@@ -79677,6 +80072,111 @@ function requireRegexpp () {
79677
80072
  max.parent = node;
79678
80073
  elements.push(node);
79679
80074
  }
80075
+ onClassIntersection(start, end) {
80076
+ var _a;
80077
+ const parent = this._node;
80078
+ if (parent.type !== "CharacterClass" || !parent.unicodeSets) {
80079
+ throw new Error("UnknownError");
80080
+ }
80081
+ const right = parent.elements.pop();
80082
+ const left = (_a = this._expressionBuffer) !== null && _a !== void 0 ? _a : parent.elements.pop();
80083
+ if (!left ||
80084
+ !right ||
80085
+ left.type === "ClassSubtraction" ||
80086
+ (left.type !== "ClassIntersection" && !isClassSetOperand(left)) ||
80087
+ !isClassSetOperand(right)) {
80088
+ throw new Error("UnknownError");
80089
+ }
80090
+ const node = {
80091
+ type: "ClassIntersection",
80092
+ parent: parent,
80093
+ start,
80094
+ end,
80095
+ raw: this.source.slice(start, end),
80096
+ left,
80097
+ right,
80098
+ };
80099
+ left.parent = node;
80100
+ right.parent = node;
80101
+ this._expressionBuffer = node;
80102
+ }
80103
+ onClassSubtraction(start, end) {
80104
+ var _a;
80105
+ const parent = this._node;
80106
+ if (parent.type !== "CharacterClass" || !parent.unicodeSets) {
80107
+ throw new Error("UnknownError");
80108
+ }
80109
+ const right = parent.elements.pop();
80110
+ const left = (_a = this._expressionBuffer) !== null && _a !== void 0 ? _a : parent.elements.pop();
80111
+ if (!left ||
80112
+ !right ||
80113
+ left.type === "ClassIntersection" ||
80114
+ (left.type !== "ClassSubtraction" && !isClassSetOperand(left)) ||
80115
+ !isClassSetOperand(right)) {
80116
+ throw new Error("UnknownError");
80117
+ }
80118
+ const node = {
80119
+ type: "ClassSubtraction",
80120
+ parent: parent,
80121
+ start,
80122
+ end,
80123
+ raw: this.source.slice(start, end),
80124
+ left,
80125
+ right,
80126
+ };
80127
+ left.parent = node;
80128
+ right.parent = node;
80129
+ this._expressionBuffer = node;
80130
+ }
80131
+ onClassStringDisjunctionEnter(start) {
80132
+ const parent = this._node;
80133
+ if (parent.type !== "CharacterClass" || !parent.unicodeSets) {
80134
+ throw new Error("UnknownError");
80135
+ }
80136
+ this._node = {
80137
+ type: "ClassStringDisjunction",
80138
+ parent,
80139
+ start,
80140
+ end: start,
80141
+ raw: "",
80142
+ alternatives: [],
80143
+ };
80144
+ parent.elements.push(this._node);
80145
+ }
80146
+ onClassStringDisjunctionLeave(start, end) {
80147
+ const node = this._node;
80148
+ if (node.type !== "ClassStringDisjunction" ||
80149
+ node.parent.type !== "CharacterClass") {
80150
+ throw new Error("UnknownError");
80151
+ }
80152
+ node.end = end;
80153
+ node.raw = this.source.slice(start, end);
80154
+ this._node = node.parent;
80155
+ }
80156
+ onStringAlternativeEnter(start) {
80157
+ const parent = this._node;
80158
+ if (parent.type !== "ClassStringDisjunction") {
80159
+ throw new Error("UnknownError");
80160
+ }
80161
+ this._node = {
80162
+ type: "StringAlternative",
80163
+ parent,
80164
+ start,
80165
+ end: start,
80166
+ raw: "",
80167
+ elements: [],
80168
+ };
80169
+ parent.alternatives.push(this._node);
80170
+ }
80171
+ onStringAlternativeLeave(start, end) {
80172
+ const node = this._node;
80173
+ if (node.type !== "StringAlternative") {
80174
+ throw new Error("UnknownError");
80175
+ }
80176
+ node.end = end;
80177
+ node.raw = this.source.slice(start, end);
80178
+ this._node = node.parent;
80179
+ }
79680
80180
  }
79681
80181
  class RegExpParser {
79682
80182
  constructor(options) {
@@ -79706,9 +80206,9 @@ function requireRegexpp () {
79706
80206
  this._validator.validateFlags(source, start, end);
79707
80207
  return this._state.flags;
79708
80208
  }
79709
- parsePattern(source, start = 0, end = source.length, uFlag = false) {
80209
+ parsePattern(source, start = 0, end = source.length, uFlagOrFlags = undefined) {
79710
80210
  this._state.source = source;
79711
- this._validator.validatePattern(source, start, end, uFlag);
80211
+ this._validator.validatePattern(source, start, end, uFlagOrFlags);
79712
80212
  return this._state.pattern;
79713
80213
  }
79714
80214
  }
@@ -79743,6 +80243,18 @@ function requireRegexpp () {
79743
80243
  case "CharacterSet":
79744
80244
  this.visitCharacterSet(node);
79745
80245
  break;
80246
+ case "ClassIntersection":
80247
+ this.visitClassIntersection(node);
80248
+ break;
80249
+ case "ClassStringDisjunction":
80250
+ this.visitClassStringDisjunction(node);
80251
+ break;
80252
+ case "ClassSubtraction":
80253
+ this.visitClassSubtraction(node);
80254
+ break;
80255
+ case "ExpressionCharacterClass":
80256
+ this.visitExpressionCharacterClass(node);
80257
+ break;
79746
80258
  case "Flags":
79747
80259
  this.visitFlags(node);
79748
80260
  break;
@@ -79758,6 +80270,9 @@ function requireRegexpp () {
79758
80270
  case "RegExpLiteral":
79759
80271
  this.visitRegExpLiteral(node);
79760
80272
  break;
80273
+ case "StringAlternative":
80274
+ this.visitStringAlternative(node);
80275
+ break;
79761
80276
  default:
79762
80277
  throw new Error(`Unknown type: ${node.type}`);
79763
80278
  }
@@ -79834,6 +80349,44 @@ function requireRegexpp () {
79834
80349
  this._handlers.onCharacterSetLeave(node);
79835
80350
  }
79836
80351
  }
80352
+ visitClassIntersection(node) {
80353
+ if (this._handlers.onClassIntersectionEnter) {
80354
+ this._handlers.onClassIntersectionEnter(node);
80355
+ }
80356
+ this.visit(node.left);
80357
+ this.visit(node.right);
80358
+ if (this._handlers.onClassIntersectionLeave) {
80359
+ this._handlers.onClassIntersectionLeave(node);
80360
+ }
80361
+ }
80362
+ visitClassStringDisjunction(node) {
80363
+ if (this._handlers.onClassStringDisjunctionEnter) {
80364
+ this._handlers.onClassStringDisjunctionEnter(node);
80365
+ }
80366
+ node.alternatives.forEach(this.visit, this);
80367
+ if (this._handlers.onClassStringDisjunctionLeave) {
80368
+ this._handlers.onClassStringDisjunctionLeave(node);
80369
+ }
80370
+ }
80371
+ visitClassSubtraction(node) {
80372
+ if (this._handlers.onClassSubtractionEnter) {
80373
+ this._handlers.onClassSubtractionEnter(node);
80374
+ }
80375
+ this.visit(node.left);
80376
+ this.visit(node.right);
80377
+ if (this._handlers.onClassSubtractionLeave) {
80378
+ this._handlers.onClassSubtractionLeave(node);
80379
+ }
80380
+ }
80381
+ visitExpressionCharacterClass(node) {
80382
+ if (this._handlers.onExpressionCharacterClassEnter) {
80383
+ this._handlers.onExpressionCharacterClassEnter(node);
80384
+ }
80385
+ this.visit(node.expression);
80386
+ if (this._handlers.onExpressionCharacterClassLeave) {
80387
+ this._handlers.onExpressionCharacterClassLeave(node);
80388
+ }
80389
+ }
79837
80390
  visitFlags(node) {
79838
80391
  if (this._handlers.onFlagsEnter) {
79839
80392
  this._handlers.onFlagsEnter(node);
@@ -79879,6 +80432,15 @@ function requireRegexpp () {
79879
80432
  this._handlers.onRegExpLiteralLeave(node);
79880
80433
  }
79881
80434
  }
80435
+ visitStringAlternative(node) {
80436
+ if (this._handlers.onStringAlternativeEnter) {
80437
+ this._handlers.onStringAlternativeEnter(node);
80438
+ }
80439
+ node.elements.forEach(this.visit, this);
80440
+ if (this._handlers.onStringAlternativeLeave) {
80441
+ this._handlers.onStringAlternativeLeave(node);
80442
+ }
80443
+ }
79882
80444
  }
79883
80445
 
79884
80446
  function parseRegExpLiteral(source, options) {
@@ -79922,6 +80484,16 @@ function requireNoControlRegex () {
79922
80484
  }
79923
80485
 
79924
80486
  onPatternEnter() {
80487
+
80488
+ /*
80489
+ * `RegExpValidator` may parse the pattern twice in one `validatePattern`.
80490
+ * So `this._controlChars` should be cleared here as well.
80491
+ *
80492
+ * For example, the `/(?<a>\x1f)/` regex will parse the pattern twice.
80493
+ * This is based on the content described in Annex B.
80494
+ * If the regex contains a `GroupName` and the `u` flag is not used, `ParseText` will be called twice.
80495
+ * See https://tc39.es/ecma262/2023/multipage/additional-ecmascript-features-for-web-browsers.html#sec-parsepattern-annexb
80496
+ */
79925
80497
  this._controlChars = [];
79926
80498
  }
79927
80499
 
@@ -79940,10 +80512,13 @@ function requireNoControlRegex () {
79940
80512
 
79941
80513
  collectControlChars(regexpStr, flags) {
79942
80514
  const uFlag = typeof flags === "string" && flags.includes("u");
80515
+ const vFlag = typeof flags === "string" && flags.includes("v");
80516
+
80517
+ this._controlChars = [];
80518
+ this._source = regexpStr;
79943
80519
 
79944
80520
  try {
79945
- this._source = regexpStr;
79946
- this._validator.validatePattern(regexpStr, void 0, void 0, uFlag); // Call onCharacter hook
80521
+ this._validator.validatePattern(regexpStr, void 0, void 0, { unicode: uFlag, unicodeSets: vFlag }); // Call onCharacter hook
79947
80522
  } catch {
79948
80523
 
79949
80524
  // Ignore syntax errors in RegExp.
@@ -81716,20 +82291,18 @@ function requireNoEmptyCharacterClass () {
81716
82291
  if (hasRequiredNoEmptyCharacterClass) return noEmptyCharacterClass;
81717
82292
  hasRequiredNoEmptyCharacterClass = 1;
81718
82293
 
82294
+ //------------------------------------------------------------------------------
82295
+ // Requirements
82296
+ //------------------------------------------------------------------------------
82297
+
82298
+ const { RegExpParser, visitRegExpAST } = requireRegexpp();
82299
+
81719
82300
  //------------------------------------------------------------------------------
81720
82301
  // Helpers
81721
82302
  //------------------------------------------------------------------------------
81722
82303
 
81723
- /*
81724
- * plain-English description of the following regexp:
81725
- * 0. `^` fix the match at the beginning of the string
81726
- * 1. `([^\\[]|\\.|\[([^\\\]]|\\.)+\])*`: regexp contents; 0 or more of the following
81727
- * 1.0. `[^\\[]`: any character that's not a `\` or a `[` (anything but escape sequences and character classes)
81728
- * 1.1. `\\.`: an escape sequence
81729
- * 1.2. `\[([^\\\]]|\\.)+\]`: a character class that isn't empty
81730
- * 2. `$`: fix the match at the end of the string
81731
- */
81732
- const regex = /^([^\\[]|\\.|\[([^\\\]]|\\.)+\])*$/u;
82304
+ const parser = new RegExpParser();
82305
+ const QUICK_TEST_REGEX = /\[\]/u;
81733
82306
 
81734
82307
  //------------------------------------------------------------------------------
81735
82308
  // Rule Definition
@@ -81756,9 +82329,32 @@ function requireNoEmptyCharacterClass () {
81756
82329
  create(context) {
81757
82330
  return {
81758
82331
  "Literal[regex]"(node) {
81759
- if (!regex.test(node.regex.pattern)) {
81760
- context.report({ node, messageId: "unexpected" });
82332
+ const { pattern, flags } = node.regex;
82333
+
82334
+ if (!QUICK_TEST_REGEX.test(pattern)) {
82335
+ return;
82336
+ }
82337
+
82338
+ let regExpAST;
82339
+
82340
+ try {
82341
+ regExpAST = parser.parsePattern(pattern, 0, pattern.length, {
82342
+ unicode: flags.includes("u"),
82343
+ unicodeSets: flags.includes("v")
82344
+ });
82345
+ } catch {
82346
+
82347
+ // Ignore regular expressions that regexpp cannot parse
82348
+ return;
81761
82349
  }
82350
+
82351
+ visitRegExpAST(regExpAST, {
82352
+ onCharacterClassEnter(characterClass) {
82353
+ if (!characterClass.negate && characterClass.elements.length === 0) {
82354
+ context.report({ node, messageId: "unexpected" });
82355
+ }
82356
+ }
82357
+ });
81762
82358
  }
81763
82359
  };
81764
82360
 
@@ -81954,6 +82550,8 @@ function requireNoEmptyPattern () {
81954
82550
  if (hasRequiredNoEmptyPattern) return noEmptyPattern;
81955
82551
  hasRequiredNoEmptyPattern = 1;
81956
82552
 
82553
+ const astUtils = requireAstUtils();
82554
+
81957
82555
  //------------------------------------------------------------------------------
81958
82556
  // Rule Definition
81959
82557
  //------------------------------------------------------------------------------
@@ -81969,7 +82567,18 @@ function requireNoEmptyPattern () {
81969
82567
  url: "https://eslint.org/docs/latest/rules/no-empty-pattern"
81970
82568
  },
81971
82569
 
81972
- schema: [],
82570
+ schema: [
82571
+ {
82572
+ type: "object",
82573
+ properties: {
82574
+ allowObjectPatternsAsParameters: {
82575
+ type: "boolean",
82576
+ default: false
82577
+ }
82578
+ },
82579
+ additionalProperties: false
82580
+ }
82581
+ ],
81973
82582
 
81974
82583
  messages: {
81975
82584
  unexpected: "Unexpected empty {{type}} pattern."
@@ -81977,11 +82586,33 @@ function requireNoEmptyPattern () {
81977
82586
  },
81978
82587
 
81979
82588
  create(context) {
82589
+ const options = context.options[0] || {},
82590
+ allowObjectPatternsAsParameters = options.allowObjectPatternsAsParameters || false;
82591
+
81980
82592
  return {
81981
82593
  ObjectPattern(node) {
81982
- if (node.properties.length === 0) {
81983
- context.report({ node, messageId: "unexpected", data: { type: "object" } });
82594
+
82595
+ if (node.properties.length > 0) {
82596
+ return;
81984
82597
  }
82598
+
82599
+ // Allow {} and {} = {} empty object patterns as parameters when allowObjectPatternsAsParameters is true
82600
+ if (
82601
+ allowObjectPatternsAsParameters &&
82602
+ (
82603
+ astUtils.isFunction(node.parent) ||
82604
+ (
82605
+ node.parent.type === "AssignmentPattern" &&
82606
+ astUtils.isFunction(node.parent.parent) &&
82607
+ node.parent.right.type === "ObjectExpression" &&
82608
+ node.parent.right.properties.length === 0
82609
+ )
82610
+ )
82611
+ ) {
82612
+ return;
82613
+ }
82614
+
82615
+ context.report({ node, messageId: "unexpected", data: { type: "object" } });
81985
82616
  },
81986
82617
  ArrayPattern(node) {
81987
82618
  if (node.elements.length === 0) {
@@ -86457,7 +87088,7 @@ function requireNoInvalidRegexp () {
86457
87088
 
86458
87089
  const RegExpValidator = requireRegexpp().RegExpValidator;
86459
87090
  const validator = new RegExpValidator();
86460
- const validFlags = /[dgimsuy]/gu;
87091
+ const validFlags = /[dgimsuvy]/gu;
86461
87092
  const undefined1 = void 0;
86462
87093
 
86463
87094
  //------------------------------------------------------------------------------
@@ -86555,12 +87186,14 @@ function requireNoInvalidRegexp () {
86555
87186
  /**
86556
87187
  * Check syntax error in a given pattern.
86557
87188
  * @param {string} pattern The RegExp pattern to validate.
86558
- * @param {boolean} uFlag The Unicode flag.
87189
+ * @param {Object} flags The RegExp flags to validate.
87190
+ * @param {boolean} [flags.unicode] The Unicode flag.
87191
+ * @param {boolean} [flags.unicodeSets] The UnicodeSets flag.
86559
87192
  * @returns {string|null} The syntax error.
86560
87193
  */
86561
- function validateRegExpPattern(pattern, uFlag) {
87194
+ function validateRegExpPattern(pattern, flags) {
86562
87195
  try {
86563
- validator.validatePattern(pattern, undefined1, undefined1, uFlag);
87196
+ validator.validatePattern(pattern, undefined1, undefined1, flags);
86564
87197
  return null;
86565
87198
  } catch (err) {
86566
87199
  return err.message;
@@ -86578,10 +87211,19 @@ function requireNoInvalidRegexp () {
86578
87211
  }
86579
87212
  try {
86580
87213
  validator.validateFlags(flags);
86581
- return null;
86582
87214
  } catch {
86583
87215
  return `Invalid flags supplied to RegExp constructor '${flags}'`;
86584
87216
  }
87217
+
87218
+ /*
87219
+ * `regexpp` checks the combination of `u` and `v` flags when parsing `Pattern` according to `ecma262`,
87220
+ * but this rule may check only the flag when the pattern is unidentifiable, so check it here.
87221
+ * https://tc39.es/ecma262/multipage/text-processing.html#sec-parsepattern
87222
+ */
87223
+ if (flags.includes("u") && flags.includes("v")) {
87224
+ return "Regex 'u' and 'v' flags cannot be used together";
87225
+ }
87226
+ return null;
86585
87227
  }
86586
87228
 
86587
87229
  return {
@@ -86613,8 +87255,12 @@ function requireNoInvalidRegexp () {
86613
87255
 
86614
87256
  // If flags are unknown, report the regex only if its pattern is invalid both with and without the "u" flag
86615
87257
  flags === null
86616
- ? validateRegExpPattern(pattern, true) && validateRegExpPattern(pattern, false)
86617
- : validateRegExpPattern(pattern, flags.includes("u"))
87258
+ ? (
87259
+ validateRegExpPattern(pattern, { unicode: true, unicodeSets: false }) &&
87260
+ validateRegExpPattern(pattern, { unicode: false, unicodeSets: true }) &&
87261
+ validateRegExpPattern(pattern, { unicode: false, unicodeSets: false })
87262
+ )
87263
+ : validateRegExpPattern(pattern, { unicode: flags.includes("u"), unicodeSets: flags.includes("v") })
86618
87264
  );
86619
87265
 
86620
87266
  if (message) {
@@ -87806,7 +88452,7 @@ function requireNoLoopFunc () {
87806
88452
  }
87807
88453
 
87808
88454
  const references = sourceCode.getScope(node).through;
87809
- const unsafeRefs = references.filter(r => !isSafe(loopNode, r)).map(r => r.identifier.name);
88455
+ const unsafeRefs = references.filter(r => r.resolved && !isSafe(loopNode, r)).map(r => r.identifier.name);
87810
88456
 
87811
88457
  if (unsafeRefs.length > 0) {
87812
88458
  context.report({
@@ -88424,7 +89070,7 @@ function requireRegularExpressions () {
88424
89070
 
88425
89071
  const { RegExpValidator } = requireRegexpp();
88426
89072
 
88427
- const REGEXPP_LATEST_ECMA_VERSION = 2022;
89073
+ const REGEXPP_LATEST_ECMA_VERSION = 2024;
88428
89074
 
88429
89075
  /**
88430
89076
  * Checks if the given regular expression pattern would be valid with the `u` flag.
@@ -88444,7 +89090,7 @@ function requireRegularExpressions () {
88444
89090
  });
88445
89091
 
88446
89092
  try {
88447
- validator.validatePattern(pattern, void 0, void 0, /* uFlag = */ true);
89093
+ validator.validatePattern(pattern, void 0, void 0, { unicode: /* uFlag = */ true });
88448
89094
  } catch {
88449
89095
  return false;
88450
89096
  }
@@ -88485,7 +89131,7 @@ function requireNoMisleadingCharacterClass () {
88485
89131
  *
88486
89132
  * CharacterClassRange syntax can steal a part of character sequence,
88487
89133
  * so this function reverts CharacterClassRange syntax and restore the sequence.
88488
- * @param {regexpp.AST.CharacterClassElement[]} nodes The node list to iterate character sequences.
89134
+ * @param {import('@eslint-community/regexpp').AST.CharacterClassElement[]} nodes The node list to iterate character sequences.
88489
89135
  * @returns {IterableIterator<number[]>} The list of character sequences.
88490
89136
  */
88491
89137
  function *iterateCharacterSequence(nodes) {
@@ -88504,6 +89150,9 @@ function requireNoMisleadingCharacterClass () {
88504
89150
  break;
88505
89151
 
88506
89152
  case "CharacterSet":
89153
+ case "CharacterClass": // [[]] nesting character class
89154
+ case "ClassStringDisjunction": // \q{...}
89155
+ case "ExpressionCharacterClass": // [A--B]
88507
89156
  if (seq.length > 0) {
88508
89157
  yield seq;
88509
89158
  seq = [];
@@ -88611,7 +89260,10 @@ function requireNoMisleadingCharacterClass () {
88611
89260
  pattern,
88612
89261
  0,
88613
89262
  pattern.length,
88614
- flags.includes("u")
89263
+ {
89264
+ unicode: flags.includes("u"),
89265
+ unicodeSets: flags.includes("v")
89266
+ }
88615
89267
  );
88616
89268
  } catch {
88617
89269
 
@@ -91990,7 +92642,7 @@ function requireNoRegexSpaces () {
91990
92642
  let regExpAST;
91991
92643
 
91992
92644
  try {
91993
- regExpAST = regExpParser.parsePattern(pattern, 0, pattern.length, flags.includes("u"));
92645
+ regExpAST = regExpParser.parsePattern(pattern, 0, pattern.length, { unicode: flags.includes("u"), unicodeSets: flags.includes("v") });
91994
92646
  } catch {
91995
92647
 
91996
92648
  // Ignore regular expressions with syntax errors
@@ -92068,13 +92720,28 @@ function requireNoRegexSpaces () {
92068
92720
  const regExpVar = astUtils.getVariableByName(scope, "RegExp");
92069
92721
  const shadowed = regExpVar && regExpVar.defs.length > 0;
92070
92722
  const patternNode = node.arguments[0];
92071
- const flagsNode = node.arguments[1];
92072
92723
 
92073
92724
  if (node.callee.type === "Identifier" && node.callee.name === "RegExp" && isString(patternNode) && !shadowed) {
92074
92725
  const pattern = patternNode.value;
92075
92726
  const rawPattern = patternNode.raw.slice(1, -1);
92076
92727
  const rawPatternStartRange = patternNode.range[0] + 1;
92077
- const flags = isString(flagsNode) ? flagsNode.value : "";
92728
+ let flags;
92729
+
92730
+ if (node.arguments.length < 2) {
92731
+
92732
+ // It has no flags.
92733
+ flags = "";
92734
+ } else {
92735
+ const flagsNode = node.arguments[1];
92736
+
92737
+ if (isString(flagsNode)) {
92738
+ flags = flagsNode.value;
92739
+ } else {
92740
+
92741
+ // The flags cannot be determined.
92742
+ return;
92743
+ }
92744
+ }
92078
92745
 
92079
92746
  checkRegex(
92080
92747
  node,
@@ -94035,6 +94702,7 @@ function requireNoReturnAssign () {
94035
94702
  /**
94036
94703
  * @fileoverview Disallows unnecessary `return await`
94037
94704
  * @author Jordan Harband
94705
+ * @deprecated in ESLint v8.46.0
94038
94706
  */
94039
94707
 
94040
94708
  var noReturnAwait;
@@ -94066,6 +94734,10 @@ function requireNoReturnAwait () {
94066
94734
 
94067
94735
  fixable: null,
94068
94736
 
94737
+ deprecated: true,
94738
+
94739
+ replacedBy: [],
94740
+
94069
94741
  schema: [
94070
94742
  ],
94071
94743
 
@@ -100183,7 +100855,7 @@ function requireNoUselessBackreference () {
100183
100855
  let regExpAST;
100184
100856
 
100185
100857
  try {
100186
- regExpAST = parser.parsePattern(pattern, 0, pattern.length, flags.includes("u"));
100858
+ regExpAST = parser.parsePattern(pattern, 0, pattern.length, { unicode: flags.includes("u"), unicodeSets: flags.includes("v") });
100187
100859
  } catch {
100188
100860
 
100189
100861
  // Ignore regular expressions with syntax errors
@@ -100958,7 +101630,12 @@ function requireNoUselessEscape () {
100958
101630
  hasRequiredNoUselessEscape = 1;
100959
101631
 
100960
101632
  const astUtils = requireAstUtils();
101633
+ const { RegExpParser, visitRegExpAST } = requireRegexpp();
100961
101634
 
101635
+ /**
101636
+ * @typedef {import('@eslint-community/regexpp').AST.CharacterClass} CharacterClass
101637
+ * @typedef {import('@eslint-community/regexpp').AST.ExpressionCharacterClass} ExpressionCharacterClass
101638
+ */
100962
101639
  //------------------------------------------------------------------------------
100963
101640
  // Rule Definition
100964
101641
  //------------------------------------------------------------------------------
@@ -100980,55 +101657,17 @@ function requireNoUselessEscape () {
100980
101657
  const REGEX_GENERAL_ESCAPES = new Set("\\bcdDfnpPrsStvwWxu0123456789]");
100981
101658
  const REGEX_NON_CHARCLASS_ESCAPES = union(REGEX_GENERAL_ESCAPES, new Set("^/.$*+?[{}|()Bk"));
100982
101659
 
100983
- /**
100984
- * Parses a regular expression into a list of characters with character class info.
100985
- * @param {string} regExpText The raw text used to create the regular expression
100986
- * @returns {Object[]} A list of characters, each with info on escaping and whether they're in a character class.
100987
- * @example
100988
- *
100989
- * parseRegExp("a\\b[cd-]");
100990
- *
100991
- * // returns:
100992
- * [
100993
- * { text: "a", index: 0, escaped: false, inCharClass: false, startsCharClass: false, endsCharClass: false },
100994
- * { text: "b", index: 2, escaped: true, inCharClass: false, startsCharClass: false, endsCharClass: false },
100995
- * { text: "c", index: 4, escaped: false, inCharClass: true, startsCharClass: true, endsCharClass: false },
100996
- * { text: "d", index: 5, escaped: false, inCharClass: true, startsCharClass: false, endsCharClass: false },
100997
- * { text: "-", index: 6, escaped: false, inCharClass: true, startsCharClass: false, endsCharClass: false }
100998
- * ];
100999
- *
101660
+ /*
101661
+ * Set of characters that require escaping in character classes in `unicodeSets` mode.
101662
+ * ( ) [ ] { } / - \ | are ClassSetSyntaxCharacter
101000
101663
  */
101001
- function parseRegExp(regExpText) {
101002
- const charList = [];
101003
-
101004
- regExpText.split("").reduce((state, char, index) => {
101005
- if (!state.escapeNextChar) {
101006
- if (char === "\\") {
101007
- return Object.assign(state, { escapeNextChar: true });
101008
- }
101009
- if (char === "[" && !state.inCharClass) {
101010
- return Object.assign(state, { inCharClass: true, startingCharClass: true });
101011
- }
101012
- if (char === "]" && state.inCharClass) {
101013
- if (charList.length && charList[charList.length - 1].inCharClass) {
101014
- charList[charList.length - 1].endsCharClass = true;
101015
- }
101016
- return Object.assign(state, { inCharClass: false, startingCharClass: false });
101017
- }
101018
- }
101019
- charList.push({
101020
- text: char,
101021
- index,
101022
- escaped: state.escapeNextChar,
101023
- inCharClass: state.inCharClass,
101024
- startsCharClass: state.startingCharClass,
101025
- endsCharClass: false
101026
- });
101027
- return Object.assign(state, { escapeNextChar: false, startingCharClass: false });
101028
- }, { escapeNextChar: false, inCharClass: false, startingCharClass: false });
101664
+ const REGEX_CLASSSET_CHARACTER_ESCAPES = union(REGEX_GENERAL_ESCAPES, new Set("q/[{}|()-"));
101029
101665
 
101030
- return charList;
101031
- }
101666
+ /*
101667
+ * A single character set of ClassSetReservedDoublePunctuator.
101668
+ * && !! ## $$ %% ** ++ ,, .. :: ;; << == >> ?? @@ ^^ `` ~~ are ClassSetReservedDoublePunctuator
101669
+ */
101670
+ const REGEX_CLASS_SET_RESERVED_DOUBLE_PUNCTUATOR = new Set("!#$%&*+,.:;<=>?@^`~");
101032
101671
 
101033
101672
  /** @type {import('../shared/types').Rule} */
101034
101673
  noUselessEscape = {
@@ -101055,15 +101694,17 @@ function requireNoUselessEscape () {
101055
101694
 
101056
101695
  create(context) {
101057
101696
  const sourceCode = context.sourceCode;
101697
+ const parser = new RegExpParser();
101058
101698
 
101059
101699
  /**
101060
101700
  * Reports a node
101061
101701
  * @param {ASTNode} node The node to report
101062
101702
  * @param {number} startOffset The backslash's offset from the start of the node
101063
101703
  * @param {string} character The uselessly escaped character (not including the backslash)
101704
+ * @param {boolean} [disableEscapeBackslashSuggest] `true` if escapeBackslash suggestion should be turned off.
101064
101705
  * @returns {void}
101065
101706
  */
101066
- function report(node, startOffset, character) {
101707
+ function report(node, startOffset, character, disableEscapeBackslashSuggest) {
101067
101708
  const rangeStart = node.range[0] + startOffset;
101068
101709
  const range = [rangeStart, rangeStart + 1];
101069
101710
  const start = sourceCode.getLocFromIndex(rangeStart);
@@ -101086,12 +101727,16 @@ function requireNoUselessEscape () {
101086
101727
  return fixer.removeRange(range);
101087
101728
  }
101088
101729
  },
101089
- {
101090
- messageId: "escapeBackslash",
101091
- fix(fixer) {
101092
- return fixer.insertTextBeforeRange(range, "\\");
101093
- }
101094
- }
101730
+ ...disableEscapeBackslashSuggest
101731
+ ? []
101732
+ : [
101733
+ {
101734
+ messageId: "escapeBackslash",
101735
+ fix(fixer) {
101736
+ return fixer.insertTextBeforeRange(range, "\\");
101737
+ }
101738
+ }
101739
+ ]
101095
101740
  ]
101096
101741
  });
101097
101742
  }
@@ -101134,6 +101779,133 @@ function requireNoUselessEscape () {
101134
101779
  }
101135
101780
  }
101136
101781
 
101782
+ /**
101783
+ * Checks if the escape character in given regexp is unnecessary.
101784
+ * @private
101785
+ * @param {ASTNode} node node to validate.
101786
+ * @returns {void}
101787
+ */
101788
+ function validateRegExp(node) {
101789
+ const { pattern, flags } = node.regex;
101790
+ let patternNode;
101791
+ const unicode = flags.includes("u");
101792
+ const unicodeSets = flags.includes("v");
101793
+
101794
+ try {
101795
+ patternNode = parser.parsePattern(pattern, 0, pattern.length, { unicode, unicodeSets });
101796
+ } catch {
101797
+
101798
+ // Ignore regular expressions with syntax errors
101799
+ return;
101800
+ }
101801
+
101802
+ /** @type {(CharacterClass | ExpressionCharacterClass)[]} */
101803
+ const characterClassStack = [];
101804
+
101805
+ visitRegExpAST(patternNode, {
101806
+ onCharacterClassEnter: characterClassNode => characterClassStack.unshift(characterClassNode),
101807
+ onCharacterClassLeave: () => characterClassStack.shift(),
101808
+ onExpressionCharacterClassEnter: characterClassNode => characterClassStack.unshift(characterClassNode),
101809
+ onExpressionCharacterClassLeave: () => characterClassStack.shift(),
101810
+ onCharacterEnter(characterNode) {
101811
+ if (!characterNode.raw.startsWith("\\")) {
101812
+
101813
+ // It's not an escaped character.
101814
+ return;
101815
+ }
101816
+
101817
+ const escapedChar = characterNode.raw.slice(1);
101818
+
101819
+ if (escapedChar !== String.fromCodePoint(characterNode.value)) {
101820
+
101821
+ // It's a valid escape.
101822
+ return;
101823
+ }
101824
+ let allowedEscapes;
101825
+
101826
+ if (characterClassStack.length) {
101827
+ allowedEscapes = unicodeSets ? REGEX_CLASSSET_CHARACTER_ESCAPES : REGEX_GENERAL_ESCAPES;
101828
+ } else {
101829
+ allowedEscapes = REGEX_NON_CHARCLASS_ESCAPES;
101830
+ }
101831
+ if (allowedEscapes.has(escapedChar)) {
101832
+ return;
101833
+ }
101834
+
101835
+ const reportedIndex = characterNode.start + 1;
101836
+ let disableEscapeBackslashSuggest = false;
101837
+
101838
+ if (characterClassStack.length) {
101839
+ const characterClassNode = characterClassStack[0];
101840
+
101841
+ if (escapedChar === "^") {
101842
+
101843
+ /*
101844
+ * The '^' character is also a special case; it must always be escaped outside of character classes, but
101845
+ * it only needs to be escaped in character classes if it's at the beginning of the character class. To
101846
+ * account for this, consider it to be a valid escape character outside of character classes, and filter
101847
+ * out '^' characters that appear at the start of a character class.
101848
+ */
101849
+ if (characterClassNode.start + 1 === characterNode.start) {
101850
+
101851
+ return;
101852
+ }
101853
+ }
101854
+ if (!unicodeSets) {
101855
+ if (escapedChar === "-") {
101856
+
101857
+ /*
101858
+ * The '-' character is a special case, because it's only valid to escape it if it's in a character
101859
+ * class, and is not at either edge of the character class. To account for this, don't consider '-'
101860
+ * characters to be valid in general, and filter out '-' characters that appear in the middle of a
101861
+ * character class.
101862
+ */
101863
+ if (characterClassNode.start + 1 !== characterNode.start && characterNode.end !== characterClassNode.end - 1) {
101864
+
101865
+ return;
101866
+ }
101867
+ }
101868
+ } else { // unicodeSets mode
101869
+ if (REGEX_CLASS_SET_RESERVED_DOUBLE_PUNCTUATOR.has(escapedChar)) {
101870
+
101871
+ // Escaping is valid if it is a ClassSetReservedDoublePunctuator.
101872
+ if (pattern[characterNode.end] === escapedChar) {
101873
+ return;
101874
+ }
101875
+ if (pattern[characterNode.start - 1] === escapedChar) {
101876
+ if (escapedChar !== "^") {
101877
+ return;
101878
+ }
101879
+
101880
+ // If the previous character is a `negate` caret(`^`), escape to caret is unnecessary.
101881
+
101882
+ if (!characterClassNode.negate) {
101883
+ return;
101884
+ }
101885
+ const negateCaretIndex = characterClassNode.start + 1;
101886
+
101887
+ if (negateCaretIndex < characterNode.start - 1) {
101888
+ return;
101889
+ }
101890
+ }
101891
+ }
101892
+
101893
+ if (characterNode.parent.type === "ClassIntersection" || characterNode.parent.type === "ClassSubtraction") {
101894
+ disableEscapeBackslashSuggest = true;
101895
+ }
101896
+ }
101897
+ }
101898
+
101899
+ report(
101900
+ node,
101901
+ reportedIndex,
101902
+ escapedChar,
101903
+ disableEscapeBackslashSuggest
101904
+ );
101905
+ }
101906
+ });
101907
+ }
101908
+
101137
101909
  /**
101138
101910
  * Checks if a node has an escape.
101139
101911
  * @param {ASTNode} node node to check.
@@ -101172,32 +101944,7 @@ function requireNoUselessEscape () {
101172
101944
  validateString(node, match);
101173
101945
  }
101174
101946
  } else if (node.regex) {
101175
- parseRegExp(node.regex.pattern)
101176
-
101177
- /*
101178
- * The '-' character is a special case, because it's only valid to escape it if it's in a character
101179
- * class, and is not at either edge of the character class. To account for this, don't consider '-'
101180
- * characters to be valid in general, and filter out '-' characters that appear in the middle of a
101181
- * character class.
101182
- */
101183
- .filter(charInfo => !(charInfo.text === "-" && charInfo.inCharClass && !charInfo.startsCharClass && !charInfo.endsCharClass))
101184
-
101185
- /*
101186
- * The '^' character is also a special case; it must always be escaped outside of character classes, but
101187
- * it only needs to be escaped in character classes if it's at the beginning of the character class. To
101188
- * account for this, consider it to be a valid escape character outside of character classes, and filter
101189
- * out '^' characters that appear at the start of a character class.
101190
- */
101191
- .filter(charInfo => !(charInfo.text === "^" && charInfo.startsCharClass))
101192
-
101193
- // Filter out characters that aren't escaped.
101194
- .filter(charInfo => charInfo.escaped)
101195
-
101196
- // Filter out characters that are valid to escape, based on their position in the regular expression.
101197
- .filter(charInfo => !(charInfo.inCharClass ? REGEX_GENERAL_ESCAPES : REGEX_NON_CHARCLASS_ESCAPES).has(charInfo.text))
101198
-
101199
- // Report all the remaining characters.
101200
- .forEach(charInfo => report(node, charInfo.index, charInfo.text));
101947
+ validateRegExp(node);
101201
101948
  }
101202
101949
 
101203
101950
  }
@@ -107524,14 +108271,17 @@ function requirePreferNamedCaptureGroup () {
107524
108271
  * @param {string} pattern The regular expression pattern to be checked.
107525
108272
  * @param {ASTNode} node AST node which contains the regular expression or a call/new expression.
107526
108273
  * @param {ASTNode} regexNode AST node which contains the regular expression.
107527
- * @param {boolean} uFlag Flag indicates whether unicode mode is enabled or not.
108274
+ * @param {string|null} flags The regular expression flags to be checked.
107528
108275
  * @returns {void}
107529
108276
  */
107530
- function checkRegex(pattern, node, regexNode, uFlag) {
108277
+ function checkRegex(pattern, node, regexNode, flags) {
107531
108278
  let ast;
107532
108279
 
107533
108280
  try {
107534
- ast = parser.parsePattern(pattern, 0, pattern.length, uFlag);
108281
+ ast = parser.parsePattern(pattern, 0, pattern.length, {
108282
+ unicode: Boolean(flags && flags.includes("u")),
108283
+ unicodeSets: Boolean(flags && flags.includes("v"))
108284
+ });
107535
108285
  } catch {
107536
108286
 
107537
108287
  // ignore regex syntax errors
@@ -107560,7 +108310,7 @@ function requirePreferNamedCaptureGroup () {
107560
108310
  return {
107561
108311
  Literal(node) {
107562
108312
  if (node.regex) {
107563
- checkRegex(node.regex.pattern, node, node, node.regex.flags.includes("u"));
108313
+ checkRegex(node.regex.pattern, node, node, node.regex.flags);
107564
108314
  }
107565
108315
  },
107566
108316
  Program(node) {
@@ -107578,7 +108328,7 @@ function requirePreferNamedCaptureGroup () {
107578
108328
  const flags = getStringIfConstant(refNode.arguments[1]);
107579
108329
 
107580
108330
  if (regex) {
107581
- checkRegex(regex, refNode, refNode.arguments[0], flags && flags.includes("u"));
108331
+ checkRegex(regex, refNode, refNode.arguments[0], flags);
107582
108332
  }
107583
108333
  }
107584
108334
  }
@@ -108697,7 +109447,7 @@ function requirePreferRegexLiterals () {
108697
109447
  /**
108698
109448
  * Returns a ecmaVersion compatible for regexpp.
108699
109449
  * @param {number} ecmaVersion The ecmaVersion to convert.
108700
- * @returns {import("regexpp/ecma-versions").EcmaVersion} The resulting ecmaVersion compatible for regexpp.
109450
+ * @returns {import("@eslint-community/regexpp/ecma-versions").EcmaVersion} The resulting ecmaVersion compatible for regexpp.
108701
109451
  */
108702
109452
  function getRegexppEcmaVersion(ecmaVersion) {
108703
109453
  if (ecmaVersion <= 5) {
@@ -108753,7 +109503,10 @@ function requirePreferRegexLiterals () {
108753
109503
  const validator = new RegExpValidator({ ecmaVersion: regexppEcmaVersion });
108754
109504
 
108755
109505
  try {
108756
- validator.validatePattern(pattern, 0, pattern.length, flags ? flags.includes("u") : false);
109506
+ validator.validatePattern(pattern, 0, pattern.length, {
109507
+ unicode: flags ? flags.includes("u") : false,
109508
+ unicodeSets: flags ? flags.includes("v") : false
109509
+ });
108757
109510
  if (flags) {
108758
109511
  validator.validateFlags(flags);
108759
109512
  }
@@ -108917,7 +109670,10 @@ function requirePreferRegexLiterals () {
108917
109670
  if (regexContent && !noFix) {
108918
109671
  let charIncrease = 0;
108919
109672
 
108920
- const ast = new RegExpParser({ ecmaVersion: regexppEcmaVersion }).parsePattern(regexContent, 0, regexContent.length, flags ? flags.includes("u") : false);
109673
+ const ast = new RegExpParser({ ecmaVersion: regexppEcmaVersion }).parsePattern(regexContent, 0, regexContent.length, {
109674
+ unicode: flags ? flags.includes("u") : false,
109675
+ unicodeSets: flags ? flags.includes("v") : false
109676
+ });
108921
109677
 
108922
109678
  visitRegExpAST(ast, {
108923
109679
  onCharacterEnter(characterNode) {
@@ -110952,7 +111708,7 @@ function requireRequireUnicodeRegexp () {
110952
111708
  type: "suggestion",
110953
111709
 
110954
111710
  docs: {
110955
- description: "Enforce the use of `u` flag on RegExp",
111711
+ description: "Enforce the use of `u` or `v` flag on RegExp",
110956
111712
  recommended: false,
110957
111713
  url: "https://eslint.org/docs/latest/rules/require-unicode-regexp"
110958
111714
  },
@@ -110975,7 +111731,7 @@ function requireRequireUnicodeRegexp () {
110975
111731
  "Literal[regex]"(node) {
110976
111732
  const flags = node.regex.flags || "";
110977
111733
 
110978
- if (!flags.includes("u")) {
111734
+ if (!flags.includes("u") && !flags.includes("v")) {
110979
111735
  context.report({
110980
111736
  messageId: "requireUFlag",
110981
111737
  node,
@@ -111009,7 +111765,7 @@ function requireRequireUnicodeRegexp () {
111009
111765
  const pattern = getStringIfConstant(patternNode, scope);
111010
111766
  const flags = getStringIfConstant(flagsNode, scope);
111011
111767
 
111012
- if (!flagsNode || (typeof flags === "string" && !flags.includes("u"))) {
111768
+ if (!flagsNode || (typeof flags === "string" && !flags.includes("u") && !flags.includes("v"))) {
111013
111769
  context.report({
111014
111770
  messageId: "requireUFlag",
111015
111771
  node: refNode,
@@ -123207,6 +123963,38 @@ function requireFlatConfigSchema () {
123207
123963
  }
123208
123964
  }
123209
123965
 
123966
+ /**
123967
+ * The error type when there's an eslintrc-style options in a flat config.
123968
+ */
123969
+ class IncompatibleKeyError extends Error {
123970
+
123971
+ /**
123972
+ * @param {string} key The invalid key.
123973
+ */
123974
+ constructor(key) {
123975
+ super("This appears to be in eslintrc format rather than flat config format.");
123976
+ this.messageTemplate = "eslintrc-incompat";
123977
+ this.messageData = { key };
123978
+ }
123979
+ }
123980
+
123981
+ /**
123982
+ * The error type when there's an eslintrc-style plugins array found.
123983
+ */
123984
+ class IncompatiblePluginsError extends Error {
123985
+
123986
+ /**
123987
+ * Creates a new instance.
123988
+ * @param {Array<string>} plugins The plugins array.
123989
+ */
123990
+ constructor(plugins) {
123991
+ super("This appears to be in eslintrc format (array of strings) rather than flat config format (object).");
123992
+ this.messageTemplate = "eslintrc-plugins";
123993
+ this.messageData = { plugins };
123994
+ }
123995
+ }
123996
+
123997
+
123210
123998
  //-----------------------------------------------------------------------------
123211
123999
  // Low-Level Schemas
123212
124000
  //-----------------------------------------------------------------------------
@@ -123298,6 +124086,11 @@ function requireFlatConfigSchema () {
123298
124086
  throw new TypeError("Expected an object.");
123299
124087
  }
123300
124088
 
124089
+ // make sure it's not an array, which would mean eslintrc-style is used
124090
+ if (Array.isArray(value)) {
124091
+ throw new IncompatiblePluginsError(value);
124092
+ }
124093
+
123301
124094
  // second check the keys to make sure they are objects
123302
124095
  for (const key of Object.keys(value)) {
123303
124096
 
@@ -123433,11 +124226,44 @@ function requireFlatConfigSchema () {
123433
124226
  }
123434
124227
  };
123435
124228
 
124229
+ /**
124230
+ * Creates a schema that always throws an error. Useful for warning
124231
+ * about eslintrc-style keys.
124232
+ * @param {string} key The eslintrc key to create a schema for.
124233
+ * @returns {ObjectPropertySchema} The schema.
124234
+ */
124235
+ function createEslintrcErrorSchema(key) {
124236
+ return {
124237
+ merge: "replace",
124238
+ validate() {
124239
+ throw new IncompatibleKeyError(key);
124240
+ }
124241
+ };
124242
+ }
124243
+
124244
+ const eslintrcKeys = [
124245
+ "env",
124246
+ "extends",
124247
+ "globals",
124248
+ "ignorePatterns",
124249
+ "noInlineConfig",
124250
+ "overrides",
124251
+ "parser",
124252
+ "parserOptions",
124253
+ "reportUnusedDisableDirectives",
124254
+ "root"
124255
+ ];
124256
+
123436
124257
  //-----------------------------------------------------------------------------
123437
124258
  // Full schema
123438
124259
  //-----------------------------------------------------------------------------
123439
124260
 
123440
124261
  flatConfigSchema.flatConfigSchema = {
124262
+
124263
+ // eslintrc-style keys that should always error
124264
+ ...Object.fromEntries(eslintrcKeys.map(key => [key, createEslintrcErrorSchema(key)])),
124265
+
124266
+ // flat config keys
123441
124267
  settings: deepObjectAssignSchema,
123442
124268
  linterOptions: {
123443
124269
  schema: {
@@ -124164,7 +124990,6 @@ function requireEslintAll () {
124164
124990
  "no-restricted-properties": "error",
124165
124991
  "no-restricted-syntax": "error",
124166
124992
  "no-return-assign": "error",
124167
- "no-return-await": "error",
124168
124993
  "no-script-url": "error",
124169
124994
  "no-self-assign": "error",
124170
124995
  "no-self-compare": "error",