Repository: prettier/prettier-atom
Pull request #208 (2017-06-28 12:46:02)

feat(parsers) : add JSON support
This PR adds JSON support as prettier@^1.5.0 is now supporting JSON https://github.com/prettier/prettier/releases/tag/1.5.0

I chose to update prettier/prettier-eslint/prettier-eslint-cli to be able to format JSON files in the source code. I can revert this if needed.


Patch:
diff --git a/.all-contributorsrc b/.all-contributorsrc
index 83f67f5..63774b3 100644
--- a/.all-contributorsrc
+++ b/.all-contributorsrc
@@ -228,6 +228,15 @@
         "code",
         "bug"
       ]
+    },
+    {
+      "login": "MatthieuLemoine",
+      "name": "Matthieu Lemoine",
+      "avatar_url": "https://avatars3.githubusercontent.com/u/8517072?v=3",
+      "profile": "https://matthieulemoine.com",
+      "contributions": [
+        "code"
+      ]
     }
   ]
 }
diff --git a/README.md b/README.md
index bd66f27..7098f50 100644
--- a/README.md
+++ b/README.md
@@ -80,7 +80,7 @@ Thanks goes to these people ([emoji key][emojis]):
 | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
 | [<img src="https://avatars.githubusercontent.com/u/6182852?v=3" width="100px;"/><br /><sub>Leon Chen</sub>](https://transcranial.github.io)<br />[💻](https://github.com/prettier/prettier-atom/commits?author=transcranial "Code") | [<img src="https://avatars.githubusercontent.com/u/197597?v=3" width="100px;"/><br /><sub>Christopher Chedeau</sub>](http://blog.vjeux.com/)<br />[💬](#question-vjeux "Answering Questions") [💻](https://github.com/prettier/prettier-atom/commits?author=vjeux "Code") [🔌](#plugin-vjeux "Plugin/utility libraries") | [<img src="https://avatars.githubusercontent.com/u/646693?v=3" width="100px;"/><br /><sub>Christoph Geschwind</sub>](http://christoph-geschwind.de)<br />[💻](https://github.com/prettier/prettier-atom/commits?author=1st8 "Code") | [<img src="https://avatars.githubusercontent.com/u/35026?v=3" width="100px;"/><br /><sub>Andrew Hutchings</sub>](https://andrewhutchings.com)<br />[💻](https://github.com/prettier/prettier-atom/commits?author=ahutchings "Code") | [<img src="https://avatars.githubusercontent.com/u/875591?v=3" width="100px;"/><br /><sub>David Schnurr</sub>](http://davidschnurr.com)<br />[💻](https://github.com/prettier/prettier-atom/commits?author=schnerd "Code") | [<img src="https://avatars.githubusercontent.com/u/484801?v=3" width="100px;"/><br /><sub>Ryan Cole</sub>](http://rycole.com/)<br />[💻](https://github.com/prettier/prettier-atom/commits?author=ryancole "Code") | [<img src="https://avatars0.githubusercontent.com/u/11488612?v=3" width="100px;"/><br /><sub>Dara Hak</sub>](https://github.com/darahak)<br />[💻](https://github.com/prettier/prettier-atom/commits?author=darahak "Code") [📖](https://github.com/prettier/prettier-atom/commits?author=darahak "Documentation") |
 | [<img src="https://avatars3.githubusercontent.com/u/487068?v=3" width="100px;"/><br /><sub>Stephen John Sorensen</sub>](http://www.stephenjohnsorensen.com/)<br />[💻](https://github.com/prettier/prettier-atom/commits?author=spudly "Code") | [<img src="https://avatars2.githubusercontent.com/u/13285808?v=3" width="100px;"/><br /><sub>Lukas Geiger</sub>](https://github.com/lgeiger)<br />[💻](https://github.com/prettier/prettier-atom/commits?author=lgeiger "Code") [⚠️](https://github.com/prettier/prettier-atom/commits?author=lgeiger "Tests") | [<img src="https://avatars2.githubusercontent.com/u/1517854?v=3" width="100px;"/><br /><sub>Viktor Charypar</sub>](https://github.com/charypar)<br />[💻](https://github.com/prettier/prettier-atom/commits?author=charypar "Code") [⚠️](https://github.com/prettier/prettier-atom/commits?author=charypar "Tests") | [<img src="https://avatars0.githubusercontent.com/u/1007436?v=3" width="100px;"/><br /><sub>Mats Högberg</sub>](http://mats.hgbrg.se)<br />[💻](https://github.com/prettier/prettier-atom/commits?author=mhgbrg "Code") | [<img src="https://avatars0.githubusercontent.com/u/2602767?v=3" width="100px;"/><br /><sub>Roman</sub>](https://github.com/RoM4iK)<br />[💻](https://github.com/prettier/prettier-atom/commits?author=RoM4iK "Code") | [<img src="https://avatars2.githubusercontent.com/u/1468518?v=3" width="100px;"/><br /><sub>vaibhav</sub>](https://vaibhavchatarkar.com)<br />[💻](https://github.com/prettier/prettier-atom/commits?author=da-vaibhav "Code") | [<img src="https://avatars1.githubusercontent.com/u/1935696?v=3" width="100px;"/><br /><sub>Karl Horky</sub>](https://work.karlhorky.com)<br />[💻](https://github.com/prettier/prettier-atom/commits?author=karlhorky "Code") |
-| [<img src="https://avatars3.githubusercontent.com/u/810438?v=3" width="100px;"/><br /><sub>Dan Abramov</sub>](http://twitter.com/dan_abramov)<br />[💻](https://github.com/prettier/prettier-atom/commits?author=gaearon "Code") | [<img src="https://avatars3.githubusercontent.com/u/1227109?v=3" width="100px;"/><br /><sub>Murphy Randle</sub>](https://sploding.rocks)<br />[💻](https://github.com/prettier/prettier-atom/commits?author=splodingsocks "Code") [🐛](https://github.com/prettier/prettier-atom/issues?q=author%3Asplodingsocks "Bug reports") |
+| [<img src="https://avatars3.githubusercontent.com/u/810438?v=3" width="100px;"/><br /><sub>Dan Abramov</sub>](http://twitter.com/dan_abramov)<br />[💻](https://github.com/prettier/prettier-atom/commits?author=gaearon "Code") | [<img src="https://avatars3.githubusercontent.com/u/1227109?v=3" width="100px;"/><br /><sub>Murphy Randle</sub>](https://sploding.rocks)<br />[💻](https://github.com/prettier/prettier-atom/commits?author=splodingsocks "Code") [🐛](https://github.com/prettier/prettier-atom/issues?q=author%3Asplodingsocks "Bug reports") | [<img src="https://avatars3.githubusercontent.com/u/8517072?v=3" width="100px;"/><br /><sub>Matthieu Lemoine</sub>](https://matthieulemoine.com)<br />[💻](https://github.com/prettier/prettier-atom/commits?author=MatthieuLemoine "Code") |
 <!-- ALL-CONTRIBUTORS-LIST:END -->
 
 This project follows the [all-contributors][all-contributors] specification. Contributions of any kind are welcome!
diff --git a/dist/atomInterface/index.js b/dist/atomInterface/index.js
index 706eea7..49b1751 100644
--- a/dist/atomInterface/index.js
+++ b/dist/atomInterface/index.js
@@ -61,8 +61,12 @@ var getCssScopes = function getCssScopes() {
   return getConfigOption('formatOnSaveOptions.cssScopes');
 };
 
+var getJsonScopes = function getJsonScopes() {
+  return getConfigOption('formatOnSaveOptions.jsonScopes');
+};
+
 var getAllScopes = function getAllScopes() {
-  return [].concat(_toConsumableArray(getJavascriptScopes()), _toConsumableArray(getTypescriptScopes()), _toConsumableArray(getCssScopes()));
+  return [].concat(_toConsumableArray(getJavascriptScopes()), _toConsumableArray(getTypescriptScopes()), _toConsumableArray(getCssScopes()), _toConsumableArray(getJsonScopes()));
 };
 
 var getWhitelistedGlobs = function getWhitelistedGlobs() {
@@ -131,6 +135,7 @@ module.exports = {
   getJavascriptScopes: getJavascriptScopes,
   getTypescriptScopes: getTypescriptScopes,
   getCssScopes: getCssScopes,
+  getJsonScopes: getJsonScopes,
   getAllScopes: getAllScopes,
   getWhitelistedGlobs: getWhitelistedGlobs,
   isDisabledIfNotInPackageJson: isDisabledIfNotInPackageJson,
diff --git a/dist/config-schema.json b/dist/config-schema.json
index fbeb90a..61538ec 100644
--- a/dist/config-schema.json
+++ b/dist/config-schema.json
@@ -68,11 +68,7 @@
         "title": "TypeScript Scopes",
         "description": "Select which files containing TypeScript should be formatted.<br>Use the command `Editor: Log Cursor Scope` to determine the scopes for a file.",
         "type": "array",
-        "default": [
-          "source.ts",
-          "source.tsx",
-          "source.ts.tsx"
-        ],
+        "default": ["source.ts", "source.tsx", "source.ts.tsx"],
         "items": {
           "type": "string"
         },
@@ -82,38 +78,42 @@
         "title": "CSS Scopes",
         "description": "Select which files containing CSS should be formatted.<br>Use `Editor: Log Cursor Scope` to determine the scopes for a file.",
         "type": "array",
-        "default": [
-          "source.css",
-          "source.less",
-          "source.css.less",
-          "source.scss",
-          "source.css.scss"
-        ],
+        "default": ["source.css", "source.less", "source.css.less", "source.scss", "source.css.scss"],
         "items": {
           "type": "string"
         },
         "order": 6
       },
+      "jsonScopes": {
+        "title": "JSON Scopes",
+        "description": "Select which files containing JSON should be formatted.<br>Use `Editor: Log Cursor Scope` to determine the scopes for a file.",
+        "type": "array",
+        "default": ["source.json"],
+        "items": {
+          "type": "string"
+        },
+        "order": 7
+      },
       "excludedGlobs": {
         "title": "Exclude (list of globs)",
         "description": "A list of file globs to exclude from formatting on save (takes precedence over scopes). Use commas to separate each glob.",
         "type": "array",
         "default": [],
-        "order": 7
+        "order": 8
       },
       "whitelistedGlobs": {
         "title": "Include (list of globs)",
         "description": "A list of file globs to always format on save (takes precedence over scopes and excluded globs). Use commas to separate each glob.<br><br>**Note:** If there are globs in this list, files not matching the globs will not be formatted on save, regardless of other options.",
         "type": "array",
         "default": [],
-        "order": 8
+        "order": 9
       },
       "isDisabledIfNotInPackageJson": {
         "title": "Only format if Prettier is found in your project's dependencies",
         "description": "Does not format on save if `prettier` (or `prettier-eslint`/`prettier-eslint-cli` if using *ESLint integration*) is in your project's `package.json` (dependencies or devDependencies)",
         "type": "boolean",
         "default": false,
-        "order": 9
+        "order": 10
       }
     }
   },
@@ -175,22 +175,15 @@
         "description": "Print trailing commas wherever possible.",
         "type": "string",
         "default": "none",
-        "enum": [
-          "none",
-          "es5",
-          "all"
-        ],
+        "enum": ["none", "es5", "all"],
         "order": 8
       },
       "parser": {
         "title": "JavaScript Parser",
-        "description": "Choose which [supported parser](https://www.npmjs.com/package/prettier#language-support) to use. (Does not apply to TypeScript or CSS)",
+        "description": "Choose which [supported parser](https://www.npmjs.com/package/prettier#language-support) to use. (Does not apply to TypeScript, CSS or JSON)",
         "type": "string",
         "default": "babylon",
-        "enum": [
-          "babylon",
-          "flow"
-        ],
+        "enum": ["babylon", "flow"],
         "order": 9
       }
     }
diff --git a/dist/editorInterface/index.js b/dist/editorInterface/index.js
index 05f5c7d..0b2fea1 100644
--- a/dist/editorInterface/index.js
+++ b/dist/editorInterface/index.js
@@ -5,7 +5,8 @@ var path = require('path');
 
 var _require = require('../atomInterface'),
     getCssScopes = _require.getCssScopes,
-    getTypescriptScopes = _require.getTypescriptScopes;
+    getTypescriptScopes = _require.getTypescriptScopes,
+    getJsonScopes = _require.getJsonScopes;
 
 var EMBEDDED_SCOPES = ['text.html.vue', 'text.html.basic'];
 
@@ -29,6 +30,10 @@ var isCurrentScopeTypescriptScope = function isCurrentScopeTypescriptScope(edito
   return getTypescriptScopes().includes(getCurrentScope(editor));
 };
 
+var isCurrentScopeJsonScope = function isCurrentScopeJsonScope(editor) {
+  return getJsonScopes().includes(getCurrentScope(editor));
+};
+
 var getCurrentFilePath = function getCurrentFilePath(editor) {
   return editor.buffer.file ? editor.buffer.file.path : undefined;
 };
@@ -42,6 +47,7 @@ module.exports = {
   isCurrentScopeEmbeddedScope: isCurrentScopeEmbeddedScope,
   isCurrentScopeCssScope: isCurrentScopeCssScope,
   isCurrentScopeTypescriptScope: isCurrentScopeTypescriptScope,
+  isCurrentScopeJsonScope: isCurrentScopeJsonScope,
   getCurrentScope: getCurrentScope,
   getCurrentFilePath: getCurrentFilePath,
   getCurrentDir: getCurrentDir
diff --git a/dist/executePrettier/buildPrettierOptions.js b/dist/executePrettier/buildPrettierOptions.js
index 376be11..ea94afd 100644
--- a/dist/executePrettier/buildPrettierOptions.js
+++ b/dist/executePrettier/buildPrettierOptions.js
@@ -7,7 +7,8 @@ var _ = require('lodash/fp');
 var _require = require('../editorInterface'),
     getCurrentFilePath = _require.getCurrentFilePath,
     isCurrentScopeTypescriptScope = _require.isCurrentScopeTypescriptScope,
-    isCurrentScopeCssScope = _require.isCurrentScopeCssScope;
+    isCurrentScopeCssScope = _require.isCurrentScopeCssScope,
+    isCurrentScopeJsonScope = _require.isCurrentScopeJsonScope;
 
 var _require2 = require('../atomInterface'),
     shouldUseEditorConfig = _require2.shouldUseEditorConfig,
@@ -37,6 +38,10 @@ var buildPrettierOptions = function buildPrettierOptions(editor) {
     optionsFromSettings.parser = 'postcss';
   }
 
+  if (isCurrentScopeJsonScope(editor)) {
+    optionsFromSettings.parser = 'json';
+  }
+
   return _extends({}, optionsFromSettings, buildEditorConfigOptionsIfAppropriate(editor));
 };
 
diff --git a/package-scripts.yml b/package-scripts.yml
index 41ea561..db46b9b 100644
--- a/package-scripts.yml
+++ b/package-scripts.yml
@@ -17,7 +17,7 @@ scripts:
 
   format:
     description: Run prettier-eslint on the src code
-    script: prettier-eslint "src/**/*.js" --write
+    script: prettier-eslint "src/**/*.js" "src/**/*.json" --write
 
   flow:
     default:
diff --git a/package.json b/package.json
index a1f2ac7..c22df71 100644
--- a/package.json
+++ b/package.json
@@ -26,8 +26,8 @@
     "ignore": "^3.3.3",
     "lodash": "^4.17.4",
     "loophole": "^1.1.0",
-    "prettier": "^1.4.4",
-    "prettier-eslint": "^6.3.0",
+    "prettier": "^1.5.2",
+    "prettier-eslint": "^6.4.1",
     "read-pkg-up": "^2.0.0"
   },
   "devDependencies": {
diff --git a/src/atomInterface/index.js b/src/atomInterface/index.js
index 4d6c0ec..58f4beb 100644
--- a/src/atomInterface/index.js
+++ b/src/atomInterface/index.js
@@ -36,7 +36,14 @@ const getTypescriptScopes = () => getConfigOption('formatOnSaveOptions.typescrip
 
 const getCssScopes = () => getConfigOption('formatOnSaveOptions.cssScopes');
 
-const getAllScopes = () => [...getJavascriptScopes(), ...getTypescriptScopes(), ...getCssScopes()];
+const getJsonScopes = () => getConfigOption('formatOnSaveOptions.jsonScopes');
+
+const getAllScopes = () => [
+  ...getJavascriptScopes(),
+  ...getTypescriptScopes(),
+  ...getCssScopes(),
+  ...getJsonScopes(),
+];
 
 const getWhitelistedGlobs = () => getConfigOption('formatOnSaveOptions.whitelistedGlobs');
 
@@ -85,6 +92,7 @@ module.exports = {
   getJavascriptScopes,
   getTypescriptScopes,
   getCssScopes,
+  getJsonScopes,
   getAllScopes,
   getWhitelistedGlobs,
   isDisabledIfNotInPackageJson,
diff --git a/src/config-schema.json b/src/config-schema.json
index fbeb90a..61538ec 100644
--- a/src/config-schema.json
+++ b/src/config-schema.json
@@ -68,11 +68,7 @@
         "title": "TypeScript Scopes",
         "description": "Select which files containing TypeScript should be formatted.<br>Use the command `Editor: Log Cursor Scope` to determine the scopes for a file.",
         "type": "array",
-        "default": [
-          "source.ts",
-          "source.tsx",
-          "source.ts.tsx"
-        ],
+        "default": ["source.ts", "source.tsx", "source.ts.tsx"],
         "items": {
           "type": "string"
         },
@@ -82,38 +78,42 @@
         "title": "CSS Scopes",
         "description": "Select which files containing CSS should be formatted.<br>Use `Editor: Log Cursor Scope` to determine the scopes for a file.",
         "type": "array",
-        "default": [
-          "source.css",
-          "source.less",
-          "source.css.less",
-          "source.scss",
-          "source.css.scss"
-        ],
+        "default": ["source.css", "source.less", "source.css.less", "source.scss", "source.css.scss"],
         "items": {
           "type": "string"
         },
         "order": 6
       },
+      "jsonScopes": {
+        "title": "JSON Scopes",
+        "description": "Select which files containing JSON should be formatted.<br>Use `Editor: Log Cursor Scope` to determine the scopes for a file.",
+        "type": "array",
+        "default": ["source.json"],
+        "items": {
+          "type": "string"
+        },
+        "order": 7
+      },
       "excludedGlobs": {
         "title": "Exclude (list of globs)",
         "description": "A list of file globs to exclude from formatting on save (takes precedence over scopes). Use commas to separate each glob.",
         "type": "array",
         "default": [],
-        "order": 7
+        "order": 8
       },
       "whitelistedGlobs": {
         "title": "Include (list of globs)",
         "description": "A list of file globs to always format on save (takes precedence over scopes and excluded globs). Use commas to separate each glob.<br><br>**Note:** If there are globs in this list, files not matching the globs will not be formatted on save, regardless of other options.",
         "type": "array",
         "default": [],
-        "order": 8
+        "order": 9
       },
       "isDisabledIfNotInPackageJson": {
         "title": "Only format if Prettier is found in your project's dependencies",
         "description": "Does not format on save if `prettier` (or `prettier-eslint`/`prettier-eslint-cli` if using *ESLint integration*) is in your project's `package.json` (dependencies or devDependencies)",
         "type": "boolean",
         "default": false,
-        "order": 9
+        "order": 10
       }
     }
   },
@@ -175,22 +175,15 @@
         "description": "Print trailing commas wherever possible.",
         "type": "string",
         "default": "none",
-        "enum": [
-          "none",
-          "es5",
-          "all"
-        ],
+        "enum": ["none", "es5", "all"],
         "order": 8
       },
       "parser": {
         "title": "JavaScript Parser",
-        "description": "Choose which [supported parser](https://www.npmjs.com/package/prettier#language-support) to use. (Does not apply to TypeScript or CSS)",
+        "description": "Choose which [supported parser](https://www.npmjs.com/package/prettier#language-support) to use. (Does not apply to TypeScript, CSS or JSON)",
         "type": "string",
         "default": "babylon",
-        "enum": [
-          "babylon",
-          "flow"
-        ],
+        "enum": ["babylon", "flow"],
         "order": 9
       }
     }
diff --git a/src/editorInterface/index.js b/src/editorInterface/index.js
index 377c36a..034b04c 100644
--- a/src/editorInterface/index.js
+++ b/src/editorInterface/index.js
@@ -2,7 +2,7 @@
 const _ = require('lodash/fp');
 const path = require('path');
 
-const { getCssScopes, getTypescriptScopes } = require('../atomInterface');
+const { getCssScopes, getTypescriptScopes, getJsonScopes } = require('../atomInterface');
 
 const EMBEDDED_SCOPES = ['text.html.vue', 'text.html.basic'];
 
@@ -17,6 +17,8 @@ const isCurrentScopeCssScope = (editor: TextEditor) => getCssScopes().includes(g
 const isCurrentScopeTypescriptScope = (editor: TextEditor) =>
   getTypescriptScopes().includes(getCurrentScope(editor));
 
+const isCurrentScopeJsonScope = (editor: TextEditor) => getJsonScopes().includes(getCurrentScope(editor));
+
 const getCurrentFilePath = (editor: TextEditor) => (editor.buffer.file ? editor.buffer.file.path : undefined);
 
 const getCurrentDir: (editor: TextEditor) => ?string = _.flow(
@@ -29,6 +31,7 @@ module.exports = {
   isCurrentScopeEmbeddedScope,
   isCurrentScopeCssScope,
   isCurrentScopeTypescriptScope,
+  isCurrentScopeJsonScope,
   getCurrentScope,
   getCurrentFilePath,
   getCurrentDir,
diff --git a/src/executePrettier/buildPrettierOptions.js b/src/executePrettier/buildPrettierOptions.js
index 467b467..5b5cb8a 100644
--- a/src/executePrettier/buildPrettierOptions.js
+++ b/src/executePrettier/buildPrettierOptions.js
@@ -4,6 +4,7 @@ const {
   getCurrentFilePath,
   isCurrentScopeTypescriptScope,
   isCurrentScopeCssScope,
+  isCurrentScopeJsonScope,
 } = require('../editorInterface');
 const { shouldUseEditorConfig, getPrettierOptions, getAtomTabLength } = require('../atomInterface');
 const buildEditorConfigOptions = require('./buildEditorConfigOptions');
@@ -35,6 +36,10 @@ const buildPrettierOptions = (editor: TextEditor) => {
     optionsFromSettings.parser = 'postcss';
   }
 
+  if (isCurrentScopeJsonScope(editor)) {
+    optionsFromSettings.parser = 'json';
+  }
+
   return {
     ...optionsFromSettings,
     ...buildEditorConfigOptionsIfAppropriate(editor),
diff --git a/yarn.lock b/yarn.lock
index ac273db..403c29e 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3286,9 +3286,9 @@ prettier-eslint-cli@^4.1.1:
     rxjs "^5.3.0"
     yargs "^7.1.0"
 
-prettier-eslint@^6.0.0, prettier-eslint@^6.3.0:
-  version "6.3.0"
-  resolved "https://registry.yarnpkg.com/prettier-eslint/-/prettier-eslint-6.3.0.tgz#2c86ae959439c25d9a9ce8fce90c7bd809b7082f"
+prettier-eslint@^6.0.0, prettier-eslint@^6.4.1:
+  version "6.4.1"
+  resolved "https://registry.yarnpkg.com/prettier-eslint/-/prettier-eslint-6.4.1.tgz#14672e297b9049775c638c6448c3998c1f0268f9"
   dependencies:
     common-tags "^1.4.0"
     dlv "^1.1.0"
@@ -3296,13 +3296,13 @@ prettier-eslint@^6.0.0, prettier-eslint@^6.3.0:
     indent-string "^3.1.0"
     lodash.merge "^4.6.0"
     loglevel-colored-level-prefix "^1.0.0"
-    prettier "^1.4.2"
+    prettier "^1.5.0"
     pretty-format "^20.0.3"
     require-relative "^0.8.7"
 
-prettier@^1.4.2, prettier@^1.4.4:
-  version "1.4.4"
-  resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.4.4.tgz#a8d1447b14c9bf67e6d420dcadd10fb9a4fad65a"
+prettier@^1.5.0, prettier@^1.5.2:
+  version "1.5.2"
+  resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.5.2.tgz#7ea0751da27b93bfb6cecfcec509994f52d83bb3"
 
 pretty-format@^20.0.3:
   version "20.0.3"


Test patch:
diff --git a/src/editorInterface/index.test.js b/src/editorInterface/index.test.js
index 84c57e9..99f8d23 100644
--- a/src/editorInterface/index.test.js
+++ b/src/editorInterface/index.test.js
@@ -1,13 +1,14 @@
 jest.mock('../atomInterface');
 
 const buildMockTextEditor = require('../../tests/mocks/textEditor');
-const { getCssScopes, getTypescriptScopes } = require('../atomInterface');
+const { getCssScopes, getTypescriptScopes, getJsonScopes } = require('../atomInterface');
 const {
   getBufferRange,
   getCurrentScope,
   isCurrentScopeEmbeddedScope,
   isCurrentScopeCssScope,
   isCurrentScopeTypescriptScope,
+  isCurrentScopeJsonScope,
   getCurrentFilePath,
 } = require('./index');
 
@@ -95,6 +96,28 @@ describe('isCurrentScopeTypescriptScope()', () => {
   });
 });
 
+describe('isCurrentScopeJsonScope()', () => {
+  it('returns true if the current scope is a JSON scope type', () => {
+    const scopeName = 'src.json';
+    const editor = buildMockTextEditor({ getGrammar: () => ({ scopeName }) });
+    getJsonScopes.mockImplementation(() => ['src.json']);
+
+    const actual = isCurrentScopeJsonScope(editor);
+
+    expect(actual).toBe(true);
+  });
+
+  it('returns false if the current scope is not a JSON scope type', () => {
+    const scopeName = 'src.css';
+    const editor = buildMockTextEditor({ getGrammar: () => ({ scopeName }) });
+    getJsonScopes.mockImplementation(() => ['src.json']);
+
+    const actual = isCurrentScopeJsonScope(editor);
+
+    expect(actual).toBe(false);
+  });
+});
+
 describe('getCurrentFilePath()', () => {
   it('returns the current file path if there is one', () => {
     const file = { path: 'xyz.js' };
diff --git a/src/executePrettier/buildPrettierOptions.test.js b/src/executePrettier/buildPrettierOptions.test.js
index ee24972..49e4421 100644
--- a/src/executePrettier/buildPrettierOptions.test.js
+++ b/src/executePrettier/buildPrettierOptions.test.js
@@ -7,6 +7,7 @@ const {
   getCurrentFilePath,
   isCurrentScopeTypescriptScope,
   isCurrentScopeCssScope,
+  isCurrentScopeJsonScope,
 } = require('../editorInterface');
 const buildEditorConfigOptions = require('./buildEditorConfigOptions');
 const buildMockEditor = require('../../tests/mocks/textEditor');
@@ -55,6 +56,17 @@ it('uses postcss as the parser if current scope is listed as a CSS scope in sett
   expect(actual).toEqual({ parser: 'postcss' });
 });
 
+it('uses json as the parser if current scope is listed as a JSON scope in settings', () => {
+  const editor = buildMockEditor();
+  const fakePrettierOptions = { parser: 'babylon' };
+  getPrettierOptions.mockImplementation(() => fakePrettierOptions);
+  isCurrentScopeJsonScope.mockImplementation(() => true);
+
+  const actual = buildPrettierOptions(editor);
+
+  expect(actual).toEqual({ parser: 'json' });
+});
+
 it('does not use editorconfig options if that setting is not enabled', () => {
   const editor = buildMockEditor();
   getPrettierOptions.mockImplementation(() => ({}));
diff --git a/src/statusTile/updateStatusTileScope.js b/src/statusTile/updateStatusTileScope.js
index 2ae4e4e..5a6bc61 100644
--- a/src/statusTile/updateStatusTileScope.js
+++ b/src/statusTile/updateStatusTileScope.js
@@ -5,9 +5,8 @@ const { getAllScopes } = require('../atomInterface');
 const updateStatusTileScope = (element: HTMLElement, editor: ?TextEditor) => {
   // The editor can be undefined if there is no active editor (e.g. closed all tabs).
   // eslint-disable-next-line no-param-reassign
-  element.dataset.prettierMatchScope = editor && getAllScopes().includes(getCurrentScope(editor))
-    ? 'true'
-    : 'false';
+  element.dataset.prettierMatchScope =
+    editor && getAllScopes().includes(getCurrentScope(editor)) ? 'true' : 'false';
 };
 
 module.exports = updateStatusTileScope;