oxc-project / oxc

⚓ A collection of JavaScript tools written in Rust.
https://oxc.rs
MIT License
11.86k stars 426 forks source link

Consolidate side effect detection #6481

Open Boshen opened 4 days ago

Boshen commented 4 days ago
pumano commented 4 days ago

@Boshen how do you think about oxlint rule that help developers found potentially problematic "side-effect" places in source code? Currently I try to migrate my large monorepo to isolatedModules / isolatedDeclarations and also mark libs as "sideEffects": false but has fear about potential side effects :)

TypeScript 5.6 add some useful --noUncheckedSideEffectImports but only for checking possibility to import it correctly. But would be good to have warns / errors when code not just imported but run (evaluated) after import in old school fashion.

Boshen commented 3 days ago

@Boshen how do you think about oxlint rule that help developers found potentially problematic "side-effect" places in source code? Currently I try to migrate my large monorepo to isolatedModules / isolatedDeclarations and also mark libs as "sideEffects": false but has fear about potential side effects :)

TypeScript 5.6 add some useful --noUncheckedSideEffectImports but only for checking possibility to import it correctly. But would be good to have warns / errors when code not just imported but run (evaluated) after import in old school fashion.

It's doable but probably not at this stage. We also have tree_shaking/no-side-effects-in-initialization https://oxc.rs/docs/guide/usage/linter/rules/tree_shaking/no-side-effects-in-initialization.html for libraries.

Boshen commented 3 days ago

I managed to fix this issue by juggling Rust in https://github.com/oxc-project/oxc/pull/6549