Commit Graph
2752 Commits
Author SHA1 Message Date
chimuraiandfisker Cheung 794d9d1558 bugfix(graphql): Keep useful empty lines in description (#13013)
Co-authored-by: fisker Cheung <lionkay@gmail.com>
2022-06-16 13:33:09 +08:00
fisker Cheung d2bcaea121 Throw errors for invalid TSEmptyBodyFunctionExpression node (#12982) 2022-06-14 12:33:44 +08:00
HosokawaR 1bec824556 Revert "print as instead of colon for babel-ts parser" (#12995)
This reverts commit f49114141a21f4f3cb1bb569e241ce1dbcdece44.

; Conflicts:
;	src/language-js/print/misc.js
2022-06-12 12:19:09 +09:00
Sosuke Suzuki 2316e2fecd Update linguist-language (#12994)
* Install new `linguist-language`

* Remove `.mts` and `.cts`

* Update tests
2022-06-12 01:55:11 +09:00
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 be9d63e543 Avoid printing attribute per line in Vue SFC blocks (#12895)
* Avoid print single attribute perline for Vue SFC blocks

* Add tests

* Add changelog

* Fix typo

* Add more tests
2022-06-04 23:25:27 +09:00
fisker Cheung 83ec3c36e3 Build: stricter warning check (#12956) 2022-06-01 19:23:13 +08:00
HosokawaR a089819223 fix formatting for typescript Enum with computed members (#12930)
* fix formatting for typescript Enum with computed members

* add change log

* remove extra examples in change log
2022-05-27 20:44:17 +09:00
Sosuke Suzuki 3147244f55 Update dependencies to support TypeScript 4.7 (#12921)
* Update `@typescript-eslint/typescript-estree` to 5.26.0

* Update `typescript` to `4.7.1-rc`

* Fix syntax kind

* Add `jsdoc_only_types.ts` to unstable tests

* Make printing jsdoc type stable

* Update typescript
2022-05-27 01:46:31 +09:00
Sosuke Suzuki 2fc6e5dd4f Support TS 4.7 optional variance (#12900)
* Print `in` and `out`

* Add tests

* Add tests for jsx
2022-05-22 03:33:05 +09:00
Sosuke Suzuki 1eecc85985 Support TS 4.7 instantiation expression (#12898)
* Handle `TSInstantiationExpression`

* Print `typeParameters` for `TSTypeQuery`

* Add tests

* Add more tests
2022-05-22 03:30:47 +09:00
Sosuke Suzuki 36c20c51bc Support Speculation Rules API formatting in HTML (#12882)
* Add script formatting for `speculationrules`

* Fix lint problems
2022-05-17 10:38:46 +09:00
HosokawaR 765d78305f Fix exports comment formats. (#12860)
* fix exports comment formats

* add tests

* add change log

* rename function name

* merge logic

* add tests to compare comment formats in `export` and `import`
2022-05-15 22:39:55 +09:00
HosokawaRandfisker Cheung 7ab6198453 Make more callee patterns recognized as "test call callee". (#12779)
* make more pattern recognized as test call callee

* add tests

* add change log

* make collate logic easier to read.

* add typedef

* remove extra processing

* fix filename mistake is-noded-matches.js -> is-node-matches.js

* add correct words to cspell config

* add a comment about copying

* move patterns outside

* Minor tweak

* rename valiable name

* Adding changelog real-world use case

Co-authored-by: fisker Cheung <lionkay@gmail.com>
2022-05-07 16:44:56 +09:00
Sosuke Suzuki 9fd05e8de5 Sort options (#12801) 2022-05-07 15:18:52 +09:00
053022f5ed Infer Stylus parser in Vue SFC (#12707)
Co-authored-by: Sosuke Suzuki <aosukeke@gmail.com>
Co-authored-by: fisker Cheung <lionkay@gmail.com>
2022-05-01 23:01:24 +08:00
fisker Cheung 4c42129d96 Simplify pref test scripts (#12699) 2022-05-01 22:29:45 +08:00
Sosuke Suzuki 9348049311 Refactor: Use optional chaining in src/language-js/comments.js (#12747)
* Use optional chaining in `src/language-js/comments.js`

* Using sets

* Address review
2022-04-30 21:16:43 +09:00
Sosuke Suzuki 504d751036 Preserve blank line between export specifiers (#12746)
* Preserve blank line between export specifiers

* Add changelog

* rename
2022-04-29 17:42:42 +09:00
fisker Cheung fc74af1d94 Set loglevel to debug automatically when performance flags found (#12698) 2022-04-28 11:24:59 +08:00
fisker Cheung a1dee86841 Refactor CSS utils (#12680) 2022-04-28 11:24:33 +08:00
HosokawaRandfisker Cheung 9fbdcda5b1 Print as instead of : for babel-ts parser (#12706)
Co-authored-by: fisker Cheung <lionkay@gmail.com>
2022-04-27 17:56:38 +08:00
dependabot[bot]andfisker Cheung 586a4b2a87 Build(deps): Bump css-units-list from 0.0.5 to 1.1.0 (#12684)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: fisker Cheung <lionkay@gmail.com>
2022-04-25 14:02: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
fisker Cheung a9de2a128c Minor refactor (#12681) 2022-04-24 10:28:20 +08:00
fisker Cheung 66585d9f25 Refactor JS utils (#12623) 2022-04-22 20:51:41 +08:00
29c4a3e559 bugfix(graphql): Fix single line and empty description formatting (#12608)
Co-authored-by: Harry Hopkinson <63599884+Harry-Hopkinson@users.noreply.github.com>
Co-authored-by: fisker Cheung <lionkay@gmail.com>
2022-04-22 20:38:44 +08:00
Sosuke Suzuki a4cba80dc0 Allow formatting for Vue template expression written in TypeScript (#12584)
* Support TS expression in vue SFC

* Add changelog

* Add `__ts_expression`

* Add `__vue_ts_expression`

* Add tests

* Do not use `ast.walk`

* Address review

* Add `__vue_ts_event_binding`

* Fix
2022-04-17 13:12:19 +09: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
fisker Cheung 991708420a Simplify HTML Node class (#12622) 2022-04-09 17:34:34 +08:00
Sosuke Suzukiandfisker Cheung f8ce0e303b Fix HTML AST JSON serializer for debugging (#12611)
* Add `JSON.stringify` replacer

* Fix serializer for playground

* Use `opt.parser`

* Consitent style

* lwc

* Revert "lwc"

This reverts commit 799bf357e8b30765944b29639a45b3c326bce615.

Revert "Use `opt.parser`"

This reverts commit 3046f52798ce740ea0ed267bf46c3221606b1fbc.

Revert "Add `JSON.stringify` replacer"

This reverts commit 54266cde61ea8f7cc4b3b0c9714559c93b456923.

* Rewrite `Node` class

* Revert changes in playground

* Revert wrong changes

* Update clean.js

* Set `configurable: true`

* Fix missing `return`

* Fix: "children" and "attrs" are enumerable

* Type check

* Revert unnessary change

Co-authored-by: fisker Cheung <lionkay@gmail.com>
2022-04-08 23:36:23 +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 3fd64b4f30 Format .importmap file with json-stringify parser (#12603) 2022-04-07 09:37:30 +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
dependabot[bot]andfisker Cheung 237e681936 Build(deps): Bump escape-string-regexp from 4.0.0 to 5.0.0 (#10725)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: fisker Cheung <lionkay@gmail.com>
2022-04-02 18:34:21 +08:00
dependabot[bot]andfisker Cheung bf148376fa Build(deps): Bump html-tag-names from 1.1.5 to 2.0.0 (#10612)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: fisker Cheung <lionkay@gmail.com>
2022-04-02 14:02:39 +08:00
dependabot[bot]andfisker Cheung 141bd80c02 Build(deps): Bump html-element-attributes from 2.3.0 to 3.0.0 (#10617)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: fisker Cheung <lionkay@gmail.com>
2022-04-01 09:39:29 +08:00
dependabot[bot]andfisker Cheung 1be154650b Build(deps): Bump html-void-elements from 1.0.5 to 2.0.0 (#10623)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: fisker Cheung <lionkay@gmail.com>
2022-03-31 22:21:37 +08:00
fisker Cheung b40a5d03d6 Refactor: Simplify printSequence() (#12535) 2022-03-31 21:04:12 +08:00
fisker Cheung b429cee273 Fix less/scss format error (#12536) 2022-03-29 20:44:28 +08:00
Trevor Scheerandfisker Cheung 570c3180b9 [graphql] Add support for printing SchemaExtension nodes (#12519)
* Add support for printing SchemaExtension nodes

* Add changelog entry

* Lint

* Update 12519.md

Co-authored-by: fisker Cheung <lionkay@gmail.com>
2022-03-27 00:59:04 +09:00
Sosuke Suzuki becb6c9b74 Fix non-idempotent formatting of function calls with complex type arguments (#12508)
* Fix

* Add TS tests

* Add Flow tests

* Add changelog
2022-03-23 23:09:58 +09:00
fisker Cheung 4250812682 Remove require from UMD bundles (#12485) 2022-03-23 10:21:02 +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 f3917a3a46 Add levenshteinDistance option check (#12447) 2022-03-15 09:40:45 +08:00
fisker Cheung 4b7a39c936 Update chalk to v5 (#12446) 2022-03-15 09:40:25 +08:00