Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-eslint

Package Overview
Dependencies
Maintainers
1
Versions
135
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-eslint - npm Package Compare versions

Comparing version 1.0.14 to 2.0.0

.travis.yml

108

acorn-to-esprima.js

@@ -1,4 +0,4 @@

var tokTypes = require("babel").acorn.tokTypes;
var traverse = require("babel").traverse;
var t = require("babel").types;
var tokTypes = require("babel-core").acorn.tokTypes;
var traverse = require("babel-core").traverse;
var t = require("babel-core").types;

@@ -10,7 +10,12 @@ exports.toToken = function (token) {

token.type = "Identifier";
} else if (type === tokTypes.semi || type === tokTypes.comma || type === tokTypes.parenL || type === tokTypes.parenR || type === tokTypes.braceL || type === tokTypes.braceR || type === tokTypes.slash || type === tokTypes.dot || type.isAssign) {
} else if (type === tokTypes.semi || type === tokTypes.comma ||
type === tokTypes.parenL || type === tokTypes.parenR ||
type === tokTypes.braceL || type === tokTypes.braceR ||
type === tokTypes.slash || type === tokTypes.dot ||
type === tokTypes.bracketL || type === tokTypes.bracketR ||
type === tokTypes.ellipsis || type === tokTypes.arrow ||
type === tokTypes.star ||
type.isAssign) {
token.type = "Punctuator";
if (!token.value) {
token.value = type.type;
}
if (!token.value) token.value = type.type;
} else if (type === tokTypes.jsxTagStart) {

@@ -29,2 +34,5 @@ token.type = "Punctuator";

token.value = String(token.value);
} else if (type === tokTypes.string) {
token.type = "String";
token.value = JSON.stringify(token.value);
}

@@ -45,3 +53,3 @@

noScope: true,
enter: function (node, parent) {
exit: function (node, parent) {
if (t.isSpreadProperty(node)) {

@@ -59,20 +67,64 @@ node.type = "Property";

// playground
if (t.isAssignmentExpression(node)) {
if (node.operator === "||=" || node.operator === "?=") {
node.operator = "+=";
}
}
// modules
if (t.isImportDeclaration(node)) {
delete node.isType;
}
if (t.isExportDeclaration(node)) {
if (node.default) {
delete node.specifiers;
delete node.source;
node.type = "ExportDefaultDeclaration";
if (node.declaration.type === "FunctionExpression") {
node.declaration.type = "FunctionDeclaration";
} else if (node.declaration.type === "ClassExpression") {
node.declaration.type = "ClassDeclaration";
}
} else if (t.isExportBatchSpecifier(node.specifiers[0])) {
node.type = "ExportAllDeclaration";
delete node.specifiers;
delete node.declaration;
} else {
node.type = "ExportNamedDeclaration";
}
delete node.default;
}
if (t.isExportSpecifier(node)) {
node.local = node.id;
node.exported = node.name || node.id;
delete node.id;
delete node.name;
}
if (t.isImportSpecifier(node)) {
node.local = node.name || node.id;
if (node.default) {
node.type = "ImportDefaultSpecifier";
} else {
node.imported = node.id;
}
delete node.id;
delete node.name;
delete node.default;
}
if (t.isImportBatchSpecifier(node)) {
// ImportBatchSpecifier<name> => ImportNamespaceSpecifier<id>
node.type = "ImportNamespaceSpecifier";
node.id = node.name;
node.local = node.name;
delete node.name;
}
if (t.isAwaitExpression(node)) {
node.type = "YieldExpression";
}
// classes
if (t.isClassDeclaration(node) || t.isClassExpression(node)) {
node.name = node.id;
delete node.id;
}
if (t.isReferencedIdentifier(node, parent, { name: "super" })) {

@@ -88,3 +140,3 @@ return t.inherits(t.thisExpression(), node);

// functions
if (t.isFunction(node)) {

@@ -101,18 +153,14 @@ node.defaults = [];

});
}
if (t.isArrowFunctionExpression(node)) {
node.type = "FunctionExpression";
if (node.body.type !== "BlockStatement") {
node.body = t.inherits(t.blockStatement([
node.body
]), node);
}
node.rest = null;
if (node.async) node.generator = true;
delete node.async;
}
if (t.isFunction(node) && node.async) {
node.generator = true;
node.async - false;
if (t.isAwaitExpression(node)) {
node.type = "YieldExpression";
node.delegate = node.all;
delete node.all;
}
}
};
var acornToEsprima = require("./acorn-to-esprima");
var traverse = require("babel").traverse;
var traverse = require("babel-core").traverse;
var assign = require("lodash.assign");
var Module = require("module");
var acorn = require("babel").acorn;
var acorn = require("babel-core").acorn;
var path = require("path");
var t = require("babel").types;
var t = require("babel-core").types;

@@ -46,13 +46,2 @@ var hasPatched = false;

};
var eslint = require(eslintLoc);
var getScope = eslint.linter.getScope;
eslint.linter.getScope = function () {
var scope = getScope.apply(this, arguments);
if (scope.type === "global" && !scope.__patchedWithModuleVariables) {
scope.__patchedWithModuleVariables = true;
scope.variables.push.apply(scope.variables, scope.childScopes[0].variables);
}
return scope;
};
}

@@ -59,0 +48,0 @@

{
"name": "babel-eslint",
"version": "1.0.14",
"version": "2.0.0",
"description": "",

@@ -11,5 +11,8 @@ "main": "index.js",

"dependencies": {
"babel": "^4.6.0",
"babel-core": "^4.6.0",
"lodash.assign": "^3.0.0"
},
"scripts": {
"test": "mocha"
},
"author": "Sebastian McKenzie <sebmck@gmail.com>",

@@ -22,3 +25,3 @@ "license": "MIT",

"devDependencies": {
"eslint": "^0.15.1",
"eslint": "^0.16.0",
"espree": "^1.10.0",

@@ -25,0 +28,0 @@ "mocha": "^2.1.0"

@@ -1,2 +0,2 @@

# babel-eslint
# babel-eslint [![Build Status][travis-image]][travis-url]

@@ -44,1 +44,4 @@ **babel-eslint** allows you to lint **ALL** valid Babel code with the fantastic

```
[travis-url]: https://travis-ci.org/babel/babel-eslint
[travis-image]: https://travis-ci.org/babel/babel-eslint.svg?branch=master

@@ -1,6 +0,5 @@

var util = require("util");
var espree = require("espree");
var babelEslint = require("..");
var espree = require("espree");
var util = require("util");
function assertSameAST(a, b, path) {

@@ -26,5 +25,7 @@ if (!path) {

var keyA = keysA.shift();
if (keyA && keyA[0] === "_") continue;
// Exception: ignore "end" and "start" outside "loc" properties
if ((keyA === "end" || keyA === "start") && path[path.length - 1] !== "loc") continue;
// Exception: ignore root "comments" property

@@ -36,4 +37,4 @@ if (keyA === "comments" && path.length === 0) continue;

if (keyA === undefined && keyB === undefined) break;
if (keyA === undefined || keyA > keyB) error("first does not have key \"" + keyB + "\"");
if (keyB === undefined || keyA < keyB) error("second does not have key \"" + keyA + "\"");
if (keyA === undefined || keyA > keyB) error('first does not have key "' + keyB + '"');
if (keyB === undefined || keyA < keyB) error('second does not have key "' + keyA + '"');
path.push(keyA);

@@ -49,17 +50,17 @@ assertSameAST(a[keyA], b[keyB], path);

function parseAndAssertSame(code) {
var esAST = espree.parse(code, {
ecmaFeatures: {
classes: true,
jsx: true
},
tokens: true,
loc: true,
range: true
});
var acornAST = babelEslint.parse(code);
assertSameAST(acornAST, esAST);
var esAST = espree.parse(code, {
ecmaFeatures: {
modules: true,
classes: true,
jsx: true
},
tokens: true,
loc: true,
range: true
});
var acornAST = babelEslint.parse(code);
assertSameAST(acornAST, esAST);
}
describe("acorn-to-esprima", function () {
it("simple expression", function () {

@@ -93,2 +94,45 @@ parseAndAssertSame("a = 1");

it("default import", function () {
parseAndAssertSame('import foo from "foo";');
});
it("import specifier", function () {
parseAndAssertSame('import { foo } from "foo";');
});
it("import specifier with name", function () {
parseAndAssertSame('import { foo as bar } from "foo";');
});
it("import bare", function () {
parseAndAssertSame('import "foo";');
});
it("export default class declaration", function () {
parseAndAssertSame("export default class Foo {}");
});
it("export default class expression", function () {
parseAndAssertSame("export default class {}");
});
it("export default function declaration", function () {
parseAndAssertSame("export default function Foo() {}");
});
it("export default function expression", function () {
parseAndAssertSame("export default function () {}");
});
it("export all", function () {
parseAndAssertSame('export * from "foo";');
});
it("export named", function () {
parseAndAssertSame("export { foo };");
});
it("export named alias", function () {
parseAndAssertSame("export { foo as bar };");
});
});

@@ -12,3 +12,3 @@ /*eslint-env mocha*/

env: {
node: true
node: true
}

@@ -19,3 +19,3 @@ }

if (messages.length !== expectedMessages.length) {
throw new Error("Expected " + expectedMessages.length + " message(s), got " + messages.length);
throw new Error("Expected " + expectedMessages.length + " message(s), got " + messages.length + " " + JSON.stringify(messages));
}

@@ -32,3 +32,2 @@

describe("verify", function () {
it("arrow function support (issue #1)", function () {

@@ -147,3 +146,2 @@ verifyAndAssertMessages(

});
});
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