Comparing version 6.1.2 to 6.2.0
@@ -0,1 +1,6 @@ | ||
v6.2.0 - March 2, 2020 | ||
* [`ced1b68`](https://github.com/eslint/espree/commit/ced1b6810b991531e6d3788ebd5a322fc5c7d463) Update: update acorn-jsx and fix failing test (#432) (Kai Cataldo) | ||
* [`acb8776`](https://github.com/eslint/espree/commit/acb8776d369abf9e02f79142879e9b1a4774f938) Update: add latestEcmaVersion & supportedEcmaVersions (#430) (Kai Cataldo) | ||
v6.1.2 - October 20, 2019 | ||
@@ -2,0 +7,0 @@ |
@@ -65,2 +65,3 @@ /** | ||
const espree = require("./lib/espree"); | ||
const { getLatestEcmaVersion, getSupportedEcmaVersions } = require("./lib/options"); | ||
@@ -174,1 +175,5 @@ // To initialize lazily. | ||
}()); | ||
exports.latestEcmaVersion = getLatestEcmaVersion(); | ||
exports.supportedEcmaVersions = getSupportedEcmaVersions(); |
@@ -5,75 +5,9 @@ "use strict"; | ||
const TokenTranslator = require("./token-translator"); | ||
const { normalizeOptions } = require("./options"); | ||
const DEFAULT_ECMA_VERSION = 5; | ||
const STATE = Symbol("espree's internal state"); | ||
const ESPRIMA_FINISH_NODE = Symbol("espree's esprimaFinishNode"); | ||
/** | ||
* Normalize ECMAScript version from the initial config | ||
* @param {number} ecmaVersion ECMAScript version from the initial config | ||
* @throws {Error} throws an error if the ecmaVersion is invalid. | ||
* @returns {number} normalized ECMAScript version | ||
*/ | ||
function normalizeEcmaVersion(ecmaVersion = DEFAULT_ECMA_VERSION) { | ||
if (typeof ecmaVersion !== "number") { | ||
throw new Error(`ecmaVersion must be a number. Received value of type ${typeof ecmaVersion} instead.`); | ||
} | ||
let version = ecmaVersion; | ||
// Calculate ECMAScript edition number from official year version starting with | ||
// ES2015, which corresponds with ES6 (or a difference of 2009). | ||
if (version >= 2015) { | ||
version -= 2009; | ||
} | ||
switch (version) { | ||
case 3: | ||
case 5: | ||
case 6: | ||
case 7: | ||
case 8: | ||
case 9: | ||
case 10: | ||
case 11: | ||
return version; | ||
// no default | ||
} | ||
throw new Error("Invalid ecmaVersion."); | ||
} | ||
/** | ||
* Normalize sourceType from the initial config | ||
* @param {string} sourceType to normalize | ||
* @throws {Error} throw an error if sourceType is invalid | ||
* @returns {string} normalized sourceType | ||
*/ | ||
function normalizeSourceType(sourceType = "script") { | ||
if (sourceType === "script" || sourceType === "module") { | ||
return sourceType; | ||
} | ||
throw new Error("Invalid sourceType."); | ||
} | ||
/** | ||
* Normalize parserOptions | ||
* @param {Object} options the parser options to normalize | ||
* @throws {Error} throw an error if found invalid option. | ||
* @returns {Object} normalized options | ||
*/ | ||
function normalizeOptions(options) { | ||
const ecmaVersion = normalizeEcmaVersion(options.ecmaVersion); | ||
const sourceType = normalizeSourceType(options.sourceType); | ||
const ranges = options.range === true; | ||
const locations = options.loc === true; | ||
if (sourceType === "module" && ecmaVersion < 6) { | ||
throw new Error("sourceType 'module' is not supported when ecmaVersion < 2015. Consider adding `{ ecmaVersion: 2015 }` to the parser options."); | ||
} | ||
return Object.assign({}, options, { ecmaVersion, sourceType, ranges, locations }); | ||
} | ||
/** | ||
* Converts an Acorn comment to a Esprima comment. | ||
@@ -80,0 +14,0 @@ * @param {boolean} block True if it's a block comment, false if not. |
@@ -7,3 +7,3 @@ { | ||
"main": "espree.js", | ||
"version": "6.1.2", | ||
"version": "6.2.0", | ||
"files": [ | ||
@@ -23,3 +23,3 @@ "lib", | ||
"acorn": "^7.1.0", | ||
"acorn-jsx": "^5.1.0", | ||
"acorn-jsx": "^5.2.0", | ||
"eslint-visitor-keys": "^1.1.0" | ||
@@ -26,0 +26,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
68603
11
918
0
Updatedacorn-jsx@^5.2.0