Repository: jlongster/prettier
Pull request #318 (2017-01-19 00:57:30)

Add Canonical Sublime Text Link
Hey guys... this would be the [canonical link](https://packagecontrol.io/packages/JsPrettier) ([discussion here](https://github.com/jlongster/prettier/pull/190#issuecomment-272619266)) for Sublime Text Prettier support, approved by [Package Control](https://packagecontrol.io).


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 752736783..83be70e09 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,6 @@
 # 0.0.9
 
-[link](https://github.com/jlongster/prettier/compare/0192d58...a7405257)
+[link](https://github.com/jlongster/prettier/compare/0.0.8...0.0.9)
 
 * Workaround flow bug parsing astral unicode characters (#277)
 * Allow specifying the major mode that `defun-before-save` will use. (#276
diff --git a/README.md b/README.md
index d0d13fbbc..c924af50a 100644
--- a/README.md
+++ b/README.md
@@ -185,7 +185,8 @@ Can also be installed using `ext install prettier-vscode`
 
 ### Sublime Text
 
-Please see [this issue](https://github.com/jlongster/prettier/issues/17) for those interested in working on Sublime Text integration.
+Sublime Text support is available through Package Control and 
+the [JsPrettier](https://packagecontrol.io/packages/JsPrettier) plug-in.
 
 More editors are coming soon.
 
diff --git a/package.json b/package.json
index 40ba40721..aa4b434a3 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,7 @@
 {
   "name": "prettier",
   "version": "0.0.9",
+  "description": "Prettier is an opinionated JavaScript formatter",
   "bin": {
     "prettier": "./bin/prettier.js"
   },
diff --git a/src/printer.js b/src/printer.js
index 344fd354a..8408f434c 100644
--- a/src/printer.js
+++ b/src/printer.js
@@ -1741,7 +1741,7 @@ function printFunctionParams(path, print, options) {
   }
 
   const lastParam = util.getLast(path.getValue().params);
-  const canHaveTrailingComma = lastParam.type !== "RestElement" && !fun.rest;
+  const canHaveTrailingComma = !(lastParam && lastParam.type === "RestElement") && !fun.rest;
 
   return concat([
     "(",


Test patch:
diff --git a/tests/rest/__snapshots__/jsfmt.spec.js.snap b/tests/rest/__snapshots__/jsfmt.spec.js.snap
index 70b59847b..79cff5aa0 100644
--- a/tests/rest/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/rest/__snapshots__/jsfmt.spec.js.snap
@@ -10,6 +10,8 @@ function f(
   superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong,
   ...args
 ) {}
+
+declare class C { f(...superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong): void; }
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 declare class C {
   f(
@@ -23,5 +25,11 @@ function f(
   ...args
 ) {
 }
+
+declare class C {
+  f(
+    ...superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong
+  ): void,
+}
 "
 `;
diff --git a/tests/rest/trailing-commas.js b/tests/rest/trailing-commas.js
index 39ebdccdf..65a05498a 100644
--- a/tests/rest/trailing-commas.js
+++ b/tests/rest/trailing-commas.js
@@ -9,3 +9,5 @@ function f(
   superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong,
   ...args
 ) {}
+
+declare class C { f(...superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong): void; }