Skip to content

Commit

Permalink
update Babel to 7.7.0 and enable error recovery
Browse files Browse the repository at this point in the history
  • Loading branch information
thorn0 committed Nov 5, 2019
1 parent 82257bc commit 969a702
Show file tree
Hide file tree
Showing 9 changed files with 289 additions and 212 deletions.
3 changes: 2 additions & 1 deletion cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@
"<!-- prettier-ignore -->\\n(`{3,})\\w*\\n[\\s\\S]+?\\1",
"\\[@\\w+?\\]",
"\\[`\\w+`\\]",
"ve+r+y+(long\\w+)?"
"ve{2,}r{2,}y",
"ve+r+y+long\\w*"
]
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"dependencies": {
"@angular/compiler": "8.2.13",
"@babel/code-frame": "7.5.5",
"@babel/parser": "7.6.4",
"@babel/parser": "7.7.0",
"@glimmer/syntax": "0.41.0",
"@iarna/toml": "2.2.3",
"@typescript-eslint/typescript-estree": "2.6.0",
Expand Down Expand Up @@ -74,8 +74,8 @@
"yaml-unist-parser": "1.1.1"
},
"devDependencies": {
"@babel/core": "7.6.3",
"@babel/preset-env": "7.6.3",
"@babel/core": "7.7.0",
"@babel/preset-env": "7.7.1",
"@rollup/plugin-alias": "2.2.0",
"@rollup/plugin-replace": "2.2.0",
"babel-loader": "8.0.6",
Expand Down
3 changes: 2 additions & 1 deletion src/language-js/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ function clean(ast, newObj, parent) {
"extra",
"start",
"end",
"flags"
"flags",
"errors"
].forEach(name => {
delete newObj[name];
});
Expand Down
1 change: 1 addition & 0 deletions src/language-js/parser-babylon.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function babelOptions(extraOptions, extraPlugins) {
allowReturnOutsideFunction: true,
allowSuperOutsideMethod: true,
allowUndeclaredExports: true,
errorRecovery: true,
plugins: [
"jsx",
"doExpressions",
Expand Down
1 change: 1 addition & 0 deletions src/language-js/printer-estree-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ function clean(node, newNode /*, parent*/) {
delete newNode.extra;
delete newNode.loc;
delete newNode.comments;
delete newNode.errors;

if (node.type === "Identifier") {
return { type: "StringLiteral", value: node.name };
Expand Down
16 changes: 16 additions & 0 deletions tests/js_invalid_code/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`duplicate_bindings.js 1`] = `
====================================options=====================================
parsers: ["babel"]
printWidth: 80
| printWidth
=====================================input======================================
class A{} class A{}
=====================================output=====================================
class A {}
class A {}
================================================================================
`;
1 change: 1 addition & 0 deletions tests/js_invalid_code/duplicate_bindings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
class A{} class A{}
1 change: 1 addition & 0 deletions tests/js_invalid_code/jsfmt.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
run_spec(__dirname, ["babel"]);

0 comments on commit 969a702

Please sign in to comment.