eslint-plugin-canonical

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

ESLint plugin enforcing Canonical style rules and TypeScript best practices. Current version 5.1.3 (stable, active development). Includes rules for filename conventions, import ordering, type import preferences, destructuring newlines, and identifier naming. Requires @typescript-eslint/parser. Provides recommended config. Differentiators: opinionated set of rules beyond standard ESLint/TypeScript-ESLint, promotes inline type imports, and strict naming conventions. Release cadence: multiple minor/patch releases per year.

error Error: Failed to load plugin 'canonical' declared in 'extends'
cause Missing 'eslint-plugin-canonical' in devDependencies or incorrect installation.
fix
Run 'npm install eslint-plugin-canonical --save-dev'
error Error: Cannot find module '@typescript-eslint/parser'
cause Missing required parser dependency.
fix
Run 'npm install @typescript-eslint/parser --save-dev'
error TypeError: Cannot read properties of undefined (reading 'someRule')
cause Using invalid rule name or misspelled prefix (e.g., 'canonical/some-rule' wrong).
fix
Check rule names in documentation; they must match exactly.
error Parsing error: 'parserOptions.project' has been set for @typescript-eslint/parser but the project does not exist.
cause Missing tsconfig.json path in parserOptions.
fix
Set 'parserOptions.project' to './tsconfig.json' or adjust path.
breaking Version 3.0.0 dropped support for Node <12; requires ESLint >=6.
fix Upgrade Node to >=12, ESLint to >=6.
deprecated Rule 'no-use-extend-native' deprecated in v4.0.0.
fix Use ESLint's built-in 'no-extend-native' rule instead.
gotcha Requires @typescript-eslint/parser; using other parsers (e.g., babel-eslint) breaks rule functionality.
fix Set parser to '@typescript-eslint/parser' in ESLint config.
breaking Version 5.0.0 changed rule 'destructuring-property-newline' defaults.
fix Review rule options; previously allowed all on same line by default.
gotcha Plugin rule names require 'canonical/' prefix in ESLint config.
fix Use 'canonical/rule-name' instead of just 'rule-name'.
deprecated Rule 'id-match' deprecated in favor of built-in ESLint 'id-match' with custom options.
fix Remove 'canonical/id-match' and use ESLint's 'id-match' rule.
npm install eslint-plugin-canonical
yarn add eslint-plugin-canonical
pnpm add eslint-plugin-canonical

Configures ESLint with Canonical plugin and recommended rules, plus custom rules for filename matching and inline type imports.

// .eslintrc.json
{
  "parser": "@typescript-eslint/parser",
  "plugins": ["canonical"],
  "extends": ["plugin:canonical/recommended"],
  "rules": {
    "canonical/filename-match-exported": "error",
    "canonical/prefer-inline-type-import": "error"
  }
}