Improve error message upon an invalid JSX element

Instead of trying to handle it by itself, the special lexer for JSX should
simply defer to the vanilla lexer if it can't understand the upcoming token.

Fix #1815
Closes gh-1820
3 files changed
tree: d60f9e1dec471193915598e7aabfc394e55182bf
  1. .github/
  2. bin/
  3. dist/
  4. docs/
  5. src/
  6. test/
  7. tools/
  8. .editorconfig
  9. .gitignore
  10. .npmignore
  11. .travis.yml
  12. appveyor.yml
  13. ChangeLog
  14. circle.yml
  15. CONTRIBUTING.md
  16. LICENSE.BSD
  17. package.json
  18. README.md
  19. webpack.config.js
README.md

NPM version npm download Build Status Coverage Status

Esprima (esprima.org, BSD license) is a high performance, standard-compliant ECMAScript parser written in ECMAScript (also popularly known as JavaScript). Esprima is created and maintained by Ariya Hidayat, with the help of many contributors.

Features

API

Esprima can be used to perform lexical analysis (tokenization) or syntactic analysis (parsing) of a JavaScript program.

A simple example on Node.js REPL:

> var esprima = require('esprima');
> var program = 'const answer = 42';

> esprima.tokenize(program);
[ { type: 'Keyword', value: 'const' },
  { type: 'Identifier', value: 'answer' },
  { type: 'Punctuator', value: '=' },
  { type: 'Numeric', value: '42' } ]
  
> esprima.parse(program);
{ type: 'Program',
  body:
   [ { type: 'VariableDeclaration',
       declarations: [Object],
       kind: 'const' } ],
  sourceType: 'script' }

For more information, please read the complete documentation.