Commit Graph
124 Commits
Author SHA1 Message Date
Sosuke SuzukiandSimon Lydell fdccc0f48e Add --cache CLI option (#12800)
* Install `file-entry-cache` and types

* Implement `FormatResultsCache`

* Add `--cache` and `--cache-location` option

* Implement `--cache` and `--cache-location`

* Add tests for `--cache`

* Add tests for `--cache-location`

* Avoid spellcheck error

* Update snapshots for new options

* Add `groupBy` for website

* Use `fs.promises` instead of `fs/promises`

* Use `rimraf` instead of `fs.rm`

* Fix properties order of `options`

* Install `find-cache-dir` and types

* Change default cache file location to `node_modules/.cache/prettier`

* Fix tests following to change default cache file location

* Update snapshots for changing default cache file location

* Set `os.tmpdir()` as a fallback for default cache dir

* Add docs for `--cache` and `--cache-location`

* Use `sdbm` instead of `node:crypto`

* Add changelog

* Fix `getHashOfOptions`

* Remove `cache-location`

* `prettiercache` -> `prettier-cache`

* Remove cache file when run Prettier without `--cache` option

* Implement `--cache-strategy`

* Add tests for invalid cache strategy

* Fix lint problems

* Tweaks tests

* Add tests for timestamp

* Add tests for `--cache-strategy`

* Add docs for cache-strategy

* Address review

* Fix `findCacheFile`

* Use Set.prototype.has

* Throw error with --stdin-filepath

* Update snapshots

* Fix error for cache and stdin

* Use string constructor instead of toString

* Update changelog

* Use flag validation

* Fix `cache-strategy` definition

* Update docs

* Mark highlihgt

* Throw error for `--cache-strategy` without `--cache`

* Update docs

* Fix typo

* Updates snapshots

* Update docs/cli.md

Co-authored-by: Simon Lydell <simon.lydell@gmail.com>

* Fix error message

* Remove `:::` syntax

* Defaults `content`

* Update docs

* Fix by Prettier

Co-authored-by: Simon Lydell <simon.lydell@gmail.com>
2022-06-11 23:32:32 +09:00
Sosuke Suzuki 9fd05e8de5 Sort options (#12801) 2022-05-07 15:18:52 +09:00
fisker Cheung 4c42129d96 Simplify pref test scripts (#12699) 2022-05-01 22:29:45 +08:00
fisker Cheung fc74af1d94 Set loglevel to debug automatically when performance flags found (#12698) 2022-04-28 11:24:59 +08:00
fisker Cheung 85e6e4f73f CLI: Skip print code or write file when performance flags found (#12682) 2022-04-25 08:44:22 +08:00
Sosuke Suzukiandfisker Cheung fa3b95c2e1 Remove lodash (#12628)
* Replace `groupBy`

* Replace `partition`

* Replace `pick`

* Move `partition`

* Replace `uniqBy`

* Replace `fromPairs`

* Remove usage from website

* Reuse `partition`

* Remove from package.json

* Fix

* Use `ignore.default`

* Add `resolveConfig` to `FileInfoOptions`

* Explicit tuple types

* Make `cache` optional

* Fix cosmiconfig type

* Use `@ts-expect-error` for private property access

* Add type annotation for validate

* Fix type errors for `OptionInfo`

* Add `@ts-expect-error`

* Fix type of `normalizeOptions`

* Fix `OptionInfo` type

* Add `@ts-expect-error` for `option-normalizer`

* Avoid type error

* Fix typo

* Add types for lodash fns

Co-authored-by: fisker Cheung <lionkay@gmail.com>
2022-04-10 15:26:07 +09:00
Harry Hopkinsonandfisker Cheung f98c197b66 Print the number of files that need formatting. (#12561)
Co-authored-by: fisker Cheung <lionkay@gmail.com>
2022-04-07 09:47:13 +08:00
fisker Cheung 86b64183f1 Enable unicorn/no-unreadable-iife and unicorn/prefer-native-coercion-functions rule (#12594) 2022-04-06 10:08:49 +08:00
dependabot[bot] c23e24ee11 Build(deps): Bump leven from 3.1.0 to 4.0.0 (#11349) 2022-04-02 11:47:46 +00:00
dependabot[bot] f4d4dc1177 Build(deps): Bump strip-ansi from 6.0.0 to 7.0.0 (#10731) 2022-04-02 11:24:18 +00:00
fisker Cheung 4d1b9e9716 Refactor: Add a wrapped normalizeCliOptions version for CLI usage (#12573) 2022-04-02 19:01:07 +08:00
fisker Cheung 5ef82125a9 CLI: Don't use logger to print information (#12477) 2022-03-21 10:38:48 +08:00
fisker CheungandSosuke Suzuki cae195187f Fix diff package import (#12462)
Co-authored-by: Sosuke Suzuki <aosukeke@gmail.com>
2022-03-15 12:36:13 +08:00
fisker Cheung 4b7a39c936 Update chalk to v5 (#12446) 2022-03-15 09:40:25 +08:00
fisker Cheung 5a50a0d909 Bundle bin and cli separately (#12306) 2022-03-13 22:47:02 +08:00
fisker Cheung c7b232c8f6 Remove leven from standalone.js (#12382) 2022-03-02 13:40:59 +08:00
fisker CheungandAlexander Kachkaev 3ba48bb266 Add --no-plugin-search (#10274)
Co-authored-by: Alexander Kachkaev <alexander@kachkaev.ru>
2022-02-18 16:36:53 +08:00
fisker CheungandSosuke Suzuki 2fd1406f5f Remove chalk from standalone.js (#12162)
Co-authored-by: Sosuke Suzuki <aosukeke@gmail.com>
2022-01-28 09:24:48 +08:00
fisker Cheung 7d7f7e928a Reduce bundled size of diff package (#12160) 2022-01-27 15:04:07 +08:00
fisker Cheung cf4bf1adc0 Simplify cli options stack (#11994) 2021-12-24 19:34:18 +08:00
fisker Cheung 306d009904 Use camelCase cli arguments internally (#11976) 2021-12-18 11:11:49 +08:00
fisker Cheung 326f23cd35 Restructure cli files (#11974) 2021-12-16 09:21:15 +08:00
Sosuke SuzukiandGeorgii Dolzhykov aa63269743 Add new CLI option debug-print-ast (#11514)
* Add new CLI option debug-print-ast

* Add tests

* Add changelog

* Remove text from ast

* Update tests/integration/__tests__/debug-print-ast.js

Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>

* Update tests

Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>
2021-09-15 21:03:04 +09:00
fisker Cheung 894f841fbd Style: Enforce extensions (#11227) 2021-07-21 09:10:34 +08:00
fisker Cheung 57616ad865 Enable no-return-await and require-await rule, fix clean-cspell script (#11079) 2021-06-16 22:20:47 +08:00
fisker Cheung ce96e4899f CLI: Fix failure on dir with trailing slash (#11000) 2021-06-11 11:03:42 +08:00
fisker Cheung d3b777dd7d Update build script (#10946) 2021-05-27 08:54:42 +08:00
fisker CheungandGeorgii Dolzhykov 2e1021ca79 Reduce use of Array#reduce() (#10863)
Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>
2021-05-16 12:43:13 +08:00
fisker Cheung e161350309 Use fsPromises in CLI (#10852) 2021-05-12 01:05:54 +08:00
fisker Cheung 98abb990cc Use Object.fromEntries(), Array#flat() and Array#flatMap() (#10853) 2021-05-12 01:05:29 +08:00
fisker Cheung b7983971ce Drop Node.js 10 support for development "build" (#10842) 2021-05-11 08:52:38 +08:00
fisker Cheung 6e71422548 Use async APIs in CLI (#10841)
* Use async API in CLI

* Remove `synchronous-promise`
2021-05-11 01:50:50 +03:00
Georgii Dolzhykov 3d8dc612b5 Bump Prettier dependency to 2.3.0 2021-05-10 00:07:47 +03:00
164a6e2351 Switch CLI to async (#10804)
* Switch CLI to async

* Rewrite test

* Fix tests

* Comment out failed test

* Comment out failed test

* Fix test

Co-authored-by: Connor Peet <connor@peet.io>

* Update patterns-dirs.js

* Fix `hasRunningCli` flag

* Fix grammar

* Update tests/integration/runPrettier.js

Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>

Co-authored-by: Connor Peet <connor@peet.io>
Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>
2021-05-09 15:43:10 +03:00
fisker Cheung 64a3906571 Enable unicorn/prefer-optional-catch-binding (#9464) 2021-02-25 18:28:55 +08:00
2245e93900 Don't skip file paths contains special words like constructor (#10256)
Co-authored-by: fisker <lionkay@gmail.com>
Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>
2021-02-08 22:46:00 +02:00
fisker Cheung 22a10c5589 CLI: Handle logLevel parse error (#10207) 2021-02-07 09:01:28 +08:00
fisker Cheung 2a157bf7cb CLI: Print error message when --find-config-path can't find config file (#10208) 2021-02-07 08:52:32 +08:00
fisker Cheung 93409294e6 CLI: clear printed long filenames (#10217) 2021-02-07 08:51:19 +08:00
fisker Cheung 1bc457d5de Refactor CLI (#10168) 2021-02-02 09:25:36 +08:00
fisker Cheung f04b2b991c Enable no-implicit-coercion rule (#10186) 2021-02-01 13:14:04 +08:00
Georgii Dolzhykov 56840d4890 Followup for #10169: minor tweaks (#10177)
* Followup for #10169: minor tweaks

* Add Copy doc button to Playground
2021-01-30 18:25:43 +02:00
Daron McIntosh 3d9f102301 Add CLI option to prevent errors on unmatched patterns (#10058) 2021-01-28 00:30:16 +02:00
Georgii Dolzhykov 79d2f4a295 Add CLI flag for debugging comment attachment issues (#10124) 2021-01-27 12:30:10 +02:00
fisker Cheung 89e5751b46 Use Object.{entries,values} if possible (#10131) 2021-01-26 09:48:31 +08:00
fisker Cheung ce26805e84 Enable unicorn/prefer-spread (#10129) 2021-01-26 09:46:14 +08:00
fisker Cheung 181a325c1c Enable unicorn/explicit-length-check (#9975) 2021-01-04 10:11:57 +08:00
Sosuke Suzuki 23521ded6c Refactor CLI context with ES2015 class (#9964)
* Remove createContext

* Remove initContext

* Remove pushContextPlugins

* Remove popContextPlugins

* Move JSDoc comments

* Remove updateContextArgv

* Remove normalizeContextArgv

* Remove updateContextOptions

* Fix typedef

* Change exports format

* Add comment for initContext
2021-01-01 01:56:32 +09:00
Sosuke Suzuki 8d0c8b2bf4 Extract files and rename util -> core (#9826)
WIP

Extract create-minimist-options

Remove warning

Fix

Extract format.js

Fix

Remove

fix

Fix

Extract files for cli and rename util -> core

Update tsconfig
2020-12-08 14:36:46 +09:00
fisker CheungandGeorgii Dolzhykov f254314feb Use meriyah (#9731)
Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>
2020-11-23 13:57:13 +08:00