Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Fix the module side-effect lint errors in querying/expressions (#80285)

Fraser7cedc004a8ae
diff --git a/frontend/build/shared/rspack/side-effect-free-modules.js b/frontend/build/shared/rspack/side-effect-free-modules.js
index 7aae924b135..13a464bbed1 100644
--- a/frontend/build/shared/rspack/side-effect-free-modules.js
+++ b/frontend/build/shared/rspack/side-effect-free-modules.js
@@ -45,7 +45,14 @@ const SIDE_EFFECT_FREE_PATHS = [
* List `<module>/api` here when a module is enrolled: those files register their endpoints on the shared Api at import,
* so a bundle has to evaluate them even when it only reaches them by name.
*/
-const SIDE_EFFECT_PATHS = [];
+const SIDE_EFFECT_PATHS = [
+ // The pratt parser tables are built by module-scope calls that mutate the exported NODE_TYPE objects.
+ // Their results are unused, so a PURE annotation would let the minifier delete the setup.
+ path.join(
+ REPO_ROOT,
+ "frontend/src/metabase/querying/expressions/pratt/syntax.ts",
+ ),
+];
const SIDE_EFFECT_FREE_RULE = {
include: SIDE_EFFECT_FREE_PATHS,
diff --git a/frontend/lint/eslint-plugin-metabase/rules/no-module-side-effects.js b/frontend/lint/eslint-plugin-metabase/rules/no-module-side-effects.js
index 092b51144a2..f24d51778bf 100644
--- a/frontend/lint/eslint-plugin-metabase/rules/no-module-side-effects.js
+++ b/frontend/lint/eslint-plugin-metabase/rules/no-module-side-effects.js
@@ -57,6 +57,7 @@ const DEFAULT_PURE_CALLEES = [
{ module: "ttag", names: ["t", "c", "jt", "ngettext", "msgid"] },
{ module: "color", names: "*" },
{ module: "@lezer/highlight", names: "*" },
+ { module: "@lezer/lr", names: ["deserialize"] },
{ module: "@codemirror/language", names: "*" },
{
module: "@reduxjs/toolkit",
diff --git a/frontend/lint/side-effect-files.json b/frontend/lint/side-effect-files.json
index 77d5bb5ccee..d9fbc44f33b 100644
--- a/frontend/lint/side-effect-files.json
+++ b/frontend/lint/side-effect-files.json
@@ -53,6 +53,7 @@
"enterprise/frontend/src/metabase-enterprise/data_apps/runtime/app-data-app.tsx": "entry",
"enterprise/frontend/src/metabase-enterprise/data_apps/runtime/iframe-vendors.ts": "entry",
"enterprise/frontend/src/metabase-enterprise/database_replication/DatabaseReplicationForm.tsx": "self",
+ "enterprise/frontend/src/metabase-enterprise/dependencies/components/DependencyGraph/DependencyGraph.tsx": "self",
"enterprise/frontend/src/metabase-enterprise/embedding/index.ts": "global",
"enterprise/frontend/src/metabase-enterprise/license/index.ts": "global",
"enterprise/frontend/src/metabase-enterprise/moderation/constants.ts": "self",
@@ -65,6 +66,7 @@
"enterprise/frontend/src/metabase-enterprise/remote_sync/constants.ts": "self",
"enterprise/frontend/src/metabase-enterprise/remote_sync/middleware/remote-sync-listener-middleware.ts": "self",
"enterprise/frontend/src/metabase-enterprise/replacement/pages/MigrateModelsPage/ReplaceWithTransformModal/ReplaceWithTransformModal.tsx": "self",
+ "enterprise/frontend/src/metabase-enterprise/schema_viewer/components/SchemaViewer/SchemaViewer.tsx": "self",
"enterprise/frontend/src/metabase-enterprise/sdk-iframe-embedding-plugins.ts": "entry",
"enterprise/frontend/src/metabase-enterprise/sdk-iframe-embedding-script-plugins.ts": "entry",
"enterprise/frontend/src/metabase-enterprise/sdk-plugins.ts": "entry",
@@ -157,7 +159,6 @@
"frontend/src/metabase/querying/components/CodeMirrorEditor/language.ts": "self",
"frontend/src/metabase/querying/components/NativeQueryEditor/SnippetForm/SnippetForm.tsx": "self",
"frontend/src/metabase/querying/expressions/pratt/syntax.ts": "self",
- "frontend/src/metabase/querying/expressions/tokenizer/lezer.ts": "self",
"frontend/src/metabase/questions/components/CopyCardForm/CopyCardForm.tsx": "self",
"frontend/src/metabase/reducers-common.ts": "self",
"frontend/src/metabase/redux/embed/embed.ts": "self",