immosquare-cleaner 0.1.40 → 0.1.41

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/lib/immosquare-cleaner/version.rb +1 -1
  3. data/node_modules/@eslint/config-array/README.md +9 -3
  4. data/node_modules/@eslint/config-array/dist/cjs/index.cjs +1 -0
  5. data/node_modules/@eslint/config-array/dist/esm/index.js +1 -0
  6. data/node_modules/@eslint/config-array/package.json +2 -2
  7. data/node_modules/@eslint/eslintrc/node_modules/espree/LICENSE +25 -0
  8. data/node_modules/@eslint/eslintrc/node_modules/espree/README.md +244 -0
  9. data/node_modules/@eslint/eslintrc/node_modules/espree/dist/espree.cjs +883 -0
  10. data/node_modules/@eslint/eslintrc/node_modules/espree/espree.js +177 -0
  11. data/node_modules/@eslint/eslintrc/node_modules/espree/lib/espree.js +349 -0
  12. data/node_modules/@eslint/eslintrc/node_modules/espree/lib/features.js +27 -0
  13. data/node_modules/@eslint/eslintrc/node_modules/espree/lib/options.js +123 -0
  14. data/node_modules/@eslint/eslintrc/node_modules/espree/lib/token-translator.js +263 -0
  15. data/node_modules/@eslint/eslintrc/node_modules/espree/lib/version.js +3 -0
  16. data/node_modules/@eslint/eslintrc/node_modules/espree/node_modules/acorn/CHANGELOG.md +880 -0
  17. data/node_modules/@eslint/eslintrc/node_modules/espree/node_modules/acorn/LICENSE +21 -0
  18. data/node_modules/@eslint/eslintrc/node_modules/espree/node_modules/acorn/README.md +283 -0
  19. data/node_modules/@eslint/eslintrc/node_modules/espree/node_modules/acorn/bin/acorn +4 -0
  20. data/node_modules/@eslint/eslintrc/node_modules/espree/node_modules/acorn/dist/acorn.d.mts +857 -0
  21. data/node_modules/@eslint/eslintrc/node_modules/espree/node_modules/acorn/dist/acorn.d.ts +857 -0
  22. data/node_modules/@eslint/eslintrc/node_modules/espree/node_modules/acorn/dist/acorn.js +6002 -0
  23. data/node_modules/@eslint/eslintrc/node_modules/espree/node_modules/acorn/dist/acorn.mjs +5973 -0
  24. data/node_modules/@eslint/eslintrc/node_modules/espree/node_modules/acorn/dist/bin.js +90 -0
  25. data/node_modules/@eslint/eslintrc/node_modules/espree/node_modules/acorn/package.json +50 -0
  26. data/node_modules/@eslint/eslintrc/node_modules/espree/package.json +86 -0
  27. data/node_modules/@eslint/js/package.json +1 -1
  28. data/node_modules/@eslint-community/regexpp/index.d.ts +19 -5
  29. data/node_modules/@eslint-community/regexpp/index.js +138 -17
  30. data/node_modules/@eslint-community/regexpp/index.js.map +1 -1
  31. data/node_modules/@eslint-community/regexpp/index.mjs +138 -17
  32. data/node_modules/@eslint-community/regexpp/index.mjs.map +1 -1
  33. data/node_modules/@eslint-community/regexpp/package.json +1 -3
  34. data/node_modules/acorn/CHANGELOG.md +24 -0
  35. data/node_modules/acorn/README.md +5 -6
  36. data/node_modules/acorn/dist/acorn.d.mts +8 -9
  37. data/node_modules/acorn/dist/acorn.d.ts +8 -9
  38. data/node_modules/acorn/dist/acorn.js +92 -29
  39. data/node_modules/acorn/dist/acorn.mjs +92 -29
  40. data/node_modules/acorn/package.json +3 -3
  41. data/node_modules/eslint/README.md +7 -8
  42. data/node_modules/eslint/conf/ecma-version.js +1 -1
  43. data/node_modules/eslint/conf/globals.js +6 -1
  44. data/node_modules/eslint/lib/cli.js +23 -2
  45. data/node_modules/eslint/lib/eslint/eslint-helpers.js +5 -0
  46. data/node_modules/eslint/lib/eslint/eslint.js +16 -2
  47. data/node_modules/eslint/lib/eslint/legacy-eslint.js +14 -0
  48. data/node_modules/eslint/lib/languages/js/index.js +10 -5
  49. data/node_modules/eslint/lib/languages/js/source-code/source-code.js +16 -6
  50. data/node_modules/eslint/lib/linter/apply-disable-directives.js +6 -3
  51. data/node_modules/eslint/lib/linter/config-comment-parser.js +3 -16
  52. data/node_modules/eslint/lib/linter/linter.js +194 -149
  53. data/node_modules/eslint/lib/linter/node-event-generator.js +2 -4
  54. data/node_modules/eslint/lib/linter/vfile.js +7 -0
  55. data/node_modules/eslint/lib/options.js +13 -1
  56. data/node_modules/eslint/lib/rules/no-restricted-imports.js +12 -5
  57. data/node_modules/eslint/lib/rules/no-unused-vars.js +34 -32
  58. data/node_modules/eslint/lib/rules/no-useless-backreference.js +81 -31
  59. data/node_modules/eslint/lib/rules/utils/regular-expressions.js +1 -1
  60. data/node_modules/eslint/lib/shared/flags.js +26 -0
  61. data/node_modules/eslint/lib/shared/logging.js +10 -1
  62. data/node_modules/eslint/lib/shared/types.js +1 -1
  63. data/node_modules/eslint/package.json +9 -13
  64. data/node_modules/eslint-scope/dist/eslint-scope.cjs +2 -2
  65. data/node_modules/eslint-scope/lib/referencer.js +1 -1
  66. data/node_modules/eslint-scope/lib/version.js +1 -1
  67. data/node_modules/eslint-scope/package.json +2 -2
  68. data/node_modules/espree/README.md +5 -5
  69. data/node_modules/espree/dist/espree.cjs +62 -6
  70. data/node_modules/espree/espree.js +1 -4
  71. data/node_modules/espree/lib/options.js +3 -2
  72. data/node_modules/espree/lib/token-translator.js +1 -1
  73. data/node_modules/espree/lib/version.js +1 -1
  74. data/node_modules/espree/package.json +7 -7
  75. data/node_modules/js-tokens/CHANGELOG.md +17 -0
  76. data/node_modules/js-tokens/LICENSE +1 -1
  77. data/node_modules/js-tokens/README.md +25 -7
  78. data/node_modules/js-tokens/index.js +3 -3
  79. data/node_modules/js-tokens/package.json +5 -5
  80. data/node_modules/jscodeshift/CHANGELOG.md +5 -0
  81. data/node_modules/jscodeshift/bin/jscodeshift.js +1 -1
  82. data/node_modules/jscodeshift/package.json +1 -2
  83. data/node_modules/jscodeshift/website/index.htm +9 -0
  84. data/node_modules/prettier/LICENSE +35 -34
  85. data/node_modules/prettier/doc.js +2 -2
  86. data/node_modules/prettier/doc.mjs +2 -2
  87. data/node_modules/prettier/index.cjs +8 -8
  88. data/node_modules/prettier/index.d.ts +1 -2
  89. data/node_modules/prettier/index.mjs +636 -704
  90. data/node_modules/prettier/internal/cli.mjs +4 -4
  91. data/node_modules/prettier/package.json +1 -1
  92. data/node_modules/prettier/plugins/acorn.js +14 -12
  93. data/node_modules/prettier/plugins/acorn.mjs +14 -12
  94. data/node_modules/prettier/plugins/angular.js +1 -1
  95. data/node_modules/prettier/plugins/angular.mjs +1 -1
  96. data/node_modules/prettier/plugins/babel.js +10 -11
  97. data/node_modules/prettier/plugins/babel.mjs +10 -11
  98. data/node_modules/prettier/plugins/estree.js +27 -27
  99. data/node_modules/prettier/plugins/estree.mjs +27 -27
  100. data/node_modules/prettier/plugins/flow.js +15 -16
  101. data/node_modules/prettier/plugins/flow.mjs +15 -16
  102. data/node_modules/prettier/plugins/glimmer.js +5 -5
  103. data/node_modules/prettier/plugins/glimmer.mjs +5 -5
  104. data/node_modules/prettier/plugins/graphql.js +8 -8
  105. data/node_modules/prettier/plugins/graphql.mjs +8 -8
  106. data/node_modules/prettier/plugins/html.js +17 -17
  107. data/node_modules/prettier/plugins/html.mjs +17 -17
  108. data/node_modules/prettier/plugins/markdown.js +44 -44
  109. data/node_modules/prettier/plugins/markdown.mjs +44 -44
  110. data/node_modules/prettier/plugins/meriyah.js +4 -5
  111. data/node_modules/prettier/plugins/meriyah.mjs +4 -5
  112. data/node_modules/prettier/plugins/postcss.js +26 -26
  113. data/node_modules/prettier/plugins/postcss.mjs +26 -26
  114. data/node_modules/prettier/plugins/typescript.js +15 -20
  115. data/node_modules/prettier/plugins/typescript.mjs +15 -20
  116. data/node_modules/prettier/plugins/yaml.js +6 -6
  117. data/node_modules/prettier/plugins/yaml.mjs +6 -6
  118. data/node_modules/prettier/standalone.js +31 -30
  119. data/node_modules/prettier/standalone.mjs +28 -27
  120. data/package.json +4 -4
  121. metadata +24 -2
@@ -0,0 +1,177 @@
1
+ /* eslint-disable jsdoc/no-multi-asterisks -- needed to preserve original formatting of licences */
2
+
3
+ /**
4
+ * @fileoverview Main Espree file that converts Acorn into Esprima output.
5
+ *
6
+ * This file contains code from the following MIT-licensed projects:
7
+ * 1. Acorn
8
+ * 2. Babylon
9
+ * 3. Babel-ESLint
10
+ *
11
+ * This file also contains code from Esprima, which is BSD licensed.
12
+ *
13
+ * Acorn is Copyright 2012-2015 Acorn Contributors (https://github.com/marijnh/acorn/blob/master/AUTHORS)
14
+ * Babylon is Copyright 2014-2015 various contributors (https://github.com/babel/babel/blob/master/packages/babylon/AUTHORS)
15
+ * Babel-ESLint is Copyright 2014-2015 Sebastian McKenzie <sebmck@gmail.com>
16
+ *
17
+ * Redistribution and use in source and binary forms, with or without
18
+ * modification, are permitted provided that the following conditions are met:
19
+ *
20
+ * * Redistributions of source code must retain the above copyright
21
+ * notice, this list of conditions and the following disclaimer.
22
+ * * Redistributions in binary form must reproduce the above copyright
23
+ * notice, this list of conditions and the following disclaimer in the
24
+ * documentation and/or other materials provided with the distribution.
25
+ *
26
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29
+ * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
30
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
33
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
+ *
37
+ * Esprima is Copyright (c) jQuery Foundation, Inc. and Contributors, All Rights Reserved.
38
+ *
39
+ * Redistribution and use in source and binary forms, with or without
40
+ * modification, are permitted provided that the following conditions are met:
41
+ *
42
+ * * Redistributions of source code must retain the above copyright
43
+ * notice, this list of conditions and the following disclaimer.
44
+ * * Redistributions in binary form must reproduce the above copyright
45
+ * notice, this list of conditions and the following disclaimer in the
46
+ * documentation and/or other materials provided with the distribution.
47
+ *
48
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
49
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51
+ * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
52
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
53
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
54
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
55
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
56
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
57
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
58
+ */
59
+
60
+ /* eslint-enable jsdoc/no-multi-asterisks -- needed to preserve original formatting of licences */
61
+
62
+ import * as acorn from "acorn";
63
+ import jsx from "acorn-jsx";
64
+ import espree from "./lib/espree.js";
65
+ import espreeVersion from "./lib/version.js";
66
+ import * as visitorKeys from "eslint-visitor-keys";
67
+ import { getLatestEcmaVersion, getSupportedEcmaVersions } from "./lib/options.js";
68
+
69
+
70
+ // To initialize lazily.
71
+ const parsers = {
72
+ _regular: null,
73
+ _jsx: null,
74
+
75
+ get regular() {
76
+ if (this._regular === null) {
77
+ this._regular = acorn.Parser.extend(espree());
78
+ }
79
+ return this._regular;
80
+ },
81
+
82
+ get jsx() {
83
+ if (this._jsx === null) {
84
+ this._jsx = acorn.Parser.extend(jsx(), espree());
85
+ }
86
+ return this._jsx;
87
+ },
88
+
89
+ get(options) {
90
+ const useJsx = Boolean(
91
+ options &&
92
+ options.ecmaFeatures &&
93
+ options.ecmaFeatures.jsx
94
+ );
95
+
96
+ return useJsx ? this.jsx : this.regular;
97
+ }
98
+ };
99
+
100
+ //------------------------------------------------------------------------------
101
+ // Tokenizer
102
+ //------------------------------------------------------------------------------
103
+
104
+ /**
105
+ * Tokenizes the given code.
106
+ * @param {string} code The code to tokenize.
107
+ * @param {Object} options Options defining how to tokenize.
108
+ * @returns {Token[]} An array of tokens.
109
+ * @throws {SyntaxError} If the input code is invalid.
110
+ * @private
111
+ */
112
+ export function tokenize(code, options) {
113
+ const Parser = parsers.get(options);
114
+
115
+ // Ensure to collect tokens.
116
+ if (!options || options.tokens !== true) {
117
+ options = Object.assign({}, options, { tokens: true }); // eslint-disable-line no-param-reassign -- stylistic choice
118
+ }
119
+
120
+ return new Parser(options, code).tokenize();
121
+ }
122
+
123
+ //------------------------------------------------------------------------------
124
+ // Parser
125
+ //------------------------------------------------------------------------------
126
+
127
+ /**
128
+ * Parses the given code.
129
+ * @param {string} code The code to tokenize.
130
+ * @param {Object} options Options defining how to tokenize.
131
+ * @returns {ASTNode} The "Program" AST node.
132
+ * @throws {SyntaxError} If the input code is invalid.
133
+ */
134
+ export function parse(code, options) {
135
+ const Parser = parsers.get(options);
136
+
137
+ return new Parser(options, code).parse();
138
+ }
139
+
140
+ //------------------------------------------------------------------------------
141
+ // Public
142
+ //------------------------------------------------------------------------------
143
+
144
+ export const version = espreeVersion;
145
+ export const name = "espree";
146
+
147
+ /* istanbul ignore next */
148
+ export const VisitorKeys = (function() {
149
+ return visitorKeys.KEYS;
150
+ }());
151
+
152
+ // Derive node types from VisitorKeys
153
+ /* istanbul ignore next */
154
+ export const Syntax = (function() {
155
+ let key,
156
+ types = {};
157
+
158
+ if (typeof Object.create === "function") {
159
+ types = Object.create(null);
160
+ }
161
+
162
+ for (key in VisitorKeys) {
163
+ if (Object.hasOwnProperty.call(VisitorKeys, key)) {
164
+ types[key] = key;
165
+ }
166
+ }
167
+
168
+ if (typeof Object.freeze === "function") {
169
+ Object.freeze(types);
170
+ }
171
+
172
+ return types;
173
+ }());
174
+
175
+ export const latestEcmaVersion = getLatestEcmaVersion();
176
+
177
+ export const supportedEcmaVersions = getSupportedEcmaVersions();
@@ -0,0 +1,349 @@
1
+ /* eslint no-param-reassign: 0 -- stylistic choice */
2
+
3
+ import TokenTranslator from "./token-translator.js";
4
+ import { normalizeOptions } from "./options.js";
5
+
6
+
7
+ const STATE = Symbol("espree's internal state");
8
+ const ESPRIMA_FINISH_NODE = Symbol("espree's esprimaFinishNode");
9
+
10
+
11
+ /**
12
+ * Converts an Acorn comment to a Esprima comment.
13
+ * @param {boolean} block True if it's a block comment, false if not.
14
+ * @param {string} text The text of the comment.
15
+ * @param {int} start The index at which the comment starts.
16
+ * @param {int} end The index at which the comment ends.
17
+ * @param {Location} startLoc The location at which the comment starts.
18
+ * @param {Location} endLoc The location at which the comment ends.
19
+ * @param {string} code The source code being parsed.
20
+ * @returns {Object} The comment object.
21
+ * @private
22
+ */
23
+ function convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc, code) {
24
+ let type;
25
+
26
+ if (block) {
27
+ type = "Block";
28
+ } else if (code.slice(start, start + 2) === "#!") {
29
+ type = "Hashbang";
30
+ } else {
31
+ type = "Line";
32
+ }
33
+
34
+ const comment = {
35
+ type,
36
+ value: text
37
+ };
38
+
39
+ if (typeof start === "number") {
40
+ comment.start = start;
41
+ comment.end = end;
42
+ comment.range = [start, end];
43
+ }
44
+
45
+ if (typeof startLoc === "object") {
46
+ comment.loc = {
47
+ start: startLoc,
48
+ end: endLoc
49
+ };
50
+ }
51
+
52
+ return comment;
53
+ }
54
+
55
+ export default () => Parser => {
56
+ const tokTypes = Object.assign({}, Parser.acorn.tokTypes);
57
+
58
+ if (Parser.acornJsx) {
59
+ Object.assign(tokTypes, Parser.acornJsx.tokTypes);
60
+ }
61
+
62
+ return class Espree extends Parser {
63
+ constructor(opts, code) {
64
+ if (typeof opts !== "object" || opts === null) {
65
+ opts = {};
66
+ }
67
+ if (typeof code !== "string" && !(code instanceof String)) {
68
+ code = String(code);
69
+ }
70
+
71
+ // save original source type in case of commonjs
72
+ const originalSourceType = opts.sourceType;
73
+ const options = normalizeOptions(opts);
74
+ const ecmaFeatures = options.ecmaFeatures || {};
75
+ const tokenTranslator =
76
+ options.tokens === true
77
+ ? new TokenTranslator(tokTypes, code)
78
+ : null;
79
+
80
+ /*
81
+ * Data that is unique to Espree and is not represented internally
82
+ * in Acorn.
83
+ *
84
+ * For ES2023 hashbangs, Espree will call `onComment()` during the
85
+ * constructor, so we must define state before having access to
86
+ * `this`.
87
+ */
88
+ const state = {
89
+ originalSourceType: originalSourceType || options.sourceType,
90
+ tokens: tokenTranslator ? [] : null,
91
+ comments: options.comment === true ? [] : null,
92
+ impliedStrict: ecmaFeatures.impliedStrict === true && options.ecmaVersion >= 5,
93
+ ecmaVersion: options.ecmaVersion,
94
+ jsxAttrValueToken: false,
95
+ lastToken: null,
96
+ templateElements: []
97
+ };
98
+
99
+ // Initialize acorn parser.
100
+ super({
101
+
102
+ // do not use spread, because we don't want to pass any unknown options to acorn
103
+ ecmaVersion: options.ecmaVersion,
104
+ sourceType: options.sourceType,
105
+ ranges: options.ranges,
106
+ locations: options.locations,
107
+ allowReserved: options.allowReserved,
108
+
109
+ // Truthy value is true for backward compatibility.
110
+ allowReturnOutsideFunction: options.allowReturnOutsideFunction,
111
+
112
+ // Collect tokens
113
+ onToken(token) {
114
+ if (tokenTranslator) {
115
+
116
+ // Use `tokens`, `ecmaVersion`, and `jsxAttrValueToken` in the state.
117
+ tokenTranslator.onToken(token, state);
118
+ }
119
+ if (token.type !== tokTypes.eof) {
120
+ state.lastToken = token;
121
+ }
122
+ },
123
+
124
+ // Collect comments
125
+ onComment(block, text, start, end, startLoc, endLoc) {
126
+ if (state.comments) {
127
+ const comment = convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc, code);
128
+
129
+ state.comments.push(comment);
130
+ }
131
+ }
132
+ }, code);
133
+
134
+ /*
135
+ * We put all of this data into a symbol property as a way to avoid
136
+ * potential naming conflicts with future versions of Acorn.
137
+ */
138
+ this[STATE] = state;
139
+ }
140
+
141
+ tokenize() {
142
+ do {
143
+ this.next();
144
+ } while (this.type !== tokTypes.eof);
145
+
146
+ // Consume the final eof token
147
+ this.next();
148
+
149
+ const extra = this[STATE];
150
+ const tokens = extra.tokens;
151
+
152
+ if (extra.comments) {
153
+ tokens.comments = extra.comments;
154
+ }
155
+
156
+ return tokens;
157
+ }
158
+
159
+ finishNode(...args) {
160
+ const result = super.finishNode(...args);
161
+
162
+ return this[ESPRIMA_FINISH_NODE](result);
163
+ }
164
+
165
+ finishNodeAt(...args) {
166
+ const result = super.finishNodeAt(...args);
167
+
168
+ return this[ESPRIMA_FINISH_NODE](result);
169
+ }
170
+
171
+ parse() {
172
+ const extra = this[STATE];
173
+ const program = super.parse();
174
+
175
+ program.sourceType = extra.originalSourceType;
176
+
177
+ if (extra.comments) {
178
+ program.comments = extra.comments;
179
+ }
180
+ if (extra.tokens) {
181
+ program.tokens = extra.tokens;
182
+ }
183
+
184
+ /*
185
+ * Adjust opening and closing position of program to match Esprima.
186
+ * Acorn always starts programs at range 0 whereas Esprima starts at the
187
+ * first AST node's start (the only real difference is when there's leading
188
+ * whitespace or leading comments). Acorn also counts trailing whitespace
189
+ * as part of the program whereas Esprima only counts up to the last token.
190
+ */
191
+ if (program.body.length) {
192
+ const [firstNode] = program.body;
193
+
194
+ if (program.range) {
195
+ program.range[0] = firstNode.range[0];
196
+ }
197
+ if (program.loc) {
198
+ program.loc.start = firstNode.loc.start;
199
+ }
200
+ program.start = firstNode.start;
201
+ }
202
+ if (extra.lastToken) {
203
+ if (program.range) {
204
+ program.range[1] = extra.lastToken.range[1];
205
+ }
206
+ if (program.loc) {
207
+ program.loc.end = extra.lastToken.loc.end;
208
+ }
209
+ program.end = extra.lastToken.end;
210
+ }
211
+
212
+
213
+ /*
214
+ * https://github.com/eslint/espree/issues/349
215
+ * Ensure that template elements have correct range information.
216
+ * This is one location where Acorn produces a different value
217
+ * for its start and end properties vs. the values present in the
218
+ * range property. In order to avoid confusion, we set the start
219
+ * and end properties to the values that are present in range.
220
+ * This is done here, instead of in finishNode(), because Acorn
221
+ * uses the values of start and end internally while parsing, making
222
+ * it dangerous to change those values while parsing is ongoing.
223
+ * By waiting until the end of parsing, we can safely change these
224
+ * values without affect any other part of the process.
225
+ */
226
+ this[STATE].templateElements.forEach(templateElement => {
227
+ const startOffset = -1;
228
+ const endOffset = templateElement.tail ? 1 : 2;
229
+
230
+ templateElement.start += startOffset;
231
+ templateElement.end += endOffset;
232
+
233
+ if (templateElement.range) {
234
+ templateElement.range[0] += startOffset;
235
+ templateElement.range[1] += endOffset;
236
+ }
237
+
238
+ if (templateElement.loc) {
239
+ templateElement.loc.start.column += startOffset;
240
+ templateElement.loc.end.column += endOffset;
241
+ }
242
+ });
243
+
244
+ return program;
245
+ }
246
+
247
+ parseTopLevel(node) {
248
+ if (this[STATE].impliedStrict) {
249
+ this.strict = true;
250
+ }
251
+ return super.parseTopLevel(node);
252
+ }
253
+
254
+ /**
255
+ * Overwrites the default raise method to throw Esprima-style errors.
256
+ * @param {int} pos The position of the error.
257
+ * @param {string} message The error message.
258
+ * @throws {SyntaxError} A syntax error.
259
+ * @returns {void}
260
+ */
261
+ raise(pos, message) {
262
+ const loc = Parser.acorn.getLineInfo(this.input, pos);
263
+ const err = new SyntaxError(message);
264
+
265
+ err.index = pos;
266
+ err.lineNumber = loc.line;
267
+ err.column = loc.column + 1; // acorn uses 0-based columns
268
+ throw err;
269
+ }
270
+
271
+ /**
272
+ * Overwrites the default raise method to throw Esprima-style errors.
273
+ * @param {int} pos The position of the error.
274
+ * @param {string} message The error message.
275
+ * @throws {SyntaxError} A syntax error.
276
+ * @returns {void}
277
+ */
278
+ raiseRecoverable(pos, message) {
279
+ this.raise(pos, message);
280
+ }
281
+
282
+ /**
283
+ * Overwrites the default unexpected method to throw Esprima-style errors.
284
+ * @param {int} pos The position of the error.
285
+ * @throws {SyntaxError} A syntax error.
286
+ * @returns {void}
287
+ */
288
+ unexpected(pos) {
289
+ let message = "Unexpected token";
290
+
291
+ if (pos !== null && pos !== void 0) {
292
+ this.pos = pos;
293
+
294
+ if (this.options.locations) {
295
+ while (this.pos < this.lineStart) {
296
+ this.lineStart = this.input.lastIndexOf("\n", this.lineStart - 2) + 1;
297
+ --this.curLine;
298
+ }
299
+ }
300
+
301
+ this.nextToken();
302
+ }
303
+
304
+ if (this.end > this.start) {
305
+ message += ` ${this.input.slice(this.start, this.end)}`;
306
+ }
307
+
308
+ this.raise(this.start, message);
309
+ }
310
+
311
+ /*
312
+ * Esprima-FB represents JSX strings as tokens called "JSXText", but Acorn-JSX
313
+ * uses regular tt.string without any distinction between this and regular JS
314
+ * strings. As such, we intercept an attempt to read a JSX string and set a flag
315
+ * on extra so that when tokens are converted, the next token will be switched
316
+ * to JSXText via onToken.
317
+ */
318
+ jsx_readString(quote) { // eslint-disable-line camelcase -- required by API
319
+ const result = super.jsx_readString(quote);
320
+
321
+ if (this.type === tokTypes.string) {
322
+ this[STATE].jsxAttrValueToken = true;
323
+ }
324
+ return result;
325
+ }
326
+
327
+ /**
328
+ * Performs last-minute Esprima-specific compatibility checks and fixes.
329
+ * @param {ASTNode} result The node to check.
330
+ * @returns {ASTNode} The finished node.
331
+ */
332
+ [ESPRIMA_FINISH_NODE](result) {
333
+
334
+ // Acorn doesn't count the opening and closing backticks as part of templates
335
+ // so we have to adjust ranges/locations appropriately.
336
+ if (result.type === "TemplateElement") {
337
+
338
+ // save template element references to fix start/end later
339
+ this[STATE].templateElements.push(result);
340
+ }
341
+
342
+ if (result.type.includes("Function") && !result.generator) {
343
+ result.generator = false;
344
+ }
345
+
346
+ return result;
347
+ }
348
+ };
349
+ };
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @fileoverview The list of feature flags supported by the parser and their default
3
+ * settings.
4
+ * @author Nicholas C. Zakas
5
+ */
6
+
7
+ //------------------------------------------------------------------------------
8
+ // Requirements
9
+ //------------------------------------------------------------------------------
10
+
11
+ // None!
12
+
13
+ //------------------------------------------------------------------------------
14
+ // Public
15
+ //------------------------------------------------------------------------------
16
+
17
+ export default {
18
+
19
+ // React JSX parsing
20
+ jsx: false,
21
+
22
+ // allow return statement in global scope
23
+ globalReturn: false,
24
+
25
+ // allow implied strict mode
26
+ impliedStrict: false
27
+ };
@@ -0,0 +1,123 @@
1
+ /**
2
+ * @fileoverview A collection of methods for processing Espree's options.
3
+ * @author Kai Cataldo
4
+ */
5
+
6
+ //------------------------------------------------------------------------------
7
+ // Helpers
8
+ //------------------------------------------------------------------------------
9
+
10
+ const SUPPORTED_VERSIONS = [
11
+ 3,
12
+ 5,
13
+ 6, // 2015
14
+ 7, // 2016
15
+ 8, // 2017
16
+ 9, // 2018
17
+ 10, // 2019
18
+ 11, // 2020
19
+ 12, // 2021
20
+ 13, // 2022
21
+ 14, // 2023
22
+ 15 // 2024
23
+ ];
24
+
25
+ /**
26
+ * Get the latest ECMAScript version supported by Espree.
27
+ * @returns {number} The latest ECMAScript version.
28
+ */
29
+ export function getLatestEcmaVersion() {
30
+ return SUPPORTED_VERSIONS[SUPPORTED_VERSIONS.length - 1];
31
+ }
32
+
33
+ /**
34
+ * Get the list of ECMAScript versions supported by Espree.
35
+ * @returns {number[]} An array containing the supported ECMAScript versions.
36
+ */
37
+ export function getSupportedEcmaVersions() {
38
+ return [...SUPPORTED_VERSIONS];
39
+ }
40
+
41
+ /**
42
+ * Normalize ECMAScript version from the initial config
43
+ * @param {(number|"latest")} ecmaVersion ECMAScript version from the initial config
44
+ * @throws {Error} throws an error if the ecmaVersion is invalid.
45
+ * @returns {number} normalized ECMAScript version
46
+ */
47
+ function normalizeEcmaVersion(ecmaVersion = 5) {
48
+
49
+ let version = ecmaVersion === "latest" ? getLatestEcmaVersion() : ecmaVersion;
50
+
51
+ if (typeof version !== "number") {
52
+ throw new Error(`ecmaVersion must be a number or "latest". Received value of type ${typeof ecmaVersion} instead.`);
53
+ }
54
+
55
+ // Calculate ECMAScript edition number from official year version starting with
56
+ // ES2015, which corresponds with ES6 (or a difference of 2009).
57
+ if (version >= 2015) {
58
+ version -= 2009;
59
+ }
60
+
61
+ if (!SUPPORTED_VERSIONS.includes(version)) {
62
+ throw new Error("Invalid ecmaVersion.");
63
+ }
64
+
65
+ return version;
66
+ }
67
+
68
+ /**
69
+ * Normalize sourceType from the initial config
70
+ * @param {string} sourceType to normalize
71
+ * @throws {Error} throw an error if sourceType is invalid
72
+ * @returns {string} normalized sourceType
73
+ */
74
+ function normalizeSourceType(sourceType = "script") {
75
+ if (sourceType === "script" || sourceType === "module") {
76
+ return sourceType;
77
+ }
78
+
79
+ if (sourceType === "commonjs") {
80
+ return "script";
81
+ }
82
+
83
+ throw new Error("Invalid sourceType.");
84
+ }
85
+
86
+ /**
87
+ * Normalize parserOptions
88
+ * @param {Object} options the parser options to normalize
89
+ * @throws {Error} throw an error if found invalid option.
90
+ * @returns {Object} normalized options
91
+ */
92
+ export function normalizeOptions(options) {
93
+ const ecmaVersion = normalizeEcmaVersion(options.ecmaVersion);
94
+ const sourceType = normalizeSourceType(options.sourceType);
95
+ const ranges = options.range === true;
96
+ const locations = options.loc === true;
97
+
98
+ if (ecmaVersion !== 3 && options.allowReserved) {
99
+
100
+ // a value of `false` is intentionally allowed here, so a shared config can overwrite it when needed
101
+ throw new Error("`allowReserved` is only supported when ecmaVersion is 3");
102
+ }
103
+ if (typeof options.allowReserved !== "undefined" && typeof options.allowReserved !== "boolean") {
104
+ throw new Error("`allowReserved`, when present, must be `true` or `false`");
105
+ }
106
+ const allowReserved = ecmaVersion === 3 ? (options.allowReserved || "never") : false;
107
+ const ecmaFeatures = options.ecmaFeatures || {};
108
+ const allowReturnOutsideFunction = options.sourceType === "commonjs" ||
109
+ Boolean(ecmaFeatures.globalReturn);
110
+
111
+ if (sourceType === "module" && ecmaVersion < 6) {
112
+ throw new Error("sourceType 'module' is not supported when ecmaVersion < 2015. Consider adding `{ ecmaVersion: 2015 }` to the parser options.");
113
+ }
114
+
115
+ return Object.assign({}, options, {
116
+ ecmaVersion,
117
+ sourceType,
118
+ ranges,
119
+ locations,
120
+ allowReserved,
121
+ allowReturnOutsideFunction
122
+ });
123
+ }