{"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,"search_vec":"'000':12 '1':11 '10':28 '40':14 '47.4.2':25 '9':67 'appli':42 'auto':16,37 'auto-detect':36 'auto-fix':15 'ava':64 'base':46 'canon':4,82,86 'cjs':74 'comprehens':6 'config':3,9,85 'current':22 'custom':19,76 'detect':38 'differenti':34 'eslint':2,7,20,66,80,84 'eslint-config-canon':1 'eslint-plugin-canon':79 'esm':71 'esm-on':70 'etc':58 'file':49 'fixabl':17 'framework':52 'frequent':27 'graphql':56 'guid':45 'includ':35 'javascript':83 'jest':61 'key':33 'lodash':57 'mani':51 'mocha':63 'month':32 'next.js':54 'plugin':21,81 'project':48 'react':53 'recent':31 'releas':26 'relev':43 'requir':65 'rule':13,77 'ruleset':39 'shareabl':8 'stabl':23 'style':44 'support':50,75 'tool':60 'typescript':55 'version':24,29 'vitest':62","created_at":"2026-04-25T11:18:06.945868+00:00","updated_at":"2026-04-25T11:18:06.945868+00:00","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,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/gajus/eslint-config-canonical","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/eslint-config-canonical","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-24","install_tag":null}}