Skip to content

Commit

Permalink
docs(linter): improve docs for node/security/tree_shaking rules (#6097)
Browse files Browse the repository at this point in the history
Related to #6050 

As of this PR, all documents of that contain a few rules have been
corrected.
  • Loading branch information
shulaoda authored Sep 27, 2024
1 parent d56264e commit d4bed9a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions crates/oxc_linter/src/rules/node/no_exports_assign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub struct NoExportsAssign;

declare_oxc_lint!(
/// ### What it does
///
/// Disallows assignment to `exports`.
///
/// ### Why is this bad?
Expand Down
1 change: 1 addition & 0 deletions crates/oxc_linter/src/rules/security/api_keys/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ declare_oxc_lint!(
/// ```
///
/// ### What To Do Instead
///
/// :::warning
/// The Oxc team are not security experts. We do not endorse any particular
/// key management service or strategy. Do your research and choose the best
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,23 @@ declare_oxc_lint!(
///
/// ### Why is this bad?
///
/// ### Example
/// Side-effects in module initialization can hinder tree-shaking, which aims to remove
/// unused code. If side-effects exist, it's harder for the bundler to safely eliminate
/// code, leading to larger bundles and potentially unexpected behavior. Ensuring minimal
/// side-effects allows bundlers to optimize code effectively.
///
/// ### Examples
///
/// Examples of **incorrect** code for this rule:
/// ```javascript
/// myGlobal = 17; // Cannot determine side-effects of assignment to global variable
/// const x = { [globalFunction()]: "myString" }; // Cannot determine side-effects of calling global function
/// export default 42;
/// ```
///
/// Examples of **correct** code for this rule:
/// ```javascript
/// const localVar = 17; // Local variable assignment, no global side-effects
/// export default 42; // Pure export with no side-effects
/// ```
///
/// ### Options
Expand Down

0 comments on commit d4bed9a

Please sign in to comment.