babel-eslint
Advanced tools
Comparing version 8.0.0-alpha.12 to 8.0.0-alpha.13
"use strict"; | ||
// comment fixes | ||
module.exports = function (ast, comments, tokens) { | ||
module.exports = function(ast, comments, tokens) { | ||
if (comments.length) { | ||
@@ -6,0 +6,0 @@ var firstComment = comments[0]; |
"use strict"; | ||
module.exports = function (comments) { | ||
module.exports = function(comments) { | ||
for (var i = 0; i < comments.length; i++) { | ||
@@ -5,0 +5,0 @@ var comment = comments[i]; |
"use strict"; | ||
module.exports = function (tokens, tt) { | ||
var startingToken = 0; | ||
var currentToken = 0; | ||
var numBraces = 0; // track use of {} | ||
var numBackQuotes = 0; // track number of nested templates | ||
module.exports = function(tokens, tt) { | ||
var startingToken = 0; | ||
var currentToken = 0; | ||
var numBraces = 0; // track use of {} | ||
var numBackQuotes = 0; // track number of nested templates | ||
@@ -14,10 +14,11 @@ function isBackQuote(token) { | ||
function isTemplateStarter(token) { | ||
return isBackQuote(token) || | ||
// only can be a template starter when in a template already | ||
tokens[token].type === tt.braceR && numBackQuotes > 0; | ||
return ( | ||
isBackQuote(token) || | ||
// only can be a template starter when in a template already | ||
(tokens[token].type === tt.braceR && numBackQuotes > 0) | ||
); | ||
} | ||
function isTemplateEnder(token) { | ||
return isBackQuote(token) || | ||
tokens[token].type === tt.dollarBraceL; | ||
return isBackQuote(token) || tokens[token].type === tt.dollarBraceL; | ||
} | ||
@@ -48,4 +49,4 @@ | ||
start: tokens[start].loc.start, | ||
end: tokens[end].loc.end | ||
} | ||
end: tokens[end].loc.end, | ||
}, | ||
}; | ||
@@ -75,3 +76,6 @@ | ||
// check if token after template start is "template" | ||
if (currentToken >= tokens.length - 1 || tokens[currentToken].type !== tt.template) { | ||
if ( | ||
currentToken >= tokens.length - 1 || | ||
tokens[currentToken].type !== tt.template | ||
) { | ||
break; | ||
@@ -78,0 +82,0 @@ } |
"use strict"; | ||
var attachComments = require("./attachComments"); | ||
var attachComments = require("./attachComments"); | ||
var convertComments = require("./convertComments"); | ||
var toTokens = require("./toTokens"); | ||
var toAST = require("./toAST"); | ||
var toTokens = require("./toTokens"); | ||
var toAST = require("./toAST"); | ||
module.exports = function (ast, traverse, tt, code) { | ||
module.exports = function(ast, traverse, tt, code) { | ||
// remove EOF token, eslint doesn't use this for anything and it interferes | ||
@@ -10,0 +10,0 @@ // with some rules see https://github.com/babel/babel-eslint/issues/2 |
@@ -6,3 +6,3 @@ "use strict"; | ||
module.exports = function (ast, traverse, code) { | ||
module.exports = function(ast, traverse, code) { | ||
var state = { source: code }; | ||
@@ -12,3 +12,9 @@ | ||
t.VISITOR_KEYS.Property = t.VISITOR_KEYS.ObjectProperty; | ||
t.VISITOR_KEYS.MethodDefinition = ["key", "value", "decorators", "returnType", "typeParameters"]; | ||
t.VISITOR_KEYS.MethodDefinition = [ | ||
"key", | ||
"value", | ||
"decorators", | ||
"returnType", | ||
"typeParameters", | ||
]; | ||
@@ -23,3 +29,3 @@ traverse(ast, astTransformVisitor, null, state); | ||
noScope: true, | ||
enter (path) { | ||
enter(path) { | ||
var node = path.node; | ||
@@ -43,3 +49,3 @@ | ||
}, | ||
exit (path) { | ||
exit(path) { | ||
var node = path.node; | ||
@@ -56,7 +62,15 @@ | ||
if (path.isRestElement() && path.parent && path.parent.type === "ObjectPattern") { | ||
if ( | ||
path.isRestElement() && | ||
path.parent && | ||
path.parent.type === "ObjectPattern" | ||
) { | ||
node.type = "ExperimentalRestProperty"; | ||
} | ||
if (path.isSpreadElement() && path.parent && path.parent.type === "ObjectExpression") { | ||
if ( | ||
path.isSpreadElement() && | ||
path.parent && | ||
path.parent.type === "ObjectExpression" | ||
) { | ||
node.type = "ExperimentalSpreadProperty"; | ||
@@ -113,3 +127,3 @@ } | ||
} | ||
} | ||
}, | ||
}; |
"use strict"; | ||
module.exports = function (token, tt, source) { | ||
module.exports = function(token, tt, source) { | ||
var type = token.type; | ||
@@ -9,20 +9,38 @@ token.range = [token.start, token.end]; | ||
token.type = "Identifier"; | ||
} else if (type === tt.semi || type === tt.comma || | ||
type === tt.parenL || type === tt.parenR || | ||
type === tt.braceL || type === tt.braceR || | ||
type === tt.slash || type === tt.dot || | ||
type === tt.bracketL || type === tt.bracketR || | ||
type === tt.ellipsis || type === tt.arrow || | ||
type === tt.star || type === tt.incDec || | ||
type === tt.colon || type === tt.question || | ||
type === tt.template || type === tt.backQuote || | ||
type === tt.dollarBraceL || type === tt.at || | ||
type === tt.logicalOR || type === tt.logicalAND || | ||
type === tt.bitwiseOR || type === tt.bitwiseXOR || | ||
type === tt.bitwiseAND || type === tt.equality || | ||
type === tt.relational || type === tt.bitShift || | ||
type === tt.plusMin || type === tt.modulo || | ||
type === tt.exponent || type === tt.prefix || | ||
type === tt.doubleColon || | ||
type.isAssign) { | ||
} else if ( | ||
type === tt.semi || | ||
type === tt.comma || | ||
type === tt.parenL || | ||
type === tt.parenR || | ||
type === tt.braceL || | ||
type === tt.braceR || | ||
type === tt.slash || | ||
type === tt.dot || | ||
type === tt.bracketL || | ||
type === tt.bracketR || | ||
type === tt.ellipsis || | ||
type === tt.arrow || | ||
type === tt.star || | ||
type === tt.incDec || | ||
type === tt.colon || | ||
type === tt.question || | ||
type === tt.template || | ||
type === tt.backQuote || | ||
type === tt.dollarBraceL || | ||
type === tt.at || | ||
type === tt.logicalOR || | ||
type === tt.logicalAND || | ||
type === tt.bitwiseOR || | ||
type === tt.bitwiseXOR || | ||
type === tt.bitwiseAND || | ||
type === tt.equality || | ||
type === tt.relational || | ||
type === tt.bitShift || | ||
type === tt.plusMin || | ||
type === tt.modulo || | ||
type === tt.exponent || | ||
type === tt.prefix || | ||
type === tt.doubleColon || | ||
type.isAssign | ||
) { | ||
token.type = "Punctuator"; | ||
@@ -57,3 +75,3 @@ if (!token.value) token.value = type.label; | ||
pattern: value.pattern, | ||
flags: value.flags | ||
flags: value.flags, | ||
}; | ||
@@ -60,0 +78,0 @@ token.value = `/${value.pattern}/${value.flags}`; |
@@ -6,3 +6,3 @@ "use strict"; | ||
module.exports = function (tokens, tt, code) { | ||
module.exports = function(tokens, tt, code) { | ||
// transform tokens to type "Template" | ||
@@ -9,0 +9,0 @@ convertTemplateType(tokens, tt); |
91
index.js
var babylonToEspree = require("./babylon-to-espree"); | ||
var Module = require("module"); | ||
var path = require("path"); | ||
var parse = require("babylon").parse; | ||
var t = require("babel-types"); | ||
var tt = require("babylon").tokTypes; | ||
var traverse = require("babel-traverse").default; | ||
var Module = require("module"); | ||
var path = require("path"); | ||
var parse = require("babylon").parse; | ||
var t = require("babel-types"); | ||
var tt = require("babylon").tokTypes; | ||
var traverse = require("babel-traverse").default; | ||
var codeFrameColumns = require("babel-code-frame").codeFrameColumns; | ||
@@ -33,6 +33,7 @@ | ||
var escope = eslintMod.require("eslint-scope"); | ||
var Definition = eslintMod.require("eslint-scope/lib/definition").Definition; | ||
var Definition = eslintMod.require("eslint-scope/lib/definition") | ||
.Definition; | ||
var referencer = eslintMod.require("eslint-scope/lib/referencer"); | ||
} catch (err) { | ||
escope = eslintMod.require("escope"); | ||
escope = eslintMod.require("escope"); | ||
Definition = eslintMod.require("escope/lib/definition").Definition; | ||
@@ -65,3 +66,3 @@ referencer = eslintMod.require("escope/lib/referencer"); | ||
var analyze = escope.analyze; | ||
escope.analyze = function (ast, opts) { | ||
escope.analyze = function(ast, opts) { | ||
opts = opts || {}; | ||
@@ -99,3 +100,3 @@ opts.ecmaVersion = eslintOptions.ecmaVersion; | ||
"ObjectPattern", | ||
"RestElement" | ||
"RestElement", | ||
]); | ||
@@ -126,3 +127,3 @@ var visitorKeysMap = Object.keys(t.VISITOR_KEYS).reduce(function(acc, key) { | ||
typeParameters: { type: "typeParameters" }, | ||
id: { type: "id" } | ||
id: { type: "id" }, | ||
}; | ||
@@ -189,3 +190,9 @@ | ||
var parentScope = manager.__currentScope; | ||
var scope = new escope.Scope(manager, "type-parameters", parentScope, node, false); | ||
var scope = new escope.Scope( | ||
manager, | ||
"type-parameters", | ||
parentScope, | ||
node, | ||
false | ||
); | ||
manager.__nestScope(scope); | ||
@@ -304,12 +311,6 @@ for (var j = 0; j < node.typeParameters.params.length; j++) { | ||
function createScopeVariable (node, name) { | ||
this.currentScope().variableScope.__define(name, | ||
new Definition( | ||
"Variable", | ||
name, | ||
node, | ||
null, | ||
null, | ||
null | ||
) | ||
function createScopeVariable(node, name) { | ||
this.currentScope().variableScope.__define( | ||
name, | ||
new Definition("Variable", name, node, null, null, null) | ||
); | ||
@@ -348,6 +349,5 @@ } | ||
referencer.prototype.DeclareModule = | ||
referencer.prototype.DeclareFunction = | ||
referencer.prototype.DeclareVariable = | ||
referencer.prototype.DeclareClass = function(node) { | ||
referencer.prototype.DeclareModule = referencer.prototype.DeclareFunction = referencer.prototype.DeclareVariable = referencer.prototype.DeclareClass = function( | ||
node | ||
) { | ||
if (node.id) { | ||
@@ -367,7 +367,9 @@ createScopeVariable.call(this, node, node.id); | ||
exports.parse = function (code, options) { | ||
exports.parse = function(code, options) { | ||
options = options || {}; | ||
eslintOptions.ecmaVersion = options.ecmaVersion = options.ecmaVersion || 6; | ||
eslintOptions.sourceType = options.sourceType = options.sourceType || "module"; | ||
eslintOptions.allowImportExportEverywhere = options.allowImportExportEverywhere = options.allowImportExportEverywhere || false; | ||
eslintOptions.sourceType = options.sourceType = | ||
options.sourceType || "module"; | ||
eslintOptions.allowImportExportEverywhere = options.allowImportExportEverywhere = | ||
options.allowImportExportEverywhere || false; | ||
if (options.sourceType === "module") { | ||
@@ -392,3 +394,3 @@ eslintOptions.globalReturn = false; | ||
exports.parseNoPatch = function (code, options) { | ||
exports.parseNoPatch = function(code, options) { | ||
var opts = { | ||
@@ -422,3 +424,3 @@ codeFrame: options.hasOwnProperty("codeFrame") ? options.codeFrame : true, | ||
"classPrivateProperties", | ||
] | ||
], | ||
}; | ||
@@ -431,3 +433,2 @@ | ||
if (err instanceof SyntaxError) { | ||
err.lineNumber = err.loc.line; | ||
@@ -441,11 +442,19 @@ err.column = err.loc.column; | ||
// remove trailing "(LINE:COLUMN)" acorn message and add in esprima syntax error message start | ||
err.message = "Line " + err.lineNumber + ": " + err.message.replace(/ \((\d+):(\d+)\)$/, "") + | ||
// add codeframe | ||
"\n\n" + | ||
codeFrameColumns(code, { | ||
start: { | ||
line: err.lineNumber, | ||
column: err.column, | ||
}, | ||
}, { highlightCode: true }); | ||
err.message = | ||
"Line " + | ||
err.lineNumber + | ||
": " + | ||
err.message.replace(/ \((\d+):(\d+)\)$/, "") + | ||
// add codeframe | ||
"\n\n" + | ||
codeFrameColumns( | ||
code, | ||
{ | ||
start: { | ||
line: err.lineNumber, | ||
column: err.column, | ||
}, | ||
}, | ||
{ highlightCode: true } | ||
); | ||
} | ||
@@ -452,0 +461,0 @@ } |
{ | ||
"name": "babel-eslint", | ||
"version": "8.0.0-alpha.12", | ||
"version": "8.0.0-alpha.13", | ||
"description": "Custom parser for ESLint", | ||
@@ -18,3 +18,3 @@ "main": "index.js", | ||
"babel-types": "7.0.0-alpha.12", | ||
"babylon": "7.0.0-beta.13" | ||
"babylon": "7.0.0-beta.14" | ||
}, | ||
@@ -26,2 +26,3 @@ "scripts": { | ||
"fix": "eslint index.js babylon-to-espree test --fix", | ||
"precommit": "lint-staged", | ||
"preversion": "npm test", | ||
@@ -43,7 +44,17 @@ "changelog": "git log `git describe --tags --abbrev=0`..HEAD --pretty=format:' * %s (%an)' | grep -v 'Merge pull request'" | ||
"eslint": "^3.18.0", | ||
"eslint-config-babel": "^6.0.0", | ||
"eslint-config-babel": "^7.0.1", | ||
"eslint-plugin-flowtype": "^2.30.3", | ||
"eslint-plugin-prettier": "^2.1.2", | ||
"espree": "^3.4.0", | ||
"mocha": "^3.0.0" | ||
"husky": "^0.13.2", | ||
"lint-staged": "^3.6.1", | ||
"mocha": "^3.0.0", | ||
"prettier": "1.4.4" | ||
}, | ||
"lint-staged": { | ||
"*.js": [ | ||
"eslint --format=codeframe --fix", | ||
"git add" | ||
] | ||
} | ||
} |
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
32362
798
11
+ Addedbabylon@7.0.0-beta.14(transitive)
- Removedbabylon@7.0.0-beta.13(transitive)
Updatedbabylon@7.0.0-beta.14