Skip to content

Illegal whitespace not found by no-raw-text #203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
draperunner opened this issue Oct 12, 2018 · 2 comments
Closed

Illegal whitespace not found by no-raw-text #203

draperunner opened this issue Oct 12, 2018 · 2 comments

Comments

@draperunner
Copy link
Contributor

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',
      }],
    },
  ],
}
@draperunner draperunner changed the title Missing cases for no-raw-text Illegal whitespace not found by no-raw-text Oct 12, 2018
@AleksandrZhukov
Copy link
Contributor

Fixed here #205

@draperunner
Copy link
Contributor Author

Great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants