-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathespree.javascript.txt
47 lines (39 loc) · 2.92 KB
/
espree.javascript.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
┏━━━━━━━━━━━━┓
┃ ESPREE ┃
┗━━━━━━━━━━━━┛
ALTERNATIVES ==> #See acorn
#Still documented since it used by ESLint
VERSION ==> #10.3.0
DIFFERENCES FROM ACORN ==> #Built on top of acorn but:
# - OPTS: different names and fewer options
# - no plugins
# - TOP_NODE.comments instead of OPTS.onComment()
# - trim whitespaces|comments for PROGRAM.loc|range
# - TOKENs use Esprima format
┌────────────┐
│ PARSER │
└────────────┘
ESPREE.parse('JS'[, OPTS]) #Like ACORN.parse('JS'), but with different OPTS:
->TOP_NODE # - ecmaVersion (def: 5) (can be 'latest')
# - sourceType 'module' (ES modules), 'script' (browser, def) or 'commonjs'
# - loc: like ACORN OPTS.locations
# - range: like ACORN OPTS.ranges
# - comment BOOL (def: false): set TOP_NODE.comments COMMENT_ARR
# - tokens BOOL (def: false): set TOP_NODE.tokens TOKEN_ARR
# - allowReserved BOOL (def: false):
# - allow reserved words
# - only if ecmaVersion 3
# - ecmaFeatures:
# - impliedStrict BOOL (def: false): imply 'use strict'
# - globalReturn BOOL (def: false unless sourceType 'commonjs'): use ACORN OPTS.allowReturnOutsideFunction
# - jsx BOOL (def: false): use acorn-jsx
┌───────────────┐
│ TOKENIZER │
└───────────────┘
ESPREE.tokenize('JS'[, OPTS]) #Like [...ACORN.tokenizer('JS')], but:
->TOKEN_ARR # - converts to Esprima token format OBJ:
# - type STR, among: Null, Boolean, Numeric, String, RegularExpression, Template,
# Identifier, Keyword, Punctuator, JSXText, JSXIdentifier, <end>
# - value STR
# - start|end|range|loc
# - same OPTS as above except tokens