Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(transform_conformance): correctly handle BABEL_8_BREAKING #2990

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
4 changes: 2 additions & 2 deletions tasks/transform_conformance/babel.snap.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Passed: 94/228
Passed: 93/227

# All Passed:
* babel-plugin-transform-react-jsx-source
Expand Down Expand Up @@ -137,7 +137,7 @@ Passed: 94/228
* regression/another-preset-with-custom-jsx-keep-source-self/input.mjs
* regression/runtime-classic-allow-multiple-source-self/input.mjs

# babel-plugin-transform-react-jsx (34/37)
# babel-plugin-transform-react-jsx (33/36)
* autoImport/auto-import-react-source-type-module/input.js
* autoImport/complicated-scope-module/input.js
* autoImport/react-defined/input.js
Expand Down
25 changes: 9 additions & 16 deletions tasks/transform_conformance/src/test_case.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,24 +131,16 @@ pub trait TestCase {
return true;
}

let dir = self.path().parent().unwrap();
// Skip Babel 7 specific tests
// https://github.com/babel/babel/issues/10746
// We implement Babel 8 breaking changes under the BABEL_8_BREAKING env flag.
// To test the breaking changes, please duplicate the affected tests with the -babel-7 suffix and add BABEL_8_BREAKING: false to test options.
if dir
.file_name()
.is_some_and(|file_name| file_name.to_string_lossy().ends_with("-babel-7"))
{
return true;
}

// Skip deprecated react options
if options.babel_8_breaking.is_some_and(|b| b) {
if let Ok(options) = self.transform_options() {
if options.react.use_built_ins.is_some() || options.react.use_spread.is_some() {
if let Some(b) = options.babel_8_breaking {
if b {
// Skip deprecated react options
if self.transform_options().as_ref().is_ok_and(|options| {
options.react.use_built_ins.is_some() || options.react.use_spread.is_some()
}) {
return true;
}
} else {
return true;
}
}

Expand All @@ -166,6 +158,7 @@ pub trait TestCase {

// babel skip test cases that in a directory starting with a dot
// https://github.com/babel/babel/blob/0effd92d886b7135469d23612ceba6414c721673/packages/babel-helper-fixtures/src/index.ts#L223
let dir = self.path().parent().unwrap();
if dir.file_name().is_some_and(|n| n.to_string_lossy().starts_with('.')) {
return true;
}
Expand Down
Loading