Fix pragma detection/insertion for JSON (#4333)

master
Lucas Duailibe 2018-04-24 10:10:16 -03:00 committed by GitHub
parent 586b55b326
commit 50101e98c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 105 additions and 1 deletions

View File

@ -181,7 +181,7 @@ const parsers = {
babylon,
json: Object.assign({}, babylon, {
hasPragma() {
return false;
return true;
}
}),
flow: {

View File

@ -0,0 +1,38 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`does-nothing.json 1`] = `
{"allOn": "Single", "Line": "example",
"noSpace":true,
"quote": {
"singleQuote": "example",
"indented": true,
},
"phoneNumbers": [
{"type": "home",
"number": "212 555-1234"},
{"type": "office",
"trailing": "commas by accident"},
],
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{
"allOn": "Single",
"Line": "example",
"noSpace": true,
"quote": {
"singleQuote": "example",
"indented": true
},
"phoneNumbers": [
{
"type": "home",
"number": "212 555-1234"
},
{
"type": "office",
"trailing": "commas by accident"
}
]
}
`;

View File

@ -0,0 +1,13 @@
{"allOn": "Single", "Line": "example",
"noSpace":true,
"quote": {
"singleQuote": "example",
"indented": true,
},
"phoneNumbers": [
{"type": "home",
"number": "212 555-1234"},
{"type": "office",
"trailing": "commas by accident"},
],
}

View File

@ -0,0 +1 @@
run_spec(__dirname, ["json"], { insertPragma: true });

View File

@ -0,0 +1,38 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`format-anyway.json 1`] = `
{"allOn": "Single", "Line": "example",
"noSpace":true,
"quote": {
"singleQuote": "example",
"indented": true,
},
"phoneNumbers": [
{"type": "home",
"number": "212 555-1234"},
{"type": "office",
"trailing": "commas by accident"},
],
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{
"allOn": "Single",
"Line": "example",
"noSpace": true,
"quote": {
"singleQuote": "example",
"indented": true
},
"phoneNumbers": [
{
"type": "home",
"number": "212 555-1234"
},
{
"type": "office",
"trailing": "commas by accident"
}
]
}
`;

View File

@ -0,0 +1,13 @@
{"allOn": "Single", "Line": "example",
"noSpace":true,
"quote": {
"singleQuote": "example",
"indented": true,
},
"phoneNumbers": [
{"type": "home",
"number": "212 555-1234"},
{"type": "office",
"trailing": "commas by accident"},
],
}

View File

@ -0,0 +1 @@
run_spec(__dirname, ["json"], { requirePragma: true });