-
Notifications
You must be signed in to change notification settings - Fork 216
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Description
Steps to reproduce:
npx create-react-native-library@latest awesome-library
cd awesome-library
- Rename
example/src/App.tsx
toexample/src/App.jsx
- Modify
example/src/App.jsx
.
- const [result, setResult] = React.useState<number | undefined>();
+ const [result, setResult] = React.useState();
- Modify
package.json
- "lint": "eslint \"**/*.{js,ts,tsx}\"",
+ "lint": "eslint \"**/*.{js,jsx,ts,tsx}\"",
- Run
yarn lint
MacBook-Pro:awesome-library davidangulo$ yarn lint
yarn run v1.22.19
$ eslint "**/*.{js,jsx,ts,tsx}"
/Users/davidangulo/Desktop/apps/awesome-library/example/src/App.jsx
14:5 error Parsing error: Unexpected token <
Expectations:
Should not throw an error.
Why this happens?
As mentioned in #432, this uses an old eslint config which does not have jsx
defined so you have to manually add it.
https://github.com/facebook/react-native/blob/v0.71.12/packages/eslint-config-react-native-community/index.js#L37-L68
Where in the latest version jsx
is defined.
https://github.com/facebook/react-native/blob/v0.72.0/packages/eslint-config-react-native-community/index.js#L52-L55
Temporary fix:
Add to eslintConfig
"overrides": [
{
"files": [
"*.jsx"
],
"parser": "@babel/eslint-parser"
}
]
Permanent fix:
Migrate @react-native-community/eslint-config
to @react-native/eslint-config
.
Packages
- create-react-native-library
- react-native-builder-bob
Selected options
--
Link to repro
No response
Environment
--
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working