Skip to content

Commit b0fd9b1

Browse files
committed
style(traverse, tasks): prefer const to let (#16396)
Use `const` where variables are not reassigned instead of `let`. Preparation for enabling ESLint's `prefer-const` rule (running as an Oxlint JS plugin) in our linting setup.
1 parent fed6180 commit b0fd9b1

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

crates/oxc_traverse/scripts/lib/walk.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ function generateWalkForStruct(type, types) {
134134

135135
// const Var = Self::Top.bits() | Self::Function.bits() | Self::ClassStaticBlock.bits() | Self::TsModuleBlock.bits();
136136
// `Function` type is a special case as its flags are set dynamically depending on the parent.
137-
let isVarHoistingScope =
137+
const isVarHoistingScope =
138138
type.name == "Function" ||
139139
["Top", "Function", "ClassStaticBlock", "TsModuleBlock"].some((flag) =>
140140
scopeArgs.flags.includes(flag),
@@ -148,7 +148,7 @@ function generateWalkForStruct(type, types) {
148148
}
149149

150150
// TODO: Type names shouldn't be hard-coded here. Block scopes should be signalled by attrs in AST.
151-
let isBlockScope = [
151+
const isBlockScope = [
152152
"Program",
153153
"BlockStatement",
154154
"Function",
@@ -227,8 +227,8 @@ function generateWalkForStruct(type, types) {
227227
// Special case for `Vec<Statement>`
228228
walkVecCode = `walk_statements(traverser, ${fieldCode}, ctx);`;
229229
} else {
230-
let walkCode = `${fieldWalkName}(traverser, item as *mut _, ctx);`,
231-
iteratorCode = "";
230+
const walkCode = `${fieldWalkName}(traverser, item as *mut _, ctx);`;
231+
let iteratorCode;
232232
if (field.wrappers.length === 2 && field.wrappers[1] === "Option") {
233233
iteratorCode = `(*(${fieldCode})).iter_mut().flatten()`;
234234
} else {

tasks/transform_conformance/update_fixtures.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,13 @@ function updateOptions(options) {
147147

148148
// Ensure all class plugins are enabled if any of class related plugins are enabled
149149
function ensureAllClassPluginsEnabled(options) {
150-
let plugins = options.plugins;
150+
const { plugins } = options;
151151
if (!plugins) return false;
152152

153-
let already_enabled = [];
153+
const already_enabled = [];
154154
let pluginOptions;
155155
plugins.forEach((plugin) => {
156-
let pluginName = getName(plugin);
156+
const pluginName = getName(plugin);
157157
if (CLASS_PLUGINS.includes(pluginName)) {
158158
if (Array.isArray(plugin) && plugin[1]) {
159159
// Store options for the plugin, so that we can ensure all plugins are

0 commit comments

Comments
 (0)