Schemalint is a Node.js-based command-line interface (CLI) tool designed to apply linting rules to PostgreSQL database schemas. It aims to enforce consistent naming conventions, best practices, and architectural patterns directly on the database structure, similar to how ESLint functions for JavaScript code. The package is currently at version 2.3.2 and receives regular updates, often bumping dependencies and occasionally adding new built-in rules or features, typically every few weeks or months. Its key differentiators include built-in rules for common PostgreSQL patterns (e.g., preferring `text` to `varchar`, `jsonb` to `json`), the ability to define custom rules via a plugin system, and a robust configuration model that allows for fine-grained control over rule severity and ignored identifiers. It integrates directly with `node-postgres` for schema extraction.
npm install schemalintVerified import paths — ran on the pinned version, not inferred.
Demonstrates the basic installation and command-line execution of Schemalint, along with a complete example of a `.schemalintrc.js` configuration file for linting a PostgreSQL schema with common rules.
Review the new rules in the documentation and explicitly disable any unwanted rules in your `.schemalintrc.js` configuration, or adjust your schema to comply.
If developing custom plugins or using Schemalint programmatically, review your code against the new TypeScript definitions and ensure compatibility with updated interfaces.
Upgrade your Node.js environment to version 16.0.0 or newer to ensure compatibility.
Double-check all `connection` parameters in your `.schemalintrc.js` file, ensuring they accurately reflect your PostgreSQL server's configuration and credentials.
For versions before 2.3.1, use absolute paths for plugins. For v2.3.1 and later, ensure relative paths are correctly specified from the current working directory where `npx schemalint` is executed.
Ensure you run `npx schemalint` from the root directory of your project where `.schemalintrc.js` is located, or specify the path to the config file via CLI options if supported.
Verify that your PostgreSQL server is running and accessible. Check the `host` and `port` (if specified) in your `.schemalintrc.js` `connection` object to ensure they are correct.
When using TypeScript, `Config` should only be imported with `import type { Config } from 'schemalint'` for type declarations, not for runtime instantiation.Check the spelling of the rule name. For custom rules, ensure the plugin file is correctly specified in the `plugins` array and that the rule is exported with the correct name from the plugin module.