diff --git a/src/language-js/index.js b/src/language-js/index.js index 69d40941..d7babf05 100644 --- a/src/language-js/index.js +++ b/src/language-js/index.js @@ -181,7 +181,7 @@ const parsers = { babylon, json: Object.assign({}, babylon, { hasPragma() { - return false; + return true; } }), flow: { diff --git a/tests/insert-pragma/json/__snapshots__/jsfmt.spec.js.snap b/tests/insert-pragma/json/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 00000000..6bb1d04a --- /dev/null +++ b/tests/insert-pragma/json/__snapshots__/jsfmt.spec.js.snap @@ -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" + } + ] +} + +`; diff --git a/tests/insert-pragma/json/does-nothing.json b/tests/insert-pragma/json/does-nothing.json new file mode 100644 index 00000000..3b5ca8d0 --- /dev/null +++ b/tests/insert-pragma/json/does-nothing.json @@ -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"}, + ], +} diff --git a/tests/insert-pragma/json/jsfmt.spec.js b/tests/insert-pragma/json/jsfmt.spec.js new file mode 100644 index 00000000..b008c3e5 --- /dev/null +++ b/tests/insert-pragma/json/jsfmt.spec.js @@ -0,0 +1 @@ +run_spec(__dirname, ["json"], { insertPragma: true }); diff --git a/tests/require-pragma/json/__snapshots__/jsfmt.spec.js.snap b/tests/require-pragma/json/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 00000000..569b569e --- /dev/null +++ b/tests/require-pragma/json/__snapshots__/jsfmt.spec.js.snap @@ -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" + } + ] +} + +`; diff --git a/tests/require-pragma/json/format-anyway.json b/tests/require-pragma/json/format-anyway.json new file mode 100644 index 00000000..ad8ce37e --- /dev/null +++ b/tests/require-pragma/json/format-anyway.json @@ -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"}, + ], +} diff --git a/tests/require-pragma/json/jsfmt.spec.js b/tests/require-pragma/json/jsfmt.spec.js new file mode 100644 index 00000000..c725321b --- /dev/null +++ b/tests/require-pragma/json/jsfmt.spec.js @@ -0,0 +1 @@ +run_spec(__dirname, ["json"], { requirePragma: true });