From d0af30c0d7eccea359b338b98ac60d2500dc20e9 Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Sat, 12 Jul 2025 20:15:29 +0000 Subject: [PATCH] refactor(napi/oxlint): rename vars (#12244) Follow-on after #12160. Pure refactor. Rename vars, notably name vars containing file paths `path` not `name`. --- napi/oxlint2/src/index.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/napi/oxlint2/src/index.js b/napi/oxlint2/src/index.js index ddc590d852f44..430deca34f981 100644 --- a/napi/oxlint2/src/index.js +++ b/napi/oxlint2/src/index.js @@ -1,17 +1,17 @@ import { lint } from './bindings.js'; class PluginRegistry { - registeredPlugins = new Set(); + registeredPluginPaths = new Set(); registeredRules = []; isPluginRegistered(path) { - return this.registeredPlugins.has(path); + return this.registeredPluginPaths.has(path); } registerPlugin(path, plugin) { // TODO: use a validation library to assert the shape of the plugin - this.registeredPlugins.add(path); + this.registeredPluginPaths.add(path); const ret = { name: plugin.meta.name, offset: this.registeredRules.length, @@ -41,18 +41,18 @@ class Linter { } /** - * @param {string} pluginName The name of the plugin we're loading + * @param {string} path - The absolute path of the plugin we're loading */ - loadPlugin = async (pluginName) => { - if (this.pluginRegistry.isPluginRegistered(pluginName)) { + loadPlugin = async (path) => { + if (this.pluginRegistry.isPluginRegistered(path)) { return JSON.stringify({ Failure: 'This plugin has already been registered', }); } try { - const { default: plugin } = await import(pluginName); - const ret = this.pluginRegistry.registerPlugin(pluginName, plugin); + const { default: plugin } = await import(path); + const ret = this.pluginRegistry.registerPlugin(path, plugin); return JSON.stringify({ Success: ret }); } catch (error) { const errorMessage = 'message' in error && typeof error.message === 'string' @@ -99,8 +99,8 @@ class Linter { async function main() { const linter = new Linter(); - const result = await linter.run(); - if (!result) { + const success = await linter.run(); + if (!success) { process.exit(1); } }