Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(babel-plugin-formatjs): support preserving whitespace and newlines
- Loading branch information
Showing
6 changed files
with
225 additions
and
11 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
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
79 changes: 79 additions & 0 deletions
79
packages/babel-plugin-formatjs/tests/fixtures/defineMessagesPreserveWhitespace/actual.js
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 |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// @react-intl project:amazing | ||
import React, {Component} from 'react'; | ||
import {defineMessages, FormattedMessage} from 'react-intl'; | ||
|
||
const msgs = defineMessages({ | ||
header: { | ||
id: 'foo.bar.baz', | ||
defaultMessage: 'Hello World!', | ||
description: 'The default message', | ||
}, | ||
content: { | ||
id: 'foo.bar.biff', | ||
defaultMessage: 'Hello Nurse!', | ||
description: 'Another message', | ||
}, | ||
kittens: { | ||
id: 'app.home.kittens', | ||
description: 'Counts kittens', | ||
defaultMessage: '{count, plural, =0 {😭} one {# kitten} other {# kittens}}', | ||
}, | ||
trailingWhitespace: { | ||
id: 'trailing.ws', | ||
description: 'Whitespace', | ||
defaultMessage: ' Some whitespace ', | ||
}, | ||
escaped: { | ||
id: 'escaped.apostrophe', | ||
description: 'Escaped apostrophe', | ||
defaultMessage: "A quoted value ''{value}'", | ||
}, | ||
newline: { | ||
id: 'newline', | ||
description: 'this is \ | ||
a \ | ||
description', | ||
defaultMessage: 'this is \ | ||
a message', | ||
}, | ||
linebreak: { | ||
id: 'linebreak', | ||
description: 'this is\na\ndescription', | ||
defaultMessage: 'this is\na message', | ||
}, | ||
templateLinebreak: { | ||
id: 'templateLinebreak', | ||
description: `this is | ||
a | ||
description`, | ||
defaultMessage: `this is | ||
a message`, | ||
}, | ||
}); | ||
|
||
export default class Foo extends Component { | ||
render() { | ||
return ( | ||
<div> | ||
<h1> | ||
<FormattedMessage {...msgs.header} /> | ||
</h1> | ||
<p> | ||
<FormattedMessage {...msgs.content} /> | ||
</p> | ||
<p> | ||
<FormattedMessage {...msgs.kittens} /> | ||
</p> | ||
<p> | ||
<FormattedMessage | ||
id="inline.linebreak" | ||
defaultMessage="formatted message | ||
with linebreak" | ||
description="foo | ||
bar" | ||
/> | ||
</p> | ||
</div> | ||
); | ||
} | ||
} |
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