Commit Graph
100 Commits
Author SHA1 Message Date
Simon Lydell ca437912cc Update stable docs (#8652) 2020-07-01 08:44:21 +02:00
554b15473d Document recommended setup and improve docs overall (#8510)
Co-authored-by: Jed Fox <git@twopointzero.us>
Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>
2020-06-28 09:47:29 +08:00
Simon Lydell 9184743081 Quote and unquote number keys (#8508)
* Quote and unquote number keys

* Add changelog entry

* Add tests for escapes

* Fix idempotency

* Only run flow-repo/ tests with flow

271 jsfmt.spec.js in flow-repo use only the flow parser.
18 use flow and babel.
Now, all of them use only flow.

* Don’t unquote negative numbers

* Don’t quote/unquote numbers in TypeScript

* Quote BigInt

* Fix AST check

* Fix condition

* Fix BigInt to string

* Fix ESLint not recognizing BigInt

* Only quote/unquote “simple” numbers

* No need to clean BigIntLiteral anymore

* Add tests for 1. and .1

* Fix 1. and .1

* Remove unnecessary babel-ts from tests

* Only unquote numbers for babel

* Update changelog
2020-06-18 18:13:25 +03:00
Simon Lydell 992e410aa7 Update stable docs 2019-11-16 12:29:06 +01:00
Simon Lydell 44b819144b Support string-to-package config in JSON schema: (#6941)
Prettier supports having just a string in the config file to use a
shared config from a package. Example:

    "@company/prettier-config"

But the JSON schema generated by running `node
scripts/generate-schema.js` did not include that possibility.

See https://github.com/SchemaStore/schemastore/pull/855 for more
information.
2019-11-13 17:45:59 +01:00
Simon Lydell b56f95c975 Add missing headings to changelog 2019-11-09 13:38:29 +01:00
Simon Lydell 15acf45c9e Fix code block in changelog 2019-11-09 13:29:18 +01:00
Simon Lydell c060b2544d Bump Prettier dependency to 1.19.1 2019-11-09 13:23:22 +01:00
Simon Lydell 95b8e54d1a Release 1.19.1 2019-11-09 13:20:32 +01:00
Simon Lydell 9b1726d3cd Quick-fix for stdin being broken in 1.19.0 (#6894)
Closes #6891.

This downgrades the get-stream package from 5.x to 4.x, which does not
use `async` functions which works around the problem of
`regeneratorRuntime` not being defined (it shouldn’t be needed).

This is an alternative solution to #6893 because I don’t know yet if we
want to enable `corejs` given that we will most likely drop support for
Node.js 8 and older in the next version.

Just like #6893 this PR comes without tests, but I verified locally that
`--stdin` works after this change.
2019-11-09 12:48:56 +01:00
Simon Lydell 6cba8ceb9e Fix since version for vueIndentScriptAndStyle (#6897)
See #6887.
2019-11-09 12:48:24 +01:00
Simon Lydell b091fd3b59 Remove out-of-date comment 2019-11-09 12:12:31 +01:00
Simon Lydell 8c3efeb9df Try to fix some code blocks in 1.19.0 blog post 2019-11-09 01:44:53 +01:00
Simon Lydell 4eb3e2650a Blog post, changelog and docs for 1.19 (#6787) 2019-11-09 01:23:57 +01:00
Simon Lydell 98d27c7de2 Bump Prettier dependency to 1.19.0 2019-11-09 01:14:31 +01:00
Simon Lydell e788e8d3d5 Release 1.19.0 2019-11-09 01:09:19 +01:00
Simon Lydell 057e15d50d prettier 1.19.0-beta.1 2019-11-09 01:03:57 +01:00
Simon Lydell 677b46df71 Update angular-html-parser (#6785)
Fixes #6749. Closes #6784.
2019-11-02 15:58:28 +01:00
Simon Lydell 8d0ac8bb58 Update website/versioned_docs/version-stable/ 2019-09-14 13:11:52 +02:00
Simon Lydell 2827543154 Improve overrides documentation (#6416)
Refs. #6415.
2019-08-27 07:09:12 +02:00
Simon Lydell b9cbca9ece Update website/versioned_docs/version-stable/ 2019-08-12 19:17:55 +02:00
Simon Lydell 26c835c60c Update option philosophy (#6387)
... to more closely align with what we’ve learned the past 3 years.

Note: These are not my personal opinions. It’s my attempt at distilling
internal core discussions into a short document.
2019-08-12 18:25:45 +03:00
Simon Lydell 4893a86a6f Fix markdown syntax highlighting for babel-flow (#6231)
Previously, the "Copy markdown" button in the playground generated
markdown containing this when having selected "babel-flow" as parser:

    ```babel-flow

This commit changes it to:

    ```jsx

So that the code blocks get syntax highlighting on GitHub.
2019-06-17 17:58:38 +02:00
Simon Lydell 9cb23fbf24 Playground: Remove parser from Copy config JSON (#6155) 2019-05-25 09:31:10 -03:00
Simon Lydell 56dc7b03ec Mention new 1.15 options in the option philosophy (#5419) 2018-11-10 19:04:59 +02:00
Simon Lydell 164801aa93 Update rationale to expand on sorting (#5417)
Inspired by #5412.
2018-11-09 18:58:53 +01:00
Simon Lydell e0362516af Update rationale for the 1.15 changes (#5332) 2018-11-07 09:13:08 +08:00
Simon Lydell e2d8834c49 Fix link to jsx-single-quotes option 2018-11-05 09:37:30 +01:00
Simon Lydell 275b0543c8 Never put spaces to the right of stars in indentable block comments (#5330)
Fixes #5323. Previously we added space after `/*` _on the first line
only,_ but the intent is to only fix the indentation of comments, not
changing their "contents". Besides, this was inconsistent with the
handling of every following line. Finally, it broke `/*!` comments which
some minifiers look for to know which (license) comments to keep.

People can use https://eslint.org/docs/rules/spaced-comment to enforce
when to start comments with spaces.
2018-11-03 20:53:24 +01:00
Simon Lydell f87c82cc4e Improve glimmer parse errors (#5161)
Instead of showing 80 carets, point out just which line the error was
on, and rely on the original message to point out the "column".

I thought about matching the `----^` in the original message with a
regex and use the length of it as the column number, but unfortunately
the original message does not show the original code (in this example
some whitespace is missing), so it wouldn't work.

Before:

```
$ ./bin/prettier.js test.hbs --parser glimmer
[error] test.hbs: SyntaxError: Parse error on line 2:
[error] {{one}}{{
[error] ---------^
[error] Expecting 'ID', 'STRING', 'NUMBER', 'BOOLEAN', 'UNDEFINED', 'NULL', 'DATA', got 'EOF' (2:0)
[error]   1 | {{one}}
[error] > 2 | {{
[error]     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[error]   3 |
```

After:

```
$ ./bin/prettier.js test.hbs --parser glimmer
[error] test.hbs: SyntaxError: Parse error on line 2:
[error] {{one}}{{
[error] ---------^
[error] Expecting 'ID', 'STRING', 'NUMBER', 'BOOLEAN', 'UNDEFINED', 'NULL', 'DATA', got 'EOF' (2:0)
[error]   1 | {{one}}
[error] > 2 | {{
[error]   3 |
```
2018-09-30 00:25:45 +02:00
Simon Lydell 87e109f884 Escape not just backticks but ${ as well in graphql tags (#5137)
* Escape not just backticks but `${` as well in graphql tags

Fixes #4974.

* Also escape backslashes correctly in graphql tags
2018-09-29 09:42:44 +02:00
Simon Lydell a459743eb2 Update rationale (#5136)
* Clarify semicolon example

* Add rationale for print width

Fixes #5081.

* Link options and rationale

* Add rationale for comments

Refs. #5121.

* Mention that spaces can be used for alignment for --use-tabs

Refs. #4199.

* Add missing word

* Remove bad `istanbul ignore next` example
2018-09-29 09:41:21 +02:00
Simon Lydell 265d9337f6 Update vim docs (#5131)
* Update "Running Prettier manually in Vim" docs

- Add `--stdin-filepath` for parser inference.
- Reword "if you need a little more control" since it can be argued that
this approach gives you _less_ control than the plugins.
- Add note about error messages.
- Add note about cursor position.

* Clean up vim.md

- Replace the out-of-date vim-prettier information with a link to its
readme. Move vim-prettier to the top as compensation for its reduced
part of the page.
- Remove out-of-date instructions.
- Try to provide roughly the same information about Neoformat and ALE.
- Simplify language and formatting.
2018-09-29 09:40:49 +02:00
Simon Lydell dc590e5e4b Improve documentation for the parser option (#5129)
- Warn about setting parser at the top level. Refs. #4638.
- Remove top level parser from examples. Instead show the most common
options (I also removed printWidth, since we don't recommend changing
it). Refs. #4638.
- Show how to configure the flow parser for .js files. Refs. #4638.
- Update valid options for the parser option, including links and "since
version".
- Clarify babylon vs flow.
2018-09-29 09:40:19 +02:00
Simon Lydell 8ab09cc753 Add playground examples for all languages (#4107)
* playground: Add GraphQL example

* playground: Add markdown example

* playground: Add Flow example

* playground: Add Less example

* playground: Add Vue example
2018-03-06 20:09:16 +11:00
Simon Lydell 9ad1f80221 Add more stuff to the Rationale page (#4101)
* Add no-semi rationale

* Add rationale for import statements

* Add rationale for JSX

* Add prettier-ignore comments
2018-03-05 17:43:22 +01:00
Simon Lydell 2897c950f8 Try to clarify when to use the issue template (#4059) 2018-02-28 18:53:08 +01:00
Simon Lydell e591b00005 Add option philosophy to docs (#3855) 2018-02-02 08:07:58 +01:00
Simon Lydell 0c6253d1cf Tweak rationale.md and remove outdated/incorrect stuff (#3853) 2018-02-01 07:47:05 +01:00
Simon Lydell d80728b5ff Support toplevel interpolations in graphql tags (#3370)
* Refactor multiparser

* Add support for toplevel interpolations in graphql tags

* Update snapshots

* Fix JSX-in-markdown special-case
2017-12-03 12:31:23 +11:00
Simon Lydell 56951a71b4 Don't lowercase element names and attribute names in selectors (#3317)
* Don't lowercase element names and attribute names in selectors

https://www.w3.org/TR/css3-selectors/#casesens

> All Selectors syntax is case-insensitive within the ASCII range (i.e.
> [a-z] and [A-Z] are equivalent), except for parts that are not under the
> control of Selectors. The case sensitivity of document language element
> names, attribute names, and attribute values in selectors depends on the
> document language. For example, in HTML, element names are
> case-insensitive, but in XML, they are case-sensitive.

Fixes #3304.

* Fix number normalization in selector interpolation
2017-11-27 13:28:03 +01:00
Simon Lydell bc420370c6 Include duration in --write snapshots (#2960) 2017-10-06 08:20:47 +02:00
Simon Lydell fcdf6b5806 Add test for #2880 (#2959)
I added the test in css_case/case.less because it also tests that
`!important` is lowercased in this case.
2017-10-02 21:17:08 +02:00
Simon Lydell 43cb08c45c Make production tests always run against dist/ (attempt 2) (#2942)
* Make production tests always run against dist/

* Try to mock process.stdin instead of get-stream

* fix: mock `get-stream` from `index.js`

* refactor: remove unnecessary variable

* Try `transform: {}` in jest.config.js

* Add comment explaining the unusual get-stream mocking
2017-10-02 17:58:55 +02:00
Simon Lydell 808dc4e7e3 Add missing quote in README.md
Fixes #2935.
2017-09-30 10:00:47 +02:00
Simon Lydell 9d448fb217 Try to fix website deploy 2017-09-29 10:50:58 +02:00
Simon Lydell fa882b26af Fix Travis production builds (#2933)
* Fix Travis production builds

* Fix Travis production builds, attempt 2

* Remove `allow_failures` in .travis.yml

The reason we allowed the production builds to fail in the first place:

    ❯ git show 532ac0d3f
    commit 532ac0d3f8
    Author: Joseph Frazier <1212jtraceur@gmail.com>
    Date:   2017-06-17 19:37:51 -0400

        Build/test dist/ on Travis (#2176)

        This helps us keep track of whether or not the dist/ build actually
        works (see https://github.com/prettier/prettier/pull/2174). Note that
        the dist/ jobs are allowed to fail, and do not affect overall build
        time, so they shouldn't slow anything down (see
        https://blog.travis-ci.com/2013-11-27-fast-finishing-builds/).

However, as we discovered in #2933 requiring the production builds to
succeed only adds about 1 minute of build time, so it is not worth the
risk of missing that the production builds fail.
2017-09-29 09:34:47 +02:00
Simon Lydell 63916beebb Try to fix cosmiconfig in the built version of Prettier (#2930) 2017-09-29 09:27:50 +02:00
Simon Lydell 51d123b3f1 Update postcss-values-parser (#2928)
My PR has been merged and released to npm, so no need to depend on my
fork anymore.
2017-09-28 19:59:14 +02:00
Simon Lydell 0313ce6299 Fix the playground for 1.7.1 2017-09-27 20:38:16 +02:00
Simon Lydell c6bac7cfe6 Split Less and SCSS parsing into different parsers (#2844)
* Split Less and SCSS parsing into different parsers

Now, .less files are always parsed with postcss-less, and .scss files
areare always parsed with postcss-scss. This:

- Is less hacky.
- Is meant to avoid issues like #2829.
- Is probably more performant.

`parser: "postcss"` and `--parser postcss` continue to work like before:
First trying postcss-less, and if that fails, postcss-scss, unless a
regex says that we should try in the opposite order. The new values for
the parser option are "postcss-less" and "postcss-scss".

* Remove postcss from package.json since it is not used

* Rename parser-less to less and parser-scss to scss

* Deprecate parser:postcss in favor of parser:css

* Fix CSS tests
2017-09-26 07:08:11 +02:00
Simon Lydell cd4d4e7273 Don't lowercase SCSS placeholder selectors (#2876)
Fixes #2872.
2017-09-21 20:23:22 +02:00
Simon Lydell 68d1b56696 Comment out config file extensions docs until next release
See #2861.
2017-09-19 21:37:20 +02:00
Simon Lydell ed67690925 Fix playground for the next release 2017-09-16 15:35:32 +02:00
Simon Lydell fb55367633 Don't lowercase Less variables when parsed with SCSS parser (#2833)
Fixes #2829
2017-09-15 19:48:16 +02:00
Simon Lydell 23041e2113 Don't lowercase &class in SCSS/Less selectors (#2834)
Fixes #2830
2017-09-15 19:48:04 +02:00
Simon Lydell 06c9127f02 Update instructions for running tests against dist
Fixes #2819.
2017-09-14 21:56:59 +02:00
Simon Lydell ec4abdfb1e Don't lowercase CSS custom media names (#2822)
Fixes #2820. While that issue is about `@media (--fooBar)` in
particular, this commit changes to never lowercase stuff starting with
`--` in general, as it seems like those `--customStuff` things can pop
up kind of anywhere.
2017-09-14 21:55:11 +02:00
Simon Lydell 219acfe0f8 Fix playground error 2017-09-14 19:52:37 +02:00
Simon Lydell 2ef7173f13 Fix playground button color 2017-09-14 19:40:38 +02:00
Simon Lydell 9c598b1846 Adjust quotes in some more cases of @import in CSS (#2818)
Fixes #2817.
2017-09-14 14:04:04 +02:00
Simon Lydell 1be06af923 Merge pull request #2814 from ikatyang/chore/jest-21
chore(deps): update jest-* to v21.1.0
2017-09-14 13:21:50 +02:00
Simon Lydell 457903ff74 Merge pull request #2791 from lydell/playground
Improve the playground
2017-09-14 12:24:02 +02:00
Simon Lydell 2756ab9a75 Add syntax highlighting for issue template options 2017-09-14 08:51:37 +02:00
Simon Lydell 1469ef9cea Use the jsx CodeMirror mode instead of javascript
Unfortunately, the "neat" theme we were using for CodeMirror does not
appear to support JSX, so I removed it and went back to the default
theme.
2017-09-14 08:49:20 +02:00
Simon Lydell 5d0ed5c671 Remove 1px page scrollbar in playground 2017-09-14 01:03:38 +02:00
Simon Lydell b9c35cc249 Merge branch 'master' into playground
Conflicts:
	scripts/build/build.js
2017-09-14 00:50:14 +02:00
Simon Lydell 40cf41b15e Try to improve the playground default example 2017-09-14 00:48:22 +02:00
Simon Lydell 1375e6880a Generate ISSUE_TEMPLATE.md on build 2017-09-14 00:14:35 +02:00
Simon Lydell ecaeec5b59 Add feature to test idempotency in playground 2017-09-13 23:40:51 +02:00
Simon Lydell 5b576f4e78 Add more buttons to the playground 2017-09-13 23:07:19 +02:00
Simon Lydell 323941bfd8 Clean up playground CSS and design
- Move the version to the header. Saves some vertical space.
- Use system font.
- Simplify CSS.
- Better header alignment.
2017-09-13 21:01:11 +02:00
Simon Lydell cf9d52e9f3 Hide ast and doc editors while loading the playground 2017-09-13 16:47:21 +02:00
Simon Lydell 709e271051 Improve CLI usage summary and fix typo 2017-09-13 18:21:04 +08:00
Simon Lydell 45d200a06d Improve option categorization and usage summary
- Move the very important options --write and --list-different to the
  top, in the new Output category. It could be argued that --help and
  --version also belong there, but I don't think they deserve such a
  prominent position, so they are left in the Other category.
  --find-config-path could also be considered an Output option, but I
  think it fits better in the Config category.
- Now that there's an Output category, should there also be an Input
  category? I thought about that, but the only candidates for such a
  category are --stdin and --stdin-filepath and I don't think they are
  important enough to have their own category, so they stay in Other.
- Move --cursor-offset, --range-end and --range-start to a new Editor
  category, since they are mainly for editor integrations.
- Document how Prettier deals with input and output by default.
2017-09-13 18:21:04 +08:00
Simon Lydell 32dfb80c86 Remove unnecessary fall-through comment 2017-09-13 18:21:04 +08:00
Simon Lydell be65370301 Remove reassignment in createOptionUsage 2017-09-13 18:21:04 +08:00
Simon Lydell 5d435abe0a Tweak option categories
- Move Format options first, since they feel the most important.
- Move --find-config-path to the Config category.
- Merge Command into Other. It wasn't clear what "Command" options are,
  and the Other category isn't too long anyway.
- Move --range-end and --range-start into Other. The aren't Format
  options.
2017-09-13 18:21:04 +08:00
Simon Lydell c99f7e2e38 Tweak option descriptions 2017-09-13 18:21:04 +08:00
Simon Lydell 602c2a2774 Rename detailOptions to detailedOptions 2017-09-13 18:21:04 +08:00
Simon Lydell 661c029036 Make createUsage a bit easier to read 2017-09-13 18:21:04 +08:00
Simon Lydell 4e5c808730 Fix typo in option description 2017-09-13 18:21:04 +08:00
Simon Lydell e060406df1 Update options config comment 2017-09-13 18:21:04 +08:00
Simon Lydell 2b9e1f80c5 Refactor option category grouping 2017-09-13 18:21:04 +08:00
Simon Lydell c2847d90cd Make ESLint catch category typos 2017-09-13 18:21:04 +08:00
Simon Lydell f53eab9b8d Make cli-util.js a bit more readable 2017-09-13 18:21:04 +08:00
Simon Lydell e192279218 Remove the other .splice in cli-util.js 2017-09-13 18:21:04 +08:00
Simon Lydell 1c6a881ed9 Remove one .splice in cli-util.js 2017-09-13 18:21:04 +08:00
Simon Lydell 79eaa5a6e1 Remove reassignment in createUsage 2017-09-13 18:21:04 +08:00
Simon Lydell 72132b4e97 Remove trailing whitespace in cli-constant.js 2017-09-13 18:21:04 +08:00
Simon Lydell 8ba2acadbb Make sure that shown playground Prettier version always is in sync 2017-09-12 22:17:06 +02:00
Simon Lydell 951aed47f6 Print playground AST with Prettier to make it easier to read 2017-09-12 22:17:06 +02:00
Simon Lydell 482a1d8311 Improve doc and ast editor appearance 2017-09-12 22:17:06 +02:00
Simon Lydell c08b70a0da Update playground service worker script caching 2017-09-12 08:03:10 +02:00
Simon Lydell d6eeaae29b Fix some playground HTML errors and warnings 2017-09-11 19:59:03 +02:00
Simon Lydell cdb7c0d4e3 Set playground Codemirror mode based on parser 2017-09-11 19:55:15 +02:00
Simon Lydell a768740945 Update issue template 2017-09-11 19:28:17 +02:00
Simon Lydell 1827d65d93 Add a "Copy as markdown" button to the playground 2017-09-11 19:27:56 +02:00
Simon Lydell a29b407dda Generalize run-external-typescript-tests.js (#2742)
... so it can run external Flow tests as well (or any external tests for
that matter).
2017-09-03 13:41:07 -07:00
Simon Lydell 133303f47a Ignore some things in coverage (#2741)
- If statements for old deprecated stuff.
- "This should never happen" (and never happens in the tests) code paths.
2017-09-03 13:40:44 -07:00