docs(traverse): tidy doc comments for TraverseCtx::is_static (#7267)

Better describe what this method does in its doc comment, and tidy up wording a little.
This commit is contained in:
overlookmotel 2024-11-13 11:40:07 +00:00
parent 7a4872818e
commit 834c94d9d2
2 changed files with 6 additions and 9 deletions

View file

@ -545,12 +545,12 @@ impl<'a> TraverseCtx<'a> {
/// Determine whether evaluating the specific input `node` is a consequenceless reference. /// Determine whether evaluating the specific input `node` is a consequenceless reference.
/// ///
/// I.E evaluating it won't result in potentially arbitrary code from being ran. The following are /// i.e. evaluating it won't result in potentially arbitrary code from being run.
/// allowed and determined not to cause side effects: /// The following are allowed and determined not to cause side effects:
/// ///
/// - `this` expressions /// - `this` expressions
/// - `super` expressions /// - `super` expressions
/// - Bound identifiers /// - Bound identifiers which are not mutated
/// ///
/// This is a shortcut for `ctx.scoping.is_static`. /// This is a shortcut for `ctx.scoping.is_static`.
#[inline] #[inline]

View file

@ -353,18 +353,15 @@ impl TraverseScoping {
/// Determine whether evaluating the specific input `node` is a consequenceless reference. /// Determine whether evaluating the specific input `node` is a consequenceless reference.
/// ///
/// I.E evaluating it won't result in potentially arbitrary code from being ran. The following are /// i.e. evaluating it won't result in potentially arbitrary code from being run.
/// allowed and determined not to cause side effects: /// The following are allowed and determined not to cause side effects:
/// ///
/// - `this` expressions /// - `this` expressions
/// - `super` expressions /// - `super` expressions
/// - Bound identifiers /// - Bound identifiers which are not mutated
/// ///
/// Based on Babel's `scope.isStatic` logic. /// Based on Babel's `scope.isStatic` logic.
/// <https://github.com/babel/babel/blob/419644f27c5c59deb19e71aaabd417a3bc5483ca/packages/babel-traverse/src/scope/index.ts#L557> /// <https://github.com/babel/babel/blob/419644f27c5c59deb19e71aaabd417a3bc5483ca/packages/babel-traverse/src/scope/index.ts#L557>
///
/// # Panics
/// Can only panic if [`IdentifierReference`] does not have a reference_id, which it always should.
#[inline] #[inline]
pub fn is_static(&self, expr: &Expression) -> bool { pub fn is_static(&self, expr: &Expression) -> bool {
match expr { match expr {