prettier 1.6.0 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -48,12 +48,10 @@ conforms to a consistent style. (See this [blog post](http://jlongster.com/A-Pre
48
48
  + [Range](#range)
49
49
  + [Parser](#parser)
50
50
  + [Filepath](#filepath)
51
- <!--
52
51
  * [Configuration File](#configuration-file)
53
52
  + [Basic Configuration](#basic-configuration)
54
53
  + [Configuration Overrides](#configuration-overrides)
55
54
  + [Configuration Schema](#configuration-schema)
56
- -->
57
55
  * [Editor Integration](#editor-integration)
58
56
  + [Atom](#atom)
59
57
  + [Emacs](#emacs)
@@ -247,7 +245,7 @@ Another useful flag is `--list-different` (or `-l`) which prints the filenames o
247
245
  ```bash
248
246
  prettier --single-quote --list-different "src/**/*.js"
249
247
  ```
250
- <!--
248
+
251
249
  #### `--find-config-path` and `--config`
252
250
 
253
251
  If you are repeatedly formatting individual files with `prettier`, you will incur a small performance cost
@@ -270,7 +268,6 @@ such as a `config/` directory.
270
268
 
271
269
  If you don't have a configuration file, or want to ignore it if it does exist,
272
270
  you can pass `--no-config` instead.
273
- -->
274
271
 
275
272
  #### `--debug-check`
276
273
 
@@ -412,8 +409,7 @@ prettier.formatWithCursor(" 1", { cursorOffset: 2 });
412
409
  // -> { formatted: '1;\n', cursorOffset: 1 }
413
410
  ```
414
411
 
415
- <!--
416
- #### `prettier.resolveConfig([filePath] [, options])`
412
+ #### `prettier.resolveConfig([filePath [, options]])`
417
413
 
418
414
  `resolveConfig` can be used to resolve configuration for a given source file.
419
415
  The function optionally accepts an input file path as an argument, which defaults to the current working directory.
@@ -423,7 +419,7 @@ A promise is returned which will resolve to:
423
419
 
424
420
  The promise will be rejected if there was an error parsing the configuration file.
425
421
 
426
- If `options.withCache` is `false`, all caching will be bypassed.
422
+ If `options.useCache` is `false`, all caching will be bypassed.
427
423
 
428
424
  ```js
429
425
  const text = fs.readFileSync(filePath, "utf8");
@@ -437,7 +433,6 @@ prettier.resolveConfig(filePath).then(options => {
437
433
  As you repeatedly call `resolveConfig`, the file system structure will be cached for performance.
438
434
  This function will clear the cache. Generally this is only needed for editor integrations that
439
435
  know that the file system has changed since the last format took place.
440
- -->
441
436
 
442
437
  #### Custom Parser API
443
438
 
@@ -625,7 +620,6 @@ Default | CLI Override | API Override
625
620
  --------|--------------|-------------
626
621
  None | `--stdin-filepath <string>` | `filepath: "<string>"`
627
622
 
628
- <!--
629
623
  ## Configuration File
630
624
 
631
625
  Prettier uses [cosmiconfig](https://github.com/davidtheclark/cosmiconfig) for configuration file support.
@@ -708,7 +702,6 @@ For more information on how to use the CLI to locate a file, see the [CLI](#cli)
708
702
  ### Configuration Schema
709
703
 
710
704
  If you'd like a JSON schema to validate your configuration, one is available here: http://json.schemastore.org/prettierrc.
711
- -->
712
705
 
713
706
  ## Editor Integration
714
707
 
package/bin/prettier.js CHANGED
@@ -7895,12 +7895,12 @@ var parseJson_1 = function (json, filepath) {
7895
7895
  }
7896
7896
  };
7897
7897
 
7898
- var path$8 = require$$0$1;
7898
+ var path$7 = require$$0$1;
7899
7899
  var readFile = readFile$1;
7900
7900
  var parseJson = parseJson_1;
7901
7901
 
7902
7902
  var loadPackageProp$1 = function (packageDir, options) {
7903
- var packagePath = path$8.join(packageDir, 'package.json');
7903
+ var packagePath = path$7.join(packageDir, 'package.json');
7904
7904
 
7905
7905
  return readFile(packagePath).then(function (content) {
7906
7906
  if (!content) return null;
@@ -11904,7 +11904,7 @@ function tryRequire(content, filepath, cb) {
11904
11904
  }
11905
11905
  }
11906
11906
 
11907
- var path$7 = require$$0$1;
11907
+ var path$6 = require$$0$1;
11908
11908
  var isDir = index$48;
11909
11909
  var loadPackageProp = loadPackageProp$1;
11910
11910
  var loadRc = loadRc$1;
@@ -11936,7 +11936,7 @@ var createExplorer$1 = function (options) {
11936
11936
  }
11937
11937
 
11938
11938
  if (configPath) {
11939
- var absoluteConfigPath = path$7.resolve(process.cwd(), configPath);
11939
+ var absoluteConfigPath = path$6.resolve(process.cwd(), configPath);
11940
11940
  if (fileCache && fileCache.has(absoluteConfigPath)) {
11941
11941
  return fileCache.get(absoluteConfigPath);
11942
11942
  }
@@ -11948,13 +11948,13 @@ var createExplorer$1 = function (options) {
11948
11948
 
11949
11949
  if (!searchPath) return Promise.resolve(null);
11950
11950
 
11951
- var absoluteSearchPath = path$7.resolve(process.cwd(), searchPath);
11951
+ var absoluteSearchPath = path$6.resolve(process.cwd(), searchPath);
11952
11952
 
11953
11953
  return isDirectory(absoluteSearchPath)
11954
11954
  .then(function (searchPathIsDirectory) {
11955
11955
  var directory = (searchPathIsDirectory)
11956
11956
  ? absoluteSearchPath
11957
- : path$7.dirname(absoluteSearchPath);
11957
+ : path$6.dirname(absoluteSearchPath);
11958
11958
  return searchDirectory(directory);
11959
11959
  });
11960
11960
  }
@@ -11971,18 +11971,18 @@ var createExplorer$1 = function (options) {
11971
11971
  })
11972
11972
  .then(function (result) {
11973
11973
  if (result || !options.rc) return result;
11974
- return loadRc(path$7.join(directory, options.rc), options);
11974
+ return loadRc(path$6.join(directory, options.rc), options);
11975
11975
  })
11976
11976
  .then(function (result) {
11977
11977
  if (result || !options.js) return result;
11978
- return loadJs(path$7.join(directory, options.js));
11978
+ return loadJs(path$6.join(directory, options.js));
11979
11979
  })
11980
11980
  .then(function (result) {
11981
11981
  if (result) return result;
11982
11982
 
11983
- var splitPath = directory.split(path$7.sep);
11983
+ var splitPath = directory.split(path$6.sep);
11984
11984
  var nextDirectory = (splitPath.length > 1)
11985
- ? splitPath.slice(0, -1).join(path$7.sep)
11985
+ ? splitPath.slice(0, -1).join(path$6.sep)
11986
11986
  : null;
11987
11987
 
11988
11988
  if (!nextDirectory || directory === options.stopDir) return null;
@@ -12016,7 +12016,7 @@ function identityPromise(x) {
12016
12016
  return Promise.resolve(x);
12017
12017
  }
12018
12018
 
12019
- var path$6 = require$$0$1;
12019
+ var path$5 = require$$0$1;
12020
12020
  var oshomedir = index$46;
12021
12021
  var minimist$1 = index$42;
12022
12022
  var assign = index$28;
@@ -12036,7 +12036,7 @@ var index$44 = function (moduleName, options) {
12036
12036
  }, options);
12037
12037
 
12038
12038
  if (options.argv && parsedCliArgs[options.argv]) {
12039
- options.configPath = path$6.resolve(parsedCliArgs[options.argv]);
12039
+ options.configPath = path$5.resolve(parsedCliArgs[options.argv]);
12040
12040
  }
12041
12041
 
12042
12042
  return createExplorer(options);
@@ -12044,16 +12044,14 @@ var index$44 = function (moduleName, options) {
12044
12044
 
12045
12045
  const cosmiconfig = index$44;
12046
12046
  const minimatch$4 = minimatch_1;
12047
- const path$5 = require$$0$1;
12048
12047
 
12049
12048
  const withCache = cosmiconfig("prettier");
12050
12049
  const noCache = cosmiconfig("prettier", { cache: false });
12051
12050
 
12052
12051
  function resolveConfig$1(filePath, opts) {
12053
12052
  const useCache = !(opts && opts.useCache === false);
12054
- const fileDir = filePath ? path$5.dirname(filePath) : undefined;
12055
12053
 
12056
- return (useCache ? withCache : noCache).load(fileDir).then(result => {
12054
+ return (useCache ? withCache : noCache).load(filePath).then(result => {
12057
12055
  if (!result) {
12058
12056
  return null;
12059
12057
  }
@@ -13423,7 +13421,7 @@ const argv = minimist(args, {
13423
13421
  "debug-print-doc",
13424
13422
  "debug-check",
13425
13423
  "with-node-modules"
13426
- ],
13424
+ ].concat(booleanOptionNames),
13427
13425
  string: [
13428
13426
  "cursor-offset",
13429
13427
  "range-start",
@@ -13432,7 +13430,7 @@ const argv = minimist(args, {
13432
13430
  "config",
13433
13431
  "find-config-path",
13434
13432
  "ignore-path"
13435
- ],
13433
+ ].concat(stringOptionNames),
13436
13434
  default: {
13437
13435
  color: true,
13438
13436
  "ignore-path": ".prettierignore"
@@ -13444,14 +13442,8 @@ const argv = minimist(args, {
13444
13442
  },
13445
13443
  unknown: param => {
13446
13444
  if (param.startsWith("-")) {
13447
- const paramName = param.replace(/--(no-)?/, "");
13448
- if (
13449
- booleanOptionNames.indexOf(paramName) === -1 &&
13450
- stringOptionNames.indexOf(paramName) === -1
13451
- ) {
13452
- console.warn("Ignored unknown option: " + param + "\n");
13453
- return false;
13454
- }
13445
+ console.warn("Ignored unknown option: " + param + "\n");
13446
+ return false;
13455
13447
  }
13456
13448
  }
13457
13449
  });
package/index.js CHANGED
@@ -1814,7 +1814,7 @@ var comments$1 = {
1814
1814
  };
1815
1815
 
1816
1816
  var name = "prettier";
1817
- var version$1 = "1.6.0";
1817
+ var version$1 = "1.6.1";
1818
1818
  var description = "Prettier is an opinionated code formatter";
1819
1819
  var bin = {"prettier":"./bin/prettier.js"};
1820
1820
  var repository = "prettier/prettier";
@@ -1822,8 +1822,8 @@ var homepage = "https://prettier.io";
1822
1822
  var author = "James Long";
1823
1823
  var license = "MIT";
1824
1824
  var main = "./index.js";
1825
- var dependencies = {"babel-code-frame":"7.0.0-alpha.12","babylon":"7.0.0-beta.17","chalk":"2.0.1","cosmiconfig":"2.2.2","dashify":"0.2.2","diff":"3.2.0","esutils":"2.0.2","flow-parser":"0.51.0","get-stream":"3.0.0","globby":"^6.1.0","graphql":"0.10.1","ignore":"^3.3.3","jest-validate":"20.0.3","minimatch":"3.0.4","minimist":"1.2.0","parse5":"3.0.2","postcss":"^6.0.1","postcss-less":"^1.0.0","postcss-media-query-parser":"0.2.3","postcss-scss":"1.0.0","postcss-selector-parser":"2.2.3","postcss-values-parser":"git://github.com/lydell/postcss-values-parser.git#af2c80b2bb558a6e7d61540d97f068f9fa162b38","strip-bom":"3.0.0","typescript":"2.5.1","typescript-eslint-parser":"git://github.com/eslint/typescript-eslint-parser.git#801d65585af6995a223136862944095b48f5c567"};
1826
- var devDependencies = {"babel-cli":"6.24.1","babel-preset-es2015":"6.24.1","codecov":"2.2.0","cross-env":"5.0.1","cross-spawn":"5.1.0","eslint":"4.1.1","eslint-friendly-formatter":"3.0.0","eslint-plugin-import":"2.6.1","eslint-plugin-prettier":"2.1.2","eslint-plugin-react":"7.1.0","jest":"20.0.0","mkdirp":"^0.5.1","prettier":"1.5.2","rimraf":"2.6.1","rollup":"0.41.1","rollup-plugin-commonjs":"7.0.0","rollup-plugin-json":"2.1.0","rollup-plugin-node-builtins":"2.0.0","rollup-plugin-node-globals":"1.1.0","rollup-plugin-node-resolve":"2.0.0","rollup-plugin-replace":"1.1.1","shelljs":"0.7.8","sw-toolbox":"3.6.0","uglify-es":"3.0.15","webpack":"2.6.1"};
1825
+ var dependencies = {"babel-code-frame":"7.0.0-alpha.12","babylon":"7.0.0-beta.22","chalk":"2.0.1","cosmiconfig":"2.2.2","dashify":"0.2.2","diff":"3.2.0","esutils":"2.0.2","flow-parser":"0.51.0","get-stream":"3.0.0","globby":"^6.1.0","graphql":"0.10.1","ignore":"^3.3.3","jest-validate":"20.0.3","minimatch":"3.0.4","minimist":"1.2.0","parse5":"3.0.2","postcss":"^6.0.1","postcss-less":"^1.0.0","postcss-media-query-parser":"0.2.3","postcss-scss":"1.0.0","postcss-selector-parser":"2.2.3","postcss-values-parser":"git://github.com/lydell/postcss-values-parser.git#af2c80b2bb558a6e7d61540d97f068f9fa162b38","strip-bom":"3.0.0","typescript":"2.5.1","typescript-eslint-parser":"git://github.com/eslint/typescript-eslint-parser.git#801d65585af6995a223136862944095b48f5c567"};
1826
+ var devDependencies = {"babel-cli":"6.24.1","babel-preset-es2015":"6.24.1","codecov":"2.2.0","cross-env":"5.0.1","cross-spawn":"5.1.0","eslint":"4.1.1","eslint-friendly-formatter":"3.0.0","eslint-plugin-import":"2.6.1","eslint-plugin-prettier":"2.1.2","eslint-plugin-react":"7.1.0","jest":"20.0.0","mkdirp":"^0.5.1","prettier":"1.6.0","rimraf":"2.6.1","rollup":"0.41.1","rollup-plugin-commonjs":"7.0.0","rollup-plugin-json":"2.1.0","rollup-plugin-node-builtins":"2.0.0","rollup-plugin-node-globals":"1.1.0","rollup-plugin-node-resolve":"2.0.0","rollup-plugin-replace":"1.1.1","shelljs":"0.7.8","sw-toolbox":"3.6.0","uglify-es":"3.0.15","webpack":"2.6.1"};
1827
1827
  var scripts = {"test":"jest","test-integration":"jest tests_integration","lint":"cross-env EFF_NO_LINK_RULES=true eslint . --format node_modules/eslint-friendly-formatter","build":"./scripts/build/build.js"};
1828
1828
  var _package = {
1829
1829
  name: name,
@@ -5532,7 +5532,8 @@ function genericPrintNoParens(path, options, print, args) {
5532
5532
  firstNonMemberParent = path.getParentNode(i);
5533
5533
  i++;
5534
5534
  } while (
5535
- firstNonMemberParent && firstNonMemberParent.type === "MemberExpression"
5535
+ firstNonMemberParent &&
5536
+ firstNonMemberParent.type === "MemberExpression"
5536
5537
  );
5537
5538
 
5538
5539
  const shouldInline =
@@ -7306,6 +7307,7 @@ function genericPrintNoParens(path, options, print, args) {
7306
7307
  const shouldIndent =
7307
7308
  parent.type !== "TypeParameterInstantiation" &&
7308
7309
  parent.type !== "GenericTypeAnnotation" &&
7310
+ parent.type !== "TSTypeReference" &&
7309
7311
  !(
7310
7312
  (parent.type === "TypeAlias" ||
7311
7313
  parent.type === "VariableDeclarator") &&
@@ -9515,7 +9517,10 @@ function nodeStr(node, options, isFlowOrTypeScriptDirectiveLiteral) {
9515
9517
  }
9516
9518
 
9517
9519
  function printRegex(node) {
9518
- const flags = node.flags.split("").sort().join("");
9520
+ const flags = node.flags
9521
+ .split("")
9522
+ .sort()
9523
+ .join("");
9519
9524
  return `/${node.pattern}/${flags}`;
9520
9525
  }
9521
9526
 
@@ -15995,12 +16000,12 @@ var parseJson_1 = function (json, filepath) {
15995
16000
  }
15996
16001
  };
15997
16002
 
15998
- var path$4 = require$$0$1;
16003
+ var path$3 = require$$0$1;
15999
16004
  var readFile = readFile$1;
16000
16005
  var parseJson = parseJson_1;
16001
16006
 
16002
16007
  var loadPackageProp$1 = function (packageDir, options) {
16003
- var packagePath = path$4.join(packageDir, 'package.json');
16008
+ var packagePath = path$3.join(packageDir, 'package.json');
16004
16009
 
16005
16010
  return readFile(packagePath).then(function (content) {
16006
16011
  if (!content) return null;
@@ -20004,7 +20009,7 @@ function tryRequire(content, filepath, cb) {
20004
20009
  }
20005
20010
  }
20006
20011
 
20007
- var path$3 = require$$0$1;
20012
+ var path$2 = require$$0$1;
20008
20013
  var isDir = index$56;
20009
20014
  var loadPackageProp = loadPackageProp$1;
20010
20015
  var loadRc = loadRc$1;
@@ -20036,7 +20041,7 @@ var createExplorer$1 = function (options) {
20036
20041
  }
20037
20042
 
20038
20043
  if (configPath) {
20039
- var absoluteConfigPath = path$3.resolve(process.cwd(), configPath);
20044
+ var absoluteConfigPath = path$2.resolve(process.cwd(), configPath);
20040
20045
  if (fileCache && fileCache.has(absoluteConfigPath)) {
20041
20046
  return fileCache.get(absoluteConfigPath);
20042
20047
  }
@@ -20048,13 +20053,13 @@ var createExplorer$1 = function (options) {
20048
20053
 
20049
20054
  if (!searchPath) return Promise.resolve(null);
20050
20055
 
20051
- var absoluteSearchPath = path$3.resolve(process.cwd(), searchPath);
20056
+ var absoluteSearchPath = path$2.resolve(process.cwd(), searchPath);
20052
20057
 
20053
20058
  return isDirectory(absoluteSearchPath)
20054
20059
  .then(function (searchPathIsDirectory) {
20055
20060
  var directory = (searchPathIsDirectory)
20056
20061
  ? absoluteSearchPath
20057
- : path$3.dirname(absoluteSearchPath);
20062
+ : path$2.dirname(absoluteSearchPath);
20058
20063
  return searchDirectory(directory);
20059
20064
  });
20060
20065
  }
@@ -20071,18 +20076,18 @@ var createExplorer$1 = function (options) {
20071
20076
  })
20072
20077
  .then(function (result) {
20073
20078
  if (result || !options.rc) return result;
20074
- return loadRc(path$3.join(directory, options.rc), options);
20079
+ return loadRc(path$2.join(directory, options.rc), options);
20075
20080
  })
20076
20081
  .then(function (result) {
20077
20082
  if (result || !options.js) return result;
20078
- return loadJs(path$3.join(directory, options.js));
20083
+ return loadJs(path$2.join(directory, options.js));
20079
20084
  })
20080
20085
  .then(function (result) {
20081
20086
  if (result) return result;
20082
20087
 
20083
- var splitPath = directory.split(path$3.sep);
20088
+ var splitPath = directory.split(path$2.sep);
20084
20089
  var nextDirectory = (splitPath.length > 1)
20085
- ? splitPath.slice(0, -1).join(path$3.sep)
20090
+ ? splitPath.slice(0, -1).join(path$2.sep)
20086
20091
  : null;
20087
20092
 
20088
20093
  if (!nextDirectory || directory === options.stopDir) return null;
@@ -20116,7 +20121,7 @@ function identityPromise(x) {
20116
20121
  return Promise.resolve(x);
20117
20122
  }
20118
20123
 
20119
- var path$2 = require$$0$1;
20124
+ var path$1 = require$$0$1;
20120
20125
  var oshomedir = index$50;
20121
20126
  var minimist = index$52;
20122
20127
  var assign = index$54;
@@ -20136,7 +20141,7 @@ var index$48 = function (moduleName, options) {
20136
20141
  }, options);
20137
20142
 
20138
20143
  if (options.argv && parsedCliArgs[options.argv]) {
20139
- options.configPath = path$2.resolve(parsedCliArgs[options.argv]);
20144
+ options.configPath = path$1.resolve(parsedCliArgs[options.argv]);
20140
20145
  }
20141
20146
 
20142
20147
  return createExplorer(options);
@@ -20415,9 +20420,9 @@ function expand$1(str, isTop) {
20415
20420
  var minimatch_1 = minimatch$1;
20416
20421
  minimatch$1.Minimatch = Minimatch;
20417
20422
 
20418
- var path$5 = { sep: '/' };
20423
+ var path$4 = { sep: '/' };
20419
20424
  try {
20420
- path$5 = require$$0$1;
20425
+ path$4 = require$$0$1;
20421
20426
  } catch (er) {}
20422
20427
 
20423
20428
  var GLOBSTAR = minimatch$1.GLOBSTAR = Minimatch.GLOBSTAR = {};
@@ -20534,8 +20539,8 @@ function Minimatch (pattern, options) {
20534
20539
  pattern = pattern.trim();
20535
20540
 
20536
20541
  // windows support: need to use /, not \
20537
- if (path$5.sep !== '/') {
20538
- pattern = pattern.split(path$5.sep).join('/');
20542
+ if (path$4.sep !== '/') {
20543
+ pattern = pattern.split(path$4.sep).join('/');
20539
20544
  }
20540
20545
 
20541
20546
  this.options = options;
@@ -21123,8 +21128,8 @@ function match (f, partial) {
21123
21128
  var options = this.options;
21124
21129
 
21125
21130
  // windows: need to use /, not \
21126
- if (path$5.sep !== '/') {
21127
- f = f.split(path$5.sep).join('/');
21131
+ if (path$4.sep !== '/') {
21132
+ f = f.split(path$4.sep).join('/');
21128
21133
  }
21129
21134
 
21130
21135
  // treat the test path as a set of pathparts.
@@ -21338,16 +21343,14 @@ function regExpEscape (s) {
21338
21343
 
21339
21344
  const cosmiconfig = index$48;
21340
21345
  const minimatch = minimatch_1;
21341
- const path$1 = require$$0$1;
21342
21346
 
21343
21347
  const withCache = cosmiconfig("prettier");
21344
21348
  const noCache = cosmiconfig("prettier", { cache: false });
21345
21349
 
21346
21350
  function resolveConfig(filePath, opts) {
21347
21351
  const useCache = !(opts && opts.useCache === false);
21348
- const fileDir = filePath ? path$1.dirname(filePath) : undefined;
21349
21352
 
21350
- return (useCache ? withCache : noCache).load(fileDir).then(result => {
21353
+ return (useCache ? withCache : noCache).load(filePath).then(result => {
21351
21354
  if (!result) {
21352
21355
  return null;
21353
21356
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prettier",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "Prettier is an opinionated code formatter",
5
5
  "bin": {
6
6
  "prettier": "./bin/prettier.js"
@@ -23,7 +23,7 @@
23
23
  "eslint-plugin-react": "7.1.0",
24
24
  "jest": "20.0.0",
25
25
  "mkdirp": "^0.5.1",
26
- "prettier": "1.5.2",
26
+ "prettier": "1.6.0",
27
27
  "rimraf": "2.6.1",
28
28
  "rollup": "0.41.1",
29
29
  "rollup-plugin-commonjs": "7.0.0",