{"id":19471,"library":"eslint-cdk-plugin","title":"eslint-cdk-plugin","description":"ESLint plugin for AWS CDK projects that enforces best practices and prevents common mistakes. Current stable version is 3.4.9. It is being renamed to eslint-plugin-awscdk starting from v4.0.0 to follow ESLint's naming convention. The package provides lint rules specific to CDK constructs, such as preventing construct ID collisions, ensuring proper use of stacks, and avoiding constructs in interfaces. It requires Node.js ^18.18.0 || ^20.9.0 || >=21.1.0, ESLint ^8.57.0 || ^9.0.0 || ^10.0.0, and TypeScript >=4.8.4 <6.1.0. Ships TypeScript types. Key differentiators: type-aware rules for CDK constructs, migration path from old package name, recommended config integration with typescript-eslint.","status":"active","version":"3.4.9","language":"javascript","source_language":"en","source_url":"https://github.com/ren-yamanashi/eslint-plugin-awscdk","tags":["javascript","aws","cdk","eslint","eslint-plugin","eslintplugin","typescript"],"install":[{"cmd":"npm install eslint-cdk-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-cdk-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-cdk-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; plugin requires ESLint to function.","package":"eslint","optional":false},{"reason":"Peer dependency; many rules use TypeScript type information.","package":"typescript","optional":false}],"imports":[{"note":"ESM-only since v3. Requires flat config (eslint.config.mjs). For require, use dynamic import or upgrade to v4 with eslint-plugin-awscdk.","wrong":"const cdkPlugin = require('eslint-cdk-plugin')","symbol":"eslint-cdk-plugin","correct":"import cdkPlugin from 'eslint-cdk-plugin'"},{"note":"For v3.x, use old package name. v4+ uses eslint-plugin-awscdk. Ensure correct import to avoid 'plugin not found' errors.","wrong":"import cdkPlugin from 'eslint-plugin-awscdk'","symbol":"cdkPlugin","correct":"import cdkPlugin from 'eslint-cdk-plugin'"},{"note":"refer to the plugin object itself, not its config, when setting up custom rules.","wrong":"plugins: { cdk: cdkPlugin.configs.recommended }","symbol":"cdk","correct":"plugins: { cdk: cdkPlugin }"},{"note":"config is an object, not a string. Use object spread or reference directly.","wrong":"extends: ['cdkPlugin.configs.recommended']","symbol":"cdkPlugin.configs.recommended","correct":"extends: [cdkPlugin.configs.recommended]"}],"quickstart":{"code":"import eslint from \"@eslint/js\";\nimport { defineConfig } from \"eslint/config\";\nimport tseslint from \"typescript-eslint\";\nimport cdkPlugin from \"eslint-cdk-plugin\";\n\nexport default defineConfig([\n  eslint.configs.recommended,\n  ...tseslint.configs.recommended,\n  {\n    files: [\"lib/**/*.ts\", \"bin/*.ts\"],\n    extends: [cdkPlugin.configs.recommended],\n  },\n]);","lang":"javascript","description":"Sets up flat config with recommended CDK rules using typescript-eslint. Files scope limits to CDK sources."},"warnings":[{"fix":"Uninstall old package, install new one, and use the migration script: npm uninstall eslint-cdk-plugin && npm install -D eslint-plugin-awscdk && npx migrate-cdk-plugin","message":"Package renamed from eslint-cdk-plugin to eslint-plugin-awscdk in v4.0.0.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Install typescript-eslint and configure parserOptions.projectService in your ESLint config.","message":"Plugin requires typescript-eslint for type-aware rules. Missing it will cause runtime errors on type-dependent rules.","severity":"gotcha","affected_versions":"*"},{"fix":"Migrate to flat config (eslint.config.mjs) using defineConfig or equivalent.","message":"Legacy eslintrc format ( .eslintrc ) is not supported in v3+.","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"Downgrade TypeScript to <6.1.0 or wait for an update that broadens the range.","message":"The plugin's TypeScript version peer requirement is <6.1.0. Using TypeScript >=6.1.0 will cause peer dep conflicts or runtime errors.","severity":"gotcha","affected_versions":"*"},{"fix":"Upgrade ESLint to v9 or higher, or pin plugin to v3.x.","message":"ESLint v8 support removed in v4.0.0; only ESLint v9+ is supported.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Migrate to eslint-plugin-awscdk as soon as possible.","message":"The old package name eslint-cdk-plugin will stop receiving updates after a while and will be deprecated.","severity":"deprecated","affected_versions":">=4.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run npm install -D eslint-cdk-plugin and ensure version 3.x is installed.","cause":"Package not installed or incorrect import path.","error":"ESLint: Error: Failed to load plugin 'eslint-cdk-plugin': Cannot find module 'eslint-cdk-plugin'"},{"fix":"Use import cdkPlugin from 'eslint-cdk-plugin' (ESM) or const cdkPlugin = require('eslint-cdk-plugin').default (CJS if supported).","cause":"Incorrect import of the plugin object; using default export as an object without 'default'.","error":"TypeError: Cannot read properties of undefined (reading 'configs')"},{"fix":"Set \"type\": \"module\" in package.json or rename config file to eslint.config.mjs.","cause":"ESLint config is not set up for ES module syntax.","error":"Parsing error: The 'import' keyword is not supported in the current configuration."},{"fix":"npm install -D typescript-eslint","cause":"typescript-eslint is not installed, but required by the plugin.","error":"Error: Cannot find module 'typescript-eslint'"},{"fix":"Adjust the files array in the ESLint config to match your project's CDK source directory (e.g., ['src/**/*.ts']).","cause":"Flat config files pattern does not match any files in the project.","error":"Error: No matching configuration found for 'lib/**/*.ts'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}