protobufjs 6.11.1 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (254) hide show
  1. package/README.md +7 -174
  2. package/dist/light/protobuf.js +40 -16
  3. package/dist/light/protobuf.js.map +1 -1
  4. package/dist/light/protobuf.min.js +3 -3
  5. package/dist/light/protobuf.min.js.map +1 -1
  6. package/dist/minimal/protobuf.js +27 -10
  7. package/dist/minimal/protobuf.js.map +1 -1
  8. package/dist/minimal/protobuf.min.js +3 -3
  9. package/dist/minimal/protobuf.min.js.map +1 -1
  10. package/dist/protobuf.js +109 -46
  11. package/dist/protobuf.js.map +1 -1
  12. package/dist/protobuf.min.js +3 -3
  13. package/dist/protobuf.min.js.map +1 -1
  14. package/index.d.ts +1 -1
  15. package/package.json +11 -30
  16. package/scripts/postinstall.js +0 -3
  17. package/src/converter.js +1 -1
  18. package/src/decoder.js +4 -3
  19. package/src/field.js +3 -0
  20. package/src/namespace.js +1 -2
  21. package/src/parse.js +38 -14
  22. package/src/roots.js +1 -1
  23. package/src/tokenize.js +31 -16
  24. package/src/util/minimal.js +24 -7
  25. package/src/util.js +3 -0
  26. package/src/wrappers.js +2 -2
  27. package/CHANGELOG.md +0 -1014
  28. package/bin/pbjs +0 -6
  29. package/bin/pbts +0 -6
  30. package/cli/LICENSE +0 -33
  31. package/cli/README.md +0 -174
  32. package/cli/bin/pbjs +0 -6
  33. package/cli/bin/pbts +0 -6
  34. package/cli/index.d.ts +0 -3
  35. package/cli/index.js +0 -3
  36. package/cli/lib/tsd-jsdoc/LICENSE +0 -21
  37. package/cli/lib/tsd-jsdoc/README.md +0 -23
  38. package/cli/lib/tsd-jsdoc/plugin.js +0 -21
  39. package/cli/lib/tsd-jsdoc/publish.js +0 -705
  40. package/cli/lib/tsd-jsdoc.json +0 -18
  41. package/cli/node_modules/.package-lock.json +0 -256
  42. package/cli/node_modules/acorn/CHANGELOG.md +0 -620
  43. package/cli/node_modules/acorn/LICENSE +0 -21
  44. package/cli/node_modules/acorn/README.md +0 -269
  45. package/cli/node_modules/acorn/bin/acorn +0 -4
  46. package/cli/node_modules/acorn/dist/acorn.d.ts +0 -209
  47. package/cli/node_modules/acorn/dist/acorn.js +0 -5186
  48. package/cli/node_modules/acorn/dist/acorn.js.map +0 -1
  49. package/cli/node_modules/acorn/dist/acorn.mjs +0 -5155
  50. package/cli/node_modules/acorn/dist/acorn.mjs.d.ts +0 -2
  51. package/cli/node_modules/acorn/dist/acorn.mjs.map +0 -1
  52. package/cli/node_modules/acorn/dist/bin.js +0 -64
  53. package/cli/node_modules/acorn/package.json +0 -35
  54. package/cli/node_modules/acorn-jsx/LICENSE +0 -19
  55. package/cli/node_modules/acorn-jsx/README.md +0 -40
  56. package/cli/node_modules/acorn-jsx/index.js +0 -488
  57. package/cli/node_modules/acorn-jsx/package.json +0 -27
  58. package/cli/node_modules/acorn-jsx/xhtml.js +0 -255
  59. package/cli/node_modules/balanced-match/.npmignore +0 -5
  60. package/cli/node_modules/balanced-match/LICENSE.md +0 -21
  61. package/cli/node_modules/balanced-match/README.md +0 -91
  62. package/cli/node_modules/balanced-match/index.js +0 -59
  63. package/cli/node_modules/balanced-match/package.json +0 -49
  64. package/cli/node_modules/brace-expansion/LICENSE +0 -21
  65. package/cli/node_modules/brace-expansion/README.md +0 -129
  66. package/cli/node_modules/brace-expansion/index.js +0 -201
  67. package/cli/node_modules/brace-expansion/package.json +0 -47
  68. package/cli/node_modules/concat-map/.travis.yml +0 -4
  69. package/cli/node_modules/concat-map/LICENSE +0 -18
  70. package/cli/node_modules/concat-map/README.markdown +0 -62
  71. package/cli/node_modules/concat-map/example/map.js +0 -6
  72. package/cli/node_modules/concat-map/index.js +0 -13
  73. package/cli/node_modules/concat-map/package.json +0 -43
  74. package/cli/node_modules/concat-map/test/map.js +0 -39
  75. package/cli/node_modules/deep-is/.npmignore +0 -1
  76. package/cli/node_modules/deep-is/.travis.yml +0 -6
  77. package/cli/node_modules/deep-is/LICENSE +0 -22
  78. package/cli/node_modules/deep-is/README.markdown +0 -70
  79. package/cli/node_modules/deep-is/example/cmp.js +0 -11
  80. package/cli/node_modules/deep-is/index.js +0 -102
  81. package/cli/node_modules/deep-is/package.json +0 -61
  82. package/cli/node_modules/deep-is/test/NaN.js +0 -16
  83. package/cli/node_modules/deep-is/test/cmp.js +0 -23
  84. package/cli/node_modules/deep-is/test/neg-vs-pos-0.js +0 -15
  85. package/cli/node_modules/escodegen/LICENSE.BSD +0 -21
  86. package/cli/node_modules/escodegen/README.md +0 -84
  87. package/cli/node_modules/escodegen/bin/escodegen.js +0 -77
  88. package/cli/node_modules/escodegen/bin/esgenerate.js +0 -64
  89. package/cli/node_modules/escodegen/escodegen.js +0 -2647
  90. package/cli/node_modules/escodegen/package.json +0 -62
  91. package/cli/node_modules/eslint-visitor-keys/CHANGELOG.md +0 -25
  92. package/cli/node_modules/eslint-visitor-keys/LICENSE +0 -201
  93. package/cli/node_modules/eslint-visitor-keys/README.md +0 -98
  94. package/cli/node_modules/eslint-visitor-keys/lib/index.js +0 -81
  95. package/cli/node_modules/eslint-visitor-keys/lib/visitor-keys.json +0 -284
  96. package/cli/node_modules/eslint-visitor-keys/package.json +0 -40
  97. package/cli/node_modules/espree/CHANGELOG.md +0 -509
  98. package/cli/node_modules/espree/LICENSE +0 -25
  99. package/cli/node_modules/espree/README.md +0 -233
  100. package/cli/node_modules/espree/espree.js +0 -177
  101. package/cli/node_modules/espree/lib/ast-node-types.js +0 -96
  102. package/cli/node_modules/espree/lib/espree.js +0 -286
  103. package/cli/node_modules/espree/lib/features.js +0 -29
  104. package/cli/node_modules/espree/lib/options.js +0 -106
  105. package/cli/node_modules/espree/lib/token-translator.js +0 -263
  106. package/cli/node_modules/espree/lib/visitor-keys.js +0 -123
  107. package/cli/node_modules/espree/package.json +0 -64
  108. package/cli/node_modules/esprima/ChangeLog +0 -235
  109. package/cli/node_modules/esprima/LICENSE.BSD +0 -21
  110. package/cli/node_modules/esprima/README.md +0 -46
  111. package/cli/node_modules/esprima/bin/esparse.js +0 -139
  112. package/cli/node_modules/esprima/bin/esvalidate.js +0 -236
  113. package/cli/node_modules/esprima/dist/esprima.js +0 -6709
  114. package/cli/node_modules/esprima/package.json +0 -112
  115. package/cli/node_modules/estraverse/.jshintrc +0 -16
  116. package/cli/node_modules/estraverse/LICENSE.BSD +0 -19
  117. package/cli/node_modules/estraverse/README.md +0 -153
  118. package/cli/node_modules/estraverse/estraverse.js +0 -801
  119. package/cli/node_modules/estraverse/gulpfile.js +0 -70
  120. package/cli/node_modules/estraverse/package.json +0 -40
  121. package/cli/node_modules/esutils/LICENSE.BSD +0 -19
  122. package/cli/node_modules/esutils/README.md +0 -174
  123. package/cli/node_modules/esutils/lib/ast.js +0 -144
  124. package/cli/node_modules/esutils/lib/code.js +0 -135
  125. package/cli/node_modules/esutils/lib/keyword.js +0 -165
  126. package/cli/node_modules/esutils/lib/utils.js +0 -33
  127. package/cli/node_modules/esutils/package.json +0 -44
  128. package/cli/node_modules/fast-levenshtein/LICENSE.md +0 -25
  129. package/cli/node_modules/fast-levenshtein/README.md +0 -104
  130. package/cli/node_modules/fast-levenshtein/levenshtein.js +0 -136
  131. package/cli/node_modules/fast-levenshtein/package.json +0 -39
  132. package/cli/node_modules/fs.realpath/LICENSE +0 -43
  133. package/cli/node_modules/fs.realpath/README.md +0 -33
  134. package/cli/node_modules/fs.realpath/index.js +0 -66
  135. package/cli/node_modules/fs.realpath/old.js +0 -303
  136. package/cli/node_modules/fs.realpath/package.json +0 -26
  137. package/cli/node_modules/glob/LICENSE +0 -21
  138. package/cli/node_modules/glob/README.md +0 -375
  139. package/cli/node_modules/glob/changelog.md +0 -67
  140. package/cli/node_modules/glob/common.js +0 -240
  141. package/cli/node_modules/glob/glob.js +0 -790
  142. package/cli/node_modules/glob/package.json +0 -46
  143. package/cli/node_modules/glob/sync.js +0 -486
  144. package/cli/node_modules/inflight/LICENSE +0 -15
  145. package/cli/node_modules/inflight/README.md +0 -37
  146. package/cli/node_modules/inflight/inflight.js +0 -54
  147. package/cli/node_modules/inflight/package.json +0 -29
  148. package/cli/node_modules/inherits/LICENSE +0 -16
  149. package/cli/node_modules/inherits/README.md +0 -42
  150. package/cli/node_modules/inherits/inherits.js +0 -9
  151. package/cli/node_modules/inherits/inherits_browser.js +0 -27
  152. package/cli/node_modules/inherits/package.json +0 -29
  153. package/cli/node_modules/levn/LICENSE +0 -22
  154. package/cli/node_modules/levn/README.md +0 -196
  155. package/cli/node_modules/levn/lib/cast.js +0 -298
  156. package/cli/node_modules/levn/lib/coerce.js +0 -285
  157. package/cli/node_modules/levn/lib/index.js +0 -22
  158. package/cli/node_modules/levn/lib/parse-string.js +0 -113
  159. package/cli/node_modules/levn/lib/parse.js +0 -102
  160. package/cli/node_modules/levn/package.json +0 -47
  161. package/cli/node_modules/minimatch/LICENSE +0 -15
  162. package/cli/node_modules/minimatch/README.md +0 -209
  163. package/cli/node_modules/minimatch/minimatch.js +0 -923
  164. package/cli/node_modules/minimatch/package.json +0 -30
  165. package/cli/node_modules/once/LICENSE +0 -15
  166. package/cli/node_modules/once/README.md +0 -79
  167. package/cli/node_modules/once/once.js +0 -42
  168. package/cli/node_modules/once/package.json +0 -33
  169. package/cli/node_modules/optionator/CHANGELOG.md +0 -56
  170. package/cli/node_modules/optionator/LICENSE +0 -22
  171. package/cli/node_modules/optionator/README.md +0 -238
  172. package/cli/node_modules/optionator/lib/help.js +0 -260
  173. package/cli/node_modules/optionator/lib/index.js +0 -465
  174. package/cli/node_modules/optionator/lib/util.js +0 -54
  175. package/cli/node_modules/optionator/package.json +0 -44
  176. package/cli/node_modules/path-is-absolute/index.js +0 -20
  177. package/cli/node_modules/path-is-absolute/license +0 -21
  178. package/cli/node_modules/path-is-absolute/package.json +0 -43
  179. package/cli/node_modules/path-is-absolute/readme.md +0 -59
  180. package/cli/node_modules/prelude-ls/CHANGELOG.md +0 -99
  181. package/cli/node_modules/prelude-ls/LICENSE +0 -22
  182. package/cli/node_modules/prelude-ls/README.md +0 -15
  183. package/cli/node_modules/prelude-ls/lib/Func.js +0 -65
  184. package/cli/node_modules/prelude-ls/lib/List.js +0 -686
  185. package/cli/node_modules/prelude-ls/lib/Num.js +0 -130
  186. package/cli/node_modules/prelude-ls/lib/Obj.js +0 -154
  187. package/cli/node_modules/prelude-ls/lib/Str.js +0 -92
  188. package/cli/node_modules/prelude-ls/lib/index.js +0 -178
  189. package/cli/node_modules/prelude-ls/package.json +0 -52
  190. package/cli/node_modules/rimraf/CHANGELOG.md +0 -65
  191. package/cli/node_modules/rimraf/LICENSE +0 -15
  192. package/cli/node_modules/rimraf/README.md +0 -101
  193. package/cli/node_modules/rimraf/bin.js +0 -68
  194. package/cli/node_modules/rimraf/package.json +0 -32
  195. package/cli/node_modules/rimraf/rimraf.js +0 -360
  196. package/cli/node_modules/source-map/CHANGELOG.md +0 -301
  197. package/cli/node_modules/source-map/LICENSE +0 -28
  198. package/cli/node_modules/source-map/README.md +0 -742
  199. package/cli/node_modules/source-map/dist/source-map.debug.js +0 -3234
  200. package/cli/node_modules/source-map/dist/source-map.js +0 -3233
  201. package/cli/node_modules/source-map/dist/source-map.min.js +0 -2
  202. package/cli/node_modules/source-map/dist/source-map.min.js.map +0 -1
  203. package/cli/node_modules/source-map/lib/array-set.js +0 -121
  204. package/cli/node_modules/source-map/lib/base64-vlq.js +0 -140
  205. package/cli/node_modules/source-map/lib/base64.js +0 -67
  206. package/cli/node_modules/source-map/lib/binary-search.js +0 -111
  207. package/cli/node_modules/source-map/lib/mapping-list.js +0 -79
  208. package/cli/node_modules/source-map/lib/quick-sort.js +0 -114
  209. package/cli/node_modules/source-map/lib/source-map-consumer.js +0 -1145
  210. package/cli/node_modules/source-map/lib/source-map-generator.js +0 -425
  211. package/cli/node_modules/source-map/lib/source-node.js +0 -413
  212. package/cli/node_modules/source-map/lib/util.js +0 -488
  213. package/cli/node_modules/source-map/package.json +0 -73
  214. package/cli/node_modules/source-map/source-map.d.ts +0 -98
  215. package/cli/node_modules/source-map/source-map.js +0 -8
  216. package/cli/node_modules/tmp/CHANGELOG.md +0 -288
  217. package/cli/node_modules/tmp/LICENSE +0 -21
  218. package/cli/node_modules/tmp/README.md +0 -365
  219. package/cli/node_modules/tmp/lib/tmp.js +0 -780
  220. package/cli/node_modules/tmp/package.json +0 -58
  221. package/cli/node_modules/type-check/LICENSE +0 -22
  222. package/cli/node_modules/type-check/README.md +0 -210
  223. package/cli/node_modules/type-check/lib/check.js +0 -126
  224. package/cli/node_modules/type-check/lib/index.js +0 -16
  225. package/cli/node_modules/type-check/lib/parse-type.js +0 -196
  226. package/cli/node_modules/type-check/package.json +0 -40
  227. package/cli/node_modules/word-wrap/LICENSE +0 -21
  228. package/cli/node_modules/word-wrap/README.md +0 -182
  229. package/cli/node_modules/word-wrap/index.d.ts +0 -50
  230. package/cli/node_modules/word-wrap/index.js +0 -46
  231. package/cli/node_modules/word-wrap/package.json +0 -77
  232. package/cli/node_modules/wrappy/LICENSE +0 -15
  233. package/cli/node_modules/wrappy/README.md +0 -36
  234. package/cli/node_modules/wrappy/package.json +0 -29
  235. package/cli/node_modules/wrappy/wrappy.js +0 -33
  236. package/cli/package.json +0 -8
  237. package/cli/package.standalone.json +0 -32
  238. package/cli/pbjs.d.ts +0 -9
  239. package/cli/pbjs.js +0 -330
  240. package/cli/pbts.d.ts +0 -9
  241. package/cli/pbts.js +0 -197
  242. package/cli/targets/json-module.js +0 -38
  243. package/cli/targets/json.js +0 -8
  244. package/cli/targets/proto.js +0 -326
  245. package/cli/targets/proto2.js +0 -10
  246. package/cli/targets/proto3.js +0 -10
  247. package/cli/targets/static-module.js +0 -29
  248. package/cli/targets/static.js +0 -711
  249. package/cli/util.js +0 -183
  250. package/cli/wrappers/amd.js +0 -7
  251. package/cli/wrappers/closure.js +0 -7
  252. package/cli/wrappers/commonjs.js +0 -7
  253. package/cli/wrappers/default.js +0 -15
  254. package/cli/wrappers/es6.js +0 -5
@@ -1,233 +0,0 @@
1
- [![npm version](https://img.shields.io/npm/v/espree.svg)](https://www.npmjs.com/package/espree)
2
- [![Build Status](https://travis-ci.org/eslint/espree.svg?branch=master)](https://travis-ci.org/eslint/espree)
3
- [![npm downloads](https://img.shields.io/npm/dm/espree.svg)](https://www.npmjs.com/package/espree)
4
- [![Bountysource](https://www.bountysource.com/badge/tracker?tracker_id=9348450)](https://www.bountysource.com/trackers/9348450-eslint?utm_source=9348450&utm_medium=shield&utm_campaign=TRACKER_BADGE)
5
-
6
- # Espree
7
-
8
- Espree started out as a fork of [Esprima](http://esprima.org) v1.2.2, the last stable published released of Esprima before work on ECMAScript 6 began. Espree is now built on top of [Acorn](https://github.com/ternjs/acorn), which has a modular architecture that allows extension of core functionality. The goal of Espree is to produce output that is similar to Esprima with a similar API so that it can be used in place of Esprima.
9
-
10
- ## Usage
11
-
12
- Install:
13
-
14
- ```
15
- npm i espree
16
- ```
17
-
18
- And in your Node.js code:
19
-
20
- ```javascript
21
- const espree = require("espree");
22
-
23
- const ast = espree.parse(code);
24
- ```
25
-
26
- ## API
27
-
28
- ### `parse()`
29
-
30
- `parse` parses the given code and returns a abstract syntax tree (AST). It takes two parameters.
31
-
32
- - `code` [string]() - the code which needs to be parsed.
33
- - `options (Optional)` [Object]() - read more about this [here](#options).
34
-
35
- ```javascript
36
- const espree = require("espree");
37
-
38
- const ast = espree.parse(code, options);
39
- ```
40
-
41
- **Example :**
42
-
43
- ```js
44
- const ast = espree.parse('let foo = "bar"', { ecmaVersion: 6 });
45
- console.log(ast);
46
- ```
47
-
48
- <details><summary>Output</summary>
49
- <p>
50
-
51
- ```
52
- Node {
53
- type: 'Program',
54
- start: 0,
55
- end: 15,
56
- body: [
57
- Node {
58
- type: 'VariableDeclaration',
59
- start: 0,
60
- end: 15,
61
- declarations: [Array],
62
- kind: 'let'
63
- }
64
- ],
65
- sourceType: 'script'
66
- }
67
- ```
68
-
69
- </p>
70
- </details>
71
-
72
- ### `tokenize()`
73
-
74
- `tokenize` returns the tokens of a given code. It takes two parameters.
75
-
76
- - `code` [string]() - the code which needs to be parsed.
77
- - `options (Optional)` [Object]() - read more about this [here](#options).
78
-
79
- Even if `options` is empty or undefined or `options.tokens` is `false`, it assigns it to `true` in order to get the `tokens` array
80
-
81
- **Example :**
82
-
83
- ```js
84
- const tokens = espree.tokenize('let foo = "bar"', { ecmaVersion: 6 });
85
- console.log(tokens);
86
- ```
87
-
88
- <details><summary>Output</summary>
89
- <p>
90
-
91
- ```
92
- Token { type: 'Keyword', value: 'let', start: 0, end: 3 },
93
- Token { type: 'Identifier', value: 'foo', start: 4, end: 7 },
94
- Token { type: 'Punctuator', value: '=', start: 8, end: 9 },
95
- Token { type: 'String', value: '"bar"', start: 10, end: 15 }
96
- ```
97
-
98
- </p>
99
- </details>
100
-
101
- ### `version`
102
-
103
- Returns the current `espree` version
104
-
105
- ### `VisitorKeys`
106
-
107
- Returns all visitor keys for traversing the AST from [eslint-visitor-keys](https://github.com/eslint/eslint-visitor-keys)
108
-
109
- ### `latestEcmaVersion`
110
-
111
- Returns the latest ECMAScript supported by `espree`
112
-
113
- ### `supportedEcmaVersions`
114
-
115
- Returns an array of all supported ECMAScript versions
116
-
117
- ## Options
118
-
119
- ```js
120
- const options = {
121
- // attach range information to each node
122
- range: false,
123
-
124
- // attach line/column location information to each node
125
- loc: false,
126
-
127
- // create a top-level comments array containing all comments
128
- comment: false,
129
-
130
- // create a top-level tokens array containing all tokens
131
- tokens: false,
132
-
133
- // Set to 3, 5 (default), 6, 7, 8, 9, 10, 11, or 12 to specify the version of ECMAScript syntax you want to use.
134
- // You can also set to 2015 (same as 6), 2016 (same as 7), 2017 (same as 8), 2018 (same as 9), 2019 (same as 10), 2020 (same as 11), or 2021 (same as 12) to use the year-based naming.
135
- ecmaVersion: 5,
136
-
137
- // specify which type of script you're parsing ("script" or "module")
138
- sourceType: "script",
139
-
140
- // specify additional language features
141
- ecmaFeatures: {
142
-
143
- // enable JSX parsing
144
- jsx: false,
145
-
146
- // enable return in global scope
147
- globalReturn: false,
148
-
149
- // enable implied strict mode (if ecmaVersion >= 5)
150
- impliedStrict: false
151
- }
152
- }
153
- ```
154
-
155
- ## Esprima Compatibility Going Forward
156
-
157
- The primary goal is to produce the exact same AST structure and tokens as Esprima, and that takes precedence over anything else. (The AST structure being the [ESTree](https://github.com/estree/estree) API with JSX extensions.) Separate from that, Espree may deviate from what Esprima outputs in terms of where and how comments are attached, as well as what additional information is available on AST nodes. That is to say, Espree may add more things to the AST nodes than Esprima does but the overall AST structure produced will be the same.
158
-
159
- Espree may also deviate from Esprima in the interface it exposes.
160
-
161
- ## Contributing
162
-
163
- Issues and pull requests will be triaged and responded to as quickly as possible. We operate under the [ESLint Contributor Guidelines](http://eslint.org/docs/developer-guide/contributing), so please be sure to read them before contributing. If you're not sure where to dig in, check out the [issues](https://github.com/eslint/espree/issues).
164
-
165
- Espree is licensed under a permissive BSD 2-clause license.
166
-
167
- ## Security Policy
168
-
169
- We work hard to ensure that Espree is safe for everyone and that security issues are addressed quickly and responsibly. Read the full [security policy](https://github.com/eslint/.github/blob/master/SECURITY.md).
170
-
171
- ## Build Commands
172
-
173
- * `npm test` - run all linting and tests
174
- * `npm run lint` - run all linting
175
- * `npm run browserify` - creates a version of Espree that is usable in a browser
176
-
177
- ## Differences from Espree 2.x
178
-
179
- * The `tokenize()` method does not use `ecmaFeatures`. Any string will be tokenized completely based on ECMAScript 6 semantics.
180
- * Trailing whitespace no longer is counted as part of a node.
181
- * `let` and `const` declarations are no longer parsed by default. You must opt-in by using an `ecmaVersion` newer than `5` or setting `sourceType` to `module`.
182
- * The `esparse` and `esvalidate` binary scripts have been removed.
183
- * There is no `tolerant` option. We will investigate adding this back in the future.
184
-
185
- ## Known Incompatibilities
186
-
187
- In an effort to help those wanting to transition from other parsers to Espree, the following is a list of noteworthy incompatibilities with other parsers. These are known differences that we do not intend to change.
188
-
189
- ### Esprima 1.2.2
190
-
191
- * Esprima counts trailing whitespace as part of each AST node while Espree does not. In Espree, the end of a node is where the last token occurs.
192
- * Espree does not parse `let` and `const` declarations by default.
193
- * Error messages returned for parsing errors are different.
194
- * There are two addition properties on every node and token: `start` and `end`. These represent the same data as `range` and are used internally by Acorn.
195
-
196
- ### Esprima 2.x
197
-
198
- * Esprima 2.x uses a different comment attachment algorithm that results in some comments being added in different places than Espree. The algorithm Espree uses is the same one used in Esprima 1.2.2.
199
-
200
- ## Frequently Asked Questions
201
-
202
- ### Why another parser
203
-
204
- [ESLint](http://eslint.org) had been relying on Esprima as its parser from the beginning. While that was fine when the JavaScript language was evolving slowly, the pace of development increased dramatically and Esprima had fallen behind. ESLint, like many other tools reliant on Esprima, has been stuck in using new JavaScript language features until Esprima updates, and that caused our users frustration.
205
-
206
- We decided the only way for us to move forward was to create our own parser, bringing us inline with JSHint and JSLint, and allowing us to keep implementing new features as we need them. We chose to fork Esprima instead of starting from scratch in order to move as quickly as possible with a compatible API.
207
-
208
- With Espree 2.0.0, we are no longer a fork of Esprima but rather a translation layer between Acorn and Esprima syntax. This allows us to put work back into a community-supported parser (Acorn) that is continuing to grow and evolve while maintaining an Esprima-compatible parser for those utilities still built on Esprima.
209
-
210
- ### Have you tried working with Esprima?
211
-
212
- Yes. Since the start of ESLint, we've regularly filed bugs and feature requests with Esprima and will continue to do so. However, there are some different philosophies around how the projects work that need to be worked through. The initial goal was to have Espree track Esprima and eventually merge the two back together, but we ultimately decided that building on top of Acorn was a better choice due to Acorn's plugin support.
213
-
214
- ### Why don't you just use Acorn?
215
-
216
- Acorn is a great JavaScript parser that produces an AST that is compatible with Esprima. Unfortunately, ESLint relies on more than just the AST to do its job. It relies on Esprima's tokens and comment attachment features to get a complete picture of the source code. We investigated switching to Acorn, but the inconsistencies between Esprima and Acorn created too much work for a project like ESLint.
217
-
218
- We are building on top of Acorn, however, so that we can contribute back and help make Acorn even better.
219
-
220
- ### What ECMAScript features do you support?
221
-
222
- Espree supports all ECMAScript 2020 features and partially supports ECMAScript 2021 features.
223
-
224
- Because ECMAScript 2021 is still under development, we are implementing features as they are finalized. Currently, Espree supports:
225
-
226
- * [Logical Assignment Operators](https://github.com/tc39/proposal-logical-assignment)
227
- * [Numeric Separators](https://github.com/tc39/proposal-numeric-separator)
228
-
229
- See [finished-proposals.md](https://github.com/tc39/proposals/blob/master/finished-proposals.md) to know what features are finalized.
230
-
231
- ### How do you determine which experimental features to support?
232
-
233
- In general, we do not support experimental JavaScript features. We may make exceptions from time to time depending on the maturity of the features.
@@ -1,177 +0,0 @@
1
- /**
2
- * @fileoverview Main Espree file that converts Acorn into Esprima output.
3
- *
4
- * This file contains code from the following MIT-licensed projects:
5
- * 1. Acorn
6
- * 2. Babylon
7
- * 3. Babel-ESLint
8
- *
9
- * This file also contains code from Esprima, which is BSD licensed.
10
- *
11
- * Acorn is Copyright 2012-2015 Acorn Contributors (https://github.com/marijnh/acorn/blob/master/AUTHORS)
12
- * Babylon is Copyright 2014-2015 various contributors (https://github.com/babel/babel/blob/master/packages/babylon/AUTHORS)
13
- * Babel-ESLint is Copyright 2014-2015 Sebastian McKenzie <sebmck@gmail.com>
14
- *
15
- * Redistribution and use in source and binary forms, with or without
16
- * modification, are permitted provided that the following conditions are met:
17
- *
18
- * * Redistributions of source code must retain the above copyright
19
- * notice, this list of conditions and the following disclaimer.
20
- * * Redistributions in binary form must reproduce the above copyright
21
- * notice, this list of conditions and the following disclaimer in the
22
- * documentation and/or other materials provided with the distribution.
23
- *
24
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27
- * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
28
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
- *
35
- * Esprima is Copyright (c) jQuery Foundation, Inc. and Contributors, All Rights Reserved.
36
- *
37
- * Redistribution and use in source and binary forms, with or without
38
- * modification, are permitted provided that the following conditions are met:
39
- *
40
- * * Redistributions of source code must retain the above copyright
41
- * notice, this list of conditions and the following disclaimer.
42
- * * Redistributions in binary form must reproduce the above copyright
43
- * notice, this list of conditions and the following disclaimer in the
44
- * documentation and/or other materials provided with the distribution.
45
- *
46
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
47
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
48
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
49
- * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
50
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
51
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
52
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
53
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
54
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
55
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56
- */
57
- /* eslint no-undefined:0, no-use-before-define: 0 */
58
-
59
- "use strict";
60
-
61
- const acorn = require("acorn");
62
- const jsx = require("acorn-jsx");
63
- const astNodeTypes = require("./lib/ast-node-types");
64
- const espree = require("./lib/espree");
65
- const { getLatestEcmaVersion, getSupportedEcmaVersions } = require("./lib/options");
66
-
67
- // To initialize lazily.
68
- const parsers = {
69
- _regular: null,
70
- _jsx: null,
71
-
72
- get regular() {
73
- if (this._regular === null) {
74
- this._regular = acorn.Parser.extend(espree());
75
- }
76
- return this._regular;
77
- },
78
-
79
- get jsx() {
80
- if (this._jsx === null) {
81
- this._jsx = acorn.Parser.extend(jsx(), espree());
82
- }
83
- return this._jsx;
84
- },
85
-
86
- get(options) {
87
- const useJsx = Boolean(
88
- options &&
89
- options.ecmaFeatures &&
90
- options.ecmaFeatures.jsx
91
- );
92
-
93
- return useJsx ? this.jsx : this.regular;
94
- }
95
- };
96
-
97
- //------------------------------------------------------------------------------
98
- // Tokenizer
99
- //------------------------------------------------------------------------------
100
-
101
- /**
102
- * Tokenizes the given code.
103
- * @param {string} code The code to tokenize.
104
- * @param {Object} options Options defining how to tokenize.
105
- * @returns {Token[]} An array of tokens.
106
- * @throws {SyntaxError} If the input code is invalid.
107
- * @private
108
- */
109
- function tokenize(code, options) {
110
- const Parser = parsers.get(options);
111
-
112
- // Ensure to collect tokens.
113
- if (!options || options.tokens !== true) {
114
- options = Object.assign({}, options, { tokens: true }); // eslint-disable-line no-param-reassign
115
- }
116
-
117
- return new Parser(options, code).tokenize();
118
- }
119
-
120
- //------------------------------------------------------------------------------
121
- // Parser
122
- //------------------------------------------------------------------------------
123
-
124
- /**
125
- * Parses the given code.
126
- * @param {string} code The code to tokenize.
127
- * @param {Object} options Options defining how to tokenize.
128
- * @returns {ASTNode} The "Program" AST node.
129
- * @throws {SyntaxError} If the input code is invalid.
130
- */
131
- function parse(code, options) {
132
- const Parser = parsers.get(options);
133
-
134
- return new Parser(options, code).parse();
135
- }
136
-
137
- //------------------------------------------------------------------------------
138
- // Public
139
- //------------------------------------------------------------------------------
140
-
141
- exports.version = require("./package.json").version;
142
-
143
- exports.tokenize = tokenize;
144
-
145
- exports.parse = parse;
146
-
147
- // Deep copy.
148
- /* istanbul ignore next */
149
- exports.Syntax = (function() {
150
- let name,
151
- types = {};
152
-
153
- if (typeof Object.create === "function") {
154
- types = Object.create(null);
155
- }
156
-
157
- for (name in astNodeTypes) {
158
- if (Object.hasOwnProperty.call(astNodeTypes, name)) {
159
- types[name] = astNodeTypes[name];
160
- }
161
- }
162
-
163
- if (typeof Object.freeze === "function") {
164
- Object.freeze(types);
165
- }
166
-
167
- return types;
168
- }());
169
-
170
- /* istanbul ignore next */
171
- exports.VisitorKeys = (function() {
172
- return require("eslint-visitor-keys").KEYS;
173
- }());
174
-
175
- exports.latestEcmaVersion = getLatestEcmaVersion();
176
-
177
- exports.supportedEcmaVersions = getSupportedEcmaVersions();
@@ -1,96 +0,0 @@
1
- /**
2
- * @fileoverview The AST node types produced by the parser.
3
- * @author Nicholas C. Zakas
4
- */
5
-
6
- "use strict";
7
-
8
- //------------------------------------------------------------------------------
9
- // Requirements
10
- //------------------------------------------------------------------------------
11
-
12
- // None!
13
-
14
- //------------------------------------------------------------------------------
15
- // Public
16
- //------------------------------------------------------------------------------
17
-
18
- module.exports = {
19
- AssignmentExpression: "AssignmentExpression",
20
- AssignmentPattern: "AssignmentPattern",
21
- ArrayExpression: "ArrayExpression",
22
- ArrayPattern: "ArrayPattern",
23
- ArrowFunctionExpression: "ArrowFunctionExpression",
24
- AwaitExpression: "AwaitExpression",
25
- BlockStatement: "BlockStatement",
26
- BinaryExpression: "BinaryExpression",
27
- BreakStatement: "BreakStatement",
28
- CallExpression: "CallExpression",
29
- CatchClause: "CatchClause",
30
- ClassBody: "ClassBody",
31
- ClassDeclaration: "ClassDeclaration",
32
- ClassExpression: "ClassExpression",
33
- ConditionalExpression: "ConditionalExpression",
34
- ContinueStatement: "ContinueStatement",
35
- DoWhileStatement: "DoWhileStatement",
36
- DebuggerStatement: "DebuggerStatement",
37
- EmptyStatement: "EmptyStatement",
38
- ExpressionStatement: "ExpressionStatement",
39
- ForStatement: "ForStatement",
40
- ForInStatement: "ForInStatement",
41
- ForOfStatement: "ForOfStatement",
42
- FunctionDeclaration: "FunctionDeclaration",
43
- FunctionExpression: "FunctionExpression",
44
- Identifier: "Identifier",
45
- IfStatement: "IfStatement",
46
- Literal: "Literal",
47
- LabeledStatement: "LabeledStatement",
48
- LogicalExpression: "LogicalExpression",
49
- MemberExpression: "MemberExpression",
50
- MetaProperty: "MetaProperty",
51
- MethodDefinition: "MethodDefinition",
52
- NewExpression: "NewExpression",
53
- ObjectExpression: "ObjectExpression",
54
- ObjectPattern: "ObjectPattern",
55
- Program: "Program",
56
- Property: "Property",
57
- RestElement: "RestElement",
58
- ReturnStatement: "ReturnStatement",
59
- SequenceExpression: "SequenceExpression",
60
- SpreadElement: "SpreadElement",
61
- Super: "Super",
62
- SwitchCase: "SwitchCase",
63
- SwitchStatement: "SwitchStatement",
64
- TaggedTemplateExpression: "TaggedTemplateExpression",
65
- TemplateElement: "TemplateElement",
66
- TemplateLiteral: "TemplateLiteral",
67
- ThisExpression: "ThisExpression",
68
- ThrowStatement: "ThrowStatement",
69
- TryStatement: "TryStatement",
70
- UnaryExpression: "UnaryExpression",
71
- UpdateExpression: "UpdateExpression",
72
- VariableDeclaration: "VariableDeclaration",
73
- VariableDeclarator: "VariableDeclarator",
74
- WhileStatement: "WhileStatement",
75
- WithStatement: "WithStatement",
76
- YieldExpression: "YieldExpression",
77
- JSXIdentifier: "JSXIdentifier",
78
- JSXNamespacedName: "JSXNamespacedName",
79
- JSXMemberExpression: "JSXMemberExpression",
80
- JSXEmptyExpression: "JSXEmptyExpression",
81
- JSXExpressionContainer: "JSXExpressionContainer",
82
- JSXElement: "JSXElement",
83
- JSXClosingElement: "JSXClosingElement",
84
- JSXOpeningElement: "JSXOpeningElement",
85
- JSXAttribute: "JSXAttribute",
86
- JSXSpreadAttribute: "JSXSpreadAttribute",
87
- JSXText: "JSXText",
88
- ExportDefaultDeclaration: "ExportDefaultDeclaration",
89
- ExportNamedDeclaration: "ExportNamedDeclaration",
90
- ExportAllDeclaration: "ExportAllDeclaration",
91
- ExportSpecifier: "ExportSpecifier",
92
- ImportDeclaration: "ImportDeclaration",
93
- ImportSpecifier: "ImportSpecifier",
94
- ImportDefaultSpecifier: "ImportDefaultSpecifier",
95
- ImportNamespaceSpecifier: "ImportNamespaceSpecifier"
96
- };