Fix empty file error in json and graphql (#4553)

* Fix empty file error in json and graphql

* fix AST_COMPARE=1 issue

* use tests/empty

* revert

* fix lint
This commit is contained in:
Aakansha Doshi authored and Lucas Duailibe committed 2018-06-06 10:41:12 -03:00
1 parent 70604f1fd1
commit 8ec5432768
3 files changed
+7 -4

No files matched your search

+3
View File
@@ -49,6 +49,9 @@ function genericPrint(path, options, print) {
return JSON.stringify(node.value);
case "Identifier":
return JSON.stringify(node.name);
default:
/* istanbul ignore next */
throw new Error("unknown type: " + JSON.stringify(node.type));
}
}
+4
View File
@@ -63,6 +63,10 @@ function attachComments(text, ast, opts) {
}
function coreFormat(text, opts, addAlignmentSize) {
if (!text || !text.trim().length) {
return { formatted: "", cursorOffset: 0 };
}
addAlignmentSize = addAlignmentSize || 0;
const parsed = parser.parse(text, opts);
-4
View File
@@ -8,8 +8,4 @@ run_spec(
parsers.choices
.filter(choice => !choice.deprecated)
.map(choice => choice.value)
.filter(
parser =>
["json", "json5", "json-stringify", "graphql"].indexOf(parser) === -1
)
);