Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removing redundant/unnecessary lines as these are defaults (#34587)
- [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` - [ ] Make sure the linting passes by running `yarn lint`
- Loading branch information
1 parent
bf8b835
commit b090004
Showing
25 changed files
with
334 additions
and
366 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
module.exports = { | ||
arrowParens: 'always', | ||
singleQuote: true, | ||
tabWidth: 2, | ||
semi: false, | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,63 @@ | ||
use swc_atoms::JsWord; | ||
use swc_ecmascript::ast::{ | ||
Ident, JSXAttr, JSXAttrName, JSXAttrOrSpread, JSXElementName, JSXOpeningElement, | ||
Ident, JSXAttr, JSXAttrName, JSXAttrOrSpread, JSXElementName, JSXOpeningElement, | ||
}; | ||
use swc_ecmascript::visit::Fold; | ||
|
||
pub fn amp_attributes() -> impl Fold { | ||
AmpAttributePatcher::default() | ||
AmpAttributePatcher::default() | ||
} | ||
|
||
#[derive(Debug, Default)] | ||
struct AmpAttributePatcher {} | ||
|
||
impl Fold for AmpAttributePatcher { | ||
fn fold_jsx_opening_element(&mut self, node: JSXOpeningElement) -> JSXOpeningElement { | ||
let JSXOpeningElement { | ||
name, | ||
mut attrs, | ||
span, | ||
self_closing, | ||
type_args, | ||
} = node; | ||
let n = name.clone(); | ||
|
||
if let JSXElementName::Ident(Ident { sym, .. }) = name { | ||
if sym.starts_with("amp-") { | ||
for i in 0..attrs.len() { | ||
if let JSXAttrOrSpread::JSXAttr(JSXAttr { | ||
name: | ||
JSXAttrName::Ident(Ident { | ||
sym, | ||
span: s, | ||
optional: o, | ||
}), | ||
fn fold_jsx_opening_element(&mut self, node: JSXOpeningElement) -> JSXOpeningElement { | ||
let JSXOpeningElement { | ||
name, | ||
mut attrs, | ||
span, | ||
value, | ||
}) = &attrs[i] | ||
{ | ||
if sym as &str == "className" { | ||
attrs[i] = JSXAttrOrSpread::JSXAttr(JSXAttr { | ||
name: JSXAttrName::Ident(Ident { | ||
sym: JsWord::from("class"), | ||
span: s.clone(), | ||
optional: o.clone(), | ||
}), | ||
span: span.clone(), | ||
value: value.clone(), | ||
}) | ||
self_closing, | ||
type_args, | ||
} = node; | ||
let n = name.clone(); | ||
|
||
if let JSXElementName::Ident(Ident { sym, .. }) = name { | ||
if sym.starts_with("amp-") { | ||
for i in &mut attrs { | ||
if let JSXAttrOrSpread::JSXAttr(JSXAttr { | ||
name: | ||
JSXAttrName::Ident(Ident { | ||
sym, | ||
span: s, | ||
optional: o, | ||
}), | ||
span, | ||
value, | ||
}) = &i | ||
{ | ||
if sym as &str == "className" { | ||
*i = JSXAttrOrSpread::JSXAttr(JSXAttr { | ||
name: JSXAttrName::Ident(Ident { | ||
sym: JsWord::from("class"), | ||
span: *s, | ||
optional: *o, | ||
}), | ||
span: *span, | ||
value: value.clone(), | ||
}) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
JSXOpeningElement { | ||
name: n, | ||
attrs, | ||
span, | ||
self_closing, | ||
type_args, | ||
JSXOpeningElement { | ||
name: n, | ||
attrs, | ||
span, | ||
self_closing, | ||
type_args, | ||
} | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.