prettier-plugin-solgrid

raw JSON →
0.0.14 verified Sat Apr 25 auth: no javascript

Prettier plugin for Solidity that leverages solgrid's Rust-based formatter for fast, reliable formatting and linting. Currently at v0.0.14, released weekly with active development. Key differentiators: native Rust performance, integrated linting with autofix (including import ordering, naming conventions, and NatSpec validation), and VS Code save-time stability. Unlike prettier-plugin-solidity, it uses a native parser for better edge-case handling and offers configurable operator line breaks, import grouping, and doc comment rules.

error Error: Cannot find module 'prettier-plugin-solgrid'
cause Plugin not installed or not in node_modules.
fix
Run npm install --save-dev prettier-plugin-solgrid and ensure it's in the plugins array.
error Error: [prettier] Cannot resolve parser 'solidity'
cause Prettier config missing parser or plugin not loaded.
fix
Add "parser": "solidity" and "plugins": ["prettier-plugin-solgrid"] to .prettierrc.
error TypeError: prettier.resolveConfig is not a function
cause Using prettier v2 API with v3 plugin.
fix
Upgrade prettier to v3: npm install prettier@^3.0.0.
breaking Requires prettier ^3.0.0; does not work with prettier v2.
fix Upgrade prettier to v3 or later.
gotcha Plugin options like `solidityOperatorLineBreak` must be in the Prettier config root, not under a `solidity` subkey.
fix Set options at top level of .prettierrc.
gotcha Import ordering fix may be reverted on save in VS Code if not using the latest version (v0.0.7+).
fix Upgrade to v0.0.7 or later.
deprecated The `operator_line_break` option v0.0.10 renamed to `solidityOperatorLineBreak` in later versions for Prettier consistency.
fix Use `solidityOperatorLineBreak` instead.
gotcha Config loading silently ignores unknown rule settings before v0.0.12.
fix Upgrade to v0.0.12+ to get validation errors.
npm install prettier-plugin-solgrid
yarn add prettier-plugin-solgrid
pnpm add prettier-plugin-solgrid

Installs the plugin, configures Prettier for Solidity files, and formats a .sol file.

// Install
// npm install --save-dev prettier prettier-plugin-solgrid

// .prettierrc
{
  "plugins": ["prettier-plugin-solgrid"],
  "parser": "solidity",
  "solidityOperatorLineBreak": true,
  "overrides": [{
    "files": "*.sol",
    "options": {
      "parser": "solidity"
    }
  }]
}

// Format a file
// npx prettier --write contract.sol