-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
error Parsing error: Unexpected token < #447
Comments
Even though the yields a fully functional project (on the master branch). So, the |
For one, React needs to be in scope for jsx to work, and you aren't requiring React in any of those files. |
My react is working fine. I did a fresh build off a |
The following is my /**
* eslint.json: this file provides a configuration of rules that eslint will
* implement, to validate 'jsx' files, when imported via the
* '-c [path/to/eslint.json]' flag.
*
* Note: eslint rules, and options are available:
*
* https://github.com/yannickcr/eslint-plugin-react#configuration
* http://eslint.org/docs/rules/
*/
{
"plugins": [
"react"
],
"ecmaFeatures": {
"jsx": true,
"modules": true
},
"rules": {
"react/display-name": 1,
"react/forbid-prop-types": 1,
"react/jsx-boolean-value": 1,
"react/jsx-closing-bracket-location": 1,
"react/jsx-curly-spacing": 1,
"react/jsx-handler-names": 1,
"react/jsx-indent-props": 1,
"react/jsx-key": 1,
"react/jsx-max-props-per-line": 1,
"react/jsx-no-bind": 1,
"react/jsx-no-duplicate-props": 1,
"react/jsx-no-literals": 1,
"react/jsx-no-undef": 1,
"react/jsx-pascal-case": 1,
"react/jsx-quotes": 1,
"react/jsx-sort-prop-types": 1,
"react/jsx-sort-props": 1,
"react/jsx-uses-react": 1,
"react/jsx-uses-vars": 1,
"react/no-danger": 1,
"react/no-did-mount-set-state": 1,
"react/no-did-update-set-state": 1,
"react/no-direct-mutation-state": 1,
"react/no-multi-comp": 1,
"react/no-set-state": 1,
"react/no-unknown-property": 1,
"react/prefer-es6-class": 1,
"react/prop-types": 1,
"react/react-in-jsx-scope": 1,
"react/require-extension": 1,
"react/self-closing-comp": 1,
"react/sort-comp": 1,
"react/wrap-multilines": 1
}
} |
Seems your problem come from here. By doing this you are always installing the latest ESLint release, which can introduce some breaking changes if a new major version is released... and this is what happened a few days ago with the release of ESLint 2.0.0. Since ESLint 2.0.0 the parser options format changed (migration guide), so with your current configuration the JSX/module support is not enabled. You should replace
by
Another solution is to use
Generally speaking you should at least fix the major versions of your dependencies to avoid future breaking changes, for example:
|
@yannickcr, works, thank you! I will be implementing your additional suggestion, by installing all my package dependencies, at major versions. |
Got the same problem and tried this:
Did not want to go with the babel-eslint fix because I'm using react native I think that's an unnecesary extra step to transpile it. |
But can you post your full .eslintrc config file, the code that trigger the error and the eslint/eslint-plugin-react versions ? Thanks. |
Yup that's true hehe, sorry about the misconception. Here's my .eslint:
Here's my package.json:
So I'm basically learning React Native and wanted it to add eslint to my project, the code that fails is the tutorial code from React Native:
I added Regards, |
I am using webpack like this :
Do we need 2 files ? an where do both live ? I am hoping for project root.I am almost there with linting JSX in .js files in my react project its just failing to spot the Clarity would be most welcome TY |
@landed1 See http://eslint.org/docs/user-guide/configuring. you usually only need |
TY |
In .eslintrc replace "ecmaFeatures": {
"jsx": true,
"modules": true
} with "parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true,
"modules": true,
"experimentalObjectRestSpread": true
} |
I've tried the different versions of your configurations without success. But I follow this simple tutorial and it works, I hope it can helps you. 😄 |
ecmaVersion is optional |
I think ecmaVersion does need to be |
// redux constants
export const PAGE_SIZE = 3;
// [eslint] Parsing error: The keyword 'export' is reserved
|
@xgqfrms-GitHub That's really related to eslint core, and not eslint-plugin-react, so I'm not sure why you posted that here. |
I just find this place by using google, and it works for me! |
Your note doesn't explain how the problem was fixed - it just provides an eslintrc and a warning that can't appear if that eslintrc is used, that core eslint's docs would fix, and that has nothing to do whatsoever with this repo. |
babel-eslint |
@hybrisCole 's suggestion worked for me - had to restart to Atom to pick up the changes 😅 |
I'm having this same issue.VScode's finds some eslint configuration that comes when you use create-react-app, and I'm getting this error. Any help is appreciated. |
@odm275 can you post your full I've been using VSCode as my editor for a React project that I originally generated from |
I got the same error {
"plugins": [
"react"
],
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true,
"modules": true,
"experimentalObjectRestSpread": true
}
},
"env": {
"es6": true,
"browser": true,
"node": true,
"mocha": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended"
],
"rules": {
"strict": [2, "safe"],
"no-debugger": 2,
"brace-style": [
2,
"1tbs",
{ "allowSingleLine": true }
],
"no-trailing-spaces": 2,
"keyword-spacing": 2,
"space-before-function-paren": [
2,
"never"
],
"spaced-comment": [2, "always"],
"vars-on-top": 2,
"no-undef": 2,
"no-undefined": 2,
"comma-dangle": [2, "never"],
"quotes": [2, "single"],
"semi": [2, "always"],
"guard-for-in": 2,
"no-eval": 2,
"no-with": 2,
"valid-typeof": 2,
"no-unused-vars": 2,
"no-continue": 1,
"no-extra-semi": 1,
"no-unreachable": 1,
"no-unused-expressions": 1,
"no-magic-numbers": 1,
"max-len": [1, 80, 4],
"react/prefer-es6-class": 1
} |
I’m not sure, but that’s an eslint issue, not an issue with this plugin. |
I added to the .eslintrc and it doesn't help |
…slint-loader, so have to configure eslintrc as well. Takes a while to figure out this. jsx-eslint/eslint-plugin-react#447
"parser": "babel-eslint" in .eslintrc.json solved my problem |
eslint has fixed its issue anyways. |
Fixed by setting ecmaVersion and sourceType "eslintConfig": {
"extends": "google",
"parserOptions": {
"ecmaVersion": 7,
"sourceType": "module"
}
} |
sourceType: "module" works. If you're using VSCode or Atom, restarting the editor after making the change helps. It should pick it up after. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Did anyone try this with their
I did that and it works perfectly fine for using something like |
I've installed the following within my
.travis.yml
:However, implementing
eslint
on my jsx templates, generate the following traceback errors, from my travis ci:This is strange, because nothing substantial has changed in my jsx templates. And just last week, my
eslint
, had no problems linting within my travis ci. Perhaps latest changes within this repo, has broke my linting process?Note: travis ci build logs can be reviewed, to see when
eslint
refused to accept my jsx syntax.The text was updated successfully, but these errors were encountered: