This repository was archived by the owner on Jan 1, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +3
-4
lines changed
Expand file tree Collapse file tree 2 files changed +3
-4
lines changed Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ export function converter(node: object | null | undefined): unknown {
6868 if ( isStringLiteral ( node ) ) {
6969 const { value } = node
7070 if ( / " / . test ( value ) ) {
71- throw new Error ( 'Invalid value is included. ')
71+ return value . replace ( / " / g , '\\" ')
7272 }
7373
7474 return value
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ const DEFAULT_THRESHOLD = 1024
1414export function ObjectExpression (
1515 path : NodePath < ObjectExpression > ,
1616 state : PluginState
17- ) {
17+ ) : void {
1818 try {
1919 const obj = converter ( path . node )
2020 const json = JSON . stringify ( obj )
@@ -23,8 +23,7 @@ export function ObjectExpression(
2323 // it simply isn't worth it to convert into the AST objects that are too small.
2424 // so, this plugin only convert large objects by default.
2525 const { minJSONStringSize } = state . opts
26- const threshold =
27- minJSONStringSize !== undefined ? minJSONStringSize : DEFAULT_THRESHOLD
26+ const threshold = minJSONStringSize ?? DEFAULT_THRESHOLD
2827 if ( escapedJson . length < threshold ) {
2928 return
3029 }
You can’t perform that action at this time.
0 commit comments