{"id":19496,"library":"eslint-config-canonical","title":"eslint-config-canonical","description":"A comprehensive ESLint shareable config with 1,000+ rules (40% auto-fixable) and custom ESLint plugin. Current stable version: 47.4.2. Released frequently (10+ versions in recent months). Key differentiators: includes auto-detection ruleset that only applies relevant style guides based on project files, supports many frameworks (React, Next.js, TypeScript, GraphQL, Lodash, etc.) and tools (Jest, Vitest, Mocha, AVA). Requires ESLint ^9 and is ESM-only. No CJS support. Custom rules in eslint-plugin-canonical.","status":"active","version":"47.4.2","language":"javascript","source_language":"en","source_url":"https://github.com/gajus/eslint-config-canonical","tags":["javascript","eslint","config","canonical"],"install":[{"cmd":"npm install eslint-config-canonical","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-config-canonical","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-config-canonical","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency: requires ESLint ^9 for compatibility with flat config and new rule APIs.","package":"eslint","optional":false}],"imports":[{"note":"ESM-only since v47. No CJS support. Use default import for rulesets.","wrong":"const auto = require('eslint-config-canonical/auto');","symbol":"auto","correct":"import auto from 'eslint-config-canonical/auto';"},{"note":"ESM-only. Named exports are deprecated; use specific ruleset paths like 'eslint-config-canonical/react' instead.","wrong":"const configs = require('eslint-config-canonical');","symbol":"configs","correct":"import * as configs from 'eslint-config-canonical';"},{"note":"Each ruleset is a default export from its own file. Use the path /typescript, /react, etc.","wrong":"import { typescript } from 'eslint-config-canonical';","symbol":"typescript","correct":"import typescript from 'eslint-config-canonical/typescript';"}],"quickstart":{"code":"// eslint.config.ts\nimport auto from 'eslint-config-canonical/auto';\nimport tseslint from 'typescript-eslint';\n\nexport default tseslint.config(\n  auto,\n  // Add custom overrides or other configs\n  {\n    rules: {\n      'canonical/filename-match-regex': 'off', // Example override\n    },\n  },\n);","lang":"typescript","description":"Shows how to use the auto ruleset with typescript-eslint in an ESLint flat config file."},"warnings":[{"fix":"Switch to ESM imports. If using CommonJS, use dynamic import or stay on v46.","message":"ESM-only in v47. CommonJS require() will fail with ERR_REQUIRE_ESM.","severity":"breaking","affected_versions":">=47.0.0"},{"fix":"Use path imports: import react from 'eslint-config-canonical/react';","message":"Named exports (e.g., import { react } from 'eslint-config-canonical') are deprecated.","severity":"deprecated","affected_versions":">=47.0.0"},{"fix":"Explicitly include framework-specific configs (e.g., react, next) in overrides with explicit file patterns.","message":"auto ruleset uses overrides based on detected files; may not pick up all frameworks in monorepos.","severity":"gotcha","affected_versions":">=45.0.0"},{"fix":"Migrate to ESLint 9 flat config. See ESLint migration guide.","message":"Requires ESLint ^9. Flat config is mandatory; no support for .eslintrc.","severity":"breaking","affected_versions":">=47.0.0"},{"fix":"Use canonical/vitest if possible, or copy the rules into your own config.","message":"The canonical/ava, canonical/mocha, and canonical/jest configs may be dropped in future versions in favor of vitest.","severity":"deprecated","affected_versions":">=47.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use import syntax or set \"type\": \"module\" in package.json. Alternatively use dynamic import: const auto = (await import('eslint-config-canonical/auto')).default;","cause":"Using CommonJS require() with v47 which is ESM-only.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/eslint-config-canonical/auto.js not supported."},{"fix":"Use the correct severity: \"off\", \"warn\", or \"error\" as a string, or use number 0, 1, 2.","cause":"Passing a string like 'off' without quotes or as wrong type globally.","error":"Configuration for rule \"canonical/filename-match-regex\" is invalid. Value \"string\" is not a valid severity."},{"fix":"Ensure eslint-plugin-canonical is installed as a devDependency. In flat config, use plugins: { canonical: require('eslint-plugin-canonical') } or import.","cause":"Missing eslint-plugin-canonical or not loaded properly.","error":"Could not find plugin \"canonical\" in config."},{"fix":"Use path imports like 'eslint-config-canonical/auto' or import * as configs and use configs.react etc. (note: subpath imports are recommended).","cause":"Importing from 'eslint-config-canonical' without a subpath, expecting named exports that no longer exist.","error":"TypeError: Cannot read properties of undefined (reading 'configs')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}