Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Commit c88e3ab

Browse files
committed
New: Finished up ES6 features
1 parent 0ea1e32 commit c88e3ab

File tree

9 files changed

+316
-111
lines changed

9 files changed

+316
-111
lines changed

lib/ast-converter.js

Lines changed: 314 additions & 32 deletions
Large diffs are not rendered by default.

parser.js

Lines changed: 1 addition & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -99,59 +99,6 @@ function parse(code, options) {
9999
commentAttachment.reset();
100100
}
101101

102-
if (options.sourceType === "module") {
103-
extra.ecmaFeatures = {
104-
arrowFunctions: true,
105-
binaryLiterals: true,
106-
blockBindings: true,
107-
classes: true,
108-
destructuring: true,
109-
forOf: true,
110-
generators: true,
111-
modules: true,
112-
objectLiteralComputedProperties: true,
113-
objectLiteralDuplicateProperties: true,
114-
objectLiteralShorthandMethods: true,
115-
objectLiteralShorthandProperties: true,
116-
octalLiterals: true,
117-
regexUFlag: true,
118-
regexYFlag: true,
119-
restParams: true,
120-
spread: true,
121-
templateStrings: true,
122-
unicodeCodePointEscapes: true,
123-
};
124-
acornOptions.ecmaVersion = 6;
125-
acornOptions.sourceType = "module";
126-
}
127-
128-
// apply parsing flags after sourceType to allow overriding
129-
if (options.ecmaFeatures && typeof options.ecmaFeatures === "object") {
130-
131-
var flags = Object.keys(options.ecmaFeatures);
132-
133-
// if it's a module, augment the ecmaFeatures
134-
flags.forEach(function(key) {
135-
var value = extra.ecmaFeatures[key] = options.ecmaFeatures[key];
136-
137-
if (value) {
138-
switch (key) {
139-
case "globalReturn":
140-
acornOptions.allowReturnOutsideFunction = true;
141-
break;
142-
143-
case "modules":
144-
acornOptions.sourceType = "module";
145-
// falls through
146-
147-
default:
148-
acornOptions.ecmaVersion = 6;
149-
}
150-
}
151-
});
152-
153-
}
154-
155102
var FILENAME = "eslint.ts";
156103

157104
var compilerHost = {
@@ -205,34 +152,10 @@ function parse(code, options) {
205152
};
206153
}
207154

208-
if (extra.range) {
209-
acornOptions.ranges = true;
210-
}
211-
212-
if (extra.loc) {
213-
acornOptions.locations = true;
214-
}
215-
216-
if (extra.ecmaFeatures.jsx) {
217-
if (extra.ecmaFeatures.spread !== false) {
218-
extra.ecmaFeatures.spread = true;
219-
}
220-
acornOptions.plugins = { jsx: true };
221-
}
222155
}
223156

224-
225-
// if (extra.comment || extra.attachComment) {
226-
// ast.comments = extra.comments;
227-
// }
228-
229-
// if (extra.tokens) {
230-
// ast.tokens = extra.tokens;
231-
// }
232157
var convert = require("./lib/ast-converter");
233-
return convert(ast);
234-
235-
// return ast;
158+
return convert(ast, extra);
236159
}
237160

238161
//------------------------------------------------------------------------------

tests/lib/ecma-features.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ var testFiles = shelljs.find(FIXTURES_DIR).filter(function(filename) {
4949
}).map(function(filename) {
5050
return filename.substring(FIXTURES_DIR.length - 1, filename.length - 7); // strip off ".src.js"
5151
}).filter(function(filename) {
52-
return /classes/.test(filename) && filename.indexOf("error-") === -1 && filename.indexOf("invalid-") === -1;
52+
return !(/jsx|error\-|invalid\-|globalReturn|experimental|newTarget/.test(filename));
5353
});
5454

5555
var moduleTestFiles = testFiles.filter(function(filename) {

0 commit comments

Comments
 (0)