@rsdoctor/core 1.6.1 → 2.0.0-alpha.1

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 (411) hide show
  1. package/dist/build-utils/build/chunks/assetsModules.d.ts +1 -1
  2. package/dist/build-utils/build/chunks/assetsModules.js +1 -1
  3. package/dist/build-utils/build/chunks/index.d.ts +0 -1
  4. package/dist/build-utils/build/chunks/index.js +0 -1
  5. package/dist/build-utils/build/chunks/rspack/transform.d.ts +1 -1
  6. package/dist/build-utils/build/chunks/rspack/transform.js +1 -1
  7. package/dist/build-utils/build/envinfo.d.ts +13 -0
  8. package/dist/build-utils/build/envinfo.js +60 -0
  9. package/dist/build-utils/build/file/cache.d.ts +5 -0
  10. package/dist/build-utils/build/file/cache.js +24 -0
  11. package/dist/build-utils/build/file/index.d.ts +3 -0
  12. package/dist/build-utils/build/file/index.js +5 -0
  13. package/dist/build-utils/build/file/sharding.d.ts +21 -0
  14. package/dist/build-utils/build/file/sharding.js +38 -0
  15. package/dist/build-utils/build/index.d.ts +5 -0
  16. package/dist/build-utils/build/index.js +11 -6
  17. package/dist/build-utils/build/json.d.ts +3 -0
  18. package/dist/build-utils/build/json.js +67 -0
  19. package/dist/build-utils/build/loader/probeLoader.d.ts +2 -2
  20. package/dist/build-utils/build/loader/probeLoader.js +4 -4
  21. package/dist/build-utils/build/loader/probeLoaderPlugin.d.ts +1 -1
  22. package/dist/build-utils/build/loader/probeLoaderPlugin.js +1 -1
  23. package/dist/build-utils/build/module-graph/index.d.ts +0 -3
  24. package/dist/build-utils/build/module-graph/index.js +0 -3
  25. package/dist/build-utils/build/module-graph/parser.d.ts +1 -1
  26. package/dist/build-utils/build/module-graph/parser.js +1 -1
  27. package/dist/build-utils/build/module-graph/rspack/transform.d.ts +1 -1
  28. package/dist/build-utils/build/module-graph/rspack/transform.js +7 -5
  29. package/dist/build-utils/build/module-graph/utils.d.ts +1 -1
  30. package/dist/build-utils/build/module-graph/utils.js +5 -4
  31. package/dist/build-utils/build/process.d.ts +2 -0
  32. package/dist/build-utils/build/process.js +18 -0
  33. package/dist/build-utils/build/server.d.ts +15 -0
  34. package/dist/build-utils/build/server.js +107 -0
  35. package/dist/build-utils/build/utils/loader.d.ts +2 -2
  36. package/dist/build-utils/build/utils/loader.js +10 -19
  37. package/dist/build-utils/build/utils/parseBundle.d.ts +1 -1
  38. package/dist/build-utils/build/utils/parseBundle.js +6 -8
  39. package/dist/build-utils/build/utils/plugin.d.ts +1 -1
  40. package/dist/build-utils/build/utils/plugin.js +1 -2
  41. package/dist/build-utils/index.d.ts +10 -0
  42. package/dist/build-utils/index.js +12 -2
  43. package/dist/collection.d.ts +1 -0
  44. package/dist/collection.js +2 -0
  45. package/dist/common/file.d.ts +2 -0
  46. package/dist/common/file.js +8 -0
  47. package/dist/common/global-config.d.ts +21 -0
  48. package/dist/common/global-config.js +33 -0
  49. package/dist/common/index.d.ts +4 -0
  50. package/dist/common/index.js +6 -0
  51. package/dist/common-browser.d.ts +1 -0
  52. package/dist/common-browser.js +2 -0
  53. package/dist/error/error.d.ts +35 -0
  54. package/dist/error/error.js +143 -0
  55. package/dist/error/index.d.ts +2 -0
  56. package/dist/error/index.js +3 -0
  57. package/dist/error/transform.d.ts +3 -0
  58. package/dist/error/transform.js +138 -0
  59. package/dist/error/utils.d.ts +4 -0
  60. package/dist/error/utils.js +23 -0
  61. package/dist/graph/index.d.ts +1 -0
  62. package/dist/graph/index.js +2 -0
  63. package/dist/index.d.ts +2 -0
  64. package/dist/index.js +4 -2
  65. package/dist/inner-plugins/constants.d.ts +1 -1
  66. package/dist/inner-plugins/constants.js +1 -1
  67. package/dist/inner-plugins/loaders/proxy.d.ts +4 -4
  68. package/dist/inner-plugins/plugins/base.d.ts +1 -1
  69. package/dist/inner-plugins/plugins/bundle.d.ts +1 -1
  70. package/dist/inner-plugins/plugins/bundle.js +4 -20
  71. package/dist/inner-plugins/plugins/ensureModulesChunkGraph.d.ts +6 -8
  72. package/dist/inner-plugins/plugins/ensureModulesChunkGraph.js +12 -77
  73. package/dist/inner-plugins/plugins/errors.d.ts +3 -3
  74. package/dist/inner-plugins/plugins/errors.js +6 -6
  75. package/dist/inner-plugins/plugins/index.d.ts +0 -1
  76. package/dist/inner-plugins/plugins/index.js +0 -1
  77. package/dist/inner-plugins/plugins/loader.d.ts +1 -1
  78. package/dist/inner-plugins/plugins/loader.js +8 -20
  79. package/dist/inner-plugins/plugins/plugins.d.ts +1 -1
  80. package/dist/inner-plugins/plugins/plugins.js +3 -3
  81. package/dist/inner-plugins/plugins/progress.d.ts +3 -3
  82. package/dist/inner-plugins/plugins/progress.js +16 -18
  83. package/dist/inner-plugins/plugins/resolver.d.ts +2 -3
  84. package/dist/inner-plugins/plugins/resolver.js +2 -2
  85. package/dist/inner-plugins/plugins/rspack.d.ts +8 -3
  86. package/dist/inner-plugins/plugins/rspack.js +18 -4
  87. package/dist/inner-plugins/plugins/rules.d.ts +1 -1
  88. package/dist/inner-plugins/plugins/rules.js +6 -6
  89. package/dist/inner-plugins/plugins/sourcemapTool.d.ts +2 -2
  90. package/dist/inner-plugins/plugins/sourcemapTool.js +2 -2
  91. package/dist/inner-plugins/plugins/summary.d.ts +1 -1
  92. package/dist/inner-plugins/plugins/summary.js +3 -3
  93. package/dist/inner-plugins/utils/config.d.ts +3 -4
  94. package/dist/inner-plugins/utils/config.js +4 -17
  95. package/dist/inner-plugins/utils/loader.d.ts +4 -7
  96. package/dist/inner-plugins/utils/loader.js +10 -36
  97. package/dist/inner-plugins/utils/normalize-config.d.ts +4 -7
  98. package/dist/inner-plugins/utils/openBrowser.d.ts +1 -0
  99. package/dist/inner-plugins/utils/openBrowser.js +55 -0
  100. package/dist/inner-plugins/utils/plugin-common.js +4 -4
  101. package/dist/inner-plugins/utils/plugin.d.ts +1 -1
  102. package/dist/inner-plugins/utils/plugin.js +1 -1
  103. package/dist/inner-plugins/utils/sdk.d.ts +2 -3
  104. package/dist/inner-plugins/utils/sdk.js +2 -2
  105. package/dist/logger.d.ts +9 -0
  106. package/dist/logger.js +51 -0
  107. package/dist/{inner-plugins/constants.d.cts → rspack-plugin/constants.d.ts} +4 -1
  108. package/dist/rspack-plugin/constants.js +23 -0
  109. package/dist/rspack-plugin/index.d.ts +2 -0
  110. package/dist/rspack-plugin/index.js +3 -0
  111. package/dist/rspack-plugin/multiple.d.ts +8 -0
  112. package/dist/rspack-plugin/multiple.js +39 -0
  113. package/dist/rspack-plugin/plugin.d.ts +25 -0
  114. package/dist/rspack-plugin/plugin.js +133 -0
  115. package/dist/rule-utils/document/document.d.ts +16 -0
  116. package/dist/rule-utils/document/document.js +46 -0
  117. package/dist/rule-utils/document/index.d.ts +3 -0
  118. package/dist/rule-utils/document/index.js +4 -0
  119. package/dist/rule-utils/document/server.d.ts +4 -0
  120. package/dist/rule-utils/document/server.js +13 -0
  121. package/dist/rule-utils/document/types.d.ts +31 -0
  122. package/dist/rule-utils/index.d.ts +2 -0
  123. package/dist/rule-utils/index.js +3 -0
  124. package/dist/rule-utils/parser/asserts.d.ts +81 -0
  125. package/dist/rule-utils/parser/asserts.js +105 -0
  126. package/dist/rule-utils/parser/index.d.ts +4 -0
  127. package/dist/rule-utils/parser/index.js +5 -0
  128. package/dist/rule-utils/parser/parser.d.ts +118 -0
  129. package/dist/rule-utils/parser/parser.js +24 -0
  130. package/dist/rule-utils/parser/types.d.ts +30 -0
  131. package/dist/rule-utils/parser/types.js +8 -0
  132. package/dist/rule-utils/parser/utils.d.ts +30 -0
  133. package/dist/rule-utils/parser/utils.js +106 -0
  134. package/dist/rules/linter.d.ts +1 -1
  135. package/dist/rules/linter.js +1 -1
  136. package/dist/rules/rule.d.ts +2 -2
  137. package/dist/rules/rule.js +2 -2
  138. package/dist/rules/rules/cjs-require/index.d.ts +1 -1
  139. package/dist/rules/rules/cjs-require/index.js +3 -3
  140. package/dist/rules/rules/cross-chunks-package/index.d.ts +1 -1
  141. package/dist/rules/rules/cross-chunks-package/index.js +2 -2
  142. package/dist/rules/rules/default-import-check/index.d.ts +1 -1
  143. package/dist/rules/rules/default-import-check/index.js +2 -2
  144. package/dist/rules/rules/default-import-check/utils.d.ts +2 -2
  145. package/dist/rules/rules/default-import-check/utils.js +2 -2
  146. package/dist/rules/rules/duplicate-package/index.d.ts +3 -3
  147. package/dist/rules/rules/duplicate-package/index.js +3 -3
  148. package/dist/rules/rules/duplicate-package/utils.d.ts +1 -1
  149. package/dist/rules/rules/ecma-version-check/index.d.ts +3 -2
  150. package/dist/rules/rules/ecma-version-check/index.js +1 -1
  151. package/dist/rules/rules/ecma-version-check/types.d.ts +1 -2
  152. package/dist/rules/rules/ecma-version-check/utils.d.ts +1 -1
  153. package/dist/rules/rules/esm-resolved-to-cjs/index.d.ts +1 -1
  154. package/dist/rules/rules/esm-resolved-to-cjs/index.js +3 -18
  155. package/dist/rules/rules/index.d.ts +1 -1
  156. package/dist/rules/rules/loader-performance-optimization/index.d.ts +1 -1
  157. package/dist/rules/rules/loader-performance-optimization/index.js +3 -3
  158. package/dist/rules/rules/loader-performance-optimization/types.d.ts +1 -1
  159. package/dist/rules/rules/module-mixed-chunks/index.d.ts +1 -1
  160. package/dist/rules/rules/module-mixed-chunks/index.js +2 -2
  161. package/dist/rules/rules/side-effects-only-imports/index.d.ts +1 -1
  162. package/dist/rules/rules/side-effects-only-imports/index.js +2 -2
  163. package/dist/rules/utils.d.ts +1 -1
  164. package/dist/rules/utils.js +1 -1
  165. package/dist/sdk/index.d.ts +2 -0
  166. package/dist/sdk/index.js +3 -0
  167. package/dist/sdk/multiple/controller.d.ts +12 -0
  168. package/dist/sdk/multiple/controller.js +42 -0
  169. package/dist/sdk/multiple/index.d.ts +2 -0
  170. package/dist/sdk/multiple/index.js +3 -0
  171. package/dist/sdk/multiple/primary.d.ts +32 -0
  172. package/dist/sdk/multiple/primary.js +64 -0
  173. package/dist/sdk/multiple/server.d.ts +7 -0
  174. package/dist/sdk/multiple/server.js +14 -0
  175. package/dist/sdk/sdk/core.d.ts +33 -0
  176. package/dist/sdk/sdk/core.js +163 -0
  177. package/dist/sdk/sdk/index.d.ts +52 -0
  178. package/dist/sdk/sdk/index.js +435 -0
  179. package/dist/sdk/sdk/types.d.ts +26 -0
  180. package/dist/sdk/sdk/types.js +1 -0
  181. package/dist/sdk/server/apis/alerts.d.ts +5 -0
  182. package/dist/sdk/server/apis/alerts.js +30 -0
  183. package/dist/sdk/server/apis/base.d.ts +11 -0
  184. package/dist/sdk/server/apis/base.js +22 -0
  185. package/dist/sdk/server/apis/bundle-diff.d.ts +6 -0
  186. package/dist/sdk/server/apis/bundle-diff.js +51 -0
  187. package/dist/sdk/server/apis/data.d.ts +6 -0
  188. package/dist/sdk/server/apis/data.js +44 -0
  189. package/dist/sdk/server/apis/fs.d.ts +5 -0
  190. package/dist/sdk/server/apis/fs.js +28 -0
  191. package/dist/sdk/server/apis/graph.d.ts +12 -0
  192. package/dist/sdk/server/apis/graph.js +116 -0
  193. package/dist/sdk/server/apis/index.d.ts +10 -0
  194. package/dist/sdk/server/apis/index.js +11 -0
  195. package/dist/sdk/server/apis/loader.d.ts +15 -0
  196. package/dist/sdk/server/apis/loader.js +120 -0
  197. package/dist/sdk/server/apis/plugin.d.ts +6 -0
  198. package/dist/sdk/server/apis/plugin.js +39 -0
  199. package/dist/sdk/server/apis/project.d.ts +8 -0
  200. package/dist/sdk/server/apis/project.js +59 -0
  201. package/dist/sdk/server/apis/renderer.d.ts +6 -0
  202. package/dist/sdk/server/apis/renderer.js +33 -0
  203. package/dist/sdk/server/apis/resolver.d.ts +6 -0
  204. package/dist/sdk/server/apis/resolver.js +38 -0
  205. package/dist/sdk/server/client.d.ts +3 -0
  206. package/dist/sdk/server/client.js +8 -0
  207. package/dist/sdk/server/fakeServer.d.ts +9 -0
  208. package/dist/sdk/server/fakeServer.js +12 -0
  209. package/dist/sdk/server/index.d.ts +44 -0
  210. package/dist/sdk/server/index.js +292 -0
  211. package/dist/sdk/server/json-body.d.ts +6 -0
  212. package/dist/sdk/server/json-body.js +150 -0
  213. package/dist/sdk/server/router.d.ts +24 -0
  214. package/dist/sdk/server/router.js +83 -0
  215. package/dist/sdk/server/security.d.ts +5 -0
  216. package/dist/sdk/server/security.js +47 -0
  217. package/dist/sdk/server/socket/api.d.ts +15 -0
  218. package/dist/sdk/server/socket/api.js +22 -0
  219. package/dist/sdk/server/socket/index.d.ts +48 -0
  220. package/dist/sdk/server/socket/index.js +166 -0
  221. package/dist/sdk/server/utils.d.ts +6 -0
  222. package/dist/sdk/server/utils.js +19 -0
  223. package/dist/sdk/utils/base.d.ts +1 -0
  224. package/dist/sdk/utils/base.js +22 -0
  225. package/dist/sdk/utils/constant.d.ts +1 -0
  226. package/dist/sdk/utils/constant.js +4 -0
  227. package/dist/sdk/utils/index.d.ts +3 -0
  228. package/dist/sdk/utils/index.js +4 -0
  229. package/dist/sdk/utils/openBrowser.d.ts +4 -0
  230. package/dist/sdk/utils/openBrowser.js +53 -0
  231. package/dist/sdk/utils/upload.d.ts +2 -0
  232. package/dist/sdk/utils/upload.js +6 -0
  233. package/dist/sdk.d.ts +1 -0
  234. package/dist/sdk.js +2 -0
  235. package/dist/types/index.d.ts +0 -1
  236. package/dist/types/index.js +0 -1
  237. package/dist/types/loader.d.ts +1 -1
  238. package/dist/types/plugin.d.ts +7 -28
  239. package/dist/types/rules.d.ts +4 -4
  240. package/package.json +123 -55
  241. package/static/openChrome.applescript +95 -0
  242. package/dist/build-utils/build/chunks/assetsModules.cjs +0 -46
  243. package/dist/build-utils/build/chunks/assetsModules.d.cts +0 -17
  244. package/dist/build-utils/build/chunks/chunkTransform.cjs +0 -43
  245. package/dist/build-utils/build/chunks/chunkTransform.d.cts +0 -4
  246. package/dist/build-utils/build/chunks/chunkTransform.d.ts +0 -4
  247. package/dist/build-utils/build/chunks/chunkTransform.js +0 -6
  248. package/dist/build-utils/build/chunks/index.cjs +0 -76
  249. package/dist/build-utils/build/chunks/index.d.cts +0 -3
  250. package/dist/build-utils/build/chunks/rspack/transform.cjs +0 -84
  251. package/dist/build-utils/build/chunks/rspack/transform.d.cts +0 -13
  252. package/dist/build-utils/build/index.cjs +0 -56
  253. package/dist/build-utils/build/index.d.cts +0 -5
  254. package/dist/build-utils/build/loader/index.cjs +0 -69
  255. package/dist/build-utils/build/loader/index.d.cts +0 -2
  256. package/dist/build-utils/build/loader/probeLoader.cjs +0 -93
  257. package/dist/build-utils/build/loader/probeLoader.d.cts +0 -4
  258. package/dist/build-utils/build/loader/probeLoaderPlugin.cjs +0 -69
  259. package/dist/build-utils/build/loader/probeLoaderPlugin.d.cts +0 -5
  260. package/dist/build-utils/build/module-graph/index.cjs +0 -83
  261. package/dist/build-utils/build/module-graph/index.d.cts +0 -4
  262. package/dist/build-utils/build/module-graph/parser.cjs +0 -50
  263. package/dist/build-utils/build/module-graph/parser.d.cts +0 -2
  264. package/dist/build-utils/build/module-graph/rspack/transform.cjs +0 -155
  265. package/dist/build-utils/build/module-graph/rspack/transform.d.cts +0 -26
  266. package/dist/build-utils/build/module-graph/transform.cjs +0 -44
  267. package/dist/build-utils/build/module-graph/transform.d.cts +0 -4
  268. package/dist/build-utils/build/module-graph/transform.d.ts +0 -4
  269. package/dist/build-utils/build/module-graph/transform.js +0 -7
  270. package/dist/build-utils/build/module-graph/treeShaking.cjs +0 -110
  271. package/dist/build-utils/build/module-graph/treeShaking.d.cts +0 -2
  272. package/dist/build-utils/build/module-graph/treeShaking.d.ts +0 -2
  273. package/dist/build-utils/build/module-graph/treeShaking.js +0 -73
  274. package/dist/build-utils/build/module-graph/utils.cjs +0 -99
  275. package/dist/build-utils/build/module-graph/utils.d.cts +0 -3
  276. package/dist/build-utils/build/module-graph/webpack/transform.cjs +0 -174
  277. package/dist/build-utils/build/module-graph/webpack/transform.d.cts +0 -16
  278. package/dist/build-utils/build/module-graph/webpack/transform.d.ts +0 -16
  279. package/dist/build-utils/build/module-graph/webpack/transform.js +0 -124
  280. package/dist/build-utils/build/utils/index.cjs +0 -76
  281. package/dist/build-utils/build/utils/index.d.cts +0 -3
  282. package/dist/build-utils/build/utils/loader.cjs +0 -358
  283. package/dist/build-utils/build/utils/loader.d.cts +0 -20
  284. package/dist/build-utils/build/utils/parseBundle.cjs +0 -287
  285. package/dist/build-utils/build/utils/parseBundle.d.cts +0 -12
  286. package/dist/build-utils/build/utils/plugin.cjs +0 -65
  287. package/dist/build-utils/build/utils/plugin.d.cts +0 -5
  288. package/dist/build-utils/index.cjs +0 -40
  289. package/dist/build-utils/index.d.cts +0 -1
  290. package/dist/index.cjs +0 -85
  291. package/dist/index.d.cts +0 -3
  292. package/dist/inner-plugins/constants.cjs +0 -68
  293. package/dist/inner-plugins/index.cjs +0 -69
  294. package/dist/inner-plugins/index.d.cts +0 -2
  295. package/dist/inner-plugins/loaders/proxy.cjs +0 -108
  296. package/dist/inner-plugins/loaders/proxy.d.cts +0 -7
  297. package/dist/inner-plugins/plugins/base.cjs +0 -57
  298. package/dist/inner-plugins/plugins/base.d.cts +0 -12
  299. package/dist/inner-plugins/plugins/bundle.cjs +0 -116
  300. package/dist/inner-plugins/plugins/bundle.d.cts +0 -15
  301. package/dist/inner-plugins/plugins/bundleTagPlugin.cjs +0 -88
  302. package/dist/inner-plugins/plugins/bundleTagPlugin.d.cts +0 -6
  303. package/dist/inner-plugins/plugins/bundleTagPlugin.d.ts +0 -6
  304. package/dist/inner-plugins/plugins/bundleTagPlugin.js +0 -51
  305. package/dist/inner-plugins/plugins/ensureModulesChunkGraph.cjs +0 -182
  306. package/dist/inner-plugins/plugins/ensureModulesChunkGraph.d.cts +0 -36
  307. package/dist/inner-plugins/plugins/errors.cjs +0 -102
  308. package/dist/inner-plugins/plugins/errors.d.cts +0 -11
  309. package/dist/inner-plugins/plugins/index.cjs +0 -132
  310. package/dist/inner-plugins/plugins/index.d.cts +0 -11
  311. package/dist/inner-plugins/plugins/loader.cjs +0 -169
  312. package/dist/inner-plugins/plugins/loader.d.cts +0 -10
  313. package/dist/inner-plugins/plugins/plugins.cjs +0 -77
  314. package/dist/inner-plugins/plugins/plugins.d.cts +0 -8
  315. package/dist/inner-plugins/plugins/progress.cjs +0 -74
  316. package/dist/inner-plugins/plugins/progress.d.cts +0 -8
  317. package/dist/inner-plugins/plugins/resolver.cjs +0 -94
  318. package/dist/inner-plugins/plugins/resolver.d.cts +0 -13
  319. package/dist/inner-plugins/plugins/rspack.cjs +0 -122
  320. package/dist/inner-plugins/plugins/rspack.d.cts +0 -4
  321. package/dist/inner-plugins/plugins/rules.cjs +0 -101
  322. package/dist/inner-plugins/plugins/rules.d.cts +0 -8
  323. package/dist/inner-plugins/plugins/sourcemapTool.cjs +0 -279
  324. package/dist/inner-plugins/plugins/sourcemapTool.d.cts +0 -52
  325. package/dist/inner-plugins/plugins/summary.cjs +0 -129
  326. package/dist/inner-plugins/plugins/summary.d.cts +0 -14
  327. package/dist/inner-plugins/utils/circleDetect.cjs +0 -53
  328. package/dist/inner-plugins/utils/circleDetect.d.cts +0 -4
  329. package/dist/inner-plugins/utils/config.cjs +0 -207
  330. package/dist/inner-plugins/utils/config.d.cts +0 -5
  331. package/dist/inner-plugins/utils/index.cjs +0 -110
  332. package/dist/inner-plugins/utils/index.d.cts +0 -9
  333. package/dist/inner-plugins/utils/loader.cjs +0 -222
  334. package/dist/inner-plugins/utils/loader.d.cts +0 -13
  335. package/dist/inner-plugins/utils/normalize-config.cjs +0 -126
  336. package/dist/inner-plugins/utils/normalize-config.d.cts +0 -40
  337. package/dist/inner-plugins/utils/plugin-common.cjs +0 -147
  338. package/dist/inner-plugins/utils/plugin-common.d.cts +0 -11
  339. package/dist/inner-plugins/utils/plugin.cjs +0 -110
  340. package/dist/inner-plugins/utils/plugin.d.cts +0 -4
  341. package/dist/inner-plugins/utils/sdk.cjs +0 -59
  342. package/dist/inner-plugins/utils/sdk.d.cts +0 -8
  343. package/dist/rslib-runtime.js +0 -19
  344. package/dist/rules/index.cjs +0 -85
  345. package/dist/rules/index.d.cts +0 -3
  346. package/dist/rules/linter.cjs +0 -76
  347. package/dist/rules/linter.d.cts +0 -9
  348. package/dist/rules/rule.cjs +0 -141
  349. package/dist/rules/rule.d.cts +0 -27
  350. package/dist/rules/rules/cjs-require/index.cjs +0 -87
  351. package/dist/rules/rules/cjs-require/index.d.cts +0 -4
  352. package/dist/rules/rules/cjs-require/types.cjs +0 -18
  353. package/dist/rules/rules/cjs-require/types.d.cts +0 -7
  354. package/dist/rules/rules/cross-chunks-package/index.cjs +0 -78
  355. package/dist/rules/rules/cross-chunks-package/index.d.cts +0 -4
  356. package/dist/rules/rules/cross-chunks-package/types.cjs +0 -18
  357. package/dist/rules/rules/cross-chunks-package/types.d.cts +0 -3
  358. package/dist/rules/rules/cross-chunks-package/utils.cjs +0 -44
  359. package/dist/rules/rules/cross-chunks-package/utils.d.cts +0 -1
  360. package/dist/rules/rules/default-import-check/index.cjs +0 -120
  361. package/dist/rules/rules/default-import-check/index.d.cts +0 -4
  362. package/dist/rules/rules/default-import-check/types.cjs +0 -18
  363. package/dist/rules/rules/default-import-check/types.d.cts +0 -4
  364. package/dist/rules/rules/default-import-check/utils.cjs +0 -101
  365. package/dist/rules/rules/default-import-check/utils.d.cts +0 -10
  366. package/dist/rules/rules/duplicate-package/index.cjs +0 -76
  367. package/dist/rules/rules/duplicate-package/index.d.cts +0 -4
  368. package/dist/rules/rules/duplicate-package/types.cjs +0 -64
  369. package/dist/rules/rules/duplicate-package/types.d.cts +0 -24
  370. package/dist/rules/rules/duplicate-package/utils.cjs +0 -88
  371. package/dist/rules/rules/duplicate-package/utils.d.cts +0 -3
  372. package/dist/rules/rules/ecma-version-check/index.cjs +0 -100
  373. package/dist/rules/rules/ecma-version-check/index.d.cts +0 -4
  374. package/dist/rules/rules/ecma-version-check/types.cjs +0 -18
  375. package/dist/rules/rules/ecma-version-check/types.d.cts +0 -3
  376. package/dist/rules/rules/ecma-version-check/utils.cjs +0 -43
  377. package/dist/rules/rules/ecma-version-check/utils.d.cts +0 -2
  378. package/dist/rules/rules/esm-resolved-to-cjs/index.cjs +0 -256
  379. package/dist/rules/rules/esm-resolved-to-cjs/index.d.cts +0 -4
  380. package/dist/rules/rules/esm-resolved-to-cjs/types.cjs +0 -18
  381. package/dist/rules/rules/esm-resolved-to-cjs/types.d.cts +0 -8
  382. package/dist/rules/rules/index.cjs +0 -59
  383. package/dist/rules/rules/index.d.cts +0 -2
  384. package/dist/rules/rules/loader-performance-optimization/index.cjs +0 -123
  385. package/dist/rules/rules/loader-performance-optimization/index.d.cts +0 -4
  386. package/dist/rules/rules/loader-performance-optimization/types.cjs +0 -18
  387. package/dist/rules/rules/loader-performance-optimization/types.d.cts +0 -22
  388. package/dist/rules/rules/loader-performance-optimization/utils.cjs +0 -47
  389. package/dist/rules/rules/loader-performance-optimization/utils.d.cts +0 -1
  390. package/dist/rules/rules/module-mixed-chunks/index.cjs +0 -89
  391. package/dist/rules/rules/module-mixed-chunks/index.d.cts +0 -4
  392. package/dist/rules/rules/module-mixed-chunks/types.cjs +0 -18
  393. package/dist/rules/rules/module-mixed-chunks/types.d.cts +0 -3
  394. package/dist/rules/rules/side-effects-only-imports/index.cjs +0 -118
  395. package/dist/rules/rules/side-effects-only-imports/index.d.cts +0 -4
  396. package/dist/rules/rules/side-effects-only-imports/types.cjs +0 -18
  397. package/dist/rules/rules/side-effects-only-imports/types.d.cts +0 -9
  398. package/dist/rules/utils.cjs +0 -50
  399. package/dist/rules/utils.d.cts +0 -3
  400. package/dist/types/chunks.cjs +0 -18
  401. package/dist/types/chunks.d.cts +0 -6
  402. package/dist/types/chunks.d.ts +0 -6
  403. package/dist/types/index.cjs +0 -83
  404. package/dist/types/index.d.cts +0 -4
  405. package/dist/types/loader.cjs +0 -18
  406. package/dist/types/loader.d.cts +0 -19
  407. package/dist/types/plugin.cjs +0 -18
  408. package/dist/types/plugin.d.cts +0 -51
  409. package/dist/types/rules.cjs +0 -18
  410. package/dist/types/rules.d.cts +0 -7
  411. /package/dist/{types/chunks.js → rule-utils/document/types.js} +0 -0
@@ -0,0 +1,46 @@
1
+ import "node:module";
2
+ import { Lodash } from "../../common/index.js";
3
+ import { LinesAndColumns } from "lines-and-columns";
4
+ class Document {
5
+ createFinder() {
6
+ const find = new LinesAndColumns(this._text);
7
+ this.positionAt = (offset)=>{
8
+ if (offset >= this._text.length) offset = this._text.length - 1;
9
+ if (offset < 0) offset = 0;
10
+ const result = find.locationForIndex(offset);
11
+ if (!result) return;
12
+ return {
13
+ line: result.line + 1,
14
+ column: result.column
15
+ };
16
+ };
17
+ this.offsetAt = (position)=>find.indexForLocation({
18
+ line: position.line - 1,
19
+ column: position.column
20
+ }) ?? void 0;
21
+ }
22
+ getText(range) {
23
+ if (!range) return this._text;
24
+ const start = 'number' == typeof range.start ? range.start : this.offsetAt(range.start);
25
+ const end = 'number' == typeof range.end ? range.end : this.offsetAt(range.end);
26
+ if (Lodash.isUndefined(start)) throw new Error(`Location ${JSON.stringify(start)} is illegal`);
27
+ if (Lodash.isUndefined(end)) throw new Error(`Location ${JSON.stringify(end)} is illegal`);
28
+ return this._text.slice(start, end);
29
+ }
30
+ edit(data) {
31
+ let { _text: content } = this;
32
+ const startOffset = Lodash.isNumber(data.start) ? data.start : this.offsetAt(data.start);
33
+ const endOffset = Lodash.isNumber(data.end) ? data.end : this.offsetAt(data.end);
34
+ if (Lodash.isUndefined(startOffset) || Lodash.isUndefined(endOffset)) return;
35
+ const startTxt = content.substring(0, startOffset);
36
+ const endTxt = content.substring(endOffset, content.length);
37
+ content = startTxt + data.newText + endTxt;
38
+ return content;
39
+ }
40
+ constructor(content){
41
+ this._text = '';
42
+ this._text = content;
43
+ this.createFinder();
44
+ }
45
+ }
46
+ export { Document };
@@ -0,0 +1,3 @@
1
+ export * from './document.js';
2
+ export * from './types.js';
3
+ export * from './server.js';
@@ -0,0 +1,4 @@
1
+ import "node:module";
2
+ export * from "./document.js";
3
+ export * from "./types.js";
4
+ export * from "./server.js";
@@ -0,0 +1,4 @@
1
+ import { Document } from './document.js';
2
+ /** Create Document */
3
+ export declare function getDocument(content: string): Document;
4
+ export declare function clearDocument(): void;
@@ -0,0 +1,13 @@
1
+ import "node:module";
2
+ import { Document } from "./document.js";
3
+ const store = new Map();
4
+ function getDocument(content) {
5
+ if (store.has(content)) return store.get(content);
6
+ const doc = new Document(content);
7
+ store.set(content, doc);
8
+ return doc;
9
+ }
10
+ function clearDocument() {
11
+ store.clear();
12
+ }
13
+ export { clearDocument, getDocument };
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Location
3
+ * - line starting point is 1
4
+ * - column starting point is 0
5
+ */
6
+ export interface Position {
7
+ line: number;
8
+ column: number;
9
+ }
10
+ /** Location range */
11
+ export interface Range {
12
+ start: Position;
13
+ end: Position;
14
+ }
15
+ /** Offset range */
16
+ export interface OffsetRange {
17
+ start: number;
18
+ end: number;
19
+ }
20
+ /** Text repair data */
21
+ export interface DocumentEditData {
22
+ /** Modify the starting position of string in the original text */
23
+ start: number | Position;
24
+ /** Modify string in the key position of the original text */
25
+ end: number | Position;
26
+ /**
27
+ * Replaced new text
28
+ * - If empty, delete the original text
29
+ */
30
+ newText?: string;
31
+ }
@@ -0,0 +1,2 @@
1
+ export * from './document/index.js';
2
+ export * from './parser/index.js';
@@ -0,0 +1,3 @@
1
+ import "node:module";
2
+ export * from "./document/index.js";
3
+ export * from "./parser/index.js";
@@ -0,0 +1,81 @@
1
+ import { Node } from './types.js';
2
+ export declare const asserts: {
3
+ readonly isProgram: (node: unknown) => node is Node.Program;
4
+ readonly isEmptyStatement: (node: unknown) => node is Node.EmptyStatement;
5
+ readonly isBlockStatement: (node: unknown) => node is Node.BlockStatement;
6
+ readonly isStaticBlock: (node: unknown) => node is Node.StaticBlock;
7
+ readonly isExpressionStatement: (node: unknown) => node is Node.ExpressionStatement;
8
+ readonly isIfStatement: (node: unknown) => node is Node.IfStatement;
9
+ readonly isLabeledStatement: (node: unknown) => node is Node.LabeledStatement;
10
+ readonly isBreakStatement: (node: unknown) => node is Node.BreakStatement;
11
+ readonly isContinueStatement: (node: unknown) => node is Node.ContinueStatement;
12
+ readonly isWithStatement: (node: unknown) => node is Node.WithStatement;
13
+ readonly isSwitchStatement: (node: unknown) => node is Node.SwitchStatement;
14
+ readonly isReturnStatement: (node: unknown) => node is Node.ReturnStatement;
15
+ readonly isThrowStatement: (node: unknown) => node is Node.ThrowStatement;
16
+ readonly isTryStatement: (node: unknown) => node is Node.TryStatement;
17
+ readonly isWhileStatement: (node: unknown) => node is Node.WhileStatement;
18
+ readonly isDoWhileStatement: (node: unknown) => node is Node.DoWhileStatement;
19
+ readonly isForStatement: (node: unknown) => node is Node.ForStatement;
20
+ readonly isForInStatement: (node: unknown) => node is Node.ForInStatement;
21
+ readonly isForOfStatement: (node: unknown) => node is Node.ForOfStatement;
22
+ readonly isDebuggerStatement: (node: unknown) => node is Node.DebuggerStatement;
23
+ readonly isFunctionDeclaration: (node: unknown) => node is Node.FunctionDeclaration;
24
+ readonly isVariableDeclaration: (node: unknown) => node is Node.VariableDeclaration;
25
+ readonly isVariableDeclarator: (node: unknown) => node is Node.VariableDeclarator;
26
+ readonly isChainExpression: (node: unknown) => node is Node.ChainExpression;
27
+ readonly isThisExpression: (node: unknown) => node is Node.ThisExpression;
28
+ readonly isArrayExpression: (node: unknown) => node is Node.ArrayExpression;
29
+ readonly isObjectExpression: (node: unknown) => node is Node.ObjectExpression;
30
+ readonly isPrivateIdentifier: (node: unknown) => node is Node.PrivateIdentifier;
31
+ readonly isProperty: (node: unknown) => node is Node.Property;
32
+ readonly isPropertyDefinition: (node: unknown) => node is Node.PropertyDefinition;
33
+ readonly isFunctionExpression: (node: unknown) => node is Node.FunctionExpression;
34
+ readonly isSequenceExpression: (node: unknown) => node is Node.SequenceExpression;
35
+ readonly isUnaryExpression: (node: unknown) => node is Node.UnaryExpression;
36
+ readonly isBinaryExpression: (node: unknown) => node is Node.BinaryExpression;
37
+ readonly isAssignmentExpression: (node: unknown) => node is Node.AssignmentExpression;
38
+ readonly isUpdateExpression: (node: unknown) => node is Node.UpdateExpression;
39
+ readonly isLogicalExpression: (node: unknown) => node is Node.LogicalExpression;
40
+ readonly isConditionalExpression: (node: unknown) => node is Node.ConditionalExpression;
41
+ readonly isNewExpression: (node: unknown) => node is Node.NewExpression;
42
+ readonly isSwitchCase: (node: unknown) => node is Node.SwitchCase;
43
+ readonly isCatchClause: (node: unknown) => node is Node.CatchClause;
44
+ readonly isIdentifier: (node: unknown) => node is Node.Identifier;
45
+ readonly isLiteral: (node: unknown) => node is Node.Literal;
46
+ readonly isSuper: (node: unknown) => node is Node.Super;
47
+ readonly isSpreadElement: (node: unknown) => node is Node.SpreadElement;
48
+ readonly isArrowFunctionExpression: (node: unknown) => node is Node.ArrowFunctionExpression;
49
+ readonly isYieldExpression: (node: unknown) => node is Node.YieldExpression;
50
+ readonly isTemplateLiteral: (node: unknown) => node is Node.TemplateLiteral;
51
+ readonly isTaggedTemplateExpression: (node: unknown) => node is Node.TaggedTemplateExpression;
52
+ readonly isTemplateElement: (node: unknown) => node is Node.TemplateElement;
53
+ readonly isObjectPattern: (node: unknown) => node is Node.ObjectPattern;
54
+ readonly isArrayPattern: (node: unknown) => node is Node.ArrayPattern;
55
+ readonly isRestElement: (node: unknown) => node is Node.RestElement;
56
+ readonly isAssignmentPattern: (node: unknown) => node is Node.AssignmentPattern;
57
+ readonly isClassBody: (node: unknown) => node is Node.ClassBody;
58
+ readonly isClassDeclaration: (node: unknown) => node is Node.ClassDeclaration;
59
+ readonly isClassExpression: (node: unknown) => node is Node.ClassExpression;
60
+ readonly isMetaProperty: (node: unknown) => node is Node.MetaProperty;
61
+ readonly isImportDeclaration: (node: unknown) => node is Node.ImportDeclaration;
62
+ readonly isImportSpecifier: (node: unknown) => node is Node.ImportSpecifier;
63
+ readonly isImportExpression: (node: unknown) => node is Node.ImportExpression;
64
+ readonly isImportDefaultSpecifier: (node: unknown) => node is Node.ImportDefaultSpecifier;
65
+ readonly isImportNamespaceSpecifier: (node: unknown) => node is Node.ImportNamespaceSpecifier;
66
+ readonly isExportNamedDeclaration: (node: unknown) => node is Node.ExportNamedDeclaration;
67
+ readonly isExportSpecifier: (node: unknown) => node is Node.ExportSpecifier;
68
+ readonly isExportDefaultDeclaration: (node: unknown) => node is Node.ExportDefaultDeclaration;
69
+ readonly isExportAllDeclaration: (node: unknown) => node is Node.ExportAllDeclaration;
70
+ readonly isAwaitExpression: (node: unknown) => node is Node.AwaitExpression;
71
+ readonly isMethodDefinition: (node: unknown) => node is Node.MethodDefinition;
72
+ readonly isMemberExpression: (node: unknown) => node is Node.MemberExpression;
73
+ readonly isComment: (node: unknown) => node is Node.Comment;
74
+ readonly isDirective: (node: unknown) => node is Node.Directive;
75
+ readonly isSimpleCallExpression: (node: unknown) => node is Node.SimpleCallExpression;
76
+ readonly isAssignmentProperty: (node: unknown) => node is Node.AssignmentProperty;
77
+ readonly isSimpleLiteral: (node: unknown) => node is Node.SimpleLiteral;
78
+ readonly isRegExpLiteral: (node: unknown) => node is Node.RegExpLiteral;
79
+ readonly isBigIntLiteral: (node: unknown) => node is Node.BigIntLiteral;
80
+ readonly isExportStatement: (node: unknown) => node is Node.ExportStatement;
81
+ };
@@ -0,0 +1,105 @@
1
+ import "node:module";
2
+ import { Lodash } from "../../common/index.js";
3
+ function isSyntaxNode(node) {
4
+ return Lodash.isObject(node) && 'type' in node;
5
+ }
6
+ function assertCreator(type) {
7
+ return (node)=>isSyntaxNode(node) && node.type === type;
8
+ }
9
+ const asserts = {
10
+ isProgram: assertCreator('Program'),
11
+ isEmptyStatement: assertCreator('EmptyStatement'),
12
+ isBlockStatement: assertCreator('BlockStatement'),
13
+ isStaticBlock: assertCreator('StaticBlock'),
14
+ isExpressionStatement: assertCreator('ExpressionStatement'),
15
+ isIfStatement: assertCreator('IfStatement'),
16
+ isLabeledStatement: assertCreator('LabeledStatement'),
17
+ isBreakStatement: assertCreator('BreakStatement'),
18
+ isContinueStatement: assertCreator('ContinueStatement'),
19
+ isWithStatement: assertCreator('WithStatement'),
20
+ isSwitchStatement: assertCreator('SwitchStatement'),
21
+ isReturnStatement: assertCreator('ReturnStatement'),
22
+ isThrowStatement: assertCreator('ThrowStatement'),
23
+ isTryStatement: assertCreator('TryStatement'),
24
+ isWhileStatement: assertCreator('WhileStatement'),
25
+ isDoWhileStatement: assertCreator('DoWhileStatement'),
26
+ isForStatement: assertCreator('ForStatement'),
27
+ isForInStatement: assertCreator('ForInStatement'),
28
+ isForOfStatement: assertCreator('ForOfStatement'),
29
+ isDebuggerStatement: assertCreator('DebuggerStatement'),
30
+ isFunctionDeclaration: assertCreator('FunctionDeclaration'),
31
+ isVariableDeclaration: assertCreator('VariableDeclaration'),
32
+ isVariableDeclarator: assertCreator('VariableDeclarator'),
33
+ isChainExpression: assertCreator('ChainExpression'),
34
+ isThisExpression: assertCreator('ThisExpression'),
35
+ isArrayExpression: assertCreator('ArrayExpression'),
36
+ isObjectExpression: assertCreator('ObjectExpression'),
37
+ isPrivateIdentifier: assertCreator('PrivateIdentifier'),
38
+ isProperty: assertCreator('Property'),
39
+ isPropertyDefinition: assertCreator('PropertyDefinition'),
40
+ isFunctionExpression: assertCreator('FunctionExpression'),
41
+ isSequenceExpression: assertCreator('SequenceExpression'),
42
+ isUnaryExpression: assertCreator('UnaryExpression'),
43
+ isBinaryExpression: assertCreator('BinaryExpression'),
44
+ isAssignmentExpression: assertCreator('AssignmentExpression'),
45
+ isUpdateExpression: assertCreator('UpdateExpression'),
46
+ isLogicalExpression: assertCreator('LogicalExpression'),
47
+ isConditionalExpression: assertCreator('ConditionalExpression'),
48
+ isNewExpression: assertCreator('NewExpression'),
49
+ isSwitchCase: assertCreator('SwitchCase'),
50
+ isCatchClause: assertCreator('CatchClause'),
51
+ isIdentifier: assertCreator('Identifier'),
52
+ isLiteral: assertCreator('Literal'),
53
+ isSuper: assertCreator('Super'),
54
+ isSpreadElement: assertCreator('SpreadElement'),
55
+ isArrowFunctionExpression: assertCreator('ArrowFunctionExpression'),
56
+ isYieldExpression: assertCreator('YieldExpression'),
57
+ isTemplateLiteral: assertCreator('TemplateLiteral'),
58
+ isTaggedTemplateExpression: assertCreator('TaggedTemplateExpression'),
59
+ isTemplateElement: assertCreator('TemplateElement'),
60
+ isObjectPattern: assertCreator('ObjectPattern'),
61
+ isArrayPattern: assertCreator('ArrayPattern'),
62
+ isRestElement: assertCreator('RestElement'),
63
+ isAssignmentPattern: assertCreator('AssignmentPattern'),
64
+ isClassBody: assertCreator('ClassBody'),
65
+ isClassDeclaration: assertCreator('ClassDeclaration'),
66
+ isClassExpression: assertCreator('ClassExpression'),
67
+ isMetaProperty: assertCreator('MetaProperty'),
68
+ isImportDeclaration: assertCreator('ImportDeclaration'),
69
+ isImportSpecifier: assertCreator('ImportSpecifier'),
70
+ isImportExpression: assertCreator('ImportExpression'),
71
+ isImportDefaultSpecifier: assertCreator('ImportDefaultSpecifier'),
72
+ isImportNamespaceSpecifier: assertCreator('ImportNamespaceSpecifier'),
73
+ isExportNamedDeclaration: assertCreator('ExportNamedDeclaration'),
74
+ isExportSpecifier: assertCreator('ExportSpecifier'),
75
+ isExportDefaultDeclaration: assertCreator('ExportDefaultDeclaration'),
76
+ isExportAllDeclaration: assertCreator('ExportAllDeclaration'),
77
+ isAwaitExpression: assertCreator('AwaitExpression'),
78
+ isMethodDefinition: assertCreator('MethodDefinition'),
79
+ isMemberExpression: assertCreator('MemberExpression'),
80
+ isComment (node) {
81
+ return isSyntaxNode(node) && ('Line' === node.type || 'Block' === node.type);
82
+ },
83
+ isDirective (node) {
84
+ return asserts.isExpressionStatement(node) && 'directive' in node;
85
+ },
86
+ isSimpleCallExpression (node) {
87
+ return isSyntaxNode(node) && 'CallExpression' === node.type;
88
+ },
89
+ isAssignmentProperty (node) {
90
+ return asserts.isProperty(node) && 'init' === node.kind;
91
+ },
92
+ isSimpleLiteral (node) {
93
+ return asserts.isLiteral(node) && !asserts.isRegExpLiteral(node) && !asserts.isBigIntLiteral(node);
94
+ },
95
+ isRegExpLiteral (node) {
96
+ return asserts.isLiteral(node) && 'regex' in node;
97
+ },
98
+ isBigIntLiteral (node) {
99
+ return asserts.isLiteral(node) && 'bigint' in node;
100
+ },
101
+ isExportStatement (node) {
102
+ return asserts.isExportAllDeclaration(node) || asserts.isExportDefaultDeclaration(node) || asserts.isExportNamedDeclaration(node);
103
+ }
104
+ };
105
+ export { asserts };
@@ -0,0 +1,4 @@
1
+ export * from './asserts.js';
2
+ export * from './parser.js';
3
+ export * from './utils.js';
4
+ export * from './types.js';
@@ -0,0 +1,5 @@
1
+ import "node:module";
2
+ export * from "./asserts.js";
3
+ export * from "./parser.js";
4
+ export * from "./utils.js";
5
+ export * from "./types.js";
@@ -0,0 +1,118 @@
1
+ import { Parser as AcornParser, Options, Position } from 'acorn';
2
+ import * as walk from 'acorn-walk';
3
+ import * as utils from './utils.js';
4
+ import type { Node } from './types.js';
5
+ export type { Options as ParseOptions } from 'acorn';
6
+ export interface ParseError extends Error {
7
+ loc?: Position;
8
+ pos: number;
9
+ raisedAt: number;
10
+ }
11
+ export declare const parser: {
12
+ /** AST iterator */
13
+ walk: typeof walk;
14
+ /**
15
+ * Compile code
16
+ * - Output root node is `Node.Program`
17
+ */
18
+ parse: (input: string, options: Options) => Node.Program;
19
+ /**
20
+ * Compile the next first expression
21
+ * - The output root node is `Node.ExpressionStatement`
22
+ */
23
+ parseExpressionAt: (input: string, pos: number, options: Options) => Node.ExpressionStatement;
24
+ /**
25
+ * add plugins for acorn
26
+ */
27
+ extend(...args: Parameters<typeof AcornParser.extend>): typeof AcornParser;
28
+ /** Set of assertions */
29
+ asserts: {
30
+ readonly isProgram: (node: unknown) => node is Node.Program;
31
+ readonly isEmptyStatement: (node: unknown) => node is Node.EmptyStatement;
32
+ readonly isBlockStatement: (node: unknown) => node is Node.BlockStatement;
33
+ readonly isStaticBlock: (node: unknown) => node is Node.StaticBlock;
34
+ readonly isExpressionStatement: (node: unknown) => node is Node.ExpressionStatement;
35
+ readonly isIfStatement: (node: unknown) => node is Node.IfStatement;
36
+ readonly isLabeledStatement: (node: unknown) => node is Node.LabeledStatement;
37
+ readonly isBreakStatement: (node: unknown) => node is Node.BreakStatement;
38
+ readonly isContinueStatement: (node: unknown) => node is Node.ContinueStatement;
39
+ readonly isWithStatement: (node: unknown) => node is Node.WithStatement;
40
+ readonly isSwitchStatement: (node: unknown) => node is Node.SwitchStatement;
41
+ readonly isReturnStatement: (node: unknown) => node is Node.ReturnStatement;
42
+ readonly isThrowStatement: (node: unknown) => node is Node.ThrowStatement;
43
+ readonly isTryStatement: (node: unknown) => node is Node.TryStatement;
44
+ readonly isWhileStatement: (node: unknown) => node is Node.WhileStatement;
45
+ readonly isDoWhileStatement: (node: unknown) => node is Node.DoWhileStatement;
46
+ readonly isForStatement: (node: unknown) => node is Node.ForStatement;
47
+ readonly isForInStatement: (node: unknown) => node is Node.ForInStatement;
48
+ readonly isForOfStatement: (node: unknown) => node is Node.ForOfStatement;
49
+ readonly isDebuggerStatement: (node: unknown) => node is Node.DebuggerStatement;
50
+ readonly isFunctionDeclaration: (node: unknown) => node is Node.FunctionDeclaration;
51
+ readonly isVariableDeclaration: (node: unknown) => node is Node.VariableDeclaration;
52
+ readonly isVariableDeclarator: (node: unknown) => node is Node.VariableDeclarator;
53
+ readonly isChainExpression: (node: unknown) => node is Node.ChainExpression;
54
+ readonly isThisExpression: (node: unknown) => node is Node.ThisExpression;
55
+ readonly isArrayExpression: (node: unknown) => node is Node.ArrayExpression;
56
+ readonly isObjectExpression: (node: unknown) => node is Node.ObjectExpression;
57
+ readonly isPrivateIdentifier: (node: unknown) => node is Node.PrivateIdentifier;
58
+ readonly isProperty: (node: unknown) => node is Node.Property;
59
+ readonly isPropertyDefinition: (node: unknown) => node is Node.PropertyDefinition;
60
+ readonly isFunctionExpression: (node: unknown) => node is Node.FunctionExpression;
61
+ readonly isSequenceExpression: (node: unknown) => node is Node.SequenceExpression;
62
+ readonly isUnaryExpression: (node: unknown) => node is Node.UnaryExpression;
63
+ readonly isBinaryExpression: (node: unknown) => node is Node.BinaryExpression;
64
+ readonly isAssignmentExpression: (node: unknown) => node is Node.AssignmentExpression;
65
+ readonly isUpdateExpression: (node: unknown) => node is Node.UpdateExpression;
66
+ readonly isLogicalExpression: (node: unknown) => node is Node.LogicalExpression;
67
+ readonly isConditionalExpression: (node: unknown) => node is Node.ConditionalExpression;
68
+ readonly isNewExpression: (node: unknown) => node is Node.NewExpression;
69
+ readonly isSwitchCase: (node: unknown) => node is Node.SwitchCase;
70
+ readonly isCatchClause: (node: unknown) => node is Node.CatchClause;
71
+ readonly isIdentifier: (node: unknown) => node is Node.Identifier;
72
+ readonly isLiteral: (node: unknown) => node is Node.Literal;
73
+ readonly isSuper: (node: unknown) => node is Node.Super;
74
+ readonly isSpreadElement: (node: unknown) => node is Node.SpreadElement;
75
+ readonly isArrowFunctionExpression: (node: unknown) => node is Node.ArrowFunctionExpression;
76
+ readonly isYieldExpression: (node: unknown) => node is Node.YieldExpression;
77
+ readonly isTemplateLiteral: (node: unknown) => node is Node.TemplateLiteral;
78
+ readonly isTaggedTemplateExpression: (node: unknown) => node is Node.TaggedTemplateExpression;
79
+ readonly isTemplateElement: (node: unknown) => node is Node.TemplateElement;
80
+ readonly isObjectPattern: (node: unknown) => node is Node.ObjectPattern;
81
+ readonly isArrayPattern: (node: unknown) => node is Node.ArrayPattern;
82
+ readonly isRestElement: (node: unknown) => node is Node.RestElement;
83
+ readonly isAssignmentPattern: (node: unknown) => node is Node.AssignmentPattern;
84
+ readonly isClassBody: (node: unknown) => node is Node.ClassBody;
85
+ readonly isClassDeclaration: (node: unknown) => node is Node.ClassDeclaration;
86
+ readonly isClassExpression: (node: unknown) => node is Node.ClassExpression;
87
+ readonly isMetaProperty: (node: unknown) => node is Node.MetaProperty;
88
+ readonly isImportDeclaration: (node: unknown) => node is Node.ImportDeclaration;
89
+ readonly isImportSpecifier: (node: unknown) => node is Node.ImportSpecifier;
90
+ readonly isImportExpression: (node: unknown) => node is Node.ImportExpression;
91
+ readonly isImportDefaultSpecifier: (node: unknown) => node is Node.ImportDefaultSpecifier;
92
+ readonly isImportNamespaceSpecifier: (node: unknown) => node is Node.ImportNamespaceSpecifier;
93
+ readonly isExportNamedDeclaration: (node: unknown) => node is Node.ExportNamedDeclaration;
94
+ readonly isExportSpecifier: (node: unknown) => node is Node.ExportSpecifier;
95
+ readonly isExportDefaultDeclaration: (node: unknown) => node is Node.ExportDefaultDeclaration;
96
+ readonly isExportAllDeclaration: (node: unknown) => node is Node.ExportAllDeclaration;
97
+ readonly isAwaitExpression: (node: unknown) => node is Node.AwaitExpression;
98
+ readonly isMethodDefinition: (node: unknown) => node is Node.MethodDefinition;
99
+ readonly isMemberExpression: (node: unknown) => node is Node.MemberExpression;
100
+ readonly isComment: (node: unknown) => node is Node.Comment;
101
+ readonly isDirective: (node: unknown) => node is Node.Directive;
102
+ readonly isSimpleCallExpression: (node: unknown) => node is Node.SimpleCallExpression;
103
+ readonly isAssignmentProperty: (node: unknown) => node is Node.AssignmentProperty;
104
+ readonly isSimpleLiteral: (node: unknown) => node is Node.SimpleLiteral;
105
+ readonly isRegExpLiteral: (node: unknown) => node is Node.RegExpLiteral;
106
+ readonly isBigIntLiteral: (node: unknown) => node is Node.BigIntLiteral;
107
+ readonly isExportStatement: (node: unknown) => node is Node.ExportStatement;
108
+ };
109
+ utils: typeof utils;
110
+ /**
111
+ * @internal
112
+ * parser for internal packages
113
+ */
114
+ internal: {
115
+ parse: (input: string, options: Options) => Node.Program;
116
+ parseExpressionAt: (input: string, pos: number, options: Options) => Node.ExpressionStatement;
117
+ };
118
+ };
@@ -0,0 +1,24 @@
1
+ import "node:module";
2
+ import { Parser } from "acorn";
3
+ import { importAttributes } from "acorn-import-attributes";
4
+ import * as __rspack_external_acorn_walk_1e4235a7 from "acorn-walk";
5
+ import { asserts } from "./asserts.js";
6
+ import * as __rspack_external__utils_js_a9c81ddd from "./utils.js";
7
+ const acornParserInternal = Parser.extend(importAttributes);
8
+ let acornParserExport = Parser.extend(importAttributes);
9
+ const parser = {
10
+ walk: __rspack_external_acorn_walk_1e4235a7,
11
+ parse: (input, options)=>acornParserExport.parse(input, options),
12
+ parseExpressionAt: (input, pos, options)=>acornParserExport.parseExpressionAt(input, pos, options),
13
+ extend (...args) {
14
+ acornParserExport = acornParserExport.extend(...args);
15
+ return acornParserExport;
16
+ },
17
+ asserts: asserts,
18
+ utils: __rspack_external__utils_js_a9c81ddd,
19
+ internal: {
20
+ parse: (input, options)=>acornParserInternal.parse(input, options),
21
+ parseExpressionAt: (input, pos, options)=>acornParserInternal.parseExpressionAt(input, pos, options)
22
+ }
23
+ };
24
+ export { parser };
@@ -0,0 +1,30 @@
1
+ import type * as Node from 'estree';
2
+ export type { Node };
3
+ export declare enum ECMAVersion {
4
+ ES5 = "ES5",
5
+ ES6 = "ES6",
6
+ ES7P = "ES7+"
7
+ }
8
+ /**
9
+ * estree supplement type
10
+ * Mainly to match the node type of acorn
11
+ * The main reason for not using the type of acorn directly is that the node type described by acorn itself is too simple
12
+ */
13
+ declare module 'estree' {
14
+ interface BaseNode {
15
+ start: number;
16
+ end: number;
17
+ loc?: SourceLocation | undefined;
18
+ }
19
+ interface Position {
20
+ offset: number;
21
+ }
22
+ /** all syntax nodes */
23
+ type SyntaxNode = Node.Comment | Node.Program | Node.Directive | Node.EmptyStatement | Node.BlockStatement | Node.StaticBlock | Node.ExpressionStatement | Node.IfStatement | Node.LabeledStatement | Node.BreakStatement | Node.ContinueStatement | Node.WithStatement | Node.SwitchStatement | Node.ReturnStatement | Node.ThrowStatement | Node.TryStatement | Node.WhileStatement | Node.DoWhileStatement | Node.ForStatement | Node.ForInStatement | Node.DebuggerStatement | Node.FunctionDeclaration | Node.VariableDeclaration | Node.VariableDeclarator | Node.ChainExpression | Node.ThisExpression | Node.ArrayExpression | Node.ObjectExpression | Node.PrivateIdentifier | Node.Property | Node.PropertyDefinition | Node.FunctionExpression | Node.SequenceExpression | Node.UnaryExpression | Node.BinaryExpression | Node.AssignmentExpression | Node.UpdateExpression | Node.LogicalExpression | Node.ConditionalExpression | Node.SimpleCallExpression | Node.NewExpression | Node.MemberExpression | Node.SwitchCase | Node.CatchClause | Node.Identifier | Node.SimpleLiteral | Node.RegExpLiteral | Node.BigIntLiteral | Node.ForOfStatement | Node.Super | Node.SpreadElement | Node.ArrowFunctionExpression | Node.YieldExpression | Node.TemplateLiteral | Node.TaggedTemplateExpression | Node.TemplateElement | Node.AssignmentProperty | Node.ObjectPattern | Node.ArrayPattern | Node.RestElement | Node.AssignmentPattern | Node.ClassBody | Node.MethodDefinition | Node.ClassDeclaration | Node.ClassExpression | Node.MetaProperty | Node.ImportDeclaration | Node.ImportSpecifier | Node.ImportExpression | Node.ImportDefaultSpecifier | Node.ImportNamespaceSpecifier | Node.ExportNamedDeclaration | Node.ExportSpecifier | Node.ExportDefaultDeclaration | Node.ExportAllDeclaration | Node.AwaitExpression;
24
+ /** all operators */
25
+ type SyntaxOperator = Node.UnaryOperator | Node.BinaryOperator | Node.LogicalOperator | Node.AssignmentOperator | Node.UpdateOperator;
26
+ /** Block-scoped statement */
27
+ type BlockScopeStatement = Node.StaticBlock | Node.BlockStatement | Node.ForInStatement | Node.ForOfStatement | Node.ForStatement | Node.CatchClause | Node.SwitchStatement;
28
+ /** Export statement */
29
+ type ExportStatement = Node.ExportAllDeclaration | Node.ExportDefaultDeclaration | Node.ExportNamedDeclaration;
30
+ }
@@ -0,0 +1,8 @@
1
+ import "node:module";
2
+ var types_ECMAVersion = /*#__PURE__*/ function(ECMAVersion) {
3
+ ECMAVersion["ES5"] = "ES5";
4
+ ECMAVersion["ES6"] = "ES6";
5
+ ECMAVersion["ES7P"] = "ES7+";
6
+ return ECMAVersion;
7
+ }({});
8
+ export { types_ECMAVersion as ECMAVersion };
@@ -0,0 +1,30 @@
1
+ import { ecmaVersion } from 'acorn';
2
+ import { Node, ECMAVersion } from './types.js';
3
+ /**
4
+ * Is the node semantics the same?
5
+ * @deprecated
6
+ * - Recursively compare whether the content of the node itself is the same
7
+ * - Ignore comments, positions, string symbols (single and double quotation marks)
8
+ * - String templates and string addition will be considered different
9
+ */
10
+ export declare function isSameSemantics(node1: Node.SyntaxNode, node2: Node.SyntaxNode): boolean;
11
+ /**
12
+ * Get all default reference statements
13
+ */
14
+ export declare function getDefaultImports(node: Node.Program): Node.ImportDeclaration[];
15
+ /** Get the literal in the text. */
16
+ export declare function getIdentifierInPattern(name: string, node: Node.Pattern): Node.Identifier | undefined;
17
+ /** Get the variable declaration statement identifier. */
18
+ export declare function getIdentifierInDeclaration(name: string, node: Node.SyntaxNode): Node.Identifier | undefined;
19
+ /** Get the reference declaration statement identifier. */
20
+ export declare function getIdentifierInImport(name: string, node: Node.SyntaxNode): Node.Identifier | undefined;
21
+ /** Get the export statement identifier. */
22
+ export declare function getIdentifierInExport(name: string, node: Node.SyntaxNode): Node.Identifier | undefined;
23
+ /** Determine that it can be resolved using the specified ECMA version */
24
+ export declare function canParse(code: string, ecmaVersion: ecmaVersion): boolean;
25
+ /** Determine whether it is all ES5 version code. */
26
+ export declare function isES5(code: string): boolean;
27
+ /** Determine whether it is all ES6 version code. */
28
+ export declare function isES6(code: string): boolean;
29
+ /** Detect ECMA version. */
30
+ export declare function detectECMAVersion(code: string): ECMAVersion;
@@ -0,0 +1,106 @@
1
+ import "node:module";
2
+ import { parse } from "acorn";
3
+ import { ECMAVersion } from "./types.js";
4
+ import { asserts } from "./asserts.js";
5
+ function isSameSemantics(node1, node2) {
6
+ if (node1.type !== node2.type) return false;
7
+ switch(node1.type){
8
+ case 'CallExpression':
9
+ {
10
+ const next = node2;
11
+ return node1.arguments.length === next.arguments.length && Boolean(node1.optional) === Boolean(next.optional) && isSameSemantics(node1.callee, next.callee) && node1.arguments.every((node, i)=>isSameSemantics(node, next.arguments[i]));
12
+ }
13
+ case 'MemberExpression':
14
+ {
15
+ const next = node2;
16
+ return node1.computed === next.computed && Boolean(node1.optional) === Boolean(next.optional) && isSameSemantics(node1.object, next.object) && isSameSemantics(node1.property, next.property);
17
+ }
18
+ case 'Identifier':
19
+ return node1.name === node2.name;
20
+ case 'Literal':
21
+ if (asserts.isSimpleLiteral(node1) && asserts.isSimpleLiteral(node2)) return node1.value === node2.value;
22
+ return node1.raw === node2.raw;
23
+ case 'ObjectExpression':
24
+ {
25
+ const next = node2;
26
+ return node1.properties.length === next.properties.length && node1.properties.every((prop, i)=>isSameSemantics(prop, next.properties[i]));
27
+ }
28
+ case 'Property':
29
+ {
30
+ const next = node2;
31
+ return node1.computed === next.computed && node1.kind === next.kind && node1.method === next.method && isSameSemantics(node1.key, next.key) && isSameSemantics(node1.value, next.value);
32
+ }
33
+ default:
34
+ throw new Error(`Unknown node type: ${node1.type}`);
35
+ }
36
+ }
37
+ function getDefaultImports(node) {
38
+ return node.body.filter((statement)=>{
39
+ if ('ImportDeclaration' !== statement.type) return false;
40
+ const specifier = statement?.specifiers?.[0];
41
+ if (specifier?.type === 'ImportDefaultSpecifier') return true;
42
+ return false;
43
+ });
44
+ }
45
+ function getIdentifierInPattern(name, node) {
46
+ if (asserts.isIdentifier(node) && node.name === name) return node;
47
+ if (asserts.isObjectPattern(node)) for (const prop of node.properties){
48
+ if (asserts.isAssignmentProperty(prop)) return getIdentifierInPattern(name, prop.value);
49
+ if (asserts.isRestElement(prop)) return getIdentifierInPattern(name, prop);
50
+ }
51
+ if (asserts.isArrayPattern(node)) {
52
+ for (const el of node.elements)if (el) {
53
+ const result = getIdentifierInPattern(name, el);
54
+ if (result) return result;
55
+ }
56
+ }
57
+ if (asserts.isRestElement(node)) return getIdentifierInPattern(name, node.argument);
58
+ if (asserts.isAssignmentPattern(node)) return getIdentifierInPattern(name, node.left);
59
+ }
60
+ function getIdentifierInDeclaration(name, node) {
61
+ function getId(node) {
62
+ return asserts.isIdentifier(node.id) && node.id.name === name ? node.id : void 0;
63
+ }
64
+ if (asserts.isFunctionDeclaration(node)) return getId(node);
65
+ if (asserts.isClassDeclaration(node)) return getId(node);
66
+ if (asserts.isVariableDeclaration(node)) return node.declarations.find((item)=>getIdentifierInPattern(name, item.id))?.id;
67
+ }
68
+ function getIdentifierInImport(name, node) {
69
+ if (asserts.isImportDeclaration(node)) {
70
+ for (const specifier of node.specifiers ?? [])if (specifier.local.name === name) return specifier.local;
71
+ }
72
+ }
73
+ function getIdentifierInExport(name, node) {
74
+ if (asserts.isExportNamedDeclaration(node)) {
75
+ if (node.declaration) return getIdentifierInDeclaration(name, node.declaration);
76
+ for (const specifier of node.specifiers ?? [])if (specifier.exported.name === name) return specifier.exported;
77
+ }
78
+ if (asserts.isExportAllDeclaration(node) && node.exported) {
79
+ if (node.exported.name === name) return node.exported;
80
+ }
81
+ }
82
+ function canParse(code, ecmaVersion) {
83
+ try {
84
+ parse(code, {
85
+ ecmaVersion,
86
+ sourceType: 'number' == typeof ecmaVersion && ecmaVersion <= 5 ? "script" : 'module'
87
+ });
88
+ return true;
89
+ } catch {
90
+ return false;
91
+ }
92
+ }
93
+ function isES5(code) {
94
+ return canParse(code, 5);
95
+ }
96
+ function isES6(code) {
97
+ return canParse(code, 6);
98
+ }
99
+ function detectECMAVersion(code) {
100
+ if (isES6(code)) {
101
+ if (isES5(code)) return ECMAVersion.ES5;
102
+ return ECMAVersion.ES6;
103
+ }
104
+ return ECMAVersion.ES7P;
105
+ }
106
+ export { canParse, detectECMAVersion, getDefaultImports, getIdentifierInDeclaration, getIdentifierInExport, getIdentifierInImport, getIdentifierInPattern, isES5, isES6, isSameSemantics };
@@ -1,4 +1,4 @@
1
- import { Linter as LinterType, SDK } from '@rsdoctor/types';
1
+ import { Linter as LinterType, SDK } from '@rsdoctor/shared/types';
2
2
  export { LinterType };
3
3
  export declare class Linter<Rules extends LinterType.ExtendRuleData[]> {
4
4
  private rules;