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.
npm install eslint-cdk-pluginVerified import paths — ran on the pinned version, not inferred.
Sets up flat config with recommended CDK rules using typescript-eslint. Files scope limits to CDK sources.
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
Install typescript-eslint and configure parserOptions.projectService in your ESLint config.
Migrate to flat config (eslint.config.mjs) using defineConfig or equivalent.
Downgrade TypeScript to <6.1.0 or wait for an update that broadens the range.
Upgrade ESLint to v9 or higher, or pin plugin to v3.x.
Migrate to eslint-plugin-awscdk as soon as possible.
Run npm install -D eslint-cdk-plugin and ensure version 3.x is installed.
Use import cdkPlugin from 'eslint-cdk-plugin' (ESM) or const cdkPlugin = require('eslint-cdk-plugin').default (CJS if supported).Set "type": "module" in package.json or rename config file to eslint.config.mjs.
npm install -D typescript-eslint
Adjust the files array in the ESLint config to match your project's CDK source directory (e.g., ['src/**/*.ts']).