* Add comments showing parser arguments
Since this is how they are invoked, the comments make it easier to maintain.
* Use babylon.parseExpression for JSON
See https://github.com/prettier/prettier/issues/2378#issuecomment-314600778
Note that this doesn't yet print comments:
echo '{/*comment*/"K":"V"}' | ./bin/prettier.js --parser json
* Remove parser-json.js
This reduces duplicate code in the built package.
See https://github.com/prettier/prettier/pull/2476#pullrequestreview-50181398
* Add test with block comment in JSON
* Fix test with block comment in JSON
* Add test with line comment in JSON
* Don't build now-redundant parser-json.js
* Implement cosmiconfig
* Add resolveOptions API and extname support
* Add --resolve-config and --config, rename resolveOptions to resolveConfig
* Move color to top-level CLI options
* Fix unknown param warning
* Change from {} to null when no config is found
* Change override API to emulate eslint
* Add test for eslint-style overrides
* Delete overrides from resolveConfig
* initial docusaurus set-up
* Delete why-prettier.md
* Update README.md
* Update Docusaurus structure
* Update package.json
* Update siteConfig.js
* Remove ~ files
* chore(website): update build script
* Add redirect script
* Get eslint working on website
* Fix to allow for baseUrl of '/'
* Update docusaurus version
* Update README.md
* Change redirect script to use baseUrl of '/'
* Fix index.js formatting
* Load redirect script
* General cleanup
* Add projects using prettier
* Update service worker to just scope to playground
* Reduce link repeatition
* Link "Try it out" button to /playground/
* Make header of playground approximately same as main site
* Remove .html from URLs (e.g. users.html -> users/)
* Link Gitter Chat
* Add circleci.yml
* Only run builds on master
* Do deployment using Travis
This changes the eslint error formatting from:
/Users/josephfrazier/workspace/prettier/src/printer-postcss.js
3:31 error Insert `;` prettier/prettier
to:
✘ prettier/prettier Insert `;`
src/printer-postcss.js:3:31
const util = require("./util")
^
which makes them clickable in terminals like iTerm2 and Guake. See
[eslint-friendly-formatter] for details.
[eslint-friendly-formatter]: https://github.com/royriojas/eslint-friendly-formatter
Before, this error happened upon `yarn build`:
🚨 (commonjs plugin) Binding arguments in strict mode (49161:16) in /Users/josephfrazier/workspace/prettier/node_modules/typescript/lib/typescript.js
* Fix support for node 4 (#1988)
* Fix website on iOS Safari (#1970)
Formatting change:
* Position JSX whitespace (`{" "}`) at the end of lines (#1964)
Lots of small fixes, mainly for TypeScript.
* Initial GraphQL implementation
This is the bare minimum amount of code to make graphql work. Turns out it's pretty easy to add support for other languages :)
* Fixing support for `graphql` parsing
There was a few structural changes with the addition of CSS and Typescript that we had to take into account.
* Fixing file glob, adding `graphql` to yarn.lock
* Removing extraneous file
* Adding `graphql` parser, style changes
* Splitting out graphql printer
* Removing merge conflict
* Fixing yarn.lock
* Addressing code review, using `createError`
* Adding release config
* Using exact version
* Removing destructuring
The hackiness continues! I'm now bundling an existing bundle again in order for it to get exported as a global variable :p There's likely a better solution, but it kind of works.
Because I have to regenerate the docs, I just tagged it as 1.4.0-beta and added typescript and postcss in there.
It turns out rollup doesn't use the same algorithm for bundling commonjs files when there are cycles as node, which breaks postcss: https://twitter.com/Rich_Harris/status/869021144191561729. Webpack works just fine with it.
This sucks to have this rollup/webpack frankenstein but I really want to be able to release and don't really want to spend yet another day or two trying to make it work well.
We use a heuristic to figure out if it's a SCSS or Less file. And if it doesn't work, we try again with the other one. We do the same for JSX and TypeScript.
Fixes#1784
I wanted to see how hard it would be to add support for CSS inside of prettier. Turns out, it's not that hard. I spent a few hours printing post-css values and getting all the stylefmt unit tests to not throw.
* 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`.
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/.
* fix TSCallSignature
* fix TSTypeReference
* remove test with invalid syntax
* --wip--
* partially fix TSTypeReference
* get comments right for TypeScript interfaces
* Extract custom tests from tests/flow/
Approach:
1. Remove all .js files in tests/flow except .snap.js files.
2. Copy over all .js files from tests/ in the flow repo.
3. Go through the diff looking for deletions.
- It was easy to see which deletions were due to changes in the tests
due to updates in the flow repo.
- For the rest of the deletions, I used `git blame` to verify that
they had been added by us since the flow tests were copied over.
This makes tests/flow/ simply a copy of the tests from the flow repo,
making it easier to sync with the upstream flow tests in the future.
* Add a script for syncing the flow tests
* Sync the flow tests
ast-types was missing a type, I sent a PR on ast-type ( https://github.com/benjamn/ast-types/pull/211 ) which was merged and released (thanks @benjamn for being super quick!). So I'm upgrading ast-types and add the test in this PR.
Fixes#1007
* Add some typescript tests
* fix: Remove extraneous colon in type parameter constraint
* style: Add missing newline at EOF in TS tests
* feat: Pretty print typescript object type annotations
* feat: Pretty print TSFunctionType
* fix: Type annotations was missing on class properties
* Add a new batch of tests
* Bump typescript-eslint-parser
* Add a new batch of tests and fix a syntax error in previous
* Bump typescript-eslint-parser
* WIP immediate feedback
* typescript parser is drop-in replacement for flow parser
* Add new TypeScript Parser snapshots where drop-in replacement possible
* Snapshot updates after rebasing
* Remove unnecessary stripping of properties on TypeScript parser AST
* Remove annotated issues
* Move TS dependencies to dev for now
* Make `--write` logs more informative.
* Add format duration to logs.
* Use colors instead of [ignore] and [update] labels.
* Remove `colors` dependency.
* Use `chalk` to colorize logs.
* Print filename before `format` and add duration info later.
* Print filename before read error.
This let's you run `pp(x) === pp(pp(x))` across an entire codebase quickly. I think it's small enough that we can merge it in to master while we are nailing down all the issues.
You can see the output in #610
* Validate user-provided config with jest-validate
* Don't use object shorthand
* Update jest-validate to 18.2
* Fix Node4 destructuring from require
* Make use of jest-validate for deprecation message
* Remove chalk reference
* Use babel-code-frame for syntax errors
* Support the `--color` option more explicitly
* Update rollup config to handle babel-code-frame
* Use exact dependencies
It doesn't compile cleanly anymore:
- esutils checks for Buffer.isBuffer without ensuring that Buffer exists.
- for version, we require a json file, need a rollup extension for that.
I no longer hardcode the version number.
Note: we need to merge this pull request after we have done the release so that the version number is correct and need to rebuild the minified version in a subsequent commit.
The current implementation with `JSON.stringify()` is clever but unfortunately generates incorrect JavaScript. Using `jsesc` seems like a better and safer option. https://github.com/mathiasbynens/jsesc It doesn't have any dependencies and is pretty small.
I opted for escaping all the non ascii characters, so we don't display emojis anymore. I don't think that the world is ready yet for having random unicode characters inside of source files, there still are so many parts of the toolchain that breaks with them. If we want to revert back on this decision, there's a `minimal` option on jsesc which only escapes values that need to in order to generate valid JavaScript file (assuming the encoding of the file is set to utf8).
Also, while working on React Native, we've seen that there is an optimization inside of jsc for js files that are all ascii: it doesn't do a copy for the conversion to ucs16.
Fixes#163
This is a very handy way of playing out with prettier without having to install it. People have already been using it actively in the issues. Putting it directly inside of the repo would be better than on mine.