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 lintmaster
parent
70604f1fd1
commit
8ec5432768
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
)
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue