* Implement prettier.getFileInfo() method and --file-info CLI option
* Add empty line between functions in index.js
* Support --plugin-search-dirs / pluginSearchDirs() in --file-info / getFileInfo()
* Address review comments by @ikatyang
* Fix plugin API in globally installed Prettier and introduce optional --plugin-search-dir
* Use find-parent-dir instead of find-up and test autoloading (with mocked fn)
* Add two test cases where --plugin-search-dir is not .
* Do not mutate pluginSearchDirs argument in load-plugins.js
* Do not test automatic plugin resolution as mocking of "find-parent-dir" does not work due to rollup
* Document --plugin-search-dir / pluginSearchDirs and improve spacing
* Address @ikatyang's review comments
* Fix require path for third-party
* Undo alphabetic sorting of third-party scripts
* refactor(cli): defer default value applying
* Allow plugins to override default options
* Move "defaultOptions" to top level of plugin
* Simplify implementation
* Attach plugin name
* Add pluginOptions to cli help
* Update snapshots
* Code review (immutable style)
* Add test for help output
* Use snapshot test, fix Object.assign
* Refactor to immutable style
* Add test case for automatic plugin resolution
* Add tests for applying and overriding default opts
* Remove "since" option
* Only set defaults for CLI args when no pluginDefaults are present
* Revert workaround, rebase to #4045
* Add basic documentation for `options` and `defaultOptions`
* Updated webstorm.md with file-watcher dialog changes
Changed `Immediate file synchronization` file watcher options with the updated syntax in new Webstorm version: `Auto-save edited files to trigger the watcher`
* docs(webstorm): updated file-watcher dialog image
updated Webstorm's file-watcher dialog example pic with the dialog in the latest versions of Webstorm.
* Add 1.10 blog post
Copied from releases page
* Change a few things
* Add overview of changes
* Lint docs
* Scaffold out release notes
* Add prettier-ignores
* docs: add missing references
* docs: fix heading level
* docs: fix example
* Document plugin API
* Use shellsession
* docs: fix example
* docs: fix links
* Fix heading level
* change: ts upgrade -> numeric separator support
Instead of mentioning we updated the typescript version, we should emphasize on what value we added to users
* Fix repeated phrase
* add comment type annotation explanation
* Add note on no more wrapping () JSX elements
* Grammar
* Add more release notes
* Fill out remaining release notes
* Fix lint
* Add verb
* Fix heading level
* Update 2018-01-10-1.10.0.md
* Update 2018-01-10-1.10.0.md
* Add twitter buttons
* docs: add note for #3694
* Fix cake
There's a lot of demand for vue sfc (#2097). This introduces partial support for them: all the html is printed as is, except for the script and style tags which are printed using prettier. I believe that this should cover a lot of the use cases while being simple to support and if we want we can extend to more in the future.
I copy pasted the html parser used by vue (it's just a single 400 lines file) so that we don't run the chancesof conflicts. I'm also very conservative: I only print the style and script at the top level and for the lang attributes we support.
I expect this to be landable as is and provide value, review welcome :)
* docs(ignore): mention ignore file in Ignoring Code
While working on #3321, I needed to ignore an entire file, but the "Ignoring Code" section of the docs only describes how to ignore blocks of code, so I wasn't aware of the default ignore file.
(The `.prettierignore` file is mentioned in the CLI section, but easily overlooked there.)
This commit extends the introduction sentence of the "Ignoring Code" section and adds a new subsection to explain how to ignore files.
https://github.com/prettier/prettier/issues/3321#issuecomment-350072566
* docs(cli): fix nesting error in heading hierarchy
The `--ignore-path` option currently appears as a third-level subsection of `--find-config-path` and `--config`, but this looks like an error.
This commit promotes the `--ignore-path` heading to the same (H2) level as the other CLI options.
* Adding --stdin-filepath option in order to enable filetype inference from
stdin
* Fixing typo on the documentation
* Fixing typos - fixing some typos
* Restoring static lib files back since they are artifacts
* Add option to insert @format pragma if absent
prependPragma --> insertPragma
add tst dir, move stripBom, add to README, update snapshots
remove noise from test + update snapshots
use jest@test new functions, update docs, rerun snapshots
fix accidental upgrade to jest@test
update jest-docblock again to latest with strip()
updated snapshot
* updated snapshots
* revert jest dep change
* apply a trim to parsed comments
* remove empty object
* Revert "apply a trim to parsed comments"
This reverts commit 467f71ce5f4b4f8a1b5c4474ee0484bc96c92141.
* rerun snapshots with proper jest version
* pin jest-docblock to latest @test release
* comment out docs for new feature from readme
* remove leading newlines
* ensure blank line between docblock and rest of file
* remove backtick string
* Add option to require @prettier or @format pragma
Fixes#2397.
Inspired by `eslint-plugin-prettier` and the discussion in #2397, this
implements requiring a special comment pragma to be present in a file's
first comment in order to be formatted.
This will help large codebases gradually transition to prettier over
time without tons of churn or large code reviews.
I implemented this as a standard prettier "option", not just a typical
`argv` flag, as it is relevant in both the cli and the api. This way it
can be provided programmatically, on the command line, or standardized
in a prettierrc file so like the style options, every user can use this
setting consistently and only apply prettier to relevant files, no
mattier their editor integration.
This requires the pragma begin with `@` (in fact it's inserted if the
user doesn't provide it). Currently the usage implies it must be
"prettier" or "format", but it can technically be any value other than
"none", which is similar to the `trailingCommas` option.
cc @vjeux
* Don't quote anything in runPrettier; this is usually handled by a shell
* Make --require-pragma a boolean option
* Use jest-docblock to find pragmas without parsing the ast
* Clarify docs
* includes -> indexOf
* Move test out of integration
* Update website to new docusaurus API
* Fix missing comma
* Fix link typo in users.json
* Update docusaurus to version 1.0.0-alpha.35
* Clean up siteConfig.js
* 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
* 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.
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.
In the current demo, every time the code in the left panel is changed,
the new code is stored in the URL hash, which pushes a new history
entry. This effectively "breaks" the back button. This change calls
`history.replaceState` instead, so a single click of the back button
will return the browser to whatever page was open before navigating to
the demo.
* Use babel-code-frame for syntax errors
* Support the `--color` option more explicitly
* Update rollup config to handle babel-code-frame
* Use exact dependencies
This PR adds two things:
`--debug-print-doc` command that prints the formatted doc
```js
echo "<div><</div>" | ./bin/prettier.js --stdin --debug-print-doc
[
groupConditional(
group([
group([ "<", "div", group([ indent(2, []), softline() ]), ">" ]),
"<",
"</",
"div",
">"
]),
[
group([
group([ "<", "div", group([ indent(2, []), softline() ]), ">" ]),
"<",
"</",
"div",
">"
]),
group([
group([ "<", "div", group([ indent(2, []), softline() ]), ">" ]),
indent(2, groupBreak([ hardline(), "<" ])),
hardline(),
"</",
"div",
">"
])
]
),
";",
hardline()
];
```
The ability to view the IR in real time on the browser display:
![image](https://cloud.githubusercontent.com/assets/197597/22134741/4f172f20-de7e-11e6-84bc-5f813976dc19.png)
The way it works is pretty cool, we take the doc IR and print a valid JavaScript string out of it, that we then send to prettier in order to make it look good :)