diff --git a/.prettierignore b/.prettierignore
new file mode 100644
index 0000000..693df41
--- /dev/null
+++ b/.prettierignore
@@ -0,0 +1,29 @@
+.git/*
+.DS_Store
+
+license
+yarn.lock
+.travis.yml
+
+.yarnclean
+.eslintignore
+.prettierignore
+.npmignore
+.gitignore
+.gitattributes
+.dockerignore
+.editorconfig
+
+dist
+build
+
+*.ico
+*.html
+*.log
+*.svg
+*.map
+*.png
+*.snap
+*.ttf
+*.sh
+*.txt
\ No newline at end of file
diff --git a/.prettierrc b/.prettierrc
new file mode 100644
index 0000000..9e4fb3c
--- /dev/null
+++ b/.prettierrc
@@ -0,0 +1,31 @@
+{
+ "bracketSpacing": true,
+ "jsxBracketSameLine": false,
+ "printWidth": 80,
+ "semi": true,
+ "singleQuote": true,
+ "tabWidth": 2,
+ "trailingComma": "none",
+ "useTabs": false,
+ "overrides": [
+ {
+ "files": [
+ ".prettierrc",
+ ".eslintrc",
+ ".babelrc",
+ ".tern-project",
+ ".stylelintrc",
+ ".lighthouserc"
+ ],
+ "options": {
+ "parser": "json"
+ }
+ },
+ {
+ "files": ["package.json"],
+ "options": {
+ "printWidth": 180
+ }
+ }
+ ]
+}
diff --git a/inject.js b/inject.js
index 98f7846..03f85b1 100644
--- a/inject.js
+++ b/inject.js
@@ -5,7 +5,12 @@ var XHTMLEntities = require('./xhtml');
var hexNumber = /^[\da-fA-F]+$/;
var decimalNumber = /^\d+$/;
-module.exports = function(acorn) {
+module.exports = function(acorn, injectable) {
+ if (!injectable) {
+ injectable = acorn;
+ acorn = require('acorn');
+ }
+
var tt = acorn.tokTypes;
var tc = acorn.tokContexts;
@@ -14,7 +19,7 @@ module.exports = function(acorn) {
tc.j_expr = new acorn.TokContext('...', true, true);
tt.jsxName = new acorn.TokenType('jsxName');
- tt.jsxText = new acorn.TokenType('jsxText', {beforeExpr: true});
+ tt.jsxText = new acorn.TokenType('jsxText', { beforeExpr: true });
tt.jsxTagStart = new acorn.TokenType('jsxTagStart');
tt.jsxTagEnd = new acorn.TokenType('jsxTagEnd');
@@ -25,7 +30,7 @@ module.exports = function(acorn) {
};
tt.jsxTagEnd.updateContext = function(prevType) {
var out = this.context.pop();
- if (out === tc.j_oTag && prevType === tt.slash || out === tc.j_cTag) {
+ if ((out === tc.j_oTag && prevType === tt.slash) || out === tc.j_cTag) {
this.context.pop();
this.exprAllowed = this.curContext() === tc.j_expr;
} else {
@@ -38,39 +43,40 @@ module.exports = function(acorn) {
// Reads inline JSX contents token.
pp.jsx_readToken = function() {
- var out = '', chunkStart = this.pos;
+ var out = '',
+ chunkStart = this.pos;
for (;;) {
if (this.pos >= this.input.length)
this.raise(this.start, 'Unterminated JSX contents');
var ch = this.input.charCodeAt(this.pos);
switch (ch) {
- case 60: // '<'
- case 123: // '{'
- if (this.pos === this.start) {
- if (ch === 60 && this.exprAllowed) {
- ++this.pos;
- return this.finishToken(tt.jsxTagStart);
+ case 60: // '<'
+ case 123: // '{'
+ if (this.pos === this.start) {
+ if (ch === 60 && this.exprAllowed) {
+ ++this.pos;
+ return this.finishToken(tt.jsxTagStart);
+ }
+ return this.getTokenFromCode(ch);
}
- return this.getTokenFromCode(ch);
- }
- out += this.input.slice(chunkStart, this.pos);
- return this.finishToken(tt.jsxText, out);
-
- case 38: // '&'
- out += this.input.slice(chunkStart, this.pos);
- out += this.jsx_readEntity();
- chunkStart = this.pos;
- break;
+ out += this.input.slice(chunkStart, this.pos);
+ return this.finishToken(tt.jsxText, out);
- default:
- if (acorn.isNewLine(ch)) {
+ case 38: // '&'
out += this.input.slice(chunkStart, this.pos);
- out += this.jsx_readNewLine(true);
+ out += this.jsx_readEntity();
chunkStart = this.pos;
- } else {
- ++this.pos;
- }
+ break;
+
+ default:
+ if (acorn.isNewLine(ch)) {
+ out += this.input.slice(chunkStart, this.pos);
+ out += this.jsx_readNewLine(true);
+ chunkStart = this.pos;
+ } else {
+ ++this.pos;
+ }
}
}
};
@@ -94,13 +100,15 @@ module.exports = function(acorn) {
};
pp.jsx_readString = function(quote) {
- var out = '', chunkStart = ++this.pos;
+ var out = '',
+ chunkStart = ++this.pos;
for (;;) {
if (this.pos >= this.input.length)
this.raise(this.start, 'Unterminated string constant');
var ch = this.input.charCodeAt(this.pos);
if (ch === quote) break;
- if (ch === 38) { // '&'
+ if (ch === 38) {
+ // '&'
out += this.input.slice(chunkStart, this.pos);
out += this.jsx_readEntity();
chunkStart = this.pos;
@@ -117,10 +125,11 @@ module.exports = function(acorn) {
};
pp.jsx_readEntity = function() {
- var str = '', count = 0, entity;
+ var str = '',
+ count = 0,
+ entity;
var ch = this.input[this.pos];
- if (ch !== '&')
- this.raise(this.pos, 'Entity must start with an ampersand');
+ if (ch !== '&') this.raise(this.pos, 'Entity must start with an ampersand');
var startPos = ++this.pos;
while (this.pos < this.input.length && count++ < 10) {
ch = this.input[this.pos++];
@@ -149,7 +158,6 @@ module.exports = function(acorn) {
return entity;
};
-
// Read a JSX identifier (valid tag or attribute name).
//
// Optimized version since JSX identifiers can't contain
@@ -158,7 +166,8 @@ module.exports = function(acorn) {
// by isIdentifierStart in readToken.
pp.jsx_readWord = function() {
- var ch, start = this.pos;
+ var ch,
+ start = this.pos;
do {
ch = this.input.charCodeAt(++this.pos);
} while (acorn.isIdentifierChar(ch) || ch === 45); // '-'
@@ -168,30 +177,28 @@ module.exports = function(acorn) {
// Transforms JSX element name to string.
function getQualifiedJSXName(object) {
- if (!object)
- return object;
+ if (!object) return object;
- if (object.type === 'JSXIdentifier')
- return object.name;
+ if (object.type === 'JSXIdentifier') return object.name;
if (object.type === 'JSXNamespacedName')
return object.namespace.name + ':' + object.name.name;
if (object.type === 'JSXMemberExpression')
- return getQualifiedJSXName(object.object) + '.' +
- getQualifiedJSXName(object.property);
+ return (
+ getQualifiedJSXName(object.object) +
+ '.' +
+ getQualifiedJSXName(object.property)
+ );
}
// Parse next token as JSX identifier
pp.jsx_parseIdentifier = function() {
var node = this.startNode();
- if (this.type === tt.jsxName)
- node.name = this.value;
- else if (this.type.keyword)
- node.name = this.type.keyword;
- else
- this.unexpected();
+ if (this.type === tt.jsxName) node.name = this.value;
+ else if (this.type.keyword) node.name = this.type.keyword;
+ else this.unexpected();
this.next();
return this.finishNode(node, 'JSXIdentifier');
};
@@ -199,9 +206,11 @@ module.exports = function(acorn) {
// Parse namespaced identifier.
pp.jsx_parseNamespacedName = function() {
- var startPos = this.start, startLoc = this.startLoc;
+ var startPos = this.start,
+ startLoc = this.startLoc;
var name = this.jsx_parseIdentifier();
- if (!this.options.plugins.jsx.allowNamespaces || !this.eat(tt.colon)) return name;
+ if (!this.options.plugins.jsx.allowNamespaces || !this.eat(tt.colon))
+ return name;
var node = this.startNodeAt(startPos, startLoc);
node.namespace = name;
node.name = this.jsx_parseIdentifier();
@@ -212,11 +221,15 @@ module.exports = function(acorn) {
// or single identifier.
pp.jsx_parseElementName = function() {
- if (this.type === tt.jsxTagEnd)
- return '';
- var startPos = this.start, startLoc = this.startLoc;
+ if (this.type === tt.jsxTagEnd) return '';
+ var startPos = this.start,
+ startLoc = this.startLoc;
var node = this.jsx_parseNamespacedName();
- if (this.type === tt.dot && node.type === 'JSXNamespacedName' && !this.options.plugins.jsx.allowNamespacedObjects) {
+ if (
+ this.type === tt.dot &&
+ node.type === 'JSXNamespacedName' &&
+ !this.options.plugins.jsx.allowNamespacedObjects
+ ) {
this.unexpected();
}
while (this.eat(tt.dot)) {
@@ -232,18 +245,24 @@ module.exports = function(acorn) {
pp.jsx_parseAttributeValue = function() {
switch (this.type) {
- case tt.braceL:
- var node = this.jsx_parseExpressionContainer();
- if (node.expression.type === 'JSXEmptyExpression')
- this.raise(node.start, 'JSX attributes must only be assigned a non-empty expression');
- return node;
-
- case tt.jsxTagStart:
- case tt.string:
- return this.parseExprAtom();
-
- default:
- this.raise(this.start, 'JSX value should be either an expression or a quoted JSX text');
+ case tt.braceL:
+ var node = this.jsx_parseExpressionContainer();
+ if (node.expression.type === 'JSXEmptyExpression')
+ this.raise(
+ node.start,
+ 'JSX attributes must only be assigned a non-empty expression'
+ );
+ return node;
+
+ case tt.jsxTagStart:
+ case tt.string:
+ return this.parseExprAtom();
+
+ default:
+ this.raise(
+ this.start,
+ 'JSX value should be either an expression or a quoted JSX text'
+ );
}
};
@@ -253,18 +272,23 @@ module.exports = function(acorn) {
pp.jsx_parseEmptyExpression = function() {
var node = this.startNodeAt(this.lastTokEnd, this.lastTokEndLoc);
- return this.finishNodeAt(node, 'JSXEmptyExpression', this.start, this.startLoc);
+ return this.finishNodeAt(
+ node,
+ 'JSXEmptyExpression',
+ this.start,
+ this.startLoc
+ );
};
// Parses JSX expression enclosed into curly brackets.
-
pp.jsx_parseExpressionContainer = function() {
var node = this.startNode();
this.next();
- node.expression = this.type === tt.braceR
- ? this.jsx_parseEmptyExpression()
- : this.parseExpression();
+ node.expression =
+ this.type === tt.braceR
+ ? this.jsx_parseEmptyExpression()
+ : this.parseExpression();
this.expect(tt.braceR);
return this.finishNode(node, 'JSXExpressionContainer');
};
@@ -295,7 +319,10 @@ module.exports = function(acorn) {
node.attributes.push(this.jsx_parseAttribute());
node.selfClosing = this.eat(tt.slash);
this.expect(tt.jsxTagEnd);
- return this.finishNode(node, nodeName ? 'JSXOpeningElement' : 'JSXOpeningFragment');
+ return this.finishNode(
+ node,
+ nodeName ? 'JSXOpeningElement' : 'JSXOpeningFragment'
+ );
};
// Parses JSX closing tag starting after ''.
@@ -305,7 +332,10 @@ module.exports = function(acorn) {
var nodeName = this.jsx_parseElementName();
if (nodeName) node.name = nodeName;
this.expect(tt.jsxTagEnd);
- return this.finishNode(node, nodeName ? 'JSXClosingElement' : 'JSXClosingFragment');
+ return this.finishNode(
+ node,
+ nodeName ? 'JSXClosingElement' : 'JSXClosingFragment'
+ );
};
// Parses entire JSX element, including it's opening tag
@@ -320,32 +350,42 @@ module.exports = function(acorn) {
if (!openingElement.selfClosing) {
contents: for (;;) {
switch (this.type) {
- case tt.jsxTagStart:
- startPos = this.start; startLoc = this.startLoc;
- this.next();
- if (this.eat(tt.slash)) {
- closingElement = this.jsx_parseClosingElementAt(startPos, startLoc);
- break contents;
- }
- children.push(this.jsx_parseElementAt(startPos, startLoc));
- break;
-
- case tt.jsxText:
- children.push(this.parseExprAtom());
- break;
-
- case tt.braceL:
- children.push(this.jsx_parseExpressionContainer());
- break;
-
- default:
- this.unexpected();
+ case tt.jsxTagStart:
+ startPos = this.start;
+ startLoc = this.startLoc;
+ this.next();
+ if (this.eat(tt.slash)) {
+ closingElement = this.jsx_parseClosingElementAt(
+ startPos,
+ startLoc
+ );
+ break contents;
+ }
+ children.push(this.jsx_parseElementAt(startPos, startLoc));
+ break;
+
+ case tt.jsxText:
+ children.push(this.parseExprAtom());
+ break;
+
+ case tt.braceL:
+ children.push(this.jsx_parseExpressionContainer());
+ break;
+
+ default:
+ this.unexpected();
}
}
- if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name)) {
+ if (
+ getQualifiedJSXName(closingElement.name) !==
+ getQualifiedJSXName(openingElement.name)
+ ) {
this.raise(
closingElement.start,
- 'Expected corresponding JSX closing tag for <' + getQualifiedJSXName(openingElement.name) + '>');
+ 'Expected corresponding JSX closing tag for <' +
+ getQualifiedJSXName(openingElement.name) +
+ '>'
+ );
}
}
var fragmentOrElement = openingElement.name ? 'Element' : 'Fragment';
@@ -353,8 +393,11 @@ module.exports = function(acorn) {
node['opening' + fragmentOrElement] = openingElement;
node['closing' + fragmentOrElement] = closingElement;
node.children = children;
- if (this.type === tt.relational && this.value === "<") {
- this.raise(this.start, "Adjacent JSX elements must be wrapped in an enclosing tag");
+ if (this.type === tt.relational && this.value === '<') {
+ this.raise(
+ this.start,
+ 'Adjacent JSX elements must be wrapped in an enclosing tag'
+ );
}
return this.finishNode(node, 'JSX' + fragmentOrElement);
};
@@ -363,7 +406,7 @@ module.exports = function(acorn) {
pp.jsx_parseText = function(value) {
var node = this.parseLiteral(value);
- node.type = "JSXText";
+ node.type = 'JSXText';
return node;
};
@@ -371,12 +414,13 @@ module.exports = function(acorn) {
// Parses entire JSX element from current position.
pp.jsx_parseElement = function() {
- var startPos = this.start, startLoc = this.startLoc;
+ var startPos = this.start,
+ startLoc = this.startLoc;
this.next();
return this.jsx_parseElementAt(startPos, startLoc);
};
- acorn.plugins.jsx = function(instance, opts) {
+ var toInject = function(instance, opts) {
if (!opts) {
return;
}
@@ -392,12 +436,9 @@ module.exports = function(acorn) {
instance.extend('parseExprAtom', function(inner) {
return function(refShortHandDefaultPos) {
- if (this.type === tt.jsxText)
- return this.jsx_parseText(this.value);
- else if (this.type === tt.jsxTagStart)
- return this.jsx_parseElement();
- else
- return inner.call(this, refShortHandDefaultPos);
+ if (this.type === tt.jsxText) return this.jsx_parseText(this.value);
+ else if (this.type === tt.jsxTagStart) return this.jsx_parseElement();
+ else return inner.call(this, refShortHandDefaultPos);
};
});
@@ -419,7 +460,11 @@ module.exports = function(acorn) {
return this.jsx_readString(code);
}
- if (code === 60 && this.exprAllowed && this.input.charCodeAt(this.pos + 1) !== 33) {
+ if (
+ code === 60 &&
+ this.exprAllowed &&
+ this.input.charCodeAt(this.pos + 1) !== 33
+ ) {
++this.pos;
return this.finishToken(tt.jsxTagStart);
}
@@ -446,5 +491,17 @@ module.exports = function(acorn) {
});
};
- return acorn;
+ ['pluginsLoose', 'plugins'].forEach(function(key) {
+ if (injectable[key] && !injectable[key].jsx) {
+ injectable[key].jsx = toInject;
+ return;
+ }
+
+ if (acorn[key] && !acorn[key].jsx) {
+ acorn[key].jsx = toInject;
+ return;
+ }
+ });
+
+ return injectable;
};
diff --git a/package.json b/package.json
index aba5120..5370a05 100644
--- a/package.json
+++ b/package.json
@@ -16,13 +16,15 @@
},
"license": "MIT",
"scripts": {
- "test": "node test/run.js"
+ "test": "node test/run.js",
+ "fmt": "prettier --config .prettierrc --write '**/*'"
},
"dependencies": {
- "acorn": "^5.0.3"
+ "acorn": "^5.5.3"
},
"devDependencies": {
- "chai": "^3.0.0",
- "mocha": "^3.3.0"
+ "chai": "^4.1.2",
+ "mocha": "^5.2.0",
+ "prettier": "^1.12.1"
}
}
diff --git a/test/driver.js b/test/driver.js
index 06d5644..d5a04bb 100644
--- a/test/driver.js
+++ b/test/driver.js
@@ -1,13 +1,13 @@
var tests = [];
exports.test = function(code, ast, options) {
- tests.push({code: code, ast: ast, options: options});
+ tests.push({ code: code, ast: ast, options: options });
};
exports.testFail = function(code, message, options) {
- tests.push({code: code, error: message, options: options});
+ tests.push({ code: code, error: message, options: options });
};
exports.testAssert = function(code, assert, options) {
- tests.push({code: code, assert: assert, options: options});
+ tests.push({ code: code, assert: assert, options: options });
};
exports.runTests = function(config, callback) {
@@ -17,28 +17,31 @@ exports.runTests = function(config, callback) {
var test = tests[i];
if (config.filter && !config.filter(test)) continue;
try {
- var testOpts = test.options || {locations: true};
+ var testOpts = test.options || { locations: true };
var expected = {};
- if (expected.onComment = testOpts.onComment) {
- testOpts.onComment = []
+ if ((expected.onComment = testOpts.onComment)) {
+ testOpts.onComment = [];
}
- if (expected.onToken = testOpts.onToken) {
+ if ((expected.onToken = testOpts.onToken)) {
testOpts.onToken = [];
}
testOpts.plugins = testOpts.plugins || { jsx: true };
var ast = parse(test.code, testOpts);
if (test.error) {
if (config.loose) {
- callback("ok", test.code);
+ callback('ok', test.code);
} else {
- callback("fail", test.code, "Expected error message: " + test.error + "\nBut parsing succeeded.");
+ callback(
+ 'fail',
+ test.code,
+ 'Expected error message: ' + test.error + '\nBut parsing succeeded.'
+ );
}
- }
- else if (test.assert) {
+ } else if (test.assert) {
var error = test.assert(ast);
- if (error) callback("fail", test.code,
- "\n Assertion failed:\n " + error);
- else callback("ok", test.code);
+ if (error)
+ callback('fail', test.code, '\n Assertion failed:\n ' + error);
+ else callback('ok', test.code);
} else {
var mis = misMatch(test.ast, ast);
for (var name in expected) {
@@ -48,40 +51,51 @@ exports.runTests = function(config, callback) {
testOpts[name] = expected[name];
}
}
- if (mis) callback("fail", test.code, mis);
- else callback("ok", test.code);
+ if (mis) callback('fail', test.code, mis);
+ else callback('ok', test.code);
}
- } catch(e) {
+ } catch (e) {
if (!(e instanceof SyntaxError)) {
throw e;
}
if (test.error) {
- if (e.message == test.error) callback("ok", test.code);
- else callback("fail", test.code,
- "Expected error message: " + test.error + "\nGot error message: " + e.message);
+ if (e.message == test.error) callback('ok', test.code);
+ else
+ callback(
+ 'fail',
+ test.code,
+ 'Expected error message: ' +
+ test.error +
+ '\nGot error message: ' +
+ e.message
+ );
} else {
- callback("error", test.code, e.stack || e.toString());
+ callback('error', test.code, e.stack || e.toString());
}
}
}
};
-function ppJSON(v) { return v instanceof RegExp ? v.toString() : JSON.stringify(v, null, 2); }
+function ppJSON(v) {
+ return v instanceof RegExp ? v.toString() : JSON.stringify(v, null, 2);
+}
function addPath(str, pt) {
- if (str.charAt(str.length-1) == ")")
- return str.slice(0, str.length-1) + "/" + pt + ")";
- return str + " (" + pt + ")";
+ if (str.charAt(str.length - 1) == ')')
+ return str.slice(0, str.length - 1) + '/' + pt + ')';
+ return str + ' (' + pt + ')';
}
-var misMatch = exports.misMatch = function(exp, act) {
- if (!exp || !act || (typeof exp != "object") || (typeof act != "object")) {
- if (exp !== act) return ppJSON(exp) + " !== " + ppJSON(act);
+var misMatch = (exports.misMatch = function(exp, act) {
+ if (!exp || !act || typeof exp != 'object' || typeof act != 'object') {
+ if (exp !== act) return ppJSON(exp) + ' !== ' + ppJSON(act);
} else if (exp instanceof RegExp || act instanceof RegExp) {
- var left = ppJSON(exp), right = ppJSON(act);
- if (left !== right) return left + " !== " + right;
+ var left = ppJSON(exp),
+ right = ppJSON(act);
+ if (left !== right) return left + ' !== ' + right;
} else if (exp.splice) {
- if (!act.slice) return ppJSON(exp) + " != " + ppJSON(act);
- if (act.length != exp.length) return "array length mismatch " + exp.length + " != " + act.length;
+ if (!act.slice) return ppJSON(exp) + ' != ' + ppJSON(act);
+ if (act.length != exp.length)
+ return 'array length mismatch ' + exp.length + ' != ' + act.length;
for (var i = 0; i < act.length; ++i) {
var mis = misMatch(exp[i], act[i]);
if (mis) return addPath(mis, i);
@@ -92,15 +106,18 @@ var misMatch = exports.misMatch = function(exp, act) {
if (mis) return addPath(mis, prop);
}
}
-};
+});
function mangle(ast) {
- if (typeof ast != "object" || !ast) return;
+ if (typeof ast != 'object' || !ast) return;
if (ast.slice) {
for (var i = 0; i < ast.length; ++i) mangle(ast[i]);
} else {
- var loc = ast.start && ast.end && {start: ast.start, end: ast.end};
- if (loc) { delete ast.start; delete ast.end; }
+ var loc = ast.start && ast.end && { start: ast.start, end: ast.end };
+ if (loc) {
+ delete ast.start;
+ delete ast.end;
+ }
for (var name in ast) if (ast.hasOwnProperty(name)) mangle(ast[name]);
if (loc) ast.loc = loc;
}
diff --git a/test/run.js b/test/run.js
index eda0a76..21af68d 100644
--- a/test/run.js
+++ b/test/run.js
@@ -1,70 +1,80 @@
-var driver = require("./driver.js");
-require("./tests-jsx.js");
+var driver = require('./driver.js');
+require('./tests-jsx.js');
function group(name) {
- if (typeof console === "object" && console.group) {
+ if (typeof console === 'object' && console.group) {
console.group(name);
}
}
function groupEnd() {
- if (typeof console === "object" && console.groupEnd) {
+ if (typeof console === 'object' && console.groupEnd) {
console.groupEnd(name);
}
}
function log(title, message) {
- if (typeof console === "object") console.log(title, message);
+ if (typeof console === 'object') console.log(title, message);
}
-var stats, modes = {
- Normal: {
- config: {
- parse: require("..").parse
+var stats,
+ modes = {
+ Normal: {
+ config: {
+ parse: require('..').parse
+ }
}
- }
-};
+ };
function report(state, code, message) {
- if (state != "ok") {++stats.failed; log(code, message);}
+ if (state != 'ok') {
+ ++stats.failed;
+ log(code, message);
+ }
++stats.testsRun;
}
-group("Errors");
+group('Errors');
for (var name in modes) {
group(name);
var mode = modes[name];
- stats = mode.stats = {testsRun: 0, failed: 0};
- var t0 = +new Date;
+ stats = mode.stats = { testsRun: 0, failed: 0 };
+ var t0 = +new Date();
driver.runTests(mode.config, report);
- mode.stats.duration = +new Date - t0;
+ mode.stats.duration = +new Date() - t0;
groupEnd();
}
groupEnd();
function outputStats(name, stats) {
- log(name + ":", stats.testsRun + " tests run in " + stats.duration + "ms; " +
- (stats.failed ? stats.failed + " failures." : "all passed."));
+ log(
+ name + ':',
+ stats.testsRun +
+ ' tests run in ' +
+ stats.duration +
+ 'ms; ' +
+ (stats.failed ? stats.failed + ' failures.' : 'all passed.')
+ );
}
-var total = {testsRun: 0, failed: 0, duration: 0};
+var total = { testsRun: 0, failed: 0, duration: 0 };
-group("Stats");
+group('Stats');
for (var name in modes) {
var stats = modes[name].stats;
- outputStats(name + " parser", stats);
+ outputStats(name + ' parser', stats);
for (var key in stats) total[key] += stats[key];
}
-outputStats("Total", total);
+outputStats('Total', total);
groupEnd();
-if (total.failed && typeof process === "object") {
- process.stdout.write("", function() {
+if (total.failed && typeof process === 'object') {
+ process.stdout.write('', function() {
process.exit(1);
});
}
diff --git a/test/tests-jsx.js b/test/tests-jsx.js
index edd3af4..3789e13 100644
--- a/test/tests-jsx.js
+++ b/test/tests-jsx.js
@@ -22,16 +22,16 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
var fbTestFixture = {
// Taken and adapted from esprima-fb/fbtest.js.
- 'JSX': {
+ JSX: {
'': {
- type: "ExpressionStatement",
+ type: 'ExpressionStatement',
expression: {
- type: "JSXElement",
+ type: 'JSXElement',
openingElement: {
- type: "JSXOpeningElement",
+ type: 'JSXOpeningElement',
name: {
- type: "JSXIdentifier",
- name: "a",
+ type: 'JSXIdentifier',
+ name: 'a',
range: [1, 2],
loc: {
start: { line: 1, column: 1 },
@@ -94,41 +94,43 @@ var fbTestFixture = {
}
},
selfClosing: true,
- attributes: [{
- type: 'JSXAttribute',
- name: {
- type: 'JSXNamespacedName',
- namespace: {
- type: 'JSXIdentifier',
- name: 'n',
- range: [5, 6],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 6 }
- }
- },
+ attributes: [
+ {
+ type: 'JSXAttribute',
name: {
- type: 'JSXIdentifier',
- name: 'v',
- range: [7, 8],
+ type: 'JSXNamespacedName',
+ namespace: {
+ type: 'JSXIdentifier',
+ name: 'n',
+ range: [5, 6],
+ loc: {
+ start: { line: 1, column: 5 },
+ end: { line: 1, column: 6 }
+ }
+ },
+ name: {
+ type: 'JSXIdentifier',
+ name: 'v',
+ range: [7, 8],
+ loc: {
+ start: { line: 1, column: 7 },
+ end: { line: 1, column: 8 }
+ }
+ },
+ range: [5, 8],
loc: {
- start: { line: 1, column: 7 },
+ start: { line: 1, column: 5 },
end: { line: 1, column: 8 }
}
},
+ value: null,
range: [5, 8],
loc: {
start: { line: 1, column: 5 },
end: { line: 1, column: 8 }
}
- },
- value: null,
- range: [5, 8],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 8 }
}
- }],
+ ],
range: [0, 11],
loc: {
start: { line: 1, column: 0 },
@@ -166,50 +168,52 @@ var fbTestFixture = {
}
},
selfClosing: false,
- attributes: [{
- type: 'JSXAttribute',
- name: {
- type: 'JSXNamespacedName',
- namespace: {
- type: 'JSXIdentifier',
- name: 'n',
- range: [3, 4],
+ attributes: [
+ {
+ type: 'JSXAttribute',
+ name: {
+ type: 'JSXNamespacedName',
+ namespace: {
+ type: 'JSXIdentifier',
+ name: 'n',
+ range: [3, 4],
+ loc: {
+ start: { line: 1, column: 3 },
+ end: { line: 1, column: 4 }
+ }
+ },
+ name: {
+ type: 'JSXIdentifier',
+ name: 'foo',
+ range: [5, 8],
+ loc: {
+ start: { line: 1, column: 5 },
+ end: { line: 1, column: 8 }
+ }
+ },
+ range: [3, 8],
loc: {
start: { line: 1, column: 3 },
- end: { line: 1, column: 4 }
+ end: { line: 1, column: 8 }
}
},
- name: {
- type: 'JSXIdentifier',
- name: 'foo',
- range: [5, 8],
+ value: {
+ type: 'Literal',
+ value: 'bar',
+ raw: '"bar"',
+ range: [9, 14],
loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 8 }
+ start: { line: 1, column: 9 },
+ end: { line: 1, column: 14 }
}
},
- range: [3, 8],
+ range: [3, 14],
loc: {
start: { line: 1, column: 3 },
- end: { line: 1, column: 8 }
- }
- },
- value: {
- type: 'Literal',
- value: 'bar',
- raw: '"bar"',
- range: [9, 14],
- loc: {
- start: { line: 1, column: 9 },
end: { line: 1, column: 14 }
}
- },
- range: [3, 14],
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 14 }
}
- }],
+ ],
range: [0, 15],
loc: {
start: { line: 1, column: 0 },
@@ -233,113 +237,120 @@ var fbTestFixture = {
end: { line: 1, column: 40 }
}
},
- children: [{
- type: 'JSXText',
- value: ' ',
- raw: ' ',
- range: [15, 16],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 16 }
- }
- }, {
- type: 'JSXExpressionContainer',
- expression: {
- type: 'Identifier',
- name: 'value',
- range: [17, 22],
+ children: [
+ {
+ type: 'JSXText',
+ value: ' ',
+ raw: ' ',
+ range: [15, 16],
loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 22 }
+ start: { line: 1, column: 15 },
+ end: { line: 1, column: 16 }
}
},
- range: [16, 23],
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 23 }
- }
- }, {
- type: 'JSXText',
- value: ' ',
- raw: ' ',
- range: [23, 24],
- loc: {
- start: { line: 1, column: 23 },
- end: { line: 1, column: 24 }
- }
- }, {
- type: 'JSXElement',
- openingElement: {
- type: 'JSXOpeningElement',
- name: {
- type: 'JSXIdentifier',
- name: 'b',
- range: [25, 26],
+ {
+ type: 'JSXExpressionContainer',
+ expression: {
+ type: 'Identifier',
+ name: 'value',
+ range: [17, 22],
loc: {
- start: { line: 1, column: 25 },
- end: { line: 1, column: 26 }
+ start: { line: 1, column: 17 },
+ end: { line: 1, column: 22 }
}
},
- selfClosing: false,
- attributes: [],
- range: [24, 27],
+ range: [16, 23],
loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 27 }
+ start: { line: 1, column: 16 },
+ end: { line: 1, column: 23 }
}
},
- closingElement: {
- type: 'JSXClosingElement',
- name: {
- type: 'JSXIdentifier',
- name: 'b',
- range: [34, 35],
- loc: {
- start: { line: 1, column: 34 },
- end: { line: 1, column: 35 }
- }
- },
- range: [32, 36],
+ {
+ type: 'JSXText',
+ value: ' ',
+ raw: ' ',
+ range: [23, 24],
loc: {
- start: { line: 1, column: 32 },
- end: { line: 1, column: 36 }
+ start: { line: 1, column: 23 },
+ end: { line: 1, column: 24 }
}
},
- children: [{
+ {
type: 'JSXElement',
openingElement: {
type: 'JSXOpeningElement',
name: {
type: 'JSXIdentifier',
- name: 'c',
- range: [28, 29],
+ name: 'b',
+ range: [25, 26],
loc: {
- start: { line: 1, column: 28 },
- end: { line: 1, column: 29 }
+ start: { line: 1, column: 25 },
+ end: { line: 1, column: 26 }
}
},
- selfClosing: true,
+ selfClosing: false,
attributes: [],
- range: [27, 32],
+ range: [24, 27],
loc: {
- start: { line: 1, column: 27 },
- end: { line: 1, column: 32 }
+ start: { line: 1, column: 24 },
+ end: { line: 1, column: 27 }
}
},
- closingElement: null,
- children: [],
- range: [27, 32],
+ closingElement: {
+ type: 'JSXClosingElement',
+ name: {
+ type: 'JSXIdentifier',
+ name: 'b',
+ range: [34, 35],
+ loc: {
+ start: { line: 1, column: 34 },
+ end: { line: 1, column: 35 }
+ }
+ },
+ range: [32, 36],
+ loc: {
+ start: { line: 1, column: 32 },
+ end: { line: 1, column: 36 }
+ }
+ },
+ children: [
+ {
+ type: 'JSXElement',
+ openingElement: {
+ type: 'JSXOpeningElement',
+ name: {
+ type: 'JSXIdentifier',
+ name: 'c',
+ range: [28, 29],
+ loc: {
+ start: { line: 1, column: 28 },
+ end: { line: 1, column: 29 }
+ }
+ },
+ selfClosing: true,
+ attributes: [],
+ range: [27, 32],
+ loc: {
+ start: { line: 1, column: 27 },
+ end: { line: 1, column: 32 }
+ }
+ },
+ closingElement: null,
+ children: [],
+ range: [27, 32],
+ loc: {
+ start: { line: 1, column: 27 },
+ end: { line: 1, column: 32 }
+ }
+ }
+ ],
+ range: [24, 36],
loc: {
- start: { line: 1, column: 27 },
- end: { line: 1, column: 32 }
+ start: { line: 1, column: 24 },
+ end: { line: 1, column: 36 }
}
- }],
- range: [24, 36],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 36 }
}
- }],
+ ],
range: [0, 40],
loc: {
start: { line: 1, column: 0 },
@@ -354,31 +365,31 @@ var fbTestFixture = {
},
'': {
- type: "ExpressionStatement",
+ type: 'ExpressionStatement',
expression: {
- type: "JSXElement",
+ type: 'JSXElement',
openingElement: {
- type: "JSXOpeningElement",
+ type: 'JSXOpeningElement',
name: {
- type: "JSXIdentifier",
- name: "a",
+ type: 'JSXIdentifier',
+ name: 'a',
range: [1, 2]
},
selfClosing: true,
attributes: [
{
- type: "JSXAttribute",
+ type: 'JSXAttribute',
name: {
- type: "JSXIdentifier",
- name: "b",
+ type: 'JSXIdentifier',
+ name: 'b',
range: [3, 4]
},
value: {
- type: "JSXExpressionContainer",
+ type: 'JSXExpressionContainer',
expression: {
- type: "Literal",
- value: " ",
- raw: "\" \"",
+ type: 'Literal',
+ value: ' ',
+ raw: '" "',
range: [6, 9]
},
range: [5, 10]
@@ -386,46 +397,46 @@ var fbTestFixture = {
range: [3, 10]
},
{
- type: "JSXAttribute",
+ type: 'JSXAttribute',
name: {
- type: "JSXIdentifier",
- name: "c",
+ type: 'JSXIdentifier',
+ name: 'c',
range: [11, 12]
},
value: {
- type: "Literal",
- value: " ",
- raw: "\" \"",
+ type: 'Literal',
+ value: ' ',
+ raw: '" "',
range: [13, 16]
},
range: [11, 16]
},
{
- type: "JSXAttribute",
+ type: 'JSXAttribute',
name: {
- type: "JSXIdentifier",
- name: "d",
+ type: 'JSXIdentifier',
+ name: 'd',
range: [17, 18]
},
value: {
- type: "Literal",
- value: "&",
- raw: "\"&\"",
+ type: 'Literal',
+ value: '&',
+ raw: '"&"',
range: [19, 26]
},
range: [17, 26]
},
{
- type: "JSXAttribute",
+ type: 'JSXAttribute',
name: {
- type: "JSXIdentifier",
- name: "e",
+ type: 'JSXIdentifier',
+ name: 'e',
range: [27, 28]
},
value: {
- type: "Literal",
- value: "&r;",
- raw: "\"&r;\"",
+ type: 'Literal',
+ value: '&r;',
+ raw: '"&r;"',
range: [29, 37]
},
range: [27, 37]
@@ -441,18 +452,15 @@ var fbTestFixture = {
},
'': {
- type: "ExpressionStatement",
+ type: 'ExpressionStatement',
expression: {
- type: "JSXElement",
+ type: 'JSXElement',
openingElement: {
- type: "JSXOpeningElement",
+ type: 'JSXOpeningElement',
name: {
- type: "JSXIdentifier",
- name: "a",
- range: [
- 1,
- 2
- ],
+ type: 'JSXIdentifier',
+ name: 'a',
+ range: [1, 2],
loc: {
start: {
line: 1,
@@ -466,10 +474,7 @@ var fbTestFixture = {
},
selfClosing: true,
attributes: [],
- range: [
- 0,
- 5
- ],
+ range: [0, 5],
loc: {
start: {
line: 1,
@@ -483,10 +488,7 @@ var fbTestFixture = {
},
closingElement: null,
children: [],
- range: [
- 0,
- 5
- ],
+ range: [0, 5],
loc: {
start: {
line: 1,
@@ -498,10 +500,7 @@ var fbTestFixture = {
}
}
},
- range: [
- 0,
- 5
- ],
+ range: [0, 5],
loc: {
start: {
line: 1,
@@ -515,18 +514,15 @@ var fbTestFixture = {
},
'<日本語>日本語>': {
- type: "ExpressionStatement",
+ type: 'ExpressionStatement',
expression: {
- type: "JSXElement",
+ type: 'JSXElement',
openingElement: {
- type: "JSXOpeningElement",
+ type: 'JSXOpeningElement',
name: {
- type: "JSXIdentifier",
- name: "日本語",
- range: [
- 1,
- 4
- ],
+ type: 'JSXIdentifier',
+ name: '日本語',
+ range: [1, 4],
loc: {
start: {
line: 1,
@@ -540,10 +536,7 @@ var fbTestFixture = {
},
selfClosing: false,
attributes: [],
- range: [
- 0,
- 5
- ],
+ range: [0, 5],
loc: {
start: {
line: 1,
@@ -556,14 +549,11 @@ var fbTestFixture = {
}
},
closingElement: {
- type: "JSXClosingElement",
+ type: 'JSXClosingElement',
name: {
- type: "JSXIdentifier",
- name: "日本語",
- range: [
- 7,
- 10
- ],
+ type: 'JSXIdentifier',
+ name: '日本語',
+ range: [7, 10],
loc: {
start: {
line: 1,
@@ -575,10 +565,7 @@ var fbTestFixture = {
}
}
},
- range: [
- 5,
- 11
- ],
+ range: [5, 11],
loc: {
start: {
line: 1,
@@ -591,10 +578,7 @@ var fbTestFixture = {
}
},
children: [],
- range: [
- 0,
- 11
- ],
+ range: [0, 11],
loc: {
start: {
line: 1,
@@ -606,10 +590,7 @@ var fbTestFixture = {
}
}
},
- range: [
- 0,
- 11
- ],
+ range: [0, 11],
loc: {
start: {
line: 1,
@@ -623,18 +604,15 @@ var fbTestFixture = {
},
'\nbar\nbaz\n': {
- type: "ExpressionStatement",
+ type: 'ExpressionStatement',
expression: {
- type: "JSXElement",
+ type: 'JSXElement',
openingElement: {
- type: "JSXOpeningElement",
+ type: 'JSXOpeningElement',
name: {
- type: "JSXIdentifier",
- name: "AbC-def",
- range: [
- 1,
- 8
- ],
+ type: 'JSXIdentifier',
+ name: 'AbC-def',
+ range: [1, 8],
loc: {
start: {
line: 1,
@@ -649,14 +627,11 @@ var fbTestFixture = {
selfClosing: false,
attributes: [
{
- type: "JSXAttribute",
+ type: 'JSXAttribute',
name: {
- type: "JSXIdentifier",
- name: "test",
- range: [
- 11,
- 15
- ],
+ type: 'JSXIdentifier',
+ name: 'test',
+ range: [11, 15],
loc: {
start: {
line: 2,
@@ -669,13 +644,10 @@ var fbTestFixture = {
}
},
value: {
- type: "Literal",
- value: "&&",
- raw: "\"&&\"",
- range: [
- 16,
- 31
- ],
+ type: 'Literal',
+ value: '&&',
+ raw: '"&&"',
+ range: [16, 31],
loc: {
start: {
line: 2,
@@ -687,10 +659,7 @@ var fbTestFixture = {
}
}
},
- range: [
- 11,
- 31
- ],
+ range: [11, 31],
loc: {
start: {
line: 2,
@@ -703,10 +672,7 @@ var fbTestFixture = {
}
}
],
- range: [
- 0,
- 32
- ],
+ range: [0, 32],
loc: {
start: {
line: 1,
@@ -719,14 +685,11 @@ var fbTestFixture = {
}
},
closingElement: {
- type: "JSXClosingElement",
+ type: 'JSXClosingElement',
name: {
- type: "JSXIdentifier",
- name: "AbC-def",
- range: [
- 43,
- 50
- ],
+ type: 'JSXIdentifier',
+ name: 'AbC-def',
+ range: [43, 50],
loc: {
start: {
line: 5,
@@ -738,10 +701,7 @@ var fbTestFixture = {
}
}
},
- range: [
- 41,
- 51
- ],
+ range: [41, 51],
loc: {
start: {
line: 5,
@@ -755,13 +715,10 @@ var fbTestFixture = {
},
children: [
{
- type: "JSXText",
- value: "\nbar\nbaz\n",
- raw: "\nbar\nbaz\n",
- range: [
- 32,
- 41
- ],
+ type: 'JSXText',
+ value: '\nbar\nbaz\n',
+ raw: '\nbar\nbaz\n',
+ range: [32, 41],
loc: {
start: {
line: 2,
@@ -774,10 +731,7 @@ var fbTestFixture = {
}
}
],
- range: [
- 0,
- 51
- ],
+ range: [0, 51],
loc: {
start: {
line: 1,
@@ -789,10 +743,7 @@ var fbTestFixture = {
}
}
},
- range: [
- 0,
- 51
- ],
+ range: [0, 51],
loc: {
start: {
line: 1,
@@ -806,18 +757,15 @@ var fbTestFixture = {
},
' : } />': {
- type: "ExpressionStatement",
+ type: 'ExpressionStatement',
expression: {
- type: "JSXElement",
+ type: 'JSXElement',
openingElement: {
- type: "JSXOpeningElement",
+ type: 'JSXOpeningElement',
name: {
- type: "JSXIdentifier",
- name: "a",
- range: [
- 1,
- 2
- ],
+ type: 'JSXIdentifier',
+ name: 'a',
+ range: [1, 2],
loc: {
start: {
line: 1,
@@ -832,14 +780,11 @@ var fbTestFixture = {
selfClosing: true,
attributes: [
{
- type: "JSXAttribute",
+ type: 'JSXAttribute',
name: {
- type: "JSXIdentifier",
- name: "b",
- range: [
- 3,
- 4
- ],
+ type: 'JSXIdentifier',
+ name: 'b',
+ range: [3, 4],
loc: {
start: {
line: 1,
@@ -852,16 +797,13 @@ var fbTestFixture = {
}
},
value: {
- type: "JSXExpressionContainer",
+ type: 'JSXExpressionContainer',
expression: {
- type: "ConditionalExpression",
+ type: 'ConditionalExpression',
test: {
- type: "Identifier",
- name: "x",
- range: [
- 6,
- 7
- ],
+ type: 'Identifier',
+ name: 'x',
+ range: [6, 7],
loc: {
start: {
line: 1,
@@ -874,16 +816,13 @@ var fbTestFixture = {
}
},
consequent: {
- type: "JSXElement",
+ type: 'JSXElement',
openingElement: {
- type: "JSXOpeningElement",
+ type: 'JSXOpeningElement',
name: {
- type: "JSXIdentifier",
- name: "c",
- range: [
- 11,
- 12
- ],
+ type: 'JSXIdentifier',
+ name: 'c',
+ range: [11, 12],
loc: {
start: {
line: 1,
@@ -897,10 +836,7 @@ var fbTestFixture = {
},
selfClosing: true,
attributes: [],
- range: [
- 10,
- 15
- ],
+ range: [10, 15],
loc: {
start: {
line: 1,
@@ -914,10 +850,7 @@ var fbTestFixture = {
},
closingElement: null,
children: [],
- range: [
- 10,
- 15
- ],
+ range: [10, 15],
loc: {
start: {
line: 1,
@@ -930,16 +863,13 @@ var fbTestFixture = {
}
},
alternate: {
- type: "JSXElement",
+ type: 'JSXElement',
openingElement: {
- type: "JSXOpeningElement",
+ type: 'JSXOpeningElement',
name: {
- type: "JSXIdentifier",
- name: "d",
- range: [
- 19,
- 20
- ],
+ type: 'JSXIdentifier',
+ name: 'd',
+ range: [19, 20],
loc: {
start: {
line: 1,
@@ -953,10 +883,7 @@ var fbTestFixture = {
},
selfClosing: true,
attributes: [],
- range: [
- 18,
- 23
- ],
+ range: [18, 23],
loc: {
start: {
line: 1,
@@ -970,10 +897,7 @@ var fbTestFixture = {
},
closingElement: null,
children: [],
- range: [
- 18,
- 23
- ],
+ range: [18, 23],
loc: {
start: {
line: 1,
@@ -985,10 +909,7 @@ var fbTestFixture = {
}
}
},
- range: [
- 6,
- 23
- ],
+ range: [6, 23],
loc: {
start: {
line: 1,
@@ -1000,10 +921,7 @@ var fbTestFixture = {
}
}
},
- range: [
- 5,
- 24
- ],
+ range: [5, 24],
loc: {
start: {
line: 1,
@@ -1015,10 +933,7 @@ var fbTestFixture = {
}
}
},
- range: [
- 3,
- 24
- ],
+ range: [3, 24],
loc: {
start: {
line: 1,
@@ -1031,10 +946,7 @@ var fbTestFixture = {
}
}
],
- range: [
- 0,
- 27
- ],
+ range: [0, 27],
loc: {
start: {
line: 1,
@@ -1048,10 +960,7 @@ var fbTestFixture = {
},
closingElement: null,
children: [],
- range: [
- 0,
- 27
- ],
+ range: [0, 27],
loc: {
start: {
line: 1,
@@ -1063,10 +972,7 @@ var fbTestFixture = {
}
}
},
- range: [
- 0,
- 27
- ],
+ range: [0, 27],
loc: {
start: {
line: 1,
@@ -1119,22 +1025,24 @@ var fbTestFixture = {
end: { line: 1, column: 9 }
}
},
- children: [{
- type: 'JSXExpressionContainer',
- expression: {
- type: 'JSXEmptyExpression',
- range: [4, 4],
+ children: [
+ {
+ type: 'JSXExpressionContainer',
+ expression: {
+ type: 'JSXEmptyExpression',
+ range: [4, 4],
+ loc: {
+ start: { line: 1, column: 4 },
+ end: { line: 1, column: 4 }
+ }
+ },
+ range: [3, 5],
loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 4 }
+ start: { line: 1, column: 3 },
+ end: { line: 1, column: 5 }
}
- },
- range: [3, 5],
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 5 }
}
- }],
+ ],
range: [0, 9],
loc: {
start: { line: 1, column: 0 },
@@ -1188,22 +1096,24 @@ var fbTestFixture = {
end: { line: 1, column: 32 }
}
},
- children: [{
- type: 'JSXExpressionContainer',
- expression: {
- type: 'JSXEmptyExpression',
- range: [4, 27],
+ children: [
+ {
+ type: 'JSXExpressionContainer',
+ expression: {
+ type: 'JSXEmptyExpression',
+ range: [4, 27],
+ loc: {
+ start: { line: 1, column: 4 },
+ end: { line: 1, column: 27 }
+ }
+ },
+ range: [3, 28],
loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 27 }
+ start: { line: 1, column: 3 },
+ end: { line: 1, column: 28 }
}
- },
- range: [3, 28],
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 28 }
}
- }],
+ ],
range: [0, 32],
loc: {
start: { line: 1, column: 0 },
@@ -1257,16 +1167,18 @@ var fbTestFixture = {
end: { line: 1, column: 24 }
}
},
- children: [{
- type: 'JSXText',
- value: '@test content',
- raw: '@test content',
- range: [5, 18],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 18 }
+ children: [
+ {
+ type: 'JSXText',
+ value: '@test content',
+ raw: '@test content',
+ range: [5, 18],
+ loc: {
+ start: { line: 1, column: 5 },
+ end: { line: 1, column: 18 }
+ }
}
- }],
+ ],
range: [0, 24],
loc: {
start: { line: 1, column: 0 },
@@ -1289,10 +1201,7 @@ var fbTestFixture = {
name: {
type: 'JSXIdentifier',
name: 'div',
- range: [
- 1,
- 4
- ],
+ range: [1, 4],
loc: {
start: {
line: 1,
@@ -1306,10 +1215,7 @@ var fbTestFixture = {
},
selfClosing: false,
attributes: [],
- range: [
- 0,
- 5
- ],
+ range: [0, 5],
loc: {
start: {
line: 1,
@@ -1326,10 +1232,7 @@ var fbTestFixture = {
name: {
type: 'JSXIdentifier',
name: 'div',
- range: [
- 37,
- 40
- ],
+ range: [37, 40],
loc: {
start: {
line: 1,
@@ -1341,10 +1244,7 @@ var fbTestFixture = {
}
}
},
- range: [
- 35,
- 41
- ],
+ range: [35, 41],
loc: {
start: {
line: 1,
@@ -1356,34 +1256,43 @@ var fbTestFixture = {
}
}
},
- children: [{
- type: 'JSXElement',
- openingElement: {
- type: 'JSXOpeningElement',
- name: {
- type: 'JSXIdentifier',
- name: 'br',
- range: [
- 6,
- 8
- ],
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- selfClosing: true,
- attributes: [],
- range: [
- 5,
- 11
- ],
+ children: [
+ {
+ type: 'JSXElement',
+ openingElement: {
+ type: 'JSXOpeningElement',
+ name: {
+ type: 'JSXIdentifier',
+ name: 'br',
+ range: [6, 8],
+ loc: {
+ start: {
+ line: 1,
+ column: 6
+ },
+ end: {
+ line: 1,
+ column: 8
+ }
+ }
+ },
+ selfClosing: true,
+ attributes: [],
+ range: [5, 11],
+ loc: {
+ start: {
+ line: 1,
+ column: 5
+ },
+ end: {
+ line: 1,
+ column: 11
+ }
+ }
+ },
+ closingElement: null,
+ children: [],
+ range: [5, 11],
loc: {
start: {
line: 1,
@@ -1395,45 +1304,24 @@ var fbTestFixture = {
}
}
},
- closingElement: null,
- children: [],
- range: [
- 5,
- 11
- ],
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 11
- }
- }
- }, {
- type: 'JSXText',
- value: '7x invalid-js-identifier',
- raw: '7x invalid-js-identifier',
- range: [
- 11,
- 35
- ],
- loc: {
- start: {
- line: 1,
- column: 11
- },
- end: {
- line: 1,
- column: 35
+ {
+ type: 'JSXText',
+ value: '7x invalid-js-identifier',
+ raw: '7x invalid-js-identifier',
+ range: [11, 35],
+ loc: {
+ start: {
+ line: 1,
+ column: 11
+ },
+ end: {
+ line: 1,
+ column: 35
+ }
}
}
- }],
- range: [
- 0,
- 41
],
+ range: [0, 41],
loc: {
start: {
line: 1,
@@ -1445,10 +1333,7 @@ var fbTestFixture = {
}
}
},
- range: [
- 0,
- 41
- ],
+ range: [0, 41],
loc: {
start: {
line: 1,
@@ -1462,312 +1347,261 @@ var fbTestFixture = {
},
' right=monkeys /> gorillas />': {
- "type": "ExpressionStatement",
- "expression": {
- "type": "JSXElement",
- "openingElement": {
- "type": "JSXOpeningElement",
- "name": {
- "type": "JSXIdentifier",
- "name": "LeftRight",
- "range": [
- 1,
- 10
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 1
+ type: 'ExpressionStatement',
+ expression: {
+ type: 'JSXElement',
+ openingElement: {
+ type: 'JSXOpeningElement',
+ name: {
+ type: 'JSXIdentifier',
+ name: 'LeftRight',
+ range: [1, 10],
+ loc: {
+ start: {
+ line: 1,
+ column: 1
},
- "end": {
- "line": 1,
- "column": 10
+ end: {
+ line: 1,
+ column: 10
}
}
},
- "selfClosing": true,
- "attributes": [
+ selfClosing: true,
+ attributes: [
{
- "type": "JSXAttribute",
- "name": {
- "type": "JSXIdentifier",
- "name": "left",
- "range": [
- 11,
- 15
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 11
+ type: 'JSXAttribute',
+ name: {
+ type: 'JSXIdentifier',
+ name: 'left',
+ range: [11, 15],
+ loc: {
+ start: {
+ line: 1,
+ column: 11
},
- "end": {
- "line": 1,
- "column": 15
+ end: {
+ line: 1,
+ column: 15
}
}
},
- "value": {
- "type": "JSXElement",
- "openingElement": {
- "type": "JSXOpeningElement",
- "name": {
- "type": "JSXIdentifier",
- "name": "a",
- "range": [
- 17,
- 18
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 17
+ value: {
+ type: 'JSXElement',
+ openingElement: {
+ type: 'JSXOpeningElement',
+ name: {
+ type: 'JSXIdentifier',
+ name: 'a',
+ range: [17, 18],
+ loc: {
+ start: {
+ line: 1,
+ column: 17
},
- "end": {
- "line": 1,
- "column": 18
+ end: {
+ line: 1,
+ column: 18
}
}
},
- "selfClosing": true,
- "attributes": [],
- "range": [
- 16,
- 21
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 16
+ selfClosing: true,
+ attributes: [],
+ range: [16, 21],
+ loc: {
+ start: {
+ line: 1,
+ column: 16
},
- "end": {
- "line": 1,
- "column": 21
+ end: {
+ line: 1,
+ column: 21
}
}
},
closingElement: null,
- "children": [],
- "range": [
- 16,
- 21
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 16
+ children: [],
+ range: [16, 21],
+ loc: {
+ start: {
+ line: 1,
+ column: 16
},
- "end": {
- "line": 1,
- "column": 21
+ end: {
+ line: 1,
+ column: 21
}
}
},
- "range": [
- 11,
- 21
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 11
+ range: [11, 21],
+ loc: {
+ start: {
+ line: 1,
+ column: 11
},
- "end": {
- "line": 1,
- "column": 21
+ end: {
+ line: 1,
+ column: 21
}
}
},
{
- "type": "JSXAttribute",
- "name": {
- "type": "JSXIdentifier",
- "name": "right",
- "range": [
- 22,
- 27
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 22
+ type: 'JSXAttribute',
+ name: {
+ type: 'JSXIdentifier',
+ name: 'right',
+ range: [22, 27],
+ loc: {
+ start: {
+ line: 1,
+ column: 22
},
- "end": {
- "line": 1,
- "column": 27
+ end: {
+ line: 1,
+ column: 27
}
}
},
- "value": {
- "type": "JSXElement",
- "openingElement": {
- "type": "JSXOpeningElement",
- "name": {
- "type": "JSXIdentifier",
- "name": "b",
- "range": [
- 29,
- 30
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 29
+ value: {
+ type: 'JSXElement',
+ openingElement: {
+ type: 'JSXOpeningElement',
+ name: {
+ type: 'JSXIdentifier',
+ name: 'b',
+ range: [29, 30],
+ loc: {
+ start: {
+ line: 1,
+ column: 29
},
- "end": {
- "line": 1,
- "column": 30
+ end: {
+ line: 1,
+ column: 30
}
}
},
- "selfClosing": false,
- "attributes": [],
- "range": [
- 28,
- 31
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 28
+ selfClosing: false,
+ attributes: [],
+ range: [28, 31],
+ loc: {
+ start: {
+ line: 1,
+ column: 28
},
- "end": {
- "line": 1,
- "column": 31
+ end: {
+ line: 1,
+ column: 31
}
}
},
- "closingElement": {
- "type": "JSXClosingElement",
- "name": {
- "type": "JSXIdentifier",
- "name": "b",
- "range": [
- 52,
- 53
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 52
+ closingElement: {
+ type: 'JSXClosingElement',
+ name: {
+ type: 'JSXIdentifier',
+ name: 'b',
+ range: [52, 53],
+ loc: {
+ start: {
+ line: 1,
+ column: 52
},
- "end": {
- "line": 1,
- "column": 53
+ end: {
+ line: 1,
+ column: 53
}
}
},
- "range": [
- 50,
- 54
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 50
+ range: [50, 54],
+ loc: {
+ start: {
+ line: 1,
+ column: 50
},
- "end": {
- "line": 1,
- "column": 54
+ end: {
+ line: 1,
+ column: 54
}
}
},
- "children": [
+ children: [
{
- "type": "JSXText",
- "value": "monkeys /> gorillas",
- "raw": "monkeys /> gorillas",
- "range": [
- 31,
- 50
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 31
+ type: 'JSXText',
+ value: 'monkeys /> gorillas',
+ raw: 'monkeys /> gorillas',
+ range: [31, 50],
+ loc: {
+ start: {
+ line: 1,
+ column: 31
},
- "end": {
- "line": 1,
- "column": 50
+ end: {
+ line: 1,
+ column: 50
}
}
}
],
- "range": [
- 28,
- 54
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 28
+ range: [28, 54],
+ loc: {
+ start: {
+ line: 1,
+ column: 28
},
- "end": {
- "line": 1,
- "column": 54
+ end: {
+ line: 1,
+ column: 54
}
}
},
- "range": [
- 22,
- 54
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 22
+ range: [22, 54],
+ loc: {
+ start: {
+ line: 1,
+ column: 22
},
- "end": {
- "line": 1,
- "column": 54
+ end: {
+ line: 1,
+ column: 54
}
}
}
],
- "range": [
- 0,
- 57
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 0
+ range: [0, 57],
+ loc: {
+ start: {
+ line: 1,
+ column: 0
},
- "end": {
- "line": 1,
- "column": 57
+ end: {
+ line: 1,
+ column: 57
}
}
},
closingElement: null,
- "children": [],
- "range": [
- 0,
- 57
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 0
+ children: [],
+ range: [0, 57],
+ loc: {
+ start: {
+ line: 1,
+ column: 0
},
- "end": {
- "line": 1,
- "column": 57
+ end: {
+ line: 1,
+ column: 57
}
}
},
- "range": [
- 0,
- 57
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 0
+ range: [0, 57],
+ loc: {
+ start: {
+ line: 1,
+ column: 0
},
- "end": {
- "line": 1,
- "column": 57
+ end: {
+ line: 1,
+ column: 57
}
}
},
@@ -2042,1141 +1876,961 @@ var fbTestFixture = {
},
'
': {
- "type": "ExpressionStatement",
- "expression": {
- "type": "JSXElement",
- "openingElement": {
- "type": "JSXOpeningElement",
- "name": {
- "type": "JSXIdentifier",
- "name": "div",
- "range": [
- 1,
- 4
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 1
+ type: 'ExpressionStatement',
+ expression: {
+ type: 'JSXElement',
+ openingElement: {
+ type: 'JSXOpeningElement',
+ name: {
+ type: 'JSXIdentifier',
+ name: 'div',
+ range: [1, 4],
+ loc: {
+ start: {
+ line: 1,
+ column: 1
},
- "end": {
- "line": 1,
- "column": 4
+ end: {
+ line: 1,
+ column: 4
}
}
},
- "selfClosing": true,
- "attributes": [
+ selfClosing: true,
+ attributes: [
{
- "type": "JSXSpreadAttribute",
- "argument": {
- "type": "Identifier",
- "name": "props",
- "range": [
- 9,
- 14
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 9
+ type: 'JSXSpreadAttribute',
+ argument: {
+ type: 'Identifier',
+ name: 'props',
+ range: [9, 14],
+ loc: {
+ start: {
+ line: 1,
+ column: 9
},
- "end": {
- "line": 1,
- "column": 14
+ end: {
+ line: 1,
+ column: 14
}
}
},
- "range": [
- 5,
- 15
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 5
+ range: [5, 15],
+ loc: {
+ start: {
+ line: 1,
+ column: 5
},
- "end": {
- "line": 1,
- "column": 15
+ end: {
+ line: 1,
+ column: 15
}
}
}
],
- "range": [
- 0,
- 18
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 0
+ range: [0, 18],
+ loc: {
+ start: {
+ line: 1,
+ column: 0
},
- "end": {
- "line": 1,
- "column": 18
+ end: {
+ line: 1,
+ column: 18
}
}
},
closingElement: null,
- "children": [],
- "range": [
- 0,
- 18
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 0
+ children: [],
+ range: [0, 18],
+ loc: {
+ start: {
+ line: 1,
+ column: 0
},
- "end": {
- "line": 1,
- "column": 18
+ end: {
+ line: 1,
+ column: 18
}
}
},
- "range": [
- 0,
- 18
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 0
+ range: [0, 18],
+ loc: {
+ start: {
+ line: 1,
+ column: 0
},
- "end": {
- "line": 1,
- "column": 18
+ end: {
+ line: 1,
+ column: 18
}
}
},
'': {
- "type": "ExpressionStatement",
- "expression": {
- "type": "JSXElement",
- "openingElement": {
- "type": "JSXOpeningElement",
- "name": {
- "type": "JSXIdentifier",
- "name": "div",
- "range": [
- 1,
- 4
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 1
+ type: 'ExpressionStatement',
+ expression: {
+ type: 'JSXElement',
+ openingElement: {
+ type: 'JSXOpeningElement',
+ name: {
+ type: 'JSXIdentifier',
+ name: 'div',
+ range: [1, 4],
+ loc: {
+ start: {
+ line: 1,
+ column: 1
},
- "end": {
- "line": 1,
- "column": 4
+ end: {
+ line: 1,
+ column: 4
}
}
},
- "selfClosing": true,
- "attributes": [
+ selfClosing: true,
+ attributes: [
{
- "type": "JSXSpreadAttribute",
- "argument": {
- "type": "Identifier",
- "name": "props",
- "range": [
- 9,
- 14
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 9
+ type: 'JSXSpreadAttribute',
+ argument: {
+ type: 'Identifier',
+ name: 'props',
+ range: [9, 14],
+ loc: {
+ start: {
+ line: 1,
+ column: 9
},
- "end": {
- "line": 1,
- "column": 14
+ end: {
+ line: 1,
+ column: 14
}
}
},
- "range": [
- 5,
- 15
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 5
+ range: [5, 15],
+ loc: {
+ start: {
+ line: 1,
+ column: 5
},
- "end": {
- "line": 1,
- "column": 15
+ end: {
+ line: 1,
+ column: 15
}
}
},
{
- "type": "JSXAttribute",
- "name": {
- "type": "JSXIdentifier",
- "name": "post",
- "range": [
- 16,
- 20
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 16
+ type: 'JSXAttribute',
+ name: {
+ type: 'JSXIdentifier',
+ name: 'post',
+ range: [16, 20],
+ loc: {
+ start: {
+ line: 1,
+ column: 16
},
- "end": {
- "line": 1,
- "column": 20
+ end: {
+ line: 1,
+ column: 20
}
}
},
- "value": {
- "type": "Literal",
- "value": "attribute",
- "raw": "\"attribute\"",
- "range": [
- 21,
- 32
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 21
+ value: {
+ type: 'Literal',
+ value: 'attribute',
+ raw: '"attribute"',
+ range: [21, 32],
+ loc: {
+ start: {
+ line: 1,
+ column: 21
},
- "end": {
- "line": 1,
- "column": 32
+ end: {
+ line: 1,
+ column: 32
}
}
},
- "range": [
- 16,
- 32
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 16
+ range: [16, 32],
+ loc: {
+ start: {
+ line: 1,
+ column: 16
},
- "end": {
- "line": 1,
- "column": 32
+ end: {
+ line: 1,
+ column: 32
}
}
}
],
- "range": [
- 0,
- 35
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 0
+ range: [0, 35],
+ loc: {
+ start: {
+ line: 1,
+ column: 0
},
- "end": {
- "line": 1,
- "column": 35
+ end: {
+ line: 1,
+ column: 35
}
}
},
closingElement: null,
- "children": [],
- "range": [
- 0,
- 35
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 0
+ children: [],
+ range: [0, 35],
+ loc: {
+ start: {
+ line: 1,
+ column: 0
},
- "end": {
- "line": 1,
- "column": 35
+ end: {
+ line: 1,
+ column: 35
}
}
},
- "range": [
- 0,
- 35
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 0
+ range: [0, 35],
+ loc: {
+ start: {
+ line: 1,
+ column: 0
},
- "end": {
- "line": 1,
- "column": 35
+ end: {
+ line: 1,
+ column: 35
}
}
},
'': {
- "type": "ExpressionStatement",
- "expression": {
- "type": "JSXElement",
- "openingElement": {
- "type": "JSXOpeningElement",
- "name": {
- "type": "JSXIdentifier",
- "name": "div",
- "range": [
- 1,
- 4
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 1
+ type: 'ExpressionStatement',
+ expression: {
+ type: 'JSXElement',
+ openingElement: {
+ type: 'JSXOpeningElement',
+ name: {
+ type: 'JSXIdentifier',
+ name: 'div',
+ range: [1, 4],
+ loc: {
+ start: {
+ line: 1,
+ column: 1
},
- "end": {
- "line": 1,
- "column": 4
+ end: {
+ line: 1,
+ column: 4
}
}
},
- "selfClosing": false,
- "attributes": [
+ selfClosing: false,
+ attributes: [
{
- "type": "JSXAttribute",
- "name": {
- "type": "JSXIdentifier",
- "name": "pre",
- "range": [
- 5,
- 8
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 5
+ type: 'JSXAttribute',
+ name: {
+ type: 'JSXIdentifier',
+ name: 'pre',
+ range: [5, 8],
+ loc: {
+ start: {
+ line: 1,
+ column: 5
},
- "end": {
- "line": 1,
- "column": 8
+ end: {
+ line: 1,
+ column: 8
}
}
},
- "value": {
- "type": "Literal",
- "value": "leading",
- "raw": "\"leading\"",
- "range": [
- 9,
- 18
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 9
+ value: {
+ type: 'Literal',
+ value: 'leading',
+ raw: '"leading"',
+ range: [9, 18],
+ loc: {
+ start: {
+ line: 1,
+ column: 9
},
- "end": {
- "line": 1,
- "column": 18
+ end: {
+ line: 1,
+ column: 18
}
}
},
- "range": [
- 5,
- 18
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 5
+ range: [5, 18],
+ loc: {
+ start: {
+ line: 1,
+ column: 5
},
- "end": {
- "line": 1,
- "column": 18
+ end: {
+ line: 1,
+ column: 18
}
}
},
{
- "type": "JSXAttribute",
- "name": {
- "type": "JSXIdentifier",
- "name": "pre2",
- "range": [
- 19,
- 23
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 19
+ type: 'JSXAttribute',
+ name: {
+ type: 'JSXIdentifier',
+ name: 'pre2',
+ range: [19, 23],
+ loc: {
+ start: {
+ line: 1,
+ column: 19
},
- "end": {
- "line": 1,
- "column": 23
+ end: {
+ line: 1,
+ column: 23
}
}
},
- "value": {
- "type": "Literal",
- "value": "attribute",
- "raw": "\"attribute\"",
- "range": [
- 24,
- 35
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 24
+ value: {
+ type: 'Literal',
+ value: 'attribute',
+ raw: '"attribute"',
+ range: [24, 35],
+ loc: {
+ start: {
+ line: 1,
+ column: 24
},
- "end": {
- "line": 1,
- "column": 35
+ end: {
+ line: 1,
+ column: 35
}
}
},
- "range": [
- 19,
- 35
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 19
+ range: [19, 35],
+ loc: {
+ start: {
+ line: 1,
+ column: 19
},
- "end": {
- "line": 1,
- "column": 35
+ end: {
+ line: 1,
+ column: 35
}
}
},
{
- "type": "JSXSpreadAttribute",
- "argument": {
- "type": "Identifier",
- "name": "props",
- "range": [
- 40,
- 45
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 40
+ type: 'JSXSpreadAttribute',
+ argument: {
+ type: 'Identifier',
+ name: 'props',
+ range: [40, 45],
+ loc: {
+ start: {
+ line: 1,
+ column: 40
},
- "end": {
- "line": 1,
- "column": 45
+ end: {
+ line: 1,
+ column: 45
}
}
},
- "range": [
- 36,
- 46
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 36
+ range: [36, 46],
+ loc: {
+ start: {
+ line: 1,
+ column: 36
},
- "end": {
- "line": 1,
- "column": 46
+ end: {
+ line: 1,
+ column: 46
}
}
}
],
- "range": [
- 0,
- 47
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 0
+ range: [0, 47],
+ loc: {
+ start: {
+ line: 1,
+ column: 0
},
- "end": {
- "line": 1,
- "column": 47
+ end: {
+ line: 1,
+ column: 47
}
}
},
- "closingElement": {
- "type": "JSXClosingElement",
- "name": {
- "type": "JSXIdentifier",
- "name": "div",
- "range": [
- 49,
- 52
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 49
+ closingElement: {
+ type: 'JSXClosingElement',
+ name: {
+ type: 'JSXIdentifier',
+ name: 'div',
+ range: [49, 52],
+ loc: {
+ start: {
+ line: 1,
+ column: 49
},
- "end": {
- "line": 1,
- "column": 52
+ end: {
+ line: 1,
+ column: 52
}
}
},
- "range": [
- 47,
- 53
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 47
+ range: [47, 53],
+ loc: {
+ start: {
+ line: 1,
+ column: 47
},
- "end": {
- "line": 1,
- "column": 53
+ end: {
+ line: 1,
+ column: 53
}
}
},
- "children": [],
- "range": [
- 0,
- 53
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 0
+ children: [],
+ range: [0, 53],
+ loc: {
+ start: {
+ line: 1,
+ column: 0
},
- "end": {
- "line": 1,
- "column": 53
+ end: {
+ line: 1,
+ column: 53
}
}
},
- "range": [
- 0,
- 53
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 0
+ range: [0, 53],
+ loc: {
+ start: {
+ line: 1,
+ column: 0
},
- "end": {
- "line": 1,
- "column": 53
+ end: {
+ line: 1,
+ column: 53
}
}
},
'{aa.b}
': {
- "type": "ExpressionStatement",
- "start": 0,
- "end": 52,
- "loc": {
- "start": {
- "line": 1,
- "column": 0
+ type: 'ExpressionStatement',
+ start: 0,
+ end: 52,
+ loc: {
+ start: {
+ line: 1,
+ column: 0
},
- "end": {
- "line": 1,
- "column": 52
+ end: {
+ line: 1,
+ column: 52
}
},
- "range": [
- 0,
- 52
- ],
- "expression": {
- "type": "JSXElement",
- "start": 0,
- "end": 52,
- "loc": {
- "start": {
- "line": 1,
- "column": 0
+ range: [0, 52],
+ expression: {
+ type: 'JSXElement',
+ start: 0,
+ end: 52,
+ loc: {
+ start: {
+ line: 1,
+ column: 0
},
- "end": {
- "line": 1,
- "column": 52
+ end: {
+ line: 1,
+ column: 52
}
},
- "range": [
- 0,
- 52
- ],
- "openingElement": {
- "type": "JSXOpeningElement",
- "start": 0,
- "end": 31,
- "loc": {
- "start": {
- "line": 1,
- "column": 0
+ range: [0, 52],
+ openingElement: {
+ type: 'JSXOpeningElement',
+ start: 0,
+ end: 31,
+ loc: {
+ start: {
+ line: 1,
+ column: 0
},
- "end": {
- "line": 1,
- "column": 31
+ end: {
+ line: 1,
+ column: 31
}
},
- "range": [
- 0,
- 31
- ],
- "attributes": [
+ range: [0, 31],
+ attributes: [
{
- "type": "JSXAttribute",
- "start": 3,
- "end": 16,
- "loc": {
- "start": {
- "line": 1,
- "column": 3
+ type: 'JSXAttribute',
+ start: 3,
+ end: 16,
+ loc: {
+ start: {
+ line: 1,
+ column: 3
},
- "end": {
- "line": 1,
- "column": 16
+ end: {
+ line: 1,
+ column: 16
}
},
- "range": [
- 3,
- 16
- ],
- "name": {
- "type": "JSXIdentifier",
- "start": 3,
- "end": 5,
- "loc": {
- "start": {
- "line": 1,
- "column": 3
+ range: [3, 16],
+ name: {
+ type: 'JSXIdentifier',
+ start: 3,
+ end: 5,
+ loc: {
+ start: {
+ line: 1,
+ column: 3
},
- "end": {
- "line": 1,
- "column": 5
+ end: {
+ line: 1,
+ column: 5
}
},
- "range": [
- 3,
- 5
- ],
- "name": "aa"
- },
- "value": {
- "type": "JSXExpressionContainer",
- "start": 6,
- "end": 16,
- "loc": {
- "start": {
- "line": 1,
- "column": 6
+ range: [3, 5],
+ name: 'aa'
+ },
+ value: {
+ type: 'JSXExpressionContainer',
+ start: 6,
+ end: 16,
+ loc: {
+ start: {
+ line: 1,
+ column: 6
},
- "end": {
- "line": 1,
- "column": 16
+ end: {
+ line: 1,
+ column: 16
}
},
- "range": [
- 6,
- 16
- ],
- "expression": {
- "type": "MemberExpression",
- "start": 7,
- "end": 15,
- "loc": {
- "start": {
- "line": 1,
- "column": 7
+ range: [6, 16],
+ expression: {
+ type: 'MemberExpression',
+ start: 7,
+ end: 15,
+ loc: {
+ start: {
+ line: 1,
+ column: 7
},
- "end": {
- "line": 1,
- "column": 15
+ end: {
+ line: 1,
+ column: 15
}
},
- "range": [
- 7,
- 15
- ],
- "object": {
- "type": "MemberExpression",
- "start": 7,
- "end": 12,
- "loc": {
- "start": {
- "line": 1,
- "column": 7
+ range: [7, 15],
+ object: {
+ type: 'MemberExpression',
+ start: 7,
+ end: 12,
+ loc: {
+ start: {
+ line: 1,
+ column: 7
},
- "end": {
- "line": 1,
- "column": 12
+ end: {
+ line: 1,
+ column: 12
}
},
- "range": [
- 7,
- 12
- ],
- "object": {
- "type": "Identifier",
- "start": 7,
- "end": 9,
- "loc": {
- "start": {
- "line": 1,
- "column": 7
+ range: [7, 12],
+ object: {
+ type: 'Identifier',
+ start: 7,
+ end: 9,
+ loc: {
+ start: {
+ line: 1,
+ column: 7
},
- "end": {
- "line": 1,
- "column": 9
+ end: {
+ line: 1,
+ column: 9
}
},
- "range": [
- 7,
- 9
- ],
- "name": "aa"
+ range: [7, 9],
+ name: 'aa'
},
- "property": {
- "type": "Identifier",
- "start": 10,
- "end": 12,
- "loc": {
- "start": {
- "line": 1,
- "column": 10
+ property: {
+ type: 'Identifier',
+ start: 10,
+ end: 12,
+ loc: {
+ start: {
+ line: 1,
+ column: 10
},
- "end": {
- "line": 1,
- "column": 12
+ end: {
+ line: 1,
+ column: 12
}
},
- "range": [
- 10,
- 12
- ],
- "name": "bb"
+ range: [10, 12],
+ name: 'bb'
},
- "computed": false
+ computed: false
},
- "property": {
- "type": "Identifier",
- "start": 13,
- "end": 15,
- "loc": {
- "start": {
- "line": 1,
- "column": 13
+ property: {
+ type: 'Identifier',
+ start: 13,
+ end: 15,
+ loc: {
+ start: {
+ line: 1,
+ column: 13
},
- "end": {
- "line": 1,
- "column": 15
+ end: {
+ line: 1,
+ column: 15
}
},
- "range": [
- 13,
- 15
- ],
- "name": "cc"
+ range: [13, 15],
+ name: 'cc'
},
- "computed": false
+ computed: false
}
}
},
{
- "type": "JSXAttribute",
- "start": 17,
- "end": 30,
- "loc": {
- "start": {
- "line": 1,
- "column": 17
+ type: 'JSXAttribute',
+ start: 17,
+ end: 30,
+ loc: {
+ start: {
+ line: 1,
+ column: 17
},
- "end": {
- "line": 1,
- "column": 30
+ end: {
+ line: 1,
+ column: 30
}
},
- "range": [
- 17,
- 30
- ],
- "name": {
- "type": "JSXIdentifier",
- "start": 17,
- "end": 19,
- "loc": {
- "start": {
- "line": 1,
- "column": 17
+ range: [17, 30],
+ name: {
+ type: 'JSXIdentifier',
+ start: 17,
+ end: 19,
+ loc: {
+ start: {
+ line: 1,
+ column: 17
},
- "end": {
- "line": 1,
- "column": 19
+ end: {
+ line: 1,
+ column: 19
}
},
- "range": [
- 17,
- 19
- ],
- "name": "bb"
- },
- "value": {
- "type": "JSXExpressionContainer",
- "start": 20,
- "end": 30,
- "loc": {
- "start": {
- "line": 1,
- "column": 20
+ range: [17, 19],
+ name: 'bb'
+ },
+ value: {
+ type: 'JSXExpressionContainer',
+ start: 20,
+ end: 30,
+ loc: {
+ start: {
+ line: 1,
+ column: 20
},
- "end": {
- "line": 1,
- "column": 30
+ end: {
+ line: 1,
+ column: 30
}
},
- "range": [
- 20,
- 30
- ],
- "expression": {
- "type": "MemberExpression",
- "start": 21,
- "end": 29,
- "loc": {
- "start": {
- "line": 1,
- "column": 21
+ range: [20, 30],
+ expression: {
+ type: 'MemberExpression',
+ start: 21,
+ end: 29,
+ loc: {
+ start: {
+ line: 1,
+ column: 21
},
- "end": {
- "line": 1,
- "column": 29
+ end: {
+ line: 1,
+ column: 29
}
},
- "range": [
- 21,
- 29
- ],
- "object": {
- "type": "MemberExpression",
- "start": 21,
- "end": 26,
- "loc": {
- "start": {
- "line": 1,
- "column": 21
+ range: [21, 29],
+ object: {
+ type: 'MemberExpression',
+ start: 21,
+ end: 26,
+ loc: {
+ start: {
+ line: 1,
+ column: 21
},
- "end": {
- "line": 1,
- "column": 26
+ end: {
+ line: 1,
+ column: 26
}
},
- "range": [
- 21,
- 26
- ],
- "object": {
- "type": "Identifier",
- "start": 21,
- "end": 23,
- "loc": {
- "start": {
- "line": 1,
- "column": 21
+ range: [21, 26],
+ object: {
+ type: 'Identifier',
+ start: 21,
+ end: 23,
+ loc: {
+ start: {
+ line: 1,
+ column: 21
},
- "end": {
- "line": 1,
- "column": 23
+ end: {
+ line: 1,
+ column: 23
}
},
- "range": [
- 21,
- 23
- ],
- "name": "bb"
+ range: [21, 23],
+ name: 'bb'
},
- "property": {
- "type": "Identifier",
- "start": 24,
- "end": 26,
- "loc": {
- "start": {
- "line": 1,
- "column": 24
+ property: {
+ type: 'Identifier',
+ start: 24,
+ end: 26,
+ loc: {
+ start: {
+ line: 1,
+ column: 24
},
- "end": {
- "line": 1,
- "column": 26
+ end: {
+ line: 1,
+ column: 26
}
},
- "range": [
- 24,
- 26
- ],
- "name": "cc"
+ range: [24, 26],
+ name: 'cc'
},
- "computed": false
+ computed: false
},
- "property": {
- "type": "Identifier",
- "start": 27,
- "end": 29,
- "loc": {
- "start": {
- "line": 1,
- "column": 27
+ property: {
+ type: 'Identifier',
+ start: 27,
+ end: 29,
+ loc: {
+ start: {
+ line: 1,
+ column: 27
},
- "end": {
- "line": 1,
- "column": 29
+ end: {
+ line: 1,
+ column: 29
}
},
- "range": [
- 27,
- 29
- ],
- "name": "dd"
+ range: [27, 29],
+ name: 'dd'
},
- "computed": false
+ computed: false
}
}
}
],
- "name": {
- "type": "JSXIdentifier",
- "start": 1,
- "end": 2,
- "loc": {
- "start": {
- "line": 1,
- "column": 1
- },
- "end": {
- "line": 1,
- "column": 2
+ name: {
+ type: 'JSXIdentifier',
+ start: 1,
+ end: 2,
+ loc: {
+ start: {
+ line: 1,
+ column: 1
+ },
+ end: {
+ line: 1,
+ column: 2
}
},
- "range": [
- 1,
- 2
- ],
- "name": "A"
+ range: [1, 2],
+ name: 'A'
},
- "selfClosing": false
+ selfClosing: false
},
- "closingElement": {
- "type": "JSXClosingElement",
- "start": 48,
- "end": 52,
- "loc": {
- "start": {
- "line": 1,
- "column": 48
+ closingElement: {
+ type: 'JSXClosingElement',
+ start: 48,
+ end: 52,
+ loc: {
+ start: {
+ line: 1,
+ column: 48
},
- "end": {
- "line": 1,
- "column": 52
+ end: {
+ line: 1,
+ column: 52
}
},
- "range": [
- 48,
- 52
- ],
- "name": {
- "type": "JSXIdentifier",
- "start": 50,
- "end": 51,
- "loc": {
- "start": {
- "line": 1,
- "column": 50
- },
- "end": {
- "line": 1,
- "column": 51
+ range: [48, 52],
+ name: {
+ type: 'JSXIdentifier',
+ start: 50,
+ end: 51,
+ loc: {
+ start: {
+ line: 1,
+ column: 50
+ },
+ end: {
+ line: 1,
+ column: 51
}
},
- "range": [
- 50,
- 51
- ],
- "name": "A"
+ range: [50, 51],
+ name: 'A'
}
},
- "children": [
+ children: [
{
- "type": "JSXElement",
- "start": 31,
- "end": 48,
- "loc": {
- "start": {
- "line": 1,
- "column": 31
- },
- "end": {
- "line": 1,
- "column": 48
+ type: 'JSXElement',
+ start: 31,
+ end: 48,
+ loc: {
+ start: {
+ line: 1,
+ column: 31
+ },
+ end: {
+ line: 1,
+ column: 48
}
},
- "range": [
- 31,
- 48
- ],
- "openingElement": {
- "type": "JSXOpeningElement",
- "start": 31,
- "end": 36,
- "loc": {
- "start": {
- "line": 1,
- "column": 31
+ range: [31, 48],
+ openingElement: {
+ type: 'JSXOpeningElement',
+ start: 31,
+ end: 36,
+ loc: {
+ start: {
+ line: 1,
+ column: 31
},
- "end": {
- "line": 1,
- "column": 36
+ end: {
+ line: 1,
+ column: 36
}
},
- "range": [
- 31,
- 36
- ],
- "attributes": [],
- "name": {
- "type": "JSXIdentifier",
- "start": 32,
- "end": 35,
- "loc": {
- "start": {
- "line": 1,
- "column": 32
+ range: [31, 36],
+ attributes: [],
+ name: {
+ type: 'JSXIdentifier',
+ start: 32,
+ end: 35,
+ loc: {
+ start: {
+ line: 1,
+ column: 32
},
- "end": {
- "line": 1,
- "column": 35
+ end: {
+ line: 1,
+ column: 35
}
},
- "range": [
- 32,
- 35
- ],
- "name": "div"
+ range: [32, 35],
+ name: 'div'
},
- "selfClosing": false
+ selfClosing: false
},
- "closingElement": {
- "type": "JSXClosingElement",
- "start": 42,
- "end": 48,
- "loc": {
- "start": {
- "line": 1,
- "column": 42
+ closingElement: {
+ type: 'JSXClosingElement',
+ start: 42,
+ end: 48,
+ loc: {
+ start: {
+ line: 1,
+ column: 42
},
- "end": {
- "line": 1,
- "column": 48
+ end: {
+ line: 1,
+ column: 48
}
},
- "range": [
- 42,
- 48
- ],
- "name": {
- "type": "JSXIdentifier",
- "start": 44,
- "end": 47,
- "loc": {
- "start": {
- "line": 1,
- "column": 44
+ range: [42, 48],
+ name: {
+ type: 'JSXIdentifier',
+ start: 44,
+ end: 47,
+ loc: {
+ start: {
+ line: 1,
+ column: 44
},
- "end": {
- "line": 1,
- "column": 47
+ end: {
+ line: 1,
+ column: 47
}
},
- "range": [
- 44,
- 47
- ],
- "name": "div"
+ range: [44, 47],
+ name: 'div'
}
},
- "children": [
+ children: [
{
- "type": "JSXExpressionContainer",
- "start": 36,
- "end": 42,
- "loc": {
- "start": {
- "line": 1,
- "column": 36
+ type: 'JSXExpressionContainer',
+ start: 36,
+ end: 42,
+ loc: {
+ start: {
+ line: 1,
+ column: 36
},
- "end": {
- "line": 1,
- "column": 42
+ end: {
+ line: 1,
+ column: 42
}
},
- "range": [
- 36,
- 42
- ],
- "expression": {
- "type": "MemberExpression",
- "start": 37,
- "end": 41,
- "loc": {
- "start": {
- "line": 1,
- "column": 37
+ range: [36, 42],
+ expression: {
+ type: 'MemberExpression',
+ start: 37,
+ end: 41,
+ loc: {
+ start: {
+ line: 1,
+ column: 37
},
- "end": {
- "line": 1,
- "column": 41
+ end: {
+ line: 1,
+ column: 41
}
},
- "range": [
- 37,
- 41
- ],
- "object": {
- "type": "Identifier",
- "start": 37,
- "end": 39,
- "loc": {
- "start": {
- "line": 1,
- "column": 37
+ range: [37, 41],
+ object: {
+ type: 'Identifier',
+ start: 37,
+ end: 39,
+ loc: {
+ start: {
+ line: 1,
+ column: 37
},
- "end": {
- "line": 1,
- "column": 39
+ end: {
+ line: 1,
+ column: 39
}
},
- "range": [
- 37,
- 39
- ],
- "name": "aa"
+ range: [37, 39],
+ name: 'aa'
},
- "property": {
- "type": "Identifier",
- "start": 40,
- "end": 41,
- "loc": {
- "start": {
- "line": 1,
- "column": 40
+ property: {
+ type: 'Identifier',
+ start: 40,
+ end: 41,
+ loc: {
+ start: {
+ line: 1,
+ column: 40
},
- "end": {
- "line": 1,
- "column": 41
+ end: {
+ line: 1,
+ column: 41
}
},
- "range": [
- 40,
- 41
- ],
- "name": "b"
+ range: [40, 41],
+ name: 'b'
},
- "computed": false
+ computed: false
}
}
]
@@ -3234,40 +2888,26 @@ var fbTestFixture = {
selfClosing: false
},
closingFragment: {
- type: 'JSXClosingFragment',
- start: 13,
- end: 16,
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 16
- }
- },
- range: [13, 16]
- },
- children: [{
- type: 'JSXElement',
- start: 2,
- end: 13,
+ type: 'JSXClosingFragment',
+ start: 13,
+ end: 16,
loc: {
start: {
line: 1,
- column: 2
+ column: 13
},
end: {
line: 1,
- column: 13
+ column: 16
}
},
- range: [2, 13],
- openingElement: {
- type: 'JSXOpeningElement',
+ range: [13, 16]
+ },
+ children: [
+ {
+ type: 'JSXElement',
start: 2,
- end: 7,
+ end: 13,
loc: {
start: {
line: 1,
@@ -3275,168 +2915,188 @@ var fbTestFixture = {
},
end: {
line: 1,
- column: 7
+ column: 13
}
},
- range: [2, 7],
- attributes: [],
- name: {
- type: 'JSXIdentifier',
- start: 3,
- end: 6,
+ range: [2, 13],
+ openingElement: {
+ type: 'JSXOpeningElement',
+ start: 2,
+ end: 7,
loc: {
start: {
line: 1,
- column: 3
+ column: 2
},
end: {
line: 1,
- column: 6
+ column: 7
}
},
- range: [3, 6],
- name: 'div'
- },
- selfClosing: false
- },
- closingElement: {
- type: 'JSXClosingElement',
- start: 7,
- end: 13,
- loc: {
- start: {
- line: 1,
- column: 7
+ range: [2, 7],
+ attributes: [],
+ name: {
+ type: 'JSXIdentifier',
+ start: 3,
+ end: 6,
+ loc: {
+ start: {
+ line: 1,
+ column: 3
+ },
+ end: {
+ line: 1,
+ column: 6
+ }
+ },
+ range: [3, 6],
+ name: 'div'
},
- end: {
- line: 1,
- column: 13
- }
+ selfClosing: false
},
- range: [7, 13],
- name: {
- type: 'JSXIdentifier',
- start: 9,
- end: 12,
+ closingElement: {
+ type: 'JSXClosingElement',
+ start: 7,
+ end: 13,
loc: {
start: {
line: 1,
- column: 9
+ column: 7
},
end: {
line: 1,
- column: 12
+ column: 13
}
},
- range: [9, 12],
- name: 'div'
- }
- },
- children: []
- }]
+ range: [7, 13],
+ name: {
+ type: 'JSXIdentifier',
+ start: 9,
+ end: 12,
+ loc: {
+ start: {
+ line: 1,
+ column: 9
+ },
+ end: {
+ line: 1,
+ column: 12
+ }
+ },
+ range: [9, 12],
+ name: 'div'
+ }
+ },
+ children: []
+ }
+ ]
}
}
},
- 'Regression': {
+ Regression: {
'foo bar baz
;': {
- type: "ExpressionStatement",
+ type: 'ExpressionStatement',
start: 0,
end: 40,
expression: {
- type: "JSXElement",
+ type: 'JSXElement',
start: 0,
end: 38,
openingElement: {
- type: "JSXOpeningElement",
+ type: 'JSXOpeningElement',
start: 0,
end: 3,
attributes: [],
name: {
- type: "JSXIdentifier",
+ type: 'JSXIdentifier',
start: 1,
end: 2,
- name: "p"
+ name: 'p'
},
selfClosing: false
},
closingElement: {
- type: "JSXClosingElement",
+ type: 'JSXClosingElement',
start: 34,
end: 38,
name: {
- type: "JSXIdentifier",
+ type: 'JSXIdentifier',
start: 36,
end: 37,
- name: "p"
+ name: 'p'
}
},
children: [
{
- type: "JSXText",
+ type: 'JSXText',
start: 3,
end: 7,
- value: "foo ",
- raw: "foo "
+ value: 'foo ',
+ raw: 'foo '
},
{
- type: "JSXElement",
+ type: 'JSXElement',
start: 7,
end: 30,
openingElement: {
- type: "JSXOpeningElement",
+ type: 'JSXOpeningElement',
start: 7,
end: 22,
- attributes: [{
- type: "JSXAttribute",
- start: 10,
- end: 21,
- name: {
- type: "JSXIdentifier",
+ attributes: [
+ {
+ type: 'JSXAttribute',
start: 10,
- end: 14,
- name: "href"
- },
- value: {
- type: "Literal",
- start: 15,
end: 21,
- value: "test",
- raw: "\"test\""
+ name: {
+ type: 'JSXIdentifier',
+ start: 10,
+ end: 14,
+ name: 'href'
+ },
+ value: {
+ type: 'Literal',
+ start: 15,
+ end: 21,
+ value: 'test',
+ raw: '"test"'
+ }
}
- }],
+ ],
name: {
- type: "JSXIdentifier",
+ type: 'JSXIdentifier',
start: 8,
end: 9,
- name: "a"
+ name: 'a'
},
selfClosing: false
},
closingElement: {
- type: "JSXClosingElement",
+ type: 'JSXClosingElement',
start: 26,
end: 30,
name: {
- type: "JSXIdentifier",
+ type: 'JSXIdentifier',
start: 28,
end: 29,
- name: "a"
+ name: 'a'
}
},
- children: [{
- type: "JSXText",
- start: 22,
- end: 26,
- value: " bar",
- raw: " bar"
- }]
+ children: [
+ {
+ type: 'JSXText',
+ start: 22,
+ end: 26,
+ value: ' bar',
+ raw: ' bar'
+ }
+ ]
},
{
- type: "JSXText",
+ type: 'JSXText',
start: 30,
end: 34,
- value: " baz",
- raw: " baz"
+ value: ' baz',
+ raw: ' baz'
}
]
}
@@ -3474,187 +3134,196 @@ var fbTestFixture = {
name: 'div'
}
},
- children: [{
- type: 'JSXExpressionContainer',
- start: 5,
- end: 24,
- expression: {
- type: 'JSXElement',
- start: 6,
- end: 23,
- openingElement: {
- type: 'JSXOpeningElement',
+ children: [
+ {
+ type: 'JSXExpressionContainer',
+ start: 5,
+ end: 24,
+ expression: {
+ type: 'JSXElement',
start: 6,
end: 23,
- attributes: [
- {
- type: 'JSXSpreadAttribute',
- start: 11,
- end: 20,
- argument: {
- type: 'Identifier',
- start: 15,
- end: 19,
- name: 'test'
+ openingElement: {
+ type: 'JSXOpeningElement',
+ start: 6,
+ end: 23,
+ attributes: [
+ {
+ type: 'JSXSpreadAttribute',
+ start: 11,
+ end: 20,
+ argument: {
+ type: 'Identifier',
+ start: 15,
+ end: 19,
+ name: 'test'
+ }
}
- }
- ],
- name: {
- type: 'JSXIdentifier',
- start: 7,
- end: 10,
- name: 'div'
+ ],
+ name: {
+ type: 'JSXIdentifier',
+ start: 7,
+ end: 10,
+ name: 'div'
+ },
+ selfClosing: true
},
- selfClosing: true
- },
- closingElement: null,
- children: []
+ closingElement: null,
+ children: []
+ }
}
- }]
+ ]
}
},
'{ {a} }
': {
- type: "ExpressionStatement",
+ type: 'ExpressionStatement',
start: 0,
end: 18,
expression: {
- type: "JSXElement",
+ type: 'JSXElement',
start: 0,
end: 18,
openingElement: {
- type: "JSXOpeningElement",
+ type: 'JSXOpeningElement',
start: 0,
end: 5,
attributes: [],
name: {
- type: "JSXIdentifier",
+ type: 'JSXIdentifier',
start: 1,
end: 4,
- name: "div"
+ name: 'div'
},
selfClosing: false
},
closingElement: {
- type: "JSXClosingElement",
+ type: 'JSXClosingElement',
start: 12,
end: 18,
name: {
- type: "JSXIdentifier",
+ type: 'JSXIdentifier',
start: 14,
end: 17,
- name: "div"
+ name: 'div'
}
},
- children: [{
- type: "JSXExpressionContainer",
- start: 5,
- end: 12,
- expression: {
- type: "ObjectExpression",
- start: 7,
- end: 10,
- properties: [{
- type: "Property",
- start: 8,
- end: 9,
- method: false,
- shorthand: true,
- computed: false,
- key: {
- type: "Identifier",
- start: 8,
- end: 9,
- name: "a"
- },
- kind: "init",
- value: {
- type: "Identifier",
- start: 8,
- end: 9,
- name: "a"
- }
- }]
+ children: [
+ {
+ type: 'JSXExpressionContainer',
+ start: 5,
+ end: 12,
+ expression: {
+ type: 'ObjectExpression',
+ start: 7,
+ end: 10,
+ properties: [
+ {
+ type: 'Property',
+ start: 8,
+ end: 9,
+ method: false,
+ shorthand: true,
+ computed: false,
+ key: {
+ type: 'Identifier',
+ start: 8,
+ end: 9,
+ name: 'a'
+ },
+ kind: 'init',
+ value: {
+ type: 'Identifier',
+ start: 8,
+ end: 9,
+ name: 'a'
+ }
+ }
+ ]
+ }
}
- }]
+ ]
}
},
'/text
': {
- type: "ExpressionStatement",
+ type: 'ExpressionStatement',
start: 0,
end: 16,
expression: {
- type: "JSXElement",
+ type: 'JSXElement',
start: 0,
end: 16,
openingElement: {
- type: "JSXOpeningElement",
+ type: 'JSXOpeningElement',
start: 0,
end: 5,
attributes: [],
name: {
- type: "JSXIdentifier",
+ type: 'JSXIdentifier',
start: 1,
end: 4,
- name: "div"
+ name: 'div'
},
selfClosing: false
},
closingElement: {
- type: "JSXClosingElement",
+ type: 'JSXClosingElement',
start: 10,
end: 16,
name: {
- type: "JSXIdentifier",
+ type: 'JSXIdentifier',
start: 12,
end: 15,
- name: "div"
+ name: 'div'
}
},
- children: [{
- type: "JSXText",
- start: 5,
- end: 10,
- value: "/text",
- raw: "/text"
- }]
+ children: [
+ {
+ type: 'JSXText',
+ start: 5,
+ end: 10,
+ value: '/text',
+ raw: '/text'
+ }
+ ]
}
},
'{a}{b}
': {
- type: "ExpressionStatement",
+ type: 'ExpressionStatement',
start: 0,
end: 17,
expression: {
- type: "JSXElement",
+ type: 'JSXElement',
start: 0,
end: 17,
openingElement: {
- type: "JSXOpeningElement",
+ type: 'JSXOpeningElement',
start: 0,
end: 5,
attributes: [],
name: {
- type: "JSXIdentifier",
+ type: 'JSXIdentifier',
start: 1,
end: 4,
- name: "div"
+ name: 'div'
},
selfClosing: false
},
closingElement: {
- type: "JSXClosingElement",
+ type: 'JSXClosingElement',
start: 11,
end: 17,
name: {
- type: "JSXIdentifier",
+ type: 'JSXIdentifier',
start: 13,
end: 16,
- name: "div"
+ name: 'div'
}
},
- children: [{
+ children: [
+ {
type: 'JSXExpressionContainer',
expression: {
type: 'Identifier',
@@ -3682,7 +3351,8 @@ var fbTestFixture = {
column: 8
}
}
- }, {
+ },
+ {
type: 'JSXExpressionContainer',
expression: {
type: 'Identifier',
@@ -3716,43 +3386,43 @@ var fbTestFixture = {
},
'': {
- type: "ExpressionStatement",
+ type: 'ExpressionStatement',
range: [0, 32],
expression: {
- type: "JSXElement",
+ type: 'JSXElement',
range: [0, 32],
openingElement: {
- type: "JSXOpeningElement",
+ type: 'JSXOpeningElement',
range: [0, 32],
attributes: [
{
- type: "JSXAttribute",
+ type: 'JSXAttribute',
range: [5, 18],
name: {
- type: "JSXIdentifier",
+ type: 'JSXIdentifier',
range: [5, 8],
- name: "pre"
+ name: 'pre'
},
value: {
- type: "Literal",
+ type: 'Literal',
range: [9, 18],
- value: "leading"
+ value: 'leading'
}
},
{
- type: "JSXSpreadAttribute",
+ type: 'JSXSpreadAttribute',
range: [19, 29],
argument: {
- type: "Identifier",
+ type: 'Identifier',
range: [23, 28],
- name: "props"
+ name: 'props'
}
}
],
name: {
- type: "JSXIdentifier",
+ type: 'JSXIdentifier',
range: [1, 4],
- name: "div"
+ name: 'div'
},
selfClosing: true
},
@@ -3761,38 +3431,40 @@ var fbTestFixture = {
}
},
'': {
- type: "ExpressionStatement",
+ type: 'ExpressionStatement',
expression: {
- type: "JSXElement",
+ type: 'JSXElement',
range: [0, 64],
openingElement: {
- type: "JSXOpeningElement",
+ type: 'JSXOpeningElement',
range: [0, 64],
attributes: [
{
- type: "JSXAttribute",
+ type: 'JSXAttribute',
range: [6, 62],
name: {
- type: "JSXIdentifier",
+ type: 'JSXIdentifier',
range: [6, 7],
- name: "d"
+ name: 'd'
},
value: {
- type: "Literal",
+ type: 'Literal',
loc: {
start: { line: 1, column: 8 },
end: { line: 3, column: 15 }
},
range: [8, 62],
- value: "M230 80\n\t\tA 45 45, 0, 1, 0, 275 125 \r\n L 275 80 Z",
- raw: "\"M230 80\n\t\tA 45 45, 0, 1, 0, 275 125 \r\n L 275 80 Z\""
+ value:
+ 'M230 80\n\t\tA 45 45, 0, 1, 0, 275 125 \r\n L 275 80 Z',
+ raw:
+ '"M230 80\n\t\tA 45 45, 0, 1, 0, 275 125 \r\n L 275 80 Z"'
}
}
],
name: {
- type: "JSXIdentifier",
+ type: 'JSXIdentifier',
range: [1, 5],
- name: "path"
+ name: 'path'
},
selfClosing: true
},
@@ -3803,64 +3475,73 @@ var fbTestFixture = {
}
};
-if (typeof exports !== "undefined") {
- var test = require("./driver.js").test;
- var testFail = require("./driver.js").testFail;
- var tokTypes = require("../").tokTypes;
+if (typeof exports !== 'undefined') {
+ var test = require('./driver.js').test;
+ var testFail = require('./driver.js').testFail;
+ var tokTypes = require('../').tokTypes;
}
-testFail("var x = one
two
;", "Adjacent JSX elements must be wrapped in an enclosing tag (1:22)");
+testFail(
+ 'var x = one
two
;',
+ 'Adjacent JSX elements must be wrapped in an enclosing tag (1:22)'
+);
-testFail("", "Unexpected token (1:4)");
+testFail('', 'Unexpected token (1:4)');
-test("", {
- type: "Program",
- range: [0, 9],
- body: [{
- type: "ExpressionStatement",
+test(
+ '',
+ {
+ type: 'Program',
range: [0, 9],
- expression: {
- type: "JSXElement",
- range: [0, 9],
- openingElement: {
- type: "JSXOpeningElement",
+ body: [
+ {
+ type: 'ExpressionStatement',
range: [0, 9],
- attributes: [],
- name: {
- type: "JSXMemberExpression",
- range: [1, 6],
- object: {
- type: "JSXNamespacedName",
- range: [1, 4],
- namespace: {
- type: "JSXIdentifier",
- range: [1, 2],
- name: "a"
- },
+ expression: {
+ type: 'JSXElement',
+ range: [0, 9],
+ openingElement: {
+ type: 'JSXOpeningElement',
+ range: [0, 9],
+ attributes: [],
name: {
- type: "JSXIdentifier",
- range: [3, 4],
- name: "b"
- }
+ type: 'JSXMemberExpression',
+ range: [1, 6],
+ object: {
+ type: 'JSXNamespacedName',
+ range: [1, 4],
+ namespace: {
+ type: 'JSXIdentifier',
+ range: [1, 2],
+ name: 'a'
+ },
+ name: {
+ type: 'JSXIdentifier',
+ range: [3, 4],
+ name: 'b'
+ }
+ },
+ property: {
+ type: 'JSXIdentifier',
+ range: [5, 6],
+ name: 'c'
+ }
+ },
+ selfClosing: true
},
- property: {
- type: "JSXIdentifier",
- range: [5, 6],
- name: "c"
- }
- },
- selfClosing: true
- },
- closingElement: null,
- children: []
+ closingElement: null,
+ children: []
+ }
+ }
+ ]
+ },
+ {
+ ranges: true,
+ plugins: {
+ jsx: { allowNamespacedObjects: true }
}
- }]
-}, {
- ranges: true,
- plugins: {
- jsx: { allowNamespacedObjects: true }
}
-});
+);
testFail('', 'Unexpected token (1:3)', {
plugins: {
@@ -3874,91 +3555,105 @@ testFail('', 'Unexpected token (1:7)', {
}
});
-test('{/* foo */}', {}, {
- onToken: [
- {
- type: tokTypes.jsxTagStart,
- value: undefined,
- start: 0,
- end: 1
- },
- {
- type: tokTypes.jsxName,
- value: 'a',
- start: 1,
- end: 2
- },
- {
- type: tokTypes.jsxTagEnd,
- value: undefined,
- start: 2,
- end: 3
- },
- {
- type: tokTypes.braceL,
- value: undefined,
- start: 3,
- end: 4
- },
- {
- type: tokTypes.braceR,
- value: undefined,
- start: 13,
- end: 14
- },
- {
- type: tokTypes.jsxTagStart,
- value: undefined,
- start: 14,
- end: 15
- },
- {
- type: tokTypes.slash,
- value: '/',
- start: 15,
- end: 16
- },
- {
- type: tokTypes.jsxName,
- value: 'a',
- start: 16,
- end: 17
- },
- {
- type: tokTypes.jsxTagEnd,
- value: undefined,
- start: 17,
- end: 18
- },
- {
- type: tokTypes.eof,
- value: undefined,
- start: 18,
- end: 18
- }
- ]
-});
+test(
+ '{/* foo */}',
+ {},
+ {
+ onToken: [
+ {
+ type: tokTypes.jsxTagStart,
+ value: undefined,
+ start: 0,
+ end: 1
+ },
+ {
+ type: tokTypes.jsxName,
+ value: 'a',
+ start: 1,
+ end: 2
+ },
+ {
+ type: tokTypes.jsxTagEnd,
+ value: undefined,
+ start: 2,
+ end: 3
+ },
+ {
+ type: tokTypes.braceL,
+ value: undefined,
+ start: 3,
+ end: 4
+ },
+ {
+ type: tokTypes.braceR,
+ value: undefined,
+ start: 13,
+ end: 14
+ },
+ {
+ type: tokTypes.jsxTagStart,
+ value: undefined,
+ start: 14,
+ end: 15
+ },
+ {
+ type: tokTypes.slash,
+ value: '/',
+ start: 15,
+ end: 16
+ },
+ {
+ type: tokTypes.jsxName,
+ value: 'a',
+ start: 16,
+ end: 17
+ },
+ {
+ type: tokTypes.jsxTagEnd,
+ value: undefined,
+ start: 17,
+ end: 18
+ },
+ {
+ type: tokTypes.eof,
+ value: undefined,
+ start: 18,
+ end: 18
+ }
+ ]
+ }
+);
-test('