]> git.wincent.com - dented.git/commitdiff
Add Prettier
authorGreg Hurrell <greg@hurrell.net>
Fri, 18 Jan 2019 21:27:41 +0000 (22:27 +0100)
committerGreg Hurrell <greg@hurrell.net>
Fri, 18 Jan 2019 21:27:41 +0000 (22:27 +0100)
.prettierrc.json [new file with mode: 0644]
package.json
src/dedent.js
yarn.lock

diff --git a/.prettierrc.json b/.prettierrc.json
new file mode 100644 (file)
index 0000000..f847b48
--- /dev/null
@@ -0,0 +1,6 @@
+{
+  "bracketSpacing": false,
+  "parser": "flow",
+  "singleQuote": true,
+  "trailingComma": "all"
+}
index 1e9cb032ebb8675fd261105bb1649ffe6696f2c1..caf72689c7b749d95eaf43c8659b969033a343a7 100644 (file)
   "repository": "https://github.com/wincent/dented",
   "scripts": {
     "build": "babel src -d lib",
   "repository": "https://github.com/wincent/dented",
   "scripts": {
     "build": "babel src -d lib",
+    "checkFormat": "prettier --list-different src/**/*.js *.js",
     "flow": "flow",
     "flow": "flow",
-    "prepublishOnly": "flow"
+    "format": "prettier --write src/**/*.js *.js",
+    "prepublishOnly": "flow && yarn checkFormat"
   },
   "author": "Greg Hurrell <greg@hurrell.net>",
   "license": "MIT",
   },
   "author": "Greg Hurrell <greg@hurrell.net>",
   "license": "MIT",
@@ -21,6 +23,7 @@
     "@babel/cli": "7.2.3",
     "@babel/core": "7.2.2",
     "@babel/preset-env": "7.2.3",
     "@babel/cli": "7.2.3",
     "@babel/core": "7.2.2",
     "@babel/preset-env": "7.2.3",
-    "flow-bin": "0.91.0"
+    "flow-bin": "0.91.0",
+    "prettier": "1.15.3"
   }
 }
   }
 }
index 41319b0b9ba9f1995d71846fef51344e95979d82..0cc0310e1aeacdb27730a4610e058a5bc19c5c01 100644 (file)
@@ -39,9 +39,11 @@ function dedent(
   }, Infinity);
 
   // Strip out minimum indent from every line.
   }, Infinity);
 
   // Strip out minimum indent from every line.
-  const dedented = isFinite(minimum) ? lines.map(line =>
-    line.replace(new RegExp(`^${' '.repeat(minimum)}`, 'g'), ''),
-  ) : lines;
+  const dedented = isFinite(minimum)
+    ? lines.map(line =>
+        line.replace(new RegExp(`^${' '.repeat(minimum)}`, 'g'), ''),
+      )
+    : lines;
 
   // Trim first and last line if empty.
   if (dedented[0] === '') {
 
   // Trim first and last line if empty.
   if (dedented[0] === '') {
index 6a1fa83c88520ebbfad7e1d00f4e8c1646acbe0d..c402bc3dfc84c0f41fa76a22bf1a63cead5c7cc3 100644 (file)
--- a/yarn.lock
+++ b/yarn.lock
@@ -1636,6 +1636,11 @@ posix-character-classes@^0.1.0:
   resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab"
   integrity sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=
 
   resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab"
   integrity sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=
 
+prettier@1.15.3:
+  version "1.15.3"
+  resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.15.3.tgz#1feaac5bdd181237b54dbe65d874e02a1472786a"
+  integrity sha512-gAU9AGAPMaKb3NNSUUuhhFAS7SCO4ALTN4nRIn6PJ075Qd28Yn2Ig2ahEJWdJwJmlEBTUfC7mMUSFy8MwsOCfg==
+
 private@^0.1.6:
   version "0.1.8"
   resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff"
 private@^0.1.6:
   version "0.1.8"
   resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff"