Commit Graph

918 Commits (316c76172b4d95fd278a36f5834b9aa5befd87f9)

Author SHA1 Message Date
Brian Ng 316c76172b Add test for flow class field override (#1669) 2017-05-22 15:54:20 -07:00
Karl O'Keeffe 4083d92ad1 Fix fill wrapping when text starts with whitespace (#1666) 2017-05-22 15:32:57 -07:00
Brian Ng d608b7ba28 Bump Babylon and enable additional tests (#1668) 2017-05-22 15:31:53 -07:00
Simon Lydell c2a3d23133 Improve the `--list-different` example
- Use double quotes for Windows support.
- Use the long flag for readability.
- Show that you should pass in your formatting options as well.
2017-05-22 20:30:10 +02:00
Mateusz Zatorski 0a5d035a85 Add example of `--list-different` flag usage to readme (#1665)
* Add example of `--list-different` flag usage to readme

* review fixes

* typo

* add code blocks
2017-05-22 11:27:24 -07:00
Joseph Frazier 374a68201c Don't removeLines() from TemplateLiteral quasis (#1664)
* Add tests for newlines in template literals

These are related to the following issues:

* https://github.com/prettier/prettier/issues/1662
* https://github.com/prettier/prettier/issues/821
* https://github.com/prettier/prettier/issues/1183
* https://github.com/prettier/prettier/issues/1626

* Don't removeLines() from TemplateLiteral quasis

This fixes https://github.com/prettier/prettier/issues/1662
and fixes https://github.com/prettier/prettier/issues/1626

It also affects https://github.com/prettier/prettier/issues/821 and
https://github.com/prettier/prettier/issues/1183
2017-05-22 09:00:01 -07:00
Christopher Chedeau aeed7840e2 Do not inline arrow when argument has a leading comment (#1660)
Fixes #1614
2017-05-22 09:40:19 -04:00
Joseph Frazier fa8408b53f Upgrade typescript parser, fix and run AST tests on Travis (#1657)
* Run `yarn` to update yarn.lock

* Upgrade typescript-eslint-parser, use JSXText instead of Literal for strings inside JSXElement

https://github.com/eslint/typescript-eslint-parser/pull/272 was merged,
so this fixes https://github.com/prettier/prettier/issues/1558

See here for more info about the new TSQualifiedName node type:
3491b4b73a

* Run AST comparison tests on Travis
2017-05-21 14:16:24 -07:00
Christopher Chedeau 50e95d6c7c Update README.md 2017-05-21 13:37:58 -07:00
Christopher Chedeau 5e8125b96e Move options around 2017-05-21 13:21:29 -07:00
Christopher Chedeau 801519ec79 Warn against > 80 columns 2017-05-21 13:17:02 -07:00
Jimmy Yuen Ho Wong 6f0707a995 Make emacs package summary clearer (#1655)
Currently the package summary makes no sense when viewed from Emacs's package manager, this fixes it.
2017-05-21 12:12:23 -07:00
Simon Lydell 378682350f Improve ESLint setup and fix errors (#1656)
* Improve ESLint setup

- Uses `eslint:recommended` + a handful more rules.
- Uses .eslintignore so that editors can understand which files to lint.
- Uses .eslintrc<strong>.js</strong> so more editors get syntax highlighting.

* Fix ESLint errors

About half of them were fixed by `eslint . --fix`.
2017-05-21 12:11:09 -07:00
Joseph Frazier d7aaaee0dd Add `lint` script, run it on Travis, prettify source code (#1634)
* Add `lint` script with eslint-plugin-prettier, use it in `format:all`

See https://github.com/prettier/prettier/pull/1634#issuecomment-302945967

* Run `lint` script on Travis

* Run Prettier on its own source code

This was done with

    npm run format:all
2017-05-21 11:00:16 -07:00
Joseph Frazier 569380155b Add `--range-start` and `--range-end` options to format only parts of the input (#1609)
* Add `--range-start` and `--range-end` options to format only parts of the input

These options default to `0` and `Infinity`, respectively, so that the
entire input is formatted by default. However, if either option is
specified such that a node lies completely outside the resulting range,
the node will be treated as if it has a `// prettier-ignore` comment.

Related to https://github.com/prettier/prettier/pull/1577#issuecomment-300551179
Related to https://github.com/prettier/prettier/issues/1324
Related to https://github.com/prettier/prettier/issues/593

* printer: Extract hasPrettierIgnoreComment() helper

* Move isOutsideRange() to util

* Don't throw errors about comments outside range "not printing"

* Remove unnecessary check from isOutsideRange()

* Make --range-end exclusive

This lets it use the conventional way of specifying ranges in strings.

Note that if the rangeEnd in the tests is changed to 158, it will fail,
but it wouldn't have failed before this change.

* Change range formatting approach

NOTE: This doesn't pass its test yet. Note that since we're reading the
indentation from the first line, it is expected not to change. However,
a semicolon is added, and the lines outside the range are not changed.

The new approach is roughly:

* Require that the range exactly covers an integer number of lines of the input
* Detect the indentation of the line the range starts on
* Format the range's substring using `printAstToDoc`
* Add enough `indent`s to the doc to restore the detected indentation
* Format the doc to a string with `printDocToString`
* Prepend/append the original input before/after the range

See https://github.com/prettier/prettier/pull/1609#issuecomment-301582273

---

Given `tests/range/range.js`, run the following:

    prettier tests/range/range.js --range-start 165 --range-end 246

See the range's text with:

    dd if=tests/range/range.js ibs=1 skip=165 count=81 2>/dev/null

* Don't use default function parameters

Node v4 doesn't support them. See
http://node.green/#ES2015-syntax-default-function-parameters

* Hackily fix indentation of range formatting

See
https://github.com/prettier/prettier/pull/1609#issuecomment-301625368

Also update the snapshot to reflect that the indentation actually should
decrease by one space, since there were 13 spaces in the input and we
round down after dividing by tabWidth.

* Revert "printer: Extract hasPrettierIgnoreComment() helper"

See https://github.com/prettier/prettier/pull/1609#discussion_r116804853

This reverts commit 62bf068ca98f69d4a7fd0ae188b3554d409eee8d.

* Test automatically using the beginning of the rangeStart line and same for the end

See https://github.com/prettier/prettier/pull/1609#issuecomment-301862076

* Fix automatically using the beginning of the rangeStart line and same for the end

See https://github.com/prettier/prettier/pull/1609#issuecomment-301862076

* Propagate breaks after adding an indentation-triggering hardline

See c1a61ebde8 (r116805581)

* Extract getAlignmentSize(), use instead of countIndents()

See c1a61ebde8 (r116804694)

* Extract addAlignmentToDoc(), use instead of addIndentsToDoc()

See c1a61ebde8 (r116804694)

* Document that --range-start and --range-end include the entire line

* Fix rangeStart calculation

Before, it was incorrectly resulting in 1 when the originally provided
value was 0

* Extract formatRange() helper function

* Move getAlignmentSize() from printer to util

This addresses https://github.com/prettier/prettier/pull/1609#discussion_r117636241

* Move addAlignmentToDoc() from printer to doc-builders

This addresses https://github.com/prettier/prettier/pull/1609#discussion_r117636251
2017-05-21 10:14:13 -07:00
Henric Trotzig f3a049627d Add instruction on how to set up key binding in vim (#1654)
I'm a vim user, and I use prettier on a few of my projects, but not all.
The Prettier docs listed ways to make prettier run automatically on save
(and other autocmd events), but I needed a way to invoke it manually.
After spending some time finding the right vim config, I decided it
could be useful to others as well.

Fixes #1615
2017-05-21 10:08:26 -07:00
Simon Lydell bc5186e544 Run Prettier on all source files (#1648)
This commit updates `npm run format:all` to not only format .js files in
src/ and bin/, but also tests_config/ and scripts/, as well as all
jsfmt.spec.js files.

It also includes the result of running `npm run format:all`, except
changes to src/ and bin/.
2017-05-21 08:13:11 -07:00
Joseph Frazier 226adb2e81 Allow `--write` to be used with `--list-different` (#1633)
* Allow `--write` to be used with `--list-different`

This makes it possible to simultaneously check for formatting errors and
fix them, which can be useful for CI services. For example, a CI service
could run:

    prettier --list-different --write $FILES || git diff --exit-code

to show the formatting errors. Before this change, it would be necessary
to do:

    prettier --list-different $FILES || (prettier --write $FILES; git diff --exit-code)

Here are some commands which are useful to verify that the outputs and
exit codes of `prettier --list-different` and `prettier --write` have
not changed:

    ./bin/prettier.js --list-different index.js src/*.js bin/*.js; echo $?
    ./bin/prettier.js --write index.js src/*.js bin/*.js; echo $?

* fixup! Allow `--write` to be used with `--list-different`
2017-05-21 08:12:00 -07:00
Roman Coedo 83fe8d3d18 Make package-lint happy (#1629) 2017-05-21 08:11:11 -07:00
Jimmy Yuen Ho Wong c32d567512 Add Emacs package attributes for prettier-js.el (#1651)
* Add package attributes

So we can get this into Melpa

* Add Emacs package footer

* Add elisp package file extension
2017-05-21 08:10:37 -07:00
Lucas Azzola 599444fe7f fix(typescript): add TSInterfaceHeritage to ast-types (#1644) 2017-05-21 08:10:04 -07:00
Lucas Azzola 575980d7f4 fix(typescript): handle global namespace without modifiers (#1646) 2017-05-21 08:09:29 -07:00
Lucas Azzola 5c6fd80d50 fix(typescript): handle undefined variable declarations (#1645) 2017-05-21 08:03:38 -07:00
Lucas Azzola 8f00393a56 tools(typescript): do not report SyntaxErrors as errors (#1647) 2017-05-21 07:53:30 -07:00
Danny Martini e1fdf78863 upgrade typescript-elint-parser and enable most ts tests again (#1649) 2017-05-21 07:53:00 -07:00
Simon Lydell 8ad3aeff6a Sync the Flow tests (#1638) 2017-05-20 03:16:28 -07:00
Danny Martini fc60d548aa Fix/ts interface heritage (#1601)
* fix TSCallSignature

* fix TSTypeReference

* remove test with invalid syntax

* --wip--

* partially fix TSTypeReference

* get comments right for TypeScript interfaces
2017-05-20 03:15:50 -07:00
Joseph Frazier de8a658bed Use `const`/`let` instead of `var` (#1631)
* Use `const`/`let` instead of `var`

This was done with [lebab], by running:

    lebab --replace src -t let

[lebab]: https://github.com/lebab/lebab

* Remove remaining `var` usages

These were not automatically fixed by `lebab`, so they had to be
manually refactored.
2017-05-19 13:00:38 -07:00
Roman Coedo 16ce76a082 Always run prettier if prettier-mode is active (#1623) 2017-05-18 08:56:59 -07:00
Shaun LeBron 2fd7199c11 Clarify when original styling is significant (#1620)
* Clarify when original styling is significant

* add superscript "1" as footnote link

* use "*" instead of "1" to denote a caveat
2017-05-17 21:03:52 -07:00
Joseph Frazier 4e9cdc413c Extract util.isBlockComment() helper (#1602)
* Add trailing space when changing template literal line comment to block

This was originally part of https://github.com/prettier/prettier/pull/1580,
but I decided not to include it there, since it was unrelated.

* Extract util.isBlockComment() helper

* printer: Simplify genericPrintNoParens() JSXEmptyExpression logic

* Extract makeBlockComment() helper

* Move hasBlockComments() from printer to util

Addresses https://github.com/prettier/prettier/pull/1602#issuecomment-301344310

* Revert "Extract makeBlockComment() helper"

This reverts commit 7e940f43b62fb34d71fc3015ed14f9c59cf61d1a.

* Revert "Add trailing space when changing template literal line comment to block"

This reverts commit b3cf5b24c576ed062ca86975a09138e3f4ac9597.
2017-05-14 15:58:06 -07:00
Joseph Frazier f048ad3094 (Babylon) Allow `return` outside function (#1608)
This makes it easier to format code snippets including a `return`
statement, without having to format the entire function. For example,
given the following code:

```js
function f() {
    return someVeryLongStringA && someVeryLongStringB && someVeryLongStringC && someVeryLongStringD
}
```

a developer could select the line containing `return`, then use
prettier to format the code to:

```js
function f() {
return (
  someVeryLongStringA &&
  someVeryLongStringB &&
  someVeryLongStringC &&
  someVeryLongStringD
);
}
```

which can then be reindented by the editor.

---

Related to https://github.com/prettier/prettier/issues/593
2017-05-14 14:45:33 -07:00
Lucas Azzola 1ea4ad4e30 tools(typescript): add script to run all TypeScript tests (#1606) 2017-05-14 03:26:37 -07:00
Danny Martini 19183e6452 fix TSInterfaceDeclaration, TSInterfaceBody, TSInterfaceHeritage (#1599) 2017-05-12 17:13:38 -07:00
Danny Martini c86a57a91e fix TSFunctionType (#1600) 2017-05-12 15:33:03 -07:00
Konstantin Pschera 2fc6024a20 Remove Parens from SequenceExpressions in ForStatements (#1597)
* Remove Parens from SequenceExpressions in ForStatements

Closes #1594

* Add Braces around Assignment Case
2017-05-12 10:14:58 -07:00
Konstantin Pschera 54ad598acc Move Comments to the end in TemplateLiteral (#1598)
Closes #1589
2017-05-12 10:04:22 -07:00
Joseph Frazier f5c52890b5 Fix typo: parse -> parser (#1596) 2017-05-12 08:04:42 -07:00
Dmitry Rybin 1d9478a61f Fix boolean for empty objects (#1590)
* Add test for empty object in logical expression

* Add check for empty object and array in shouldInlineLogicalExpression

* Review fixes, add additional case with function call
2017-05-12 07:48:03 -07:00
Joseph Frazier 5ca2117d23 (Babylon) Fall back to non-strict mode (#1587)
* (Babylon) Fall back to non-strict mode

This makes Prettier a little less opinionated about linting. For
example, the following can now be formatted:

```js
function f(a,a){return a}
```

whereas before it would cause an error:

    stdin: SyntaxError: Argument name clash in strict mode (1:13)
    > 1 | function f(a,a){return a}
        |              ^

This also allows octal numbers to be parsed,
and therefore fixes https://github.com/prettier/prettier/issues/228

If the code parses neither as strict nor as non-strict, the error from the
strict parse is thrown (as it was before this change).

---

I noticed this while trying out [eslump] with prettier:

    eslump | pbcopy; pbpaste | prettier

[eslump]: https://github.com/lydell/eslump

* Add missing test

* Use Object.assign() instead of mutating object
2017-05-12 07:32:27 -07:00
Brian Ng 36a6a8039e Ensure parens for more await cases (#1595) 2017-05-11 19:06:54 -07:00
Brian Ng b36504946c Fix missing parenthesis for await && (#1593) 2017-05-11 16:30:33 -07:00
Joseph Frazier b8b205691d (Flow) Extract helper functions (#1586)
* (Flow) Indicate that getters/setters use function notation

* (Flow) Extract isFunctionNotation() helper

* (Flow) Extract isGetterOrSetter() helper

* (Flow) Extract sameLocStart() helper
2017-05-11 16:29:31 -07:00
Joseph Frazier b3828eaee2 (Flow) Preserve getter/setter info on ObjectTypeProperty (#1585)
* (Flow) Preserve getter/setter info on ObjectTypeProperty

Before: `type T = { get method(): void }` -> `type T = { method: () => void };`

Demo: https://prettier.github.io/prettier/#%7B%22content%22%3A%22type%20T%20%3D%20%7B%20get%20method()%3A%20void%20%7D%22%2C%22options%22%3A%7B%22printWidth%22%3A80%2C%22tabWidth%22%3A2%2C%22singleQuote%22%3Afalse%2C%22trailingComma%22%3A%22none%22%2C%22bracketSpacing%22%3Atrue%2C%22jsxBracketSameLine%22%3Afalse%2C%22parser%22%3A%22flow%22%2C%22semi%22%3Atrue%2C%22useTabs%22%3Afalse%2C%22doc%22%3Afalse%7D%7D

---

After: `type T = { get method(): void }` -> `type T = { get method(): void };`

Demo: `echo 'type T = { get method(): void }' | prettier --stdin --parser flow`

Demo: `echo 'type T = { get method(): void }' | prettier --stdin --parser flow --debug-check`

---

This passes `AST_COMPARE=1 npm test -- tests/flow/getters_and_setters_* tests/flow/objectTypeProperty/`
and fixes https://github.com/prettier/prettier/issues/1557

* (Flow) Make getter/setter parsing more robust

Addresses https://github.com/prettier/prettier/pull/1585#discussion_r116008715
2017-05-11 08:04:54 -07:00
Joseph Frazier d7ec9dc706 Don't let trailing template literal comments escape (#1580)
* Don't let trailing template literal comments escape

This might not be the best-looking solution, but it's a start, and it
passes `AST_COMPARE=1 npm test`

Fixes https://github.com/prettier/prettier/issues/1559

* Add trailing space when changing line comment to block

* Be more discerning about template literal comment placement

Try to maintain the previous behavior if possible.

* Revert "Add trailing space when changing line comment to block"

This reverts commit 1eb42c24819a296c93a79b92a358d30a2aacc16c.
2017-05-10 21:07:55 -07:00
Karl O'Keeffe 5cda955efc New primitive to fill a line with as many doc parts as possible (#1120)
* Add new fill primitive and use it to wrap text in JSX

This adds a new `fill` primitive that can be used to fill lines with as much code as possible before moving to a new line with the same indentation.

It is used here layout JSX children. This gives us nicer wrapping for JSX elements containings lots of text interspersed with tags.

* Quick fix for jsx whitespace regressions

* Fix a couple more bugs

* Tidy up the `fill` algorithm

Attempt to make the algorithm a little more regular, and improve the naming of variables to make it a little easier to understand (I hope!).

* Small tidy up of JSX whitespace declarations

* Remove unnecessary code

It turns out that `children` is only used in the case when the element is printed on a single line, in which case all the types of JSX whitespaces behave the same, so we don't need to special case leading/trailing/solitary whitespace.

* A little more tidy up based on PR feedback

* Fix up tests after rebasing

* Make it explicit that we keep multiple consecutive spaces

* Add an explanatory comment

* Fix broken snapshot in master

* Ignore existing commands when deciding whether content will fit when using fill

* Fix a bug where children would get incorrectly filled onto a line

* Tidy up JSX whitespace names
2017-05-10 16:13:21 -07:00
Joseph Frazier d4217f5508 Unescape unnecessarily escaped characters in strings (#1575)
* Add test with unnecessarily escaped non-quote character

In 0b6d19db18,
I noticed that `makeString` doesn't unescape unnecessarily escaped
non-quote characters. This change simply adds a test for that.

* Fix test with unnecessarily escaped non-quote character

Unfortunately, this breaks a couple of other tests...

* Revert "Fix test with unnecessarily escaped non-quote character"

See https://github.com/prettier/prettier/pull/1575#issuecomment-300490172

This reverts commit d05652518fe7d4e2fb82ce48ffc922b153de5593.

* Unescape unnecessarily escaped characters in strings

* Add test for unnecessarily escaped character at not-beginning of string

* Fix test for unnecessarily escaped character at not-beginning of string

* Add test for multiple unnecessary escapes in strings

* Pass test for multiple unnecessary escapes in strings

* Add test for octal escapes in strings

See https://github.com/prettier/prettier/pull/1575#discussion_r115804065

* Pass test for octal escapes in strings

See https://github.com/prettier/prettier/pull/1575#discussion_r115804065

* Add test for unnecessarily escaped character preced by escaped backslash

See https://github.com/prettier/prettier/pull/1575#discussion_r115804065

* Pass test for unnecessarily escaped character preced by escaped backslash

This just allows an even number of backslashes to precede the
unnecessary one.

See https://github.com/prettier/prettier/pull/1575#discussion_r115804065

* Add test for unescaped character after escaped backslash in strings

* Add test for unescaped character preceded by two escaped backslashes in string

See https://github.com/prettier/prettier/pull/1575#discussion_r115808571

* Pass test for unescaped character preceded by two escaped backslashes in string

This breaks another test though...

See https://github.com/prettier/prettier/pull/1575#discussion_r115808571

* Update snapshot

It turns out the test wasn't broken, I had just flubbed the escaping in
the snapshot. The easiest way to see that this actually works is

```bash
$ cat | prettier --stdin
"hol\\a (the a is not escaped)" // press Control-D after the newline
"hol\\a (the a is not escaped)"; // press Control-D after the newline
```

* Prevent test strings from being parsed as directives

See https://github.com/prettier/prettier/pull/1575#discussion_r115820336

(cherry picked from commit 126e56ab2c79801cbf7fee22189212d8c93581df)

* Add test for consecutive unnecessarily escaped characters in strings

See https://github.com/prettier/prettier/pull/1575#discussion_r115822286

* Pass test for consecutive unnecessarily escaped characters in strings

See https://github.com/prettier/prettier/pull/1575#discussion_r115822286

This looping is hacky. We might be able to emulate lookbehind instead.

* Optimize (maybe?) string unescaping loop

Not sure how expensive string comparison is here...

See 2323c8c025 (commitcomment-22092267)

* Safeguard against string unescaping loop hanging

See https://github.com/prettier/prettier/pull/1575#discussion_r115827531

* Add more comprehensive tests for unnecessary string escapes

See https://github.com/prettier/prettier/pull/1575#discussion_r115798155

* Remove superfluous variables from makeString()

See https://github.com/prettier/prettier/pull/1575#discussion_r115834468

* Unescape unnecessary strings escapes without looping

* Unescape unnecessary string escapes while handling quotes

Kudos to @lydell for figuring this out! See
https://github.com/prettier/prettier/pull/1575/files#r115860741

* Test that unnecessary escapes remain in directive literals

See:
* https://github.com/prettier/prettier/pull/1575#discussion_r115820336
* https://github.com/prettier/prettier/pull/1575#issuecomment-300633277
2017-05-10 16:02:49 -07:00
Christopher Chedeau ef9a93dce2 Update README.md 2017-05-10 15:55:00 -07:00
Danny Martini 2c76bfe1e1 update typescript parser (#1578)
* update eslint-parser-typescript

* fix comment parsing

* disable all failing tests

* fix TSInterfaceDeclaration

* fix #1537

* only disable typescript tests for tests/function
2017-05-10 14:11:50 -07:00
Joseph Frazier 8cc38ad524 Preserve code unit sequence of directive literals (#1571)
* Print directive literals verbatim

This addresses https://github.com/prettier/prettier/issues/1555,
but doesn't seem to pass the AST_COMPARE=1 tests:

    AST_COMPARE=1 npm test -- tests/quotes -t strings

However, running `prettier --debug-check` on the relevant file *does*
work:

    prettier tests/quotes/strings.js --debug-check

* Change directive literal quotes if it doesn't contain quotes

This addresses https://github.com/prettier/prettier/pull/1560#discussion_r115396257

From https://github.com/prettier/prettier/issues/1555#issue-227206837:

> It's okay to change the type of quotation marks used, but only if
doing so does not require changing any characters within the directive.

* Don't change directive literal quotes if it contains a backslash

This passes the `--debug-check` tests again:

    prettier tests/quotes/strings.js --debug-check

* Try to add regression test for escaped directive literals

This seems not to work, despite the following command having the correct
output:

    echo "'\''" | prettier

You can use the following to get an idea of how flow/typescript parse
this:

    node -p "JSON.stringify(require('./src/parser').parse('\\'\\\\\'\\'', {parser: 'flow'}), null, 2)"
    node -p "JSON.stringify(require('./src/parser').parse('\\'\\\\\'\\'', {parser: 'typescript'}), null, 2)"

* WIP Disable Flow/Typescript for ./tests/directives

We don't yet handle escaped directives for them, but Babylon works.

(similar to 90bf93713c (diff-0de18284f37da79ab8af4e4690919abaR1))

* Revert "WIP Disable Flow/Typescript for ./tests/directives"

This reverts commit 2aba6231271f6985a395c31e3df9323e8f3da115.

* Prevent test strings from being parsed as directives

See https://github.com/prettier/prettier/pull/1560#issue-227225960

* Add more escaped directive tests

* Infer DirectiveLiterals from Flow parser

* Don't test TypeScript on directives

See https://github.com/prettier/prettier/pull/1560#issuecomment-300296221

* fixup! Infer DirectiveLiterals from Flow parser

* Don't fake objects that look like a DirectiveLiteral

Instead, add a flag to nodeStr() that deals with the Flow node
accordingly. See https://github.com/prettier/prettier/pull/1560#discussion_r115605758

* Print preferred quotes around escaped DirectiveLiteral when it doesn't contain quotes

See https://github.com/prettier/prettier/pull/1560#discussion_r115606122

* Simplify `canChangeDirectiveQuotes` logic

* Add directive test with unnecessarily escaped non-quote character

* Fix boolean logic error

I thought that this would result in the following if-block executing, as
needed to pass the test case in the previous commit. However, it appears
that it's not actually needed to pass the test case, since `makeString`
doesn't unescape unnecessarily escaped non-quote characters.
Nevertheless, I think we should leave that if-block (`if (canChangeDirectiveQuotes)`)
there, in case `makeString` is updated.

See https://github.com/prettier/prettier/pull/1571#discussion_r115658398

* Make isFlowDirectiveLiteral a separate argument to nodeStr()

See https://github.com/prettier/prettier/pull/1571#discussion_r115810988

* Simplify isFlowDirectiveLiteral logic by passing n.expression to nodeStr()

See https://github.com/prettier/prettier/pull/1571#discussion_r115811216
2017-05-10 12:15:27 -07:00