mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 20:32:10 +00:00
feat(transformer/react-jsx): support for throwing ImportSourceCannotBeSet error (#1224)
This commit is contained in:
parent
b4ce2b5f9b
commit
39e608734f
2 changed files with 10 additions and 4 deletions
|
|
@ -22,6 +22,11 @@ use crate::context::TransformerCtx;
|
|||
#[diagnostic(severity(warning), help("Remove `pragma` and `pragmaFrag` options."))]
|
||||
struct PragmaAndPragmaFragCannotBeSet;
|
||||
|
||||
#[derive(Debug, Error, Diagnostic)]
|
||||
#[error("importSource cannot be set when runtime is classic.")]
|
||||
#[diagnostic(severity(warning), help("Remove `importSource` option."))]
|
||||
struct ImportSourceCannotBeSet;
|
||||
|
||||
#[derive(Debug, Error, Diagnostic)]
|
||||
#[error("Namespace tags are not supported by default. React's JSX doesn't support namespace tags. You can set `throwIfNamespace: false` to bypass this warning.")]
|
||||
#[diagnostic(severity(warning))]
|
||||
|
|
@ -129,6 +134,9 @@ impl<'a> ReactJsx<'a> {
|
|||
|
||||
pub fn add_react_jsx_runtime_imports(&mut self, program: &mut Program<'a>) {
|
||||
if self.options.runtime.is_classic() {
|
||||
if self.options.import_source != "react" {
|
||||
self.ctx.error(ImportSourceCannotBeSet);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
Passed: 273/1113
|
||||
Passed: 275/1113
|
||||
|
||||
# All Passed:
|
||||
* babel-plugin-transform-numeric-separator
|
||||
|
|
@ -852,7 +852,7 @@ Passed: 273/1113
|
|||
* regression/11061/input.mjs
|
||||
* variable-declaration/non-null-in-optional-chain/input.ts
|
||||
|
||||
# babel-plugin-transform-react-jsx (138/170)
|
||||
# babel-plugin-transform-react-jsx (140/170)
|
||||
* autoImport/after-polyfills-compiled-to-cjs/input.mjs
|
||||
* autoImport/complicated-scope-module/input.js
|
||||
* react/adds-appropriate-newlines-when-using-spread-attribute-babel-7/input.js
|
||||
|
|
@ -864,8 +864,6 @@ Passed: 273/1113
|
|||
* react/optimisation.react.constant-elements/input.js
|
||||
* react/should-add-quotes-es3/input.js
|
||||
* react/should-disallow-spread-children/input.js
|
||||
* react/should-warn-when-importSource-is-set/input.js
|
||||
* react/should-warn-when-importSource-pragma-is-set/input.js
|
||||
* react/wraps-props-in-react-spread-for-first-spread-attributes-babel-7/input.js
|
||||
* react/wraps-props-in-react-spread-for-last-spread-attributes-babel-7/input.js
|
||||
* react/wraps-props-in-react-spread-for-middle-spread-attributes-babel-7/input.js
|
||||
|
|
|
|||
Loading…
Reference in a new issue