Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.solidscipt.zoracle.xyz/llms.txt

Use this file to discover all available pages before exploring further.

Plugins are TypeScript modules that hook into the SolidScript validator and optimizer without modifying the core toolchain. They are the right place to put organization-specific checks — things like enforcing naming conventions, banning certain patterns, or flagging incomplete work — that should run on every contract build alongside the native rules. In this guide, you’ll build a plugin that warns whenever a function has a TODO in its NatSpec.

Create the plugin file

Create a file at plugins/my-plugin.ts and export a SolidScriptPlugin object:
plugins/my-plugin.ts
import type { SolidScriptPlugin } from "solidscript";

const plugin: SolidScriptPlugin = {
  name: "my-plugin",
  validatorRules: [
    {
      name: "no-todo",
      run: (contract) => {
        const out = [];
        for (const fn of contract.functions) {
          if (fn.natspec?.some((n) => /TODO/.test(n))) {
            out.push({
              rule: "no-todo",
              severity: "warning",
              message: `function "${fn.name}" has a TODO comment`,
              loc: fn.loc,
            });
          }
        }
        return out;
      },
    },
  ],
};

export default plugin;
The run function receives the parsed contract model and returns an array of diagnostic objects. Each diagnostic includes a rule name, severity, human-readable message, and source location.

Register the plugin

Load the plugin from solidscript.config.ts by adding its path to the plugins array:
solidscript.config.ts
import type { Config } from "solidscript";

const config: Config = {
  plugins: ["./plugins/my-plugin.ts"],
};

export default config;
SolidScript resolves the path relative to the config file and loads the plugin at the start of each build.

Read diagnostic output

Plugin diagnostics are namespaced under the plugin name so they are easy to distinguish from native rules:
plugin:my-plugin/no-todo: function "setValue" has a TODO comment
Keep plugin rules deterministic. They should inspect the parsed contract model and return diagnostics, not mutate project files during validation.