diff --git a/.github/renovate.json5 b/.github/renovate.json5 index f3dd88ef6..74f9dfb2f 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -14,6 +14,10 @@ excludePackageNames: ["@babel/parser"], groupName: "babel", }, + { + matchPackagePrefixes: ["@typescript-eslint/"], + groupName: "typescript-eslint", + }, { branchPrefix: "renovate/website/", matchPaths: ["website/package.json"], diff --git a/cspell.json b/cspell.json index 45249b3b9..bd9ebdb47 100644 --- a/cspell.json +++ b/cspell.json @@ -206,6 +206,7 @@ "Monteiro", "Morrell", "motiz", + "Motoko", "mousedown", "mouseup", "mprettier", diff --git a/docs/configuration.md b/docs/configuration.md index 48b928961..9e9e2a4f6 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -80,7 +80,7 @@ singleQuote = true Overrides let you have different configuration for certain file extensions, folders and specific files. -Prettier borrows ESLint’s [override format](https://eslint.org/docs/user-guide/configuring#example-configuration). +Prettier borrows ESLint’s [override format](https://eslint.org/docs/latest/user-guide/configuring/configuration-files#how-do-overrides-work). JSON: diff --git a/docs/integrating-with-linters.md b/docs/integrating-with-linters.md index bd6c125d0..0c4a7e339 100644 --- a/docs/integrating-with-linters.md +++ b/docs/integrating-with-linters.md @@ -29,7 +29,7 @@ The downsides of those plugins are: - They are slower than running Prettier directly. - They’re yet one layer of indirection where things may break. -Finally, we have tools that run `prettier` and then immediately for example `eslint --fix` on files. +Finally, we have tools that run `prettier` and then immediately lint files by running, for example, `eslint --fix` on them. - [prettier-eslint](https://github.com/prettier/prettier-eslint) - [prettier-stylelint](https://github.com/hugomrdias/prettier-stylelint) diff --git a/docs/plugins.md b/docs/plugins.md index 8dcd3546a..b2e19e22d 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -66,6 +66,7 @@ To turn off plugin autoloading, use `--no-plugin-search` when using Prettier CLI - [`prettier-plugin-java`](https://github.com/jhipster/prettier-java) by [**@JHipster**](https://github.com/jhipster) - [`prettier-plugin-jsonata`](https://github.com/Stedi/prettier-plugin-jsonata) by [**@Stedi**](https://github.com/Stedi) - [`prettier-plugin-kotlin`](https://github.com/Angry-Potato/prettier-plugin-kotlin) by [**@Angry-Potato**](https://github.com/Angry-Potato) +- [`prettier-plugin-motoko`](https://github.com/dfinity/prettier-plugin-motoko) by [**@dfinity**](https://github.com/dfinity) - [`prettier-plugin-nginx`](https://github.com/joedeandev/prettier-plugin-nginx) by [**@joedeandev**](https://github.com/joedeandev) - [`prettier-plugin-prisma`](https://github.com/umidbekk/prettier-plugin-prisma) by [**@umidbekk**](https://github.com/umidbekk) - [`prettier-plugin-properties`](https://github.com/eemeli/prettier-plugin-properties) by [**@eemeli**](https://github.com/eemeli) @@ -164,6 +165,7 @@ export const printers = { canAttachComment, isBlockComment, printComment, + getCommentChildNodes, handleComments: { ownLine, endOfLine, @@ -373,6 +375,21 @@ Comments are often not part of a language's AST and present a challenge for pret By default, if the AST has a top-level `comments` property, Prettier assumes that `comments` stores an array of comment nodes. Prettier will then use the provided `parsers[].locStart`/`locEnd` functions to search for the AST node that each comment "belongs" to. Comments are then attached to these nodes **mutating the AST in the process**, and the `comments` property is deleted from the AST root. The `*Comment` functions are used to adjust Prettier's algorithm. Once the comments are attached to the AST, Prettier will automatically call the `printComment(path, options): Doc` function and insert the returned doc into the (hopefully) correct place. +#### (optional) `getCommentChildNodes` + +By default, Prettier searches all object properties (except for a few predefined ones) of each node recursively. This function can be provided to override that behavior. It has the signature: + +```ts +function getCommentChildNodes( + // The node whose children should be returned. + node: AST, + // Current options + options: object +): AST[] | undefined; +``` + +Return `[]` if the node has no children or `undefined` to fall back on the default behavior. + #### (optional) `printComment` Called whenever a comment node needs to be printed. It has the signature: diff --git a/package.json b/package.json index 912ddd78e..52d84505f 100644 --- a/package.json +++ b/package.json @@ -132,7 +132,7 @@ "jest-snapshot-serializer-raw": "1.2.0", "jest-watch-typeahead": "2.1.1", "node-actionlint": "1.2.2", - "node-fetch": "3.2.4", + "node-fetch": "3.2.10", "npm-run-all": "4.1.5", "path-browserify": "1.0.1", "prettier": "2.7.1", diff --git a/scripts/generate-changelog.mjs b/scripts/generate-changelog.mjs index 8578dfd6d..f3d9e7ffc 100644 --- a/scripts/generate-changelog.mjs +++ b/scripts/generate-changelog.mjs @@ -154,6 +154,10 @@ function getSyntaxFromCategory(category) { return "jsx"; case "typescript": return "tsx"; + case "css": + case "scss": + case "less": + return "css"; default: return category; } @@ -175,6 +179,8 @@ function getCommentForSyntax(syntax, comment) { return `# ${comment}`; case "hbs": return `{{! ${comment} }}`; + case "css": + return `/* ${comment} */`; default: return `// ${comment}`; } diff --git a/website/versioned_docs/version-stable/configuration.md b/website/versioned_docs/version-stable/configuration.md index 148d900f2..547c8bef8 100644 --- a/website/versioned_docs/version-stable/configuration.md +++ b/website/versioned_docs/version-stable/configuration.md @@ -67,7 +67,7 @@ singleQuote = true Overrides let you have different configuration for certain file extensions, folders and specific files. -Prettier borrows ESLint’s [override format](https://eslint.org/docs/user-guide/configuring#example-configuration). +Prettier borrows ESLint’s [override format](https://eslint.org/docs/latest/user-guide/configuring/configuration-files#how-do-overrides-work). JSON: diff --git a/yarn.lock b/yarn.lock index b7f1eb80d..d50aded68 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6241,14 +6241,14 @@ __metadata: languageName: node linkType: hard -"node-fetch@npm:3.2.4": - version: 3.2.4 - resolution: "node-fetch@npm:3.2.4" +"node-fetch@npm:3.2.10": + version: 3.2.10 + resolution: "node-fetch@npm:3.2.10" dependencies: data-uri-to-buffer: ^4.0.0 fetch-blob: ^3.1.4 formdata-polyfill: ^4.0.10 - checksum: cfc715441302167bd4a9c6d6f3ff8eecb65e5aeeccd55a690497dcce5f95ec017d65c5682414287cad3998a28b1bab4820dcbe51852902eaa5f15f3975562384 + checksum: e65322431f4897ded04197aa5923eaec63a8d53e00432de4e70a4f7006625c8dc32629c5c35f4fe8ee719a4825544d07bf53f6e146a7265914262f493e8deac1 languageName: node linkType: hard @@ -6971,7 +6971,7 @@ __metadata: minimist: 1.2.6 n-readlines: 1.0.1 node-actionlint: 1.2.2 - node-fetch: 3.2.4 + node-fetch: 3.2.10 npm-run-all: 4.1.5 outdent: 0.8.0 parse-srcset: "ikatyang/parse-srcset#54eb9c1cb21db5c62b4d0e275d7249516df6f0ee"