es6-plato
es6-plato copied to clipboard
`SyntaxError: Unexpected token` when encountering React Fragment shorthand syntax
SyntaxError: Unexpected token (112:13)
at Parser.pp$5.raise (./node_modules/babylon/lib/index.js:4454:13)
at Parser.pp.unexpected (./node_modules/babylon/lib/index.js:1761:8)
at Parser.pp$9.jsxParseIdentifier (./node_modules/babylon/lib/index.js:7029:10)
at Parser.pp$9.jsxParseNamespacedName (./node_modules/babylon/lib/index.js:7040:19)
at Parser.pp$9.jsxParseElementName (./node_modules/babylon/lib/index.js:7055:19)
at Parser.pp$9.jsxParseOpeningElementAt (./node_modules/babylon/lib/index.js:7145:20)
at Parser.pp$9.jsxParseElementAt (./node_modules/babylon/lib/index.js:7169:29)
at Parser.pp$9.jsxParseElement (./node_modules/babylon/lib/index.js:7224:15)
at Parser.parseExprAtom (./node_modules/babylon/lib/index.js:7236:21)
at Parser.pp$3.parseExprSubscripts (./node_modules/babylon/lib/index.js:3494:19)
when it encounters Babel 7's shorthand of React.Fragment, <>
.
Interesting! I probably need to update some dependencies. looks like the break is way down there in babylon. Can you show me the code it was trying to parse it that broke it, or maybe throw up a repo that reproduces this? man that could really help me fix this! Especially that second thing!!
@the-simian hello, I have the same problem. Can you fix it? THX ^_^
@luckykun can you post me a snippet of code you got that's breaking so I can use it to test? It might be in the underlying parser also.
@luckykun I'll be updating the underlying parser very soon might fix this.
(possibly duplicate of #79 )
I updated the underlying parser, lets see if this is still an issue @luckykun
Yes, still an issue. It throws the error for each file.
thanks for the update @rayno , can you post a snippet that throws so I can reproduce your exact usecase?
Environment: Windows 10 64-bit NodeJS: v10.15.0
file: test.js
import React from 'react'
function Comp() {
return (
<>
<h1>Hello</h1>
<p>Text</p>
</>
)
}
file: test-plato.js
(taken from npm page)
let plato = require('es6-plato')
let src = './test.js'
let outputDir = './plato'
let lintRules = {
rules: {
indent: [2, 'tab'],
quotes: [2, 'single'],
semi: [2, 'always'],
'no-console': [1],
curly: ['error'],
'no-dupe-keys': 2,
'func-names': [1, 'always'],
},
env: {
es6: true,
},
globals: ['require'],
parserOptions: {
sourceType: 'module',
ecmaFeatures: {
jsx: true,
modules: true,
},
},
}
let complexityRules = {}
let platoArgs = {
title: 'example',
eslint: lintRules,
complexity: complexityRules,
}
return plato.inspect(src, outputDir, platoArgs)
Console output from node ./test-plato.js
(same with no lintRules):
Processing 1 files
Error reading file test.js: SyntaxError: Unexpected token (5:5)
SyntaxError: Unexpected token (5:5)
at Parser.pp$5.raise (C:\Users\rarshinkov\projects\test-project\node_modules\babylon\lib\index.js:4454:13)
at Parser.pp.unexpected (C:\Users\rarshinkov\projects\test-project\node_modules\babylon\lib\index.js:1761:8)
at Parser.pp$9.jsxParseIdentifier (C:\Users\rarshinkov\projects\test-project\node_modules\babylon\lib\index.js:7029:10)
at Parser.pp$9.jsxParseNamespacedName (C:\Users\rarshinkov\projects\test-project\node_modules\babylon\lib\index.js:7040:19)
at Parser.pp$9.jsxParseElementName (C:\Users\rarshinkov\projects\test-project\node_modules\babylon\lib\index.js:7055:19)
at Parser.pp$9.jsxParseOpeningElementAt (C:\Users\rarshinkov\projects\test-project\node_modules\babylon\lib\index.js:7145:20)
at Parser.pp$9.jsxParseElementAt (C:\Users\rarshinkov\projects\test-project\node_modules\babylon\lib\index.js:7169:29)
at Parser.pp$9.jsxParseElement (C:\Users\rarshinkov\projects\test-project\node_modules\babylon\lib\index.js:7224:15)
at Parser.parseExprAtom (C:\Users\rarshinkov\projects\test-project\node_modules\babylon\lib\index.js:7236:21)
at Parser.pp$3.parseExprSubscripts (C:\Users\rarshinkov\projects\test-project\node_modules\babylon\lib\index.js:3494:19)
@rayno, thank you!
I have the same problem
I have the same problem. Any chance this is going to be fixed? Or an alternative? 🤔