@rsdoctor/core 2.0.0-alpha.0 → 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.
- package/dist/build-utils/build/chunks/assetsModules.d.ts +1 -1
- package/dist/build-utils/build/chunks/assetsModules.js +1 -1
- package/dist/build-utils/build/chunks/index.d.ts +0 -1
- package/dist/build-utils/build/chunks/index.js +0 -1
- package/dist/build-utils/build/chunks/rspack/transform.d.ts +1 -1
- package/dist/build-utils/build/chunks/rspack/transform.js +1 -1
- package/dist/build-utils/build/envinfo.d.ts +13 -0
- package/dist/build-utils/build/envinfo.js +60 -0
- package/dist/build-utils/build/file/cache.d.ts +5 -0
- package/dist/build-utils/build/file/cache.js +24 -0
- package/dist/build-utils/build/file/index.d.ts +3 -0
- package/dist/build-utils/build/file/index.js +5 -0
- package/dist/build-utils/build/file/sharding.d.ts +21 -0
- package/dist/build-utils/build/file/sharding.js +38 -0
- package/dist/build-utils/build/index.d.ts +5 -0
- package/dist/build-utils/build/index.js +11 -6
- package/dist/build-utils/build/json.d.ts +3 -0
- package/dist/build-utils/build/json.js +67 -0
- package/dist/build-utils/build/loader/probeLoader.d.ts +2 -2
- package/dist/build-utils/build/loader/probeLoader.js +4 -4
- package/dist/build-utils/build/loader/probeLoaderPlugin.d.ts +1 -1
- package/dist/build-utils/build/loader/probeLoaderPlugin.js +1 -1
- package/dist/build-utils/build/module-graph/index.d.ts +0 -1
- package/dist/build-utils/build/module-graph/index.js +0 -1
- package/dist/build-utils/build/module-graph/parser.d.ts +1 -1
- package/dist/build-utils/build/module-graph/parser.js +1 -1
- package/dist/build-utils/build/module-graph/rspack/transform.d.ts +1 -1
- package/dist/build-utils/build/module-graph/rspack/transform.js +6 -4
- package/dist/build-utils/build/module-graph/utils.d.ts +1 -1
- package/dist/build-utils/build/module-graph/utils.js +5 -4
- package/dist/build-utils/build/process.d.ts +2 -0
- package/dist/build-utils/build/process.js +18 -0
- package/dist/build-utils/build/server.d.ts +15 -0
- package/dist/build-utils/build/server.js +107 -0
- package/dist/build-utils/build/utils/loader.d.ts +2 -2
- package/dist/build-utils/build/utils/loader.js +10 -19
- package/dist/build-utils/build/utils/parseBundle.d.ts +1 -1
- package/dist/build-utils/build/utils/parseBundle.js +6 -8
- package/dist/build-utils/build/utils/plugin.d.ts +1 -1
- package/dist/build-utils/index.d.ts +10 -0
- package/dist/build-utils/index.js +12 -2
- package/dist/collection.d.ts +1 -0
- package/dist/collection.js +2 -0
- package/dist/common/file.d.ts +2 -0
- package/dist/common/file.js +8 -0
- package/dist/common/global-config.d.ts +21 -0
- package/dist/common/global-config.js +33 -0
- package/dist/common/index.d.ts +4 -0
- package/dist/common/index.js +6 -0
- package/dist/common-browser.d.ts +1 -0
- package/dist/common-browser.js +2 -0
- package/dist/error/error.d.ts +35 -0
- package/dist/error/error.js +143 -0
- package/dist/error/index.d.ts +2 -0
- package/dist/error/index.js +3 -0
- package/dist/error/transform.d.ts +3 -0
- package/dist/error/transform.js +138 -0
- package/dist/error/utils.d.ts +4 -0
- package/dist/error/utils.js +23 -0
- package/dist/graph/index.d.ts +1 -0
- package/dist/graph/index.js +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4 -2
- package/dist/inner-plugins/loaders/proxy.d.ts +4 -4
- package/dist/inner-plugins/plugins/base.d.ts +1 -1
- package/dist/inner-plugins/plugins/bundle.d.ts +1 -1
- package/dist/inner-plugins/plugins/bundle.js +3 -3
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.d.ts +3 -3
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.js +11 -39
- package/dist/inner-plugins/plugins/errors.d.ts +2 -2
- package/dist/inner-plugins/plugins/errors.js +3 -3
- package/dist/inner-plugins/plugins/loader.d.ts +1 -1
- package/dist/inner-plugins/plugins/loader.js +7 -19
- package/dist/inner-plugins/plugins/plugins.d.ts +1 -1
- package/dist/inner-plugins/plugins/plugins.js +2 -2
- package/dist/inner-plugins/plugins/progress.d.ts +2 -2
- package/dist/inner-plugins/plugins/progress.js +2 -2
- package/dist/inner-plugins/plugins/resolver.d.ts +1 -1
- package/dist/inner-plugins/plugins/resolver.js +2 -2
- package/dist/inner-plugins/plugins/rspack.d.ts +8 -3
- package/dist/inner-plugins/plugins/rspack.js +18 -4
- package/dist/inner-plugins/plugins/rules.d.ts +1 -1
- package/dist/inner-plugins/plugins/rules.js +3 -3
- package/dist/inner-plugins/plugins/sourcemapTool.d.ts +2 -2
- package/dist/inner-plugins/plugins/sourcemapTool.js +2 -2
- package/dist/inner-plugins/plugins/summary.d.ts +1 -1
- package/dist/inner-plugins/plugins/summary.js +3 -3
- package/dist/inner-plugins/utils/config.d.ts +2 -3
- package/dist/inner-plugins/utils/config.js +16 -17
- package/dist/inner-plugins/utils/loader.d.ts +4 -7
- package/dist/inner-plugins/utils/loader.js +8 -34
- package/dist/inner-plugins/utils/normalize-config.d.ts +1 -1
- package/dist/inner-plugins/utils/openBrowser.d.ts +1 -0
- package/dist/inner-plugins/utils/openBrowser.js +55 -0
- package/dist/inner-plugins/utils/plugin-common.js +4 -4
- package/dist/inner-plugins/utils/plugin.d.ts +1 -1
- package/dist/inner-plugins/utils/plugin.js +1 -1
- package/dist/inner-plugins/utils/sdk.d.ts +2 -3
- package/dist/inner-plugins/utils/sdk.js +2 -2
- package/dist/logger.d.ts +9 -0
- package/dist/logger.js +51 -0
- package/dist/{inner-plugins/constants.d.cts → rspack-plugin/constants.d.ts} +3 -0
- package/dist/rspack-plugin/constants.js +23 -0
- package/dist/rspack-plugin/index.d.ts +2 -0
- package/dist/rspack-plugin/index.js +3 -0
- package/dist/rspack-plugin/multiple.d.ts +8 -0
- package/dist/rspack-plugin/multiple.js +39 -0
- package/dist/rspack-plugin/plugin.d.ts +25 -0
- package/dist/rspack-plugin/plugin.js +133 -0
- package/dist/rule-utils/document/document.d.ts +16 -0
- package/dist/rule-utils/document/document.js +46 -0
- package/dist/rule-utils/document/index.d.ts +3 -0
- package/dist/rule-utils/document/index.js +4 -0
- package/dist/rule-utils/document/server.d.ts +4 -0
- package/dist/rule-utils/document/server.js +13 -0
- package/dist/rule-utils/document/types.d.ts +31 -0
- package/dist/rule-utils/index.d.ts +2 -0
- package/dist/rule-utils/index.js +3 -0
- package/dist/rule-utils/parser/asserts.d.ts +81 -0
- package/dist/rule-utils/parser/asserts.js +105 -0
- package/dist/rule-utils/parser/index.d.ts +4 -0
- package/dist/rule-utils/parser/index.js +5 -0
- package/dist/rule-utils/parser/parser.d.ts +118 -0
- package/dist/rule-utils/parser/parser.js +24 -0
- package/dist/rule-utils/parser/types.d.ts +30 -0
- package/dist/rule-utils/parser/types.js +8 -0
- package/dist/rule-utils/parser/utils.d.ts +30 -0
- package/dist/rule-utils/parser/utils.js +106 -0
- package/dist/rules/linter.d.ts +1 -1
- package/dist/rules/linter.js +1 -1
- package/dist/rules/rule.d.ts +2 -2
- package/dist/rules/rule.js +2 -2
- package/dist/rules/rules/cjs-require/index.d.ts +1 -1
- package/dist/rules/rules/cjs-require/index.js +1 -1
- package/dist/rules/rules/cross-chunks-package/index.d.ts +1 -1
- package/dist/rules/rules/cross-chunks-package/index.js +2 -2
- package/dist/rules/rules/default-import-check/index.d.ts +1 -1
- package/dist/rules/rules/default-import-check/index.js +2 -2
- package/dist/rules/rules/default-import-check/utils.d.ts +2 -2
- package/dist/rules/rules/default-import-check/utils.js +2 -2
- package/dist/rules/rules/duplicate-package/index.d.ts +3 -3
- package/dist/rules/rules/duplicate-package/index.js +3 -3
- package/dist/rules/rules/duplicate-package/utils.d.ts +1 -1
- package/dist/rules/rules/ecma-version-check/index.d.ts +3 -2
- package/dist/rules/rules/ecma-version-check/index.js +1 -1
- package/dist/rules/rules/ecma-version-check/types.d.ts +1 -2
- package/dist/rules/rules/ecma-version-check/utils.d.ts +1 -1
- package/dist/rules/rules/esm-resolved-to-cjs/index.d.ts +1 -1
- package/dist/rules/rules/esm-resolved-to-cjs/index.js +1 -1
- package/dist/rules/rules/index.d.ts +1 -1
- package/dist/rules/rules/loader-performance-optimization/index.d.ts +1 -1
- package/dist/rules/rules/loader-performance-optimization/index.js +2 -2
- package/dist/rules/rules/loader-performance-optimization/types.d.ts +1 -1
- package/dist/rules/rules/module-mixed-chunks/index.d.ts +1 -1
- package/dist/rules/rules/module-mixed-chunks/index.js +1 -1
- package/dist/rules/rules/side-effects-only-imports/index.d.ts +1 -1
- package/dist/rules/rules/side-effects-only-imports/index.js +1 -1
- package/dist/rules/utils.d.ts +1 -1
- package/dist/rules/utils.js +1 -1
- package/dist/sdk/index.d.ts +2 -0
- package/dist/sdk/index.js +3 -0
- package/dist/sdk/multiple/controller.d.ts +12 -0
- package/dist/sdk/multiple/controller.js +42 -0
- package/dist/sdk/multiple/index.d.ts +2 -0
- package/dist/sdk/multiple/index.js +3 -0
- package/dist/sdk/multiple/primary.d.ts +32 -0
- package/dist/sdk/multiple/primary.js +64 -0
- package/dist/sdk/multiple/server.d.ts +7 -0
- package/dist/sdk/multiple/server.js +14 -0
- package/dist/sdk/sdk/core.d.ts +33 -0
- package/dist/sdk/sdk/core.js +163 -0
- package/dist/sdk/sdk/index.d.ts +52 -0
- package/dist/sdk/sdk/index.js +435 -0
- package/dist/sdk/sdk/types.d.ts +26 -0
- package/dist/sdk/sdk/types.js +1 -0
- package/dist/sdk/server/apis/alerts.d.ts +5 -0
- package/dist/sdk/server/apis/alerts.js +30 -0
- package/dist/sdk/server/apis/base.d.ts +11 -0
- package/dist/sdk/server/apis/base.js +22 -0
- package/dist/sdk/server/apis/bundle-diff.d.ts +6 -0
- package/dist/sdk/server/apis/bundle-diff.js +51 -0
- package/dist/sdk/server/apis/data.d.ts +6 -0
- package/dist/sdk/server/apis/data.js +44 -0
- package/dist/sdk/server/apis/fs.d.ts +5 -0
- package/dist/sdk/server/apis/fs.js +28 -0
- package/dist/sdk/server/apis/graph.d.ts +12 -0
- package/dist/sdk/server/apis/graph.js +116 -0
- package/dist/sdk/server/apis/index.d.ts +10 -0
- package/dist/sdk/server/apis/index.js +11 -0
- package/dist/sdk/server/apis/loader.d.ts +15 -0
- package/dist/sdk/server/apis/loader.js +120 -0
- package/dist/sdk/server/apis/plugin.d.ts +6 -0
- package/dist/sdk/server/apis/plugin.js +39 -0
- package/dist/sdk/server/apis/project.d.ts +8 -0
- package/dist/sdk/server/apis/project.js +59 -0
- package/dist/sdk/server/apis/renderer.d.ts +6 -0
- package/dist/sdk/server/apis/renderer.js +33 -0
- package/dist/sdk/server/apis/resolver.d.ts +6 -0
- package/dist/sdk/server/apis/resolver.js +38 -0
- package/dist/sdk/server/client.d.ts +3 -0
- package/dist/sdk/server/client.js +8 -0
- package/dist/sdk/server/fakeServer.d.ts +9 -0
- package/dist/sdk/server/fakeServer.js +12 -0
- package/dist/sdk/server/index.d.ts +44 -0
- package/dist/sdk/server/index.js +292 -0
- package/dist/sdk/server/json-body.d.ts +6 -0
- package/dist/sdk/server/json-body.js +150 -0
- package/dist/sdk/server/router.d.ts +24 -0
- package/dist/sdk/server/router.js +83 -0
- package/dist/sdk/server/security.d.ts +5 -0
- package/dist/sdk/server/security.js +47 -0
- package/dist/sdk/server/socket/api.d.ts +15 -0
- package/dist/sdk/server/socket/api.js +22 -0
- package/dist/sdk/server/socket/index.d.ts +48 -0
- package/dist/sdk/server/socket/index.js +166 -0
- package/dist/sdk/server/utils.d.ts +6 -0
- package/dist/sdk/server/utils.js +19 -0
- package/dist/sdk/utils/base.d.ts +1 -0
- package/dist/sdk/utils/base.js +22 -0
- package/dist/sdk/utils/constant.d.ts +1 -0
- package/dist/sdk/utils/constant.js +4 -0
- package/dist/sdk/utils/index.d.ts +3 -0
- package/dist/sdk/utils/index.js +4 -0
- package/dist/sdk/utils/openBrowser.d.ts +4 -0
- package/dist/sdk/utils/openBrowser.js +53 -0
- package/dist/sdk/utils/upload.d.ts +2 -0
- package/dist/sdk/utils/upload.js +6 -0
- package/dist/sdk.d.ts +1 -0
- package/dist/sdk.js +2 -0
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.js +0 -1
- package/dist/types/loader.d.ts +1 -1
- package/dist/types/plugin.d.ts +7 -28
- package/package.json +127 -58
- package/static/openChrome.applescript +95 -0
- package/dist/build-utils/build/chunks/assetsModules.cjs +0 -42
- package/dist/build-utils/build/chunks/assetsModules.d.cts +0 -17
- package/dist/build-utils/build/chunks/chunkTransform.cjs +0 -39
- package/dist/build-utils/build/chunks/chunkTransform.d.cts +0 -4
- package/dist/build-utils/build/chunks/chunkTransform.d.ts +0 -4
- package/dist/build-utils/build/chunks/chunkTransform.js +0 -6
- package/dist/build-utils/build/chunks/index.cjs +0 -72
- package/dist/build-utils/build/chunks/index.d.cts +0 -3
- package/dist/build-utils/build/chunks/rspack/transform.cjs +0 -80
- package/dist/build-utils/build/chunks/rspack/transform.d.cts +0 -13
- package/dist/build-utils/build/index.cjs +0 -52
- package/dist/build-utils/build/index.d.cts +0 -5
- package/dist/build-utils/build/loader/index.cjs +0 -65
- package/dist/build-utils/build/loader/index.d.cts +0 -2
- package/dist/build-utils/build/loader/probeLoader.cjs +0 -89
- package/dist/build-utils/build/loader/probeLoader.d.cts +0 -4
- package/dist/build-utils/build/loader/probeLoaderPlugin.cjs +0 -65
- package/dist/build-utils/build/loader/probeLoaderPlugin.d.cts +0 -5
- package/dist/build-utils/build/module-graph/index.cjs +0 -65
- package/dist/build-utils/build/module-graph/index.d.cts +0 -2
- package/dist/build-utils/build/module-graph/parser.cjs +0 -46
- package/dist/build-utils/build/module-graph/parser.d.cts +0 -2
- package/dist/build-utils/build/module-graph/rspack/transform.cjs +0 -151
- package/dist/build-utils/build/module-graph/rspack/transform.d.cts +0 -26
- package/dist/build-utils/build/module-graph/transform.cjs +0 -39
- package/dist/build-utils/build/module-graph/transform.d.cts +0 -3
- package/dist/build-utils/build/module-graph/transform.d.ts +0 -3
- package/dist/build-utils/build/module-graph/transform.js +0 -6
- package/dist/build-utils/build/module-graph/utils.cjs +0 -95
- package/dist/build-utils/build/module-graph/utils.d.cts +0 -3
- package/dist/build-utils/build/utils/index.cjs +0 -72
- package/dist/build-utils/build/utils/index.d.cts +0 -3
- package/dist/build-utils/build/utils/loader.cjs +0 -354
- package/dist/build-utils/build/utils/loader.d.cts +0 -20
- package/dist/build-utils/build/utils/parseBundle.cjs +0 -283
- package/dist/build-utils/build/utils/parseBundle.d.cts +0 -12
- package/dist/build-utils/build/utils/plugin.cjs +0 -60
- package/dist/build-utils/build/utils/plugin.d.cts +0 -5
- package/dist/build-utils/index.cjs +0 -36
- package/dist/build-utils/index.d.cts +0 -1
- package/dist/index.cjs +0 -81
- package/dist/index.d.cts +0 -3
- package/dist/inner-plugins/constants.cjs +0 -64
- package/dist/inner-plugins/index.cjs +0 -65
- package/dist/inner-plugins/index.d.cts +0 -2
- package/dist/inner-plugins/loaders/proxy.cjs +0 -104
- package/dist/inner-plugins/loaders/proxy.d.cts +0 -7
- package/dist/inner-plugins/plugins/base.cjs +0 -53
- package/dist/inner-plugins/plugins/base.d.cts +0 -12
- package/dist/inner-plugins/plugins/bundle.cjs +0 -96
- package/dist/inner-plugins/plugins/bundle.d.cts +0 -15
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.cjs +0 -141
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.d.cts +0 -34
- package/dist/inner-plugins/plugins/errors.cjs +0 -98
- package/dist/inner-plugins/plugins/errors.d.cts +0 -11
- package/dist/inner-plugins/plugins/index.cjs +0 -121
- package/dist/inner-plugins/plugins/index.d.cts +0 -10
- package/dist/inner-plugins/plugins/loader.cjs +0 -165
- package/dist/inner-plugins/plugins/loader.d.cts +0 -10
- package/dist/inner-plugins/plugins/plugins.cjs +0 -73
- package/dist/inner-plugins/plugins/plugins.d.cts +0 -8
- package/dist/inner-plugins/plugins/progress.cjs +0 -68
- package/dist/inner-plugins/plugins/progress.d.cts +0 -8
- package/dist/inner-plugins/plugins/resolver.cjs +0 -90
- package/dist/inner-plugins/plugins/resolver.d.cts +0 -12
- package/dist/inner-plugins/plugins/rspack.cjs +0 -118
- package/dist/inner-plugins/plugins/rspack.d.cts +0 -4
- package/dist/inner-plugins/plugins/rules.cjs +0 -97
- package/dist/inner-plugins/plugins/rules.d.cts +0 -8
- package/dist/inner-plugins/plugins/sourcemapTool.cjs +0 -275
- package/dist/inner-plugins/plugins/sourcemapTool.d.cts +0 -52
- package/dist/inner-plugins/plugins/summary.cjs +0 -125
- package/dist/inner-plugins/plugins/summary.d.cts +0 -14
- package/dist/inner-plugins/utils/circleDetect.cjs +0 -49
- package/dist/inner-plugins/utils/circleDetect.d.cts +0 -4
- package/dist/inner-plugins/utils/config.cjs +0 -191
- package/dist/inner-plugins/utils/config.d.cts +0 -5
- package/dist/inner-plugins/utils/index.cjs +0 -106
- package/dist/inner-plugins/utils/index.d.cts +0 -9
- package/dist/inner-plugins/utils/loader.cjs +0 -218
- package/dist/inner-plugins/utils/loader.d.cts +0 -13
- package/dist/inner-plugins/utils/normalize-config.cjs +0 -122
- package/dist/inner-plugins/utils/normalize-config.d.cts +0 -37
- package/dist/inner-plugins/utils/plugin-common.cjs +0 -143
- package/dist/inner-plugins/utils/plugin-common.d.cts +0 -11
- package/dist/inner-plugins/utils/plugin.cjs +0 -106
- package/dist/inner-plugins/utils/plugin.d.cts +0 -4
- package/dist/inner-plugins/utils/sdk.cjs +0 -55
- package/dist/inner-plugins/utils/sdk.d.cts +0 -8
- package/dist/rslib-runtime.js +0 -19
- package/dist/rules/index.cjs +0 -81
- package/dist/rules/index.d.cts +0 -3
- package/dist/rules/linter.cjs +0 -72
- package/dist/rules/linter.d.cts +0 -9
- package/dist/rules/rule.cjs +0 -137
- package/dist/rules/rule.d.cts +0 -27
- package/dist/rules/rules/cjs-require/index.cjs +0 -83
- package/dist/rules/rules/cjs-require/index.d.cts +0 -4
- package/dist/rules/rules/cjs-require/types.cjs +0 -18
- package/dist/rules/rules/cjs-require/types.d.cts +0 -7
- package/dist/rules/rules/cross-chunks-package/index.cjs +0 -74
- package/dist/rules/rules/cross-chunks-package/index.d.cts +0 -4
- package/dist/rules/rules/cross-chunks-package/types.cjs +0 -18
- package/dist/rules/rules/cross-chunks-package/types.d.cts +0 -3
- package/dist/rules/rules/cross-chunks-package/utils.cjs +0 -40
- package/dist/rules/rules/cross-chunks-package/utils.d.cts +0 -1
- package/dist/rules/rules/default-import-check/index.cjs +0 -116
- package/dist/rules/rules/default-import-check/index.d.cts +0 -4
- package/dist/rules/rules/default-import-check/types.cjs +0 -18
- package/dist/rules/rules/default-import-check/types.d.cts +0 -4
- package/dist/rules/rules/default-import-check/utils.cjs +0 -97
- package/dist/rules/rules/default-import-check/utils.d.cts +0 -10
- package/dist/rules/rules/duplicate-package/index.cjs +0 -72
- package/dist/rules/rules/duplicate-package/index.d.cts +0 -4
- package/dist/rules/rules/duplicate-package/types.cjs +0 -60
- package/dist/rules/rules/duplicate-package/types.d.cts +0 -24
- package/dist/rules/rules/duplicate-package/utils.cjs +0 -84
- package/dist/rules/rules/duplicate-package/utils.d.cts +0 -3
- package/dist/rules/rules/ecma-version-check/index.cjs +0 -96
- package/dist/rules/rules/ecma-version-check/index.d.cts +0 -4
- package/dist/rules/rules/ecma-version-check/types.cjs +0 -18
- package/dist/rules/rules/ecma-version-check/types.d.cts +0 -3
- package/dist/rules/rules/ecma-version-check/utils.cjs +0 -39
- package/dist/rules/rules/ecma-version-check/utils.d.cts +0 -2
- package/dist/rules/rules/esm-resolved-to-cjs/index.cjs +0 -237
- package/dist/rules/rules/esm-resolved-to-cjs/index.d.cts +0 -4
- package/dist/rules/rules/esm-resolved-to-cjs/types.cjs +0 -18
- package/dist/rules/rules/esm-resolved-to-cjs/types.d.cts +0 -8
- package/dist/rules/rules/index.cjs +0 -55
- package/dist/rules/rules/index.d.cts +0 -2
- package/dist/rules/rules/loader-performance-optimization/index.cjs +0 -119
- package/dist/rules/rules/loader-performance-optimization/index.d.cts +0 -4
- package/dist/rules/rules/loader-performance-optimization/types.cjs +0 -18
- package/dist/rules/rules/loader-performance-optimization/types.d.cts +0 -22
- package/dist/rules/rules/loader-performance-optimization/utils.cjs +0 -43
- package/dist/rules/rules/loader-performance-optimization/utils.d.cts +0 -1
- package/dist/rules/rules/module-mixed-chunks/index.cjs +0 -85
- package/dist/rules/rules/module-mixed-chunks/index.d.cts +0 -4
- package/dist/rules/rules/module-mixed-chunks/types.cjs +0 -18
- package/dist/rules/rules/module-mixed-chunks/types.d.cts +0 -3
- package/dist/rules/rules/side-effects-only-imports/index.cjs +0 -114
- package/dist/rules/rules/side-effects-only-imports/index.d.cts +0 -4
- package/dist/rules/rules/side-effects-only-imports/types.cjs +0 -18
- package/dist/rules/rules/side-effects-only-imports/types.d.cts +0 -9
- package/dist/rules/utils.cjs +0 -46
- package/dist/rules/utils.d.cts +0 -3
- package/dist/types/chunks.cjs +0 -18
- package/dist/types/chunks.d.cts +0 -6
- package/dist/types/chunks.d.ts +0 -6
- package/dist/types/index.cjs +0 -79
- package/dist/types/index.d.cts +0 -4
- package/dist/types/loader.cjs +0 -18
- package/dist/types/loader.d.cts +0 -19
- package/dist/types/plugin.cjs +0 -18
- package/dist/types/plugin.d.cts +0 -51
- package/dist/types/rules.cjs +0 -18
- package/dist/types/rules.d.cts +0 -7
- /package/dist/{types/chunks.js → rule-utils/document/types.js} +0 -0
|
@@ -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,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,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 };
|
package/dist/rules/linter.d.ts
CHANGED
package/dist/rules/linter.js
CHANGED
package/dist/rules/rule.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Linter, SDK, Rule as RuleTypes } from '@rsdoctor/types';
|
|
1
|
+
import { Linter, SDK, Rule as RuleTypes } from '@rsdoctor/shared/types';
|
|
2
2
|
import { LinterType } from './linter.js';
|
|
3
3
|
type DefaultRuleConfig = Linter.DefaultRuleConfig;
|
|
4
4
|
export declare class Rule<Config = DefaultRuleConfig> implements Linter.RuleMeta<Config> {
|
|
@@ -16,7 +16,7 @@ export declare class Rule<Config = DefaultRuleConfig> implements Linter.RuleMeta
|
|
|
16
16
|
get title(): string;
|
|
17
17
|
get severity(): Linter.Severity;
|
|
18
18
|
get config(): Config | undefined;
|
|
19
|
-
get category(): "compile" | "
|
|
19
|
+
get category(): "bundle" | "compile" | "emo" | RuleTypes.RuleMessageCategory;
|
|
20
20
|
setOption(opt: Linter.RuleConfigItem): void;
|
|
21
21
|
match(level: Linter.Severity): boolean;
|
|
22
22
|
validate(context: SDK.RuntimeContext): Promise<Linter.ValidateResult>;
|
package/dist/rules/rule.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import { Linter, Rule } from "@rsdoctor/types";
|
|
3
|
-
import { Lodash } from "
|
|
2
|
+
import { Linter, Rule } from "@rsdoctor/shared/types";
|
|
3
|
+
import { Lodash } from "../common/index.js";
|
|
4
4
|
import { noop, toSeverity } from "./utils.js";
|
|
5
5
|
class rule_Rule {
|
|
6
6
|
static from(data) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import { Linter } from "@rsdoctor/types";
|
|
2
|
+
import { Linter } from "@rsdoctor/shared/types";
|
|
3
3
|
import { defineRule } from "../../rule.js";
|
|
4
4
|
import { getErrorMsgForDupPckChunks } from "./utils.js";
|
|
5
|
-
import { uniq } from "
|
|
5
|
+
import { uniq } from "../../../collection.js";
|
|
6
6
|
const title = 'cross-chunks-package';
|
|
7
7
|
const rule = defineRule(()=>({
|
|
8
8
|
meta: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
import { builtinModules } from "module";
|
|
3
|
-
import { Linter } from "@rsdoctor/types";
|
|
4
|
-
import { getDocument, parser } from "
|
|
3
|
+
import { Linter } from "@rsdoctor/shared/types";
|
|
4
|
+
import { getDocument, parser } from "../../../rule-utils/index.js";
|
|
5
5
|
import { getDefaultImportByRequest, getFixData, getSourceRangeFromTransformedOffset, hasSameLeftInAssignStatement } from "./utils.js";
|
|
6
6
|
import { defineRule } from "../../rule.js";
|
|
7
7
|
const title = 'default-import-check';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Node, Range } from '
|
|
2
|
-
import type { SDK, Linter } from '@rsdoctor/types';
|
|
1
|
+
import { Node, Range } from '../../../rule-utils/index.js';
|
|
2
|
+
import type { SDK, Linter } from '@rsdoctor/shared/types';
|
|
3
3
|
export declare function getDefaultImportByRequest(node: Node.Program, request: string): Node.ImportDeclaration | undefined;
|
|
4
4
|
/**
|
|
5
5
|
* Determine that it contains the same left value assignment expression in the enumeration.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import { getDocument, parser } from "
|
|
3
|
-
import { Lodash } from "
|
|
2
|
+
import { getDocument, parser } from "../../../rule-utils/index.js";
|
|
3
|
+
import { Lodash } from "../../../common/index.js";
|
|
4
4
|
function getDefaultImportByRequest(node, request) {
|
|
5
5
|
return parser.utils.getDefaultImports(node).find((decl)=>decl.source.value === request);
|
|
6
6
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Linter } from '@rsdoctor/types';
|
|
2
|
-
import
|
|
1
|
+
import { Linter } from '@rsdoctor/shared/types';
|
|
2
|
+
import type { Config } from './types.js';
|
|
3
3
|
export type { Config, CheckVersion } from './types.js';
|
|
4
|
-
export declare const rule: Linter.RuleData<
|
|
4
|
+
export declare const rule: Linter.RuleData<Config, "duplicate-package">;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import { Linter } from "@rsdoctor/types";
|
|
2
|
+
import { Linter } from "@rsdoctor/shared/types";
|
|
3
3
|
import { diff, gt } from "semver";
|
|
4
4
|
import { getErrorDetail, getErrorMsg } from "./utils.js";
|
|
5
5
|
import { defineRule } from "../../rule.js";
|
|
6
|
-
import * as
|
|
6
|
+
import * as __rspack_external__types_js_b06c0ce5 from "./types.js";
|
|
7
7
|
const title = 'duplicate-package';
|
|
8
|
-
const { CheckVersionMap: CheckVersionMap } =
|
|
8
|
+
const { CheckVersionMap: CheckVersionMap } = __rspack_external__types_js_b06c0ce5;
|
|
9
9
|
const rule = defineRule(()=>({
|
|
10
10
|
meta: {
|
|
11
11
|
code: 'E1001',
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { SDK, Rule } from '@rsdoctor/types';
|
|
1
|
+
import type { SDK, Rule } from '@rsdoctor/shared/types';
|
|
2
2
|
export declare function getErrorMsg(packages: SDK.PackageInstance[], root: string): string;
|
|
3
3
|
export declare function getErrorDetail(pkg: SDK.PackageInstance, pkgGraph: SDK.PackageGraphInstance): Rule.PackageRelationData;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Config } from './types.js';
|
|
2
|
-
import { Linter } from '@rsdoctor/types';
|
|
2
|
+
import { Linter } from '@rsdoctor/shared/types';
|
|
3
3
|
export type { Config } from './types.js';
|
|
4
|
-
|
|
4
|
+
declare const title = "ecma-version-check";
|
|
5
|
+
export declare const rule: Linter.RuleData<Config, typeof title>;
|
|
@@ -3,7 +3,7 @@ import path from "path";
|
|
|
3
3
|
import { CheckSyntax } from "@rsbuild/plugin-check-syntax";
|
|
4
4
|
import { loadConfig } from "browserslist-load-config";
|
|
5
5
|
import { defineRule } from "../../rule.js";
|
|
6
|
-
import { Linter } from "@rsdoctor/types";
|
|
6
|
+
import { Linter } from "@rsdoctor/shared/types";
|
|
7
7
|
const title = 'ecma-version-check';
|
|
8
8
|
const rule = defineRule(()=>({
|
|
9
9
|
meta: {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ECMAVersion } from '
|
|
1
|
+
import type { ECMAVersion } from '../../../rule-utils/index.js';
|
|
2
2
|
export declare function getVersionNumber(ECMAString: ECMAVersion): number | undefined;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import path from "path";
|
|
4
|
-
import { Linter, SDK } from "@rsdoctor/types";
|
|
4
|
+
import { Linter, SDK } from "@rsdoctor/shared/types";
|
|
5
5
|
import { defineRule } from "../../rule.js";
|
|
6
6
|
const title = 'esm-resolved-to-cjs';
|
|
7
7
|
function normalizePathForCompare(filePath) {
|