Skip to content

Commit

Permalink
chore: Upgrade to espree@9.4.0 (#16243)
Browse files Browse the repository at this point in the history
* chore: Upgrade to espree@9.4.0

* update package.json
  • Loading branch information
mdjermanovic committed Aug 26, 2022
1 parent 3e5839e commit d35fbbe
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 7 deletions.
7 changes: 6 additions & 1 deletion conf/globals.js
Expand Up @@ -124,6 +124,10 @@ const es2022 = {
...es2021
};

const es2023 = {
...es2022
};


//-----------------------------------------------------------------------------
// Exports
Expand All @@ -140,5 +144,6 @@ module.exports = {
es2019,
es2020,
es2021,
es2022
es2022,
es2023
};
2 changes: 1 addition & 1 deletion docs/src/user-guide/configuring/language-options.md
Expand Up @@ -194,7 +194,7 @@ For ES6 syntax, use `{ "parserOptions": { "ecmaVersion": 6 } }`; for new ES6 glo

Parser options are set in your `.eslintrc.*` file by using the `parserOptions` property. The available options are:

* `ecmaVersion` - set to 3, 5 (default), 6, 7, 8, 9, 10, 11, 12, or 13 to specify the version of ECMAScript syntax you want to use. You can also set to 2015 (same as 6), 2016 (same as 7), 2017 (same as 8), 2018 (same as 9), 2019 (same as 10), 2020 (same as 11), 2021 (same as 12), or 2022 (same as 13) to use the year-based naming. You can also set "latest" to use the most recently supported version.
* `ecmaVersion` - set to 3, 5 (default), 6, 7, 8, 9, 10, 11, 12, 13, or 14 to specify the version of ECMAScript syntax you want to use. You can also set to 2015 (same as 6), 2016 (same as 7), 2017 (same as 8), 2018 (same as 9), 2019 (same as 10), 2020 (same as 11), 2021 (same as 12), 2022 (same as 13), or 2023 (same as 14) to use the year-based naming. You can also set "latest" to use the most recently supported version.
* `sourceType` - set to `"script"` (default) or `"module"` if your code is in ECMAScript modules.
* `allowReserved` - allow the use of reserved words as identifiers (if `ecmaVersion` is 3).
* `ecmaFeatures` - an object indicating which additional language features you'd like to use:
Expand Down
12 changes: 9 additions & 3 deletions lib/rules/utils/ast-utils.js
Expand Up @@ -1978,15 +1978,21 @@ module.exports = {
if (comments.length) {
const lastComment = comments[comments.length - 1];

if (lastComment.range[0] > leftToken.range[0]) {
if (!leftToken || lastComment.range[0] > leftToken.range[0]) {
leftToken = lastComment;
}
}
} else {
leftToken = leftValue;
}

if (leftToken.type === "Shebang") {
/*
* If a hashbang comment was passed as a token object from SourceCode,
* its type will be "Shebang" because of the way ESLint itself handles hashbangs.
* If a hashbang comment was passed in a string and then tokenized in this function,
* its type will be "Hashbang" because of the way Espree tokenizes hashbangs.
*/
if (leftToken.type === "Shebang" || leftToken.type === "Hashbang") {
return false;
}

Expand All @@ -2007,7 +2013,7 @@ module.exports = {
if (comments.length) {
const firstComment = comments[0];

if (firstComment.range[0] < rightToken.range[0]) {
if (!rightToken || firstComment.range[0] < rightToken.range[0]) {
rightToken = firstComment;
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/shared/types.js
Expand Up @@ -21,7 +21,7 @@ module.exports = {};
/**
* @typedef {Object} ParserOptions
* @property {EcmaFeatures} [ecmaFeatures] The optional features.
* @property {3|5|6|7|8|9|10|11|12|13|2015|2016|2017|2018|2019|2020|2021|2022} [ecmaVersion] The ECMAScript version (or revision number).
* @property {3|5|6|7|8|9|10|11|12|13|14|2015|2016|2017|2018|2019|2020|2021|2022|2023} [ecmaVersion] The ECMAScript version (or revision number).
* @property {"script"|"module"} [sourceType] The source code type.
* @property {boolean} [allowReserved] Allowing the use of reserved words as identifiers in ES3.
*/
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -68,7 +68,7 @@
"eslint-scope": "^7.1.1",
"eslint-utils": "^3.0.0",
"eslint-visitor-keys": "^3.3.0",
"espree": "^9.3.3",
"espree": "^9.4.0",
"esquery": "^1.4.0",
"esutils": "^2.0.2",
"fast-deep-equal": "^3.1.3",
Expand Down
4 changes: 4 additions & 0 deletions tests/lib/rules/utils/ast-utils.js
Expand Up @@ -1486,10 +1486,14 @@ describe("ast-utils", () => {
[["a/", "+b"], true],
[["a+", "/^regex$/"], true],
[["a/", "/^regex$/"], false],
[["a+", "/**/"], true],
[["a+", "/**/b"], true],
[["//", "a"], false],
[["a/", "/**/b"], false],
[["a+", "//"], true],
[["a+", "//\nb"], true],
[["a/", "//\nb"], false],
[["/**/", "b"], true],
[["a/**/", "b"], true],
[["/**/a", "b"], false],
[["a", "/**/b"], true],
Expand Down

0 comments on commit d35fbbe

Please sign in to comment.