-
Notifications
You must be signed in to change notification settings - Fork 132
Closed
Description
We just encountered a problem which we hoped no-raw-text
would find, but it does not. The problematic case is when extra whitespace is padded around the curly brackets when referencing from JSX from a variable like so:
render() {
const someComponent = <View />
return (<View> { someComponent } </View> )
I am not sure what the proper logic would be, because not all whitespace is illegal (newlines, etc.) You can add the following tests to tests/lib/rules/no-raw-text.js
to handle this case:
const tests = {
valid: [
{
code: `
export default class MyComponent extends Component {
render() {
return (
<View>
<View />
</View>
);
}
}
`,
},
],
invalid: [
{
code: `
export default class MyComponent extends Component {
render() {
const someJsx = <View />
return <View> {someJsx}</View>;
}
}
`,
errors: [{
message: 'Raw whitespace cannot be used outside of a <Text> tag',
}],
},
],
}
Intellicode and AleksandrZhukov
Metadata
Metadata
Assignees
Labels
No labels