prettier: initial integration#15502
Open
rootvector2 wants to merge 1 commit into
Open
Conversation
|
rootvector2 is integrating a new project: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an initial OSS-Fuzz integration for Prettier, the opinionated code formatter used across a huge slice of the JS/TS/CSS/Markdown/JSON/YAML ecosystem.
The setup follows the Jazzer.js pattern used by the existing JavaScript projects in this repo (
typescript,js-yaml,fast-xml-parser, etc.).Fuzz targets
Five targets, each one wrapped around
prettier.format()for a parser family, with formatting options pulled fromFuzzedDataProvider:fuzz_format_js—babel,babel-flow,acorn,espree,meriyah,flowfuzz_format_ts—typescript,babel-tsfuzz_format_css—css,scss,lessfuzz_format_json—json,json5,jsonc,json-stringifyfuzz_format_md—markdown,mdx,remarkExpected parse failures (
SyntaxError, "Unexpected token", "Unterminated …", etc.) are filtered out so the fuzzers only surface unexpected exceptions and crashes.A couple of things worth flagging
fuzz_targets/subdirectory with its own tinypackage.jsondeclaring"type": "commonjs". Prettier's ownpackage.jsonsets"type": "module", which would otherwise make Node load every.jsfile in the repo as ESM and break the CommonJSrequire()calls in the fuzzers.@jazzer.js/coreis pinned to2.1.0. The freshly released4.0.0ships a prebuilt native addon that needsGLIBC_2.32, which isn't available yet inbase-builder-javascript(Ubuntu 20.04, glibc 2.31). Once the base image is bumped this pin can go away.format()is async, the targets are written asasync functionand--syncis not passed tocompile_javascript_fuzzer.Test plan
docker buildof the project image succeedsbase-builder-javascriptfuzz_format_jsandfuzz_format_jsonproduce non-trivial coverage in a short local run