Socket
Socket
Sign inDemoInstall

@babel/eslint-parser

Package Overview
Dependencies
Maintainers
6
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/eslint-parser - npm Package Compare versions

Comparing version 7.13.14 to 7.14.2

22

lib/analyze-scope.js

@@ -10,16 +10,14 @@ "use strict";

var _eslintScope = require("eslint-scope");
var _definition = require("eslint-scope/lib/definition");
var _eslintVisitorKeys = require("eslint-visitor-keys");
var _patternVisitor = require("eslint-scope/lib/pattern-visitor");
var _visitorKeys = _interopRequireDefault(require("./visitor-keys"));
var _referencer = require("eslint-scope/lib/referencer");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _eslintVisitorKeys = require("eslint-visitor-keys");
const escope = require("eslint-scope");
var _visitorKeys = require("./visitor-keys");
const OriginalPatternVisitor = require("eslint-scope/lib/pattern-visitor");
const OriginalReferencer = require("eslint-scope/lib/referencer");
const flowFlippedAliasKeys = _core.types.FLIPPED_ALIAS_KEYS.Flow.concat(["ArrayPattern", "ClassDeclaration", "ClassExpression", "FunctionDeclaration", "FunctionExpression", "Identifier", "ObjectPattern", "RestElement"]);

@@ -79,3 +77,3 @@

class PatternVisitor extends OriginalPatternVisitor {
class PatternVisitor extends _patternVisitor {
ArrayPattern(node) {

@@ -91,3 +89,3 @@ node.elements.forEach(this.visit, this);

class Referencer extends OriginalReferencer {
class Referencer extends _referencer {
visitPattern(node, options, callback) {

@@ -249,3 +247,3 @@ if (!node) {

const parentScope = this.scopeManager.__currentScope;
const scope = new escope.Scope(this.scopeManager, "type-parameters", parentScope, node, false);
const scope = new _eslintScope.Scope(this.scopeManager, "type-parameters", parentScope, node, false);

@@ -360,3 +358,3 @@ this.scopeManager.__nestScope(scope);

options.childVisitorKeys = _visitorKeys.default;
const scopeManager = new escope.ScopeManager(options);
const scopeManager = new _eslintScope.ScopeManager(options);
const referencer = new Referencer(options, scopeManager);

@@ -363,0 +361,0 @@ referencer.visit(ast);

@@ -10,2 +10,6 @@ "use strict";

const tl = (p => p.reduce((o, [k, v]) => Object.assign({}, o, {
[k]: v
}), {}))(Object.keys(_core.tokTypes).map(key => [key, _core.tokTypes[key].label]));
function convertTemplateType(tokens) {

@@ -22,3 +26,3 @@ let curlyBrace = null;

result += token.value;
} else if (token.type !== _core.tokTypes.template) {
} else if (token.type.label !== tl.template) {
result += token.type.label;

@@ -43,4 +47,4 @@ }

tokens.forEach(token => {
switch (token.type) {
case _core.tokTypes.backQuote:
switch (token.type.label) {
case tl.backQuote:
if (curlyBrace) {

@@ -59,3 +63,3 @@ result.push(curlyBrace);

case _core.tokTypes.dollarBraceL:
case tl.dollarBraceL:
templateTokens.push(token);

@@ -65,3 +69,3 @@ addTemplateType();

case _core.tokTypes.braceR:
case tl.braceR:
if (curlyBrace) {

@@ -74,3 +78,3 @@ result.push(curlyBrace);

case _core.tokTypes.template:
case tl.template:
if (curlyBrace) {

@@ -84,3 +88,3 @@ templateTokens.push(curlyBrace);

case _core.tokTypes.eof:
case tl.eof:
if (curlyBrace) {

@@ -105,19 +109,26 @@ result.push(curlyBrace);

function convertToken(token, source) {
const type = token.type;
const {
type
} = token;
const {
label
} = type;
token.range = [token.start, token.end];
if (type === _core.tokTypes.name) {
if (label === tl.name) {
token.type = "Identifier";
} else if (type === _core.tokTypes.semi || type === _core.tokTypes.comma || type === _core.tokTypes.parenL || type === _core.tokTypes.parenR || type === _core.tokTypes.braceL || type === _core.tokTypes.braceR || type === _core.tokTypes.slash || type === _core.tokTypes.dot || type === _core.tokTypes.bracketL || type === _core.tokTypes.bracketR || type === _core.tokTypes.ellipsis || type === _core.tokTypes.arrow || type === _core.tokTypes.pipeline || type === _core.tokTypes.star || type === _core.tokTypes.incDec || type === _core.tokTypes.colon || type === _core.tokTypes.question || type === _core.tokTypes.template || type === _core.tokTypes.backQuote || type === _core.tokTypes.dollarBraceL || type === _core.tokTypes.at || type === _core.tokTypes.logicalOR || type === _core.tokTypes.logicalAND || type === _core.tokTypes.nullishCoalescing || type === _core.tokTypes.bitwiseOR || type === _core.tokTypes.bitwiseXOR || type === _core.tokTypes.bitwiseAND || type === _core.tokTypes.equality || type === _core.tokTypes.relational || type === _core.tokTypes.bitShift || type === _core.tokTypes.plusMin || type === _core.tokTypes.modulo || type === _core.tokTypes.exponent || type === _core.tokTypes.bang || type === _core.tokTypes.tilde || type === _core.tokTypes.doubleColon || type === _core.tokTypes.hash || type === _core.tokTypes.questionDot || type.isAssign) {
} else if (label === tl.semi || label === tl.comma || label === tl.parenL || label === tl.parenR || label === tl.braceL || label === tl.braceR || label === tl.slash || label === tl.dot || label === tl.bracketL || label === tl.bracketR || label === tl.ellipsis || label === tl.arrow || label === tl.pipeline || label === tl.star || label === tl.incDec || label === tl.colon || label === tl.question || label === tl.template || label === tl.backQuote || label === tl.dollarBraceL || label === tl.at || label === tl.logicalOR || label === tl.logicalAND || label === tl.nullishCoalescing || label === tl.bitwiseOR || label === tl.bitwiseXOR || label === tl.bitwiseAND || label === tl.equality || label === tl.relational || label === tl.bitShift || label === tl.plusMin || label === tl.modulo || label === tl.exponent || label === tl.bang || label === tl.tilde || label === tl.doubleColon || label === tl.hash || label === tl.questionDot || type.isAssign) {
var _token$value;
token.type = "Punctuator";
if (!token.value) token.value = type.label;
} else if (type === _core.tokTypes.jsxTagStart) {
(_token$value = token.value) != null ? _token$value : token.value = label;
} else if (label === tl.jsxTagStart) {
token.type = "Punctuator";
token.value = "<";
} else if (type === _core.tokTypes.jsxTagEnd) {
} else if (label === tl.jsxTagEnd) {
token.type = "Punctuator";
token.value = ">";
} else if (type === _core.tokTypes.jsxName) {
} else if (label === tl.jsxName) {
token.type = "JSXIdentifier";
} else if (type === _core.tokTypes.jsxText) {
} else if (label === tl.jsxText) {
token.type = "JSXText";

@@ -130,9 +141,9 @@ } else if (type.keyword === "null") {

token.type = "Keyword";
} else if (type === _core.tokTypes.num) {
} else if (label === tl.num) {
token.type = "Numeric";
token.value = source.slice(token.start, token.end);
} else if (type === _core.tokTypes.string) {
} else if (label === tl.string) {
token.type = "String";
token.value = source.slice(token.start, token.end);
} else if (type === _core.tokTypes.regexp) {
} else if (label === tl.regexp) {
token.type = "RegularExpression";

@@ -145,5 +156,7 @@ const value = token.value;

token.value = `/${value.pattern}/${value.flags}`;
} else if (type === _core.tokTypes.bigint) {
} else if (label === tl.bigint) {
token.type = "Numeric";
token.value = `${token.value}n`;
} else if (label === tl.privateName) {
token.type = "PrivateIdentifier";
}

@@ -150,0 +163,0 @@

@@ -8,10 +8,8 @@ "use strict";

var _convertTokens = _interopRequireDefault(require("./convertTokens"));
var _convertTokens = require("./convertTokens");
var _convertComments = _interopRequireDefault(require("./convertComments"));
var _convertComments = require("./convertComments");
var _convertAST = _interopRequireDefault(require("./convertAST"));
var _convertAST = require("./convertAST");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _default(ast, code) {

@@ -18,0 +16,0 @@ ast.tokens = (0, _convertTokens.default)(ast.tokens, code);

@@ -9,2 +9,4 @@ "use strict";

var _semver = require("semver");
var _core = require("@babel/core");

@@ -14,12 +16,8 @@

var _convert = _interopRequireDefault(require("./convert"));
var _convert = require("./convert");
var _analyzeScope = _interopRequireDefault(require("./analyze-scope"));
var _analyzeScope = require("./analyze-scope");
var _visitorKeys = _interopRequireDefault(require("./visitor-keys"));
var _visitorKeys = require("./visitor-keys");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const semver = require("semver");
let isRunningMinSupportedCoreVersion = null;

@@ -31,7 +29,7 @@

if (typeof isRunningMinSupportedCoreVersion !== "boolean") {
isRunningMinSupportedCoreVersion = semver.satisfies(_core.version, minSupportedCoreVersion);
isRunningMinSupportedCoreVersion = _semver.satisfies(_core.version, minSupportedCoreVersion);
}
if (!isRunningMinSupportedCoreVersion) {
throw new Error(`@babel/eslint-parser@${"7.13.14"} does not support @babel/core@${_core.version}. Please upgrade to @babel/core@${minSupportedCoreVersion}.`);
throw new Error(`@babel/eslint-parser@${"7.14.2"} does not support @babel/core@${_core.version}. Please upgrade to @babel/core@${minSupportedCoreVersion}.`);
}

@@ -38,0 +36,0 @@

@@ -18,4 +18,3 @@ "use strict";

Property: ["decorators"].concat(_eslintVisitorKeys.KEYS.Property),
PropertyDefinition: _core.types.VISITOR_KEYS.ClassProperty,
PrivateIdentifier: []
PropertyDefinition: ["decorators"].concat(_eslintVisitorKeys.KEYS.PropertyDefinition)
};

@@ -22,0 +21,0 @@ exports.newTypes = newTypes;

{
"name": "@babel/eslint-parser",
"version": "7.13.14",
"version": "7.14.2",
"description": "ESLint parser that allows for linting of experimental syntax transformed by Babel",

@@ -34,7 +34,7 @@ "author": "The Babel Team (https://babel.dev/team)",

"eslint-scope": "^5.1.0",
"eslint-visitor-keys": "^1.3.0",
"eslint-visitor-keys": "^2.1.0",
"semver": "^6.3.0"
},
"devDependencies": {
"@babel/core": "7.13.14",
"@babel/core": "7.14.2",
"dedent": "^0.7.0",

@@ -41,0 +41,0 @@ "eslint": "^7.5.0"

@@ -34,3 +34,3 @@ # @babel/eslint-parser [![npm](https://img.shields.io/npm/v/@babel/eslint-parser.svg)](https://www.npmjs.com/package/@babel/eslint-parser) [![travis](https://img.shields.io/travis/babel/@babel/eslint-parser/main.svg)](https://travis-ci.org/babel/@babel/eslint-parser) [![npm-downloads](https://img.shields.io/npm/dm/@babel/eslint-parser.svg)](https://www.npmjs.com/package/@babel/eslint-parser)

To use @babel/eslint-parser, `"@babel/eslint-parser"` must be specified as the `parser` in your ESLint configuration file (see [here](https://eslint.org/docs/user-guide/configuring#specifying-parser) for more detailed information).
To use @babel/eslint-parser, `"@babel/eslint-parser"` must be specified as the `parser` in your ESLint configuration file (see [here](https://eslint.org/docs/user-guide/configuring/plugins#specifying-parser) for more detailed information).

@@ -47,3 +47,3 @@ **.eslintrc.js**

**Note:** The `parserOptions` described in the [official documentation](https://eslint.org/docs/user-guide/configuring#specifying-parser-options) are for the default parser and are not necessarily supported by @babel/eslint-parser. Please see the section directly below for supported `parserOptions`.
**Note:** The `parserOptions` described in the [official documentation](https://eslint.org/docs/user-guide/configuring/language-options#specifying-parser-options) are for the default parser and are not necessarily supported by @babel/eslint-parser. Please see the section directly below for supported `parserOptions`.

@@ -54,3 +54,3 @@ ### Additional parser configuration

- `requireConfigFile` (default `true`) can be set to `false` to allow @babel/eslint-parser to run on files that do not have a Babel configuration associated with them. This can be useful for linting files that are not transformed by Babel (such as tooling configuration files), though we recommend using the default parser via [glob-based configuration](https://eslint.org/docs/user-guide/configuring#configuration-based-on-glob-patterns). Note: @babel/eslint-parser will not parse any experimental syntax when no configuration file is found.
- `requireConfigFile` (default `true`) can be set to `false` to allow @babel/eslint-parser to run on files that do not have a Babel configuration associated with them. This can be useful for linting files that are not transformed by Babel (such as tooling configuration files), though we recommend using the default parser via [glob-based configuration](https://eslint.org/docs/user-guide/configuring/configuration-files#configuration-based-on-glob-patterns). Note: @babel/eslint-parser will not parse any experimental syntax when no configuration file is found.
- `sourceType` can be set to `"module"`(default) or `"script"` if your code isn't using ECMAScript modules.

@@ -97,2 +97,17 @@ - `allowImportExportEverywhere` (default `false`) can be set to `true` to allow import and export declarations to appear anywhere a statement is allowed if your build environment supports that. Otherwise import and export declarations can only appear at a program's top level.

**Monorepo configuration**
This configuration is useful for monorepo, when you are running ESLint on every package and not from the monorepo root folder, as it avoids to repeat the Babel and ESLint configuration on every package.
```js
module.exports = {
"parser": "@babel/eslint-parser",
"parserOptions": {
"babelOptions": {
"rootMode": "upward"
}
}
}
```
### Run

@@ -112,2 +127,2 @@

For questions and support please visit the [`#discussion`](https://babeljs.slack.com/messages/discussion/) Babel Slack channel (sign up [here](https://github.com/babel/notes/issues/38)) or the ESLint [Gitter](https://gitter.im/eslint/eslint).
For questions and support please visit the [`#discussion`](https://babeljs.slack.com/messages/discussion/) Babel Slack channel (sign up [here](https://slack.babeljs.io/)) or the [ESLint Discord server](https://eslint.org/chat).
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc