Repository: prettier/prettier-atom
Pull request #122 (2017-04-14 11:58:04)

feat(config): Added config options for the Prettier options 'useTabs' and 'semi'
Version 1.0 of Prettier added options to use tabs instead of spaces, and to remove semicolons at the
end of lines. This adds the ability to change these options from the package settings pane.


Patch:
diff --git a/.all-contributorsrc b/.all-contributorsrc
index 0270b60..9a2bb55 100644
--- a/.all-contributorsrc
+++ b/.all-contributorsrc
@@ -171,6 +171,15 @@
         "code",
         "test"
       ]
+    },
+    {
+      "login": "mhgbrg",
+      "name": "Mats Högberg",
+      "avatar_url": "https://avatars0.githubusercontent.com/u/1007436?v=3",
+      "profile": "http://mats.hgbrg.se",
+      "contributions": [
+        "code"
+      ]
     }
   ]
 }
diff --git a/README.md b/README.md
index 5d5e2c6..ef18971 100644
--- a/README.md
+++ b/README.md
@@ -56,7 +56,7 @@ Thanks goes to these people ([emoji key][emojis]):
 | [<img src="https://avatars.githubusercontent.com/u/17031?v=3" width="100px;"/><br /><sub>James Long</sub>](http://jlongster.com)<br />💬 [💻](https://github.com/prettier/prettier-atom/commits?author=jlongster) [📖](https://github.com/prettier/prettier-atom/commits?author=jlongster) 🔌 👀 | [<img src="https://avatars.githubusercontent.com/u/6173488?v=3" width="100px;"/><br /><sub>Rob Wise</sub>](https://robwise.github.io)<br />[💻](https://github.com/prettier/prettier-atom/commits?author=robwise) [📖](https://github.com/prettier/prettier-atom/commits?author=robwise) 💬 💡 👀 [⚠️](https://github.com/prettier/prettier-atom/commits?author=robwise) | [<img src="https://avatars.githubusercontent.com/u/1500684?v=3" width="100px;"/><br /><sub>Kent C. Dodds</sub>](https://kentcdodds.com)<br />[💻](https://github.com/prettier/prettier-atom/commits?author=kentcdodds) [📖](https://github.com/prettier/prettier-atom/commits?author=kentcdodds) 🚇 | [<img src="https://avatars.githubusercontent.com/u/1144075?v=3" width="100px;"/><br /><sub>Luca Barone</sub>](https://github.com/cloud-walker)<br /> | [<img src="https://avatars.githubusercontent.com/u/4514159?v=3" width="100px;"/><br /><sub>Arnar Þór Sveinsson</sub>](https://github.com/arnarthor)<br />[💻](https://github.com/prettier/prettier-atom/commits?author=arnarthor) | [<img src="https://avatars.githubusercontent.com/u/131916?v=3" width="100px;"/><br /><sub>Adam Miskiewicz</sub>](http://www.adammiskiewicz.com/)<br />[💻](https://github.com/prettier/prettier-atom/commits?author=skevy) | [<img src="https://avatars.githubusercontent.com/u/2685242?v=3" width="100px;"/><br /><sub>Ori Livni</sub>](http://www.orilivni.com)<br />[💻](https://github.com/prettier/prettier-atom/commits?author=oriSomething) |
 | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
 | [<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) | [<img src="https://avatars.githubusercontent.com/u/197597?v=3" width="100px;"/><br /><sub>Christopher Chedeau</sub>](http://blog.vjeux.com/)<br />💬 [💻](https://github.com/prettier/prettier-atom/commits?author=vjeux) 🔌 | [<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) | [<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) | [<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) | [<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) | [<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) |
-| [<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) | [<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) | [<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) [⚠️](https://github.com/prettier/prettier-atom/commits?author=charypar) |
+| [<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) | [<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) | [<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) [⚠️](https://github.com/prettier/prettier-atom/commits?author=charypar) | [<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) |
 <!-- ALL-CONTRIBUTORS-LIST:END -->
 
 This project follows the [all-contributors][all-contributors] specification. Contributions of any kind welcome!
diff --git a/dist/config-schema.json b/dist/config-schema.json
index 99ceeaa..65488b2 100644
--- a/dist/config-schema.json
+++ b/dist/config-schema.json
@@ -84,26 +84,40 @@
         "default": true,
         "order": 2
       },
+      "semi": {
+        "title": "Semicolons",
+        "description": "Add semicolons at the end of lines.",
+        "type": "boolean",
+        "default": true,
+        "order": 3
+      },
+      "useTabs": {
+        "title": "Use Tabs",
+        "description": "Use tabs instead of spaces.",
+        "type": "boolean",
+        "default": false,
+        "order": 4
+      },
       "jsxBracketSameLine": {
         "title": "JSX Bracket Same Line",
         "description": "Put > on the same line in JSX.",
         "type": "boolean",
         "default": false,
-        "order": 3
+        "order": 5
       },
       "printWidth": {
         "title": "Print Width",
         "description": "Fit code within this line limit",
         "type": "integer",
         "default": 80,
-        "order": 4
+        "order": 6
       },
       "tabWidth": {
         "title": "Tab Width",
         "description": "Number of spaces to use per tab. Use 'auto' to use your editor's tab width setting.",
         "type": "string",
         "default": "auto",
-        "order": 5
+        "order": 7
       },
       "trailingComma": {
         "title": "Trailing Comma",
@@ -115,7 +129,7 @@
           "es5",
           "all"
         ],
-        "order": 6
+        "order": 8
       },
       "parser": {
         "title": "Parser",
@@ -126,7 +140,7 @@
           "babylon",
           "flow"
         ],
-        "order": 7
+        "order": 9
       }
     }
   },
diff --git a/dist/helpers.js b/dist/helpers.js
index da59ef1..6d40008 100644
--- a/dist/helpers.js
+++ b/dist/helpers.js
@@ -171,6 +171,8 @@ var getPrettierOptions = function getPrettierOptions(editor) {
     singleQuote: getPrettierOption('singleQuote'),
     trailingComma: getPrettierOption('trailingComma'),
     bracketSpacing: getPrettierOption('bracketSpacing'),
+    semi: getPrettierOption('semi'),
+    useTabs: getPrettierOption('useTabs'),
     jsxBracketSameLine: getPrettierOption('jsxBracketSameLine')
   };
 };
diff --git a/src/config-schema.json b/src/config-schema.json
index 99ceeaa..65488b2 100644
--- a/src/config-schema.json
+++ b/src/config-schema.json
@@ -84,26 +84,40 @@
         "default": true,
         "order": 2
       },
+      "semi": {
+        "title": "Semicolons",
+        "description": "Add semicolons at the end of lines.",
+        "type": "boolean",
+        "default": true,
+        "order": 3
+      },
+      "useTabs": {
+        "title": "Use Tabs",
+        "description": "Use tabs instead of spaces.",
+        "type": "boolean",
+        "default": false,
+        "order": 4
+      },
       "jsxBracketSameLine": {
         "title": "JSX Bracket Same Line",
         "description": "Put > on the same line in JSX.",
         "type": "boolean",
         "default": false,
-        "order": 3
+        "order": 5
       },
       "printWidth": {
         "title": "Print Width",
         "description": "Fit code within this line limit",
         "type": "integer",
         "default": 80,
-        "order": 4
+        "order": 6
       },
       "tabWidth": {
         "title": "Tab Width",
         "description": "Number of spaces to use per tab. Use 'auto' to use your editor's tab width setting.",
         "type": "string",
         "default": "auto",
-        "order": 5
+        "order": 7
       },
       "trailingComma": {
         "title": "Trailing Comma",
@@ -115,7 +129,7 @@
           "es5",
           "all"
         ],
-        "order": 6
+        "order": 8
       },
       "parser": {
         "title": "Parser",
@@ -126,7 +140,7 @@
           "babylon",
           "flow"
         ],
-        "order": 7
+        "order": 9
       }
     }
   },
diff --git a/src/helpers.js b/src/helpers.js
index 6043b25..21c1030 100644
--- a/src/helpers.js
+++ b/src/helpers.js
@@ -127,6 +127,8 @@ const getPrettierOptions = (editor: TextEditor) => ({
   singleQuote: getPrettierOption('singleQuote'),
   trailingComma: getPrettierOption('trailingComma'),
   bracketSpacing: getPrettierOption('bracketSpacing'),
+  semi: getPrettierOption('semi'),
+  useTabs: getPrettierOption('useTabs'),
   jsxBracketSameLine: getPrettierOption('jsxBracketSameLine'),
 });
 


Test patch:
diff --git a/src/__snapshots__/helpers.test.js.snap b/src/__snapshots__/helpers.test.js.snap
index 8787d3b..798392b 100644
--- a/src/__snapshots__/helpers.test.js.snap
+++ b/src/__snapshots__/helpers.test.js.snap
@@ -12,8 +12,10 @@ Object {
   "jsxBracketSameLine": true,
   "parser": "flow",
   "printWidth": 80,
+  "semi": true,
   "singleQuote": true,
   "tabWidth": 2,
   "trailingComma": true,
+  "useTabs": true,
 }
 `;
diff --git a/src/helpers.test.js b/src/helpers.test.js
index 9710b40..14a6072 100644
--- a/src/helpers.test.js
+++ b/src/helpers.test.js
@@ -324,6 +324,8 @@ describe('getPrettierOptions', () => {
         'prettier-atom.prettierOptions.singleQuote': true,
         'prettier-atom.prettierOptions.trailingComma': true,
         'prettier-atom.prettierOptions.bracketSpacing': true,
+        'prettier-atom.prettierOptions.semi': true,
+        'prettier-atom.prettierOptions.useTabs': true,
         'prettier-atom.prettierOptions.jsxBracketSameLine': true,
       }[option]);
     atom = { config: { get: mockGet } };
@@ -345,6 +347,8 @@ describe('getPrettierOptions', () => {
           'prettier-atom.prettierOptions.singleQuote': true,
           'prettier-atom.prettierOptions.trailingComma': true,
           'prettier-atom.prettierOptions.bracketSpacing': true,
+          'prettier-atom.prettierOptions.semi': true,
+          'prettier-atom.prettierOptions.useTabs': true,
           'prettier-atom.prettierOptions.jsxBracketSameLine': true,
         }[option]);
     atom = { config: { get: mockGet } };