Skip to content
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

fix: fix read-only React props error position #478

Merged
merged 1 commit into from Apr 16, 2021
Merged

fix: fix read-only React props error position #478

merged 1 commit into from Apr 16, 2021

Conversation

mrtnzlml
Copy link
Contributor

Example from our repo before this change:

error: Props must be $ReadOnly (flowtype/require-readonly-react-props) at src/kochka.com.mx/src/Layout.js:39:7:
  37 |   return (
  38 |     <>
> 39 |       <Head>
     |       ^
  40 |         <title>KOCHKA café · {props.title}</title>
  41 |       </Head>
  42 |

As you can see the error seems to be wrongly positioned. This is even more awkward when you want to suppress this error (and you have to do it on some unrelated line).

After this fix:

error: Props must be $ReadOnly (flowtype/require-readonly-react-props) at src/kochka.com.mx/src/Layout.js:28:39:
  26 |     };
  27 |
> 28 | export default function Layout(props: Props): React.Node {
     |                                       ^
  29 |   if (props.withHiddenTitle === true) {
  30 |     invariant(props.title == null, 'Cannot use `title` together with `withHiddenTitle` property.');
  31 |     invariant(

Example from our repo before this change:

```
error: Props must be $ReadOnly (flowtype/require-readonly-react-props) at src/kochka.com.mx/src/Layout.js:39:7:
  37 |   return (
  38 |     <>
> 39 |       <Head>
     |       ^
  40 |         <title>KOCHKA café · {props.title}</title>
  41 |       </Head>
  42 |
```

As you can see the error seems to be wrongly positioned. This is even more awkward when you want to suppress this error (and you have to do it on some unrelated line).

After this fix:

```
error: Props must be $ReadOnly (flowtype/require-readonly-react-props) at src/kochka.com.mx/src/Layout.js:28:39:
  26 |     };
  27 |
> 28 | export default function Layout(props: Props): React.Node {
     |                                       ^
  29 |   if (props.withHiddenTitle === true) {
  30 |     invariant(props.title == null, 'Cannot use `title` together with `withHiddenTitle` property.');
  31 |     invariant(
```
@mrtnzlml
Copy link
Contributor Author

Side note: we are using adeira/eslint-fixtures-tester for better Eslint rules testing. It has the line/column testing integrated so it's easy to capture such things. I think it's worth considering it even though it would require more changes to this repo (for example the README generation).

@gajus gajus merged commit 0488fcb into gajus:master Apr 16, 2021
@gajus
Copy link
Owner

gajus commented Apr 16, 2021

🎉 This PR is included in version 5.7.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@gajus gajus added the released label Apr 16, 2021
@mrtnzlml mrtnzlml deleted the react_read_only_props_error_position branch April 16, 2021 20:27
mrtnzlml added a commit to adeira/universe that referenced this pull request Apr 16, 2021
kodiakhq bot pushed a commit to adeira/universe that referenced this pull request Apr 17, 2021
adeira-github-bot pushed a commit to adeira/eslint-config-adeira that referenced this pull request Apr 17, 2021
This release includes some fixes for our codebase, see:

- gajus/eslint-plugin-flowtype#477
- gajus/eslint-plugin-flowtype#478

adeira-source-id: a16fb4f4e7da1a952452a75cb4c4cc58f92e69bf
adeira-github-bot pushed a commit to adeira/sx-design that referenced this pull request Apr 17, 2021
This release includes some fixes for our codebase, see:

- gajus/eslint-plugin-flowtype#477
- gajus/eslint-plugin-flowtype#478

adeira-source-id: a16fb4f4e7da1a952452a75cb4c4cc58f92e69bf
mrtnzlml added a commit to mrtnzlml-archive/kochka.com.mx that referenced this pull request May 4, 2021
This release includes some fixes for our codebase, see:

- gajus/eslint-plugin-flowtype#477
- gajus/eslint-plugin-flowtype#478

adeira-source-id: a16fb4f4e7da1a952452a75cb4c4cc58f92e69bf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants