babel-eslint
Advanced tools
Comparing version 3.1.7 to 3.1.8
@@ -83,4 +83,6 @@ var traverse = require("babel-core").traverse; | ||
var currentToken = 0; | ||
// track use of {} | ||
var numBraces = 0; | ||
var hasTemplateEnded = true; | ||
// track number of nested templates | ||
var numBackQuotes = 0; | ||
@@ -93,3 +95,4 @@ function isBackQuote(token) { | ||
return isBackQuote(token) || | ||
tokens[token].type === tt.braceR; | ||
// only can be a template starter when in a template already | ||
tokens[token].type === tt.braceR && numBackQuotes > 0; | ||
} | ||
@@ -143,2 +146,6 @@ | ||
if (isTemplateStarter(startingToken) && numBraces === 0) { | ||
if (isBackQuote(startingToken)) { | ||
numBackQuotes++; | ||
} | ||
currentToken = startingToken + 1; | ||
@@ -159,6 +166,8 @@ | ||
hasTemplateEnded = isBackQuote(currentToken); | ||
if (isBackQuote(currentToken)) { | ||
numBackQuotes--; | ||
} | ||
// template start and end found: create new token | ||
replaceWithTemplateType(startingToken, currentToken); | ||
} else if (!hasTemplateEnded) { | ||
} else if (numBackQuotes > 0) { | ||
trackNumBraces(startingToken); | ||
@@ -165,0 +174,0 @@ } |
{ | ||
"name": "babel-eslint", | ||
"version": "3.1.7", | ||
"version": "3.1.8", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -9,2 +9,4 @@ # babel-eslint [![Build Status][travis-image]][travis-url] | ||
If there's an issue, check if it can be reproduced with the regular parser and with the latest versions of `eslint` and `babel-eslint`. For issues related to JSX, see if [eslint-plugin-react](https://github.com/yannickcr/eslint-plugin-react) helps! | ||
## How does it work? | ||
@@ -11,0 +13,0 @@ |
@@ -36,12 +36,25 @@ var babelEslint = require(".."); | ||
var esAST = espree.parse(code, { | ||
env: { | ||
"es6": true, | ||
"node": true | ||
}, | ||
ecmaFeatures: { | ||
arrowFunctions: true, | ||
blockBindings: true, | ||
destructuring: true, | ||
regexYFlag: true, | ||
regexUFlag: true, | ||
templateStrings: true, | ||
binaryLiterals: true, | ||
octalLiterals: true, | ||
unicodeCodePointEscapes: true, | ||
defaultParams: true, | ||
restParams: true, | ||
forOf: true, | ||
objectLiteralComputedProperties: true, | ||
objectLiteralShorthandMethods: true, | ||
objectLiteralShorthandProperties: true, | ||
objectLiteralDuplicateProperties: true, | ||
generators: true, | ||
spread: true, | ||
classes: true, | ||
modules: true, | ||
classes: true, | ||
jsx: true | ||
jsx: true, | ||
globalReturn: true | ||
}, | ||
@@ -128,2 +141,13 @@ tokens: true, | ||
}); | ||
it("template with destructuring #31", function () { | ||
parseAndAssertSame([ | ||
"module.exports = {", | ||
"render() {", | ||
"var {name} = this.props;", | ||
"return Math.max(null, `Name: ${name}, Name: ${name}`);", | ||
"}", | ||
"};" | ||
].join("\n")); | ||
}); | ||
}); | ||
@@ -130,0 +154,0 @@ |
@@ -167,2 +167,15 @@ /*eslint-env mocha*/ | ||
it("template with destructuring #31", function () { | ||
verifyAndAssertMessages([ | ||
"module.exports = {", | ||
"render() {", | ||
"var {name} = this.props;", | ||
"return Math.max(null, `Name: ${name}, Name: ${name}`);", | ||
"}", | ||
"};"].join("\n"), | ||
{ "comma-spacing": 1 }, | ||
[] | ||
); | ||
}); | ||
describe("decorators #72", function () { | ||
@@ -169,0 +182,0 @@ it("class declaration", function () { |
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
30405
860
49