git.iko.soy/rowtype-yoga/purslint
on main help sign in
git clone https://git.iko.soy/rowtype-yoga/purslint.git

Purslint

Purslint logo

Purslint demo

A PureScript linter.

Purslint is very new and may have bugs, so please use an editor with undo functionality. :D

Install

VS Code (Marketplace)

Install from the Visual Studio Marketplace: Purslint.

CLI (npm)

npm install -g purslint

# CLI
purslint --help

Neovim (nvim-lspconfig)

After building purslint-lsp (see build steps below), you can configure Neovim like this:

require("lspconfig").purslint = {
  default_config = {
    cmd = { "/path/to/purslint-lsp" },
    filetypes = { "purescript" },
    root_dir = require("lspconfig.util").root_pattern(".git", "spago.yaml", "package.json"),
  },
}

require("lspconfig").purslint.setup({})

If you prefer to run the bundled JS directly:

cmd = { "node", "/path/to/dist/purslint-lsp.js" }

Zed Editor

A Zed extension is available in the zed-extension/ directory. To install:

  1. Open Zed
  2. Go to Extensions (Cmd+Shift+X)
  3. Click "Install Dev Extension"
  4. Select the zed-extension/ directory

The extension will automatically use the purslint-lsp binary.

Usage

CLI

# Lint a single file
./purslint src/Main.purs

# Lint multiple files
./purslint src/*.purs

# Lint with config file (optional)
./purslint --config purslint.json src/*.purs

LSP (Language Server Protocol)

The LSP binary (purslint-lsp) provides IDE integration. It communicates via stdio using the standard LSP protocol.

Features

Purslint currently ships with 81 lint rules, covering common PureScript refactors and simplifications.

For a complete list, see lib/purslint/src/Purslint/Rules/.

Configuration

Create a purslint.json file in your project root:

{
  "disabledRules": ["LetToWhere", "EtaReduce"]
}

Architecture

Purslint is written in PureScript and compiled to JavaScript via purs-backend-es, then bundled for Node.js. This allows:

Project Structure

purslint/
├── lib/purslint/src/       # Core library
│   └── Purslint/
│       ├── Rules/          # Lint rules
│       ├── Runner.purs     # Rule runner
│       ├── Types.purs      # Core types
│       └── Imports.purs    # Import checking
├── bin/
│   ├── purslint-cli/       # CLI application
│   └── purslint-lsp/       # LSP server
├── test/                   # Test suite
└── zed-extension/          # Zed editor extension

Development

Prerequisites

Building

# Install dependencies
npm install

# Build and bundle CLI + LSP
npm run dist

# Run tests
npm test

Publishing to npm

Publishing is handled by GitHub Actions. Add an NPM_TOKEN secret with an automation or granular token that has publish rights for purslint, then create a GitHub Release to trigger the workflow. You can also run it manually via the workflow dispatch.

Adding a New Rule

  1. Create a new file in lib/purslint/src/Purslint/Rules/
  2. Implement the rule using the CST traversal API
  3. Export the rule from Purslint.Rules
  4. Add tests in test/Test/Main.purs
  5. Rebuild and test

Key Dependencies

License

MIT