Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 1 addition & 18 deletions tasks/prettier_conformance/snapshots/prettier.js.snap.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
js compatibility: 656/749 (87.58%)
js compatibility: 673/749 (89.85%)

# Failed

Expand All @@ -17,27 +17,11 @@ js compatibility: 656/749 (87.58%)
| js/comments/if.js | 💥💥 | 74.83% |
| js/comments/return-statement.js | 💥💥 | 98.28% |
| js/comments/tagged-template-literal.js | 💥💥 | 92.86% |
| js/comments/html-like/comment.js | 💥 | 0.00% |
| js/comments/tagged-template-literal/11662.js | 💥 | 80.00% |
| js/conditional/comments.js | 💥✨ | 23.69% |
| js/conditional/new-ternary-examples.js | 💥✨ | 20.14% |
| js/conditional/new-ternary-spec.js | 💥✨ | 24.35% |
| js/conditional/postfix-ternary-regressions.js | 💥✨ | 20.77% |
| js/discard-binding/array-pattern.js | 💥 | 0.00% |
| js/discard-binding/basic.js | 💥 | 0.00% |
| js/discard-binding/discard-binding-arrow-params.js | 💥 | 0.00% |
| js/discard-binding/discard-binding-assignment.js | 💥 | 0.00% |
| js/discard-binding/discard-binding-async-arrow-params.js | 💥 | 0.00% |
| js/discard-binding/discard-binding-bindings.js | 💥 | 0.00% |
| js/discard-binding/discard-binding-for-await-using-binding.js | 💥 | 0.00% |
| js/discard-binding/discard-binding-for-bindings.js | 💥 | 0.00% |
| js/discard-binding/discard-binding-for-lhs.js | 💥 | 0.00% |
| js/discard-binding/discard-binding-for-using-binding.js | 💥 | 0.00% |
| js/discard-binding/function-parameter.js | 💥 | 0.00% |
| js/discard-binding/object-pattern.js | 💥 | 0.00% |
| js/discard-binding/unary-expression-void.js | 💥 | 0.00% |
| js/discard-binding/using-variable-declarator.js | 💥 | 0.00% |
| js/discard-binding/using.js | 💥 | 0.00% |
| js/explicit-resource-management/for-await-using-of-comments.js | 💥 | 0.00% |
| js/explicit-resource-management/valid-await-using-comments.js | 💥 | 66.67% |
| js/for/9812-unstable.js | 💥 | 45.45% |
Expand Down Expand Up @@ -90,7 +74,6 @@ js compatibility: 656/749 (87.58%)
| js/test-declarations/angularjs_inject.js | 💥💥 | 91.53% |
| js/test-declarations/test_declarations.js | 💥💥 | 95.88% |
| js/trailing-comma/dynamic-import.js | 💥💥💥 | 0.00% |
| jsx/expression-with-types/expression.js | 💥💥💥💥 | 0.00% |
| jsx/fbt/test.js | 💥 | 84.06% |
| jsx/jsx/quotes.js | 💥💥💥💥 | 79.41% |
| jsx/jsx/regex.js | 💥💥💥💥 | 75.00% |
Expand Down
7 changes: 1 addition & 6 deletions tasks/prettier_conformance/snapshots/prettier.ts.snap.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
ts compatibility: 532/598 (88.96%)
ts compatibility: 537/598 (89.80%)

# Failed

| Spec path | Failed or Passed | Match ratio |
| :-------- | :--------------: | :---------: |
| jsx/expression-with-types/expression.js | 💥💥💥💥 | 0.00% |
| jsx/fbt/test.js | 💥 | 84.06% |
| jsx/jsx/quotes.js | 💥💥💥💥 | 79.41% |
| jsx/jsx/regex.js | 💥💥💥💥 | 75.00% |
Expand Down Expand Up @@ -36,9 +35,7 @@ ts compatibility: 532/598 (88.96%)
| typescript/conditional-types/nested-in-condition.ts | 💥✨ | 15.79% |
| typescript/conditional-types/new-ternary-spec.ts | 💥✨ | 10.67% |
| typescript/conditional-types/parentheses.ts | 💥✨ | 15.22% |
| typescript/conformance/types/functions/functionOverloadErrorsSyntax.ts | 💥 | 0.00% |
| typescript/decorators-ts/angular.ts | 💥 | 87.50% |
| typescript/definite/without-annotation.ts | 💥 | 91.67% |
| typescript/import-require/comments.ts | 💥 | 33.33% |
| typescript/import-type/long-module-name/long-module-name2.ts | 💥 | 25.00% |
| typescript/import-type/long-module-name/long-module-name4.ts | 💥 | 89.29% |
Expand All @@ -61,8 +58,6 @@ ts compatibility: 532/598 (88.96%)
| typescript/prettier-ignore/mapped-types.ts | 💥 | 96.61% |
| typescript/property-signature/consistent-with-flow/comments.ts | 💥 | 80.00% |
| typescript/property-signature/consistent-with-flow/union.ts | 💥 | 85.71% |
| typescript/type-arguments-bit-shift-left-like/3.ts | 💥 | 0.00% |
| typescript/type-arguments-bit-shift-left-like/5.tsx | 💥 | 0.00% |
| typescript/type-params/18041.ts | 💥 | 43.75% |
| typescript/type-params/constraints-and-default-2.ts | 💥 | 97.60% |
| typescript/type-params/constraints-and-default.ts | 💥 | 87.32% |
Expand Down
3 changes: 0 additions & 3 deletions tasks/prettier_conformance/src/ignore_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ pub const IGNORE_TESTS: &[&str] = &[
// non-standard syntax
"js/deferred-import-evaluation",
"js/bind-expressions",
// Unsupported stage3 features
"tuple-and-record.js",
"js/async-do-expressions",
// Babel plugins (mostly experimental syntaxes)
"js/babel-plugins",
"js/destructuring-private-fields",
Expand Down
36 changes: 25 additions & 11 deletions tasks/prettier_conformance/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use similar::TextDiff;
use walkdir::WalkDir;

use oxc_allocator::Allocator;
use oxc_formatter::{FormatOptions, Formatter, get_parse_options};
use oxc_formatter::{FormatOptions, Formatter, enable_jsx_source_type, get_parse_options};
use oxc_parser::Parser;
use oxc_span::SourceType;

Expand Down Expand Up @@ -240,12 +240,18 @@ impl TestRunner {
)
.unwrap();

let Some(actual) =
Self::run_oxc_formatter(path, &source_text, format_options.clone())
else {
// Skip the test if parsing failed
if self.options.debug {
println!(" => Skipped (parsing failed)");
}
continue;
};

let actual = Self::replace_escape_and_eol(
&Self::run_oxc_formatter(
&source_text,
SourceType::from_path(path).unwrap(),
format_options.clone(),
),
&actual,
expected.contains("LF>") || expected.contains("<CR"),
);

Expand Down Expand Up @@ -414,15 +420,23 @@ impl TestRunner {
}

fn run_oxc_formatter(
path: &Path,
source_text: &str,
source_type: SourceType,
formatter_options: FormatOptions,
) -> String {
format_options: FormatOptions,
) -> Option<String> {
let allocator = Allocator::default();
let source_type = source_type.with_jsx(source_type.is_javascript());

let source_type = SourceType::from_path(path).unwrap();
let source_type = enable_jsx_source_type(source_type);

let ret = Parser::new(&allocator, source_text, source_type)
.with_options(get_parse_options())
.parse();
Formatter::new(&allocator, formatter_options).build(&ret.program)
if !ret.errors.is_empty() {
return None;
}

let formatted = Formatter::new(&allocator, format_options).build(&ret.program);
Some(formatted)
}
}
Loading