Registry / aws / eslint-plugin-awscdk

eslint-plugin-awscdk

JSON →
library4.3.2jsnpmunverified

An ESLint plugin providing custom lint rules for AWS CDK projects, including rules like 'require-jsdoc', 'no-unused-props', 'prevent-construct-id-collision', and 'no-construct-in-interface'. Current stable version is 4.3.2, released under an active development cadence. It requires TypeScript and leverages type information via typescript-eslint. Differentiates from generic CDK linting by being specifically tailored to CDK constructs and patterns, offering both recommended and strict configs. Supports ESLint 8/9/10 and TypeScript 4.8+ to 6.x, and ships its own TypeScript type definitions.

npm install eslint-plugin-awscdk
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-AWSC
E
eslint-plugin-awscdk
awsjavascriptv4.3.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (cdkPlugin)
import cdkPlugin from 'eslint-plugin-awscdk';
const cdkPlugin = require('eslint-plugin-awscdk');
Plugin is ESM-first. Use import syntax. CommonJS require works but is not recommended; if used, you may need dynamic import or a CJS wrapper.
configs.recommended
cdkPlugin.configs.recommended
require('eslint-plugin-awscdk/configs/recommended')
Config objects are exported under cdkPlugin.configs. Do not use separate path imports; they are not guaranteed to exist.
rules (e.g., 'awscdk/require-jsdoc')
"awscdk/require-jsdoc": "warn"
"@awscdk/require-jsdoc": "warn"
Rule names are prefixed with 'awscdk/', not '@awscdk/'. Common mistake when copy-pasting from other plugins.

Shows flat ESLint config using the plugin with typescript-eslint, extending the recommended config and adding a custom rule.

// eslint.config.mjs import eslint from "@eslint/js"; import { defineConfig } from "eslint/config"; import tseslint from "typescript-eslint"; import cdkPlugin from "eslint-plugin-awscdk"; export default defineConfig([ { files: ["lib/**/*.ts", "bin/*.ts"], extends: [ eslint.configs.recommended, ...tseslint.configs.recommended, cdkPlugin.configs.recommended, ], rules: { "awscdk/require-jsdoc": "warn", }, }, ]);
Debug
Known issues
breakingSince v4, the plugin requires ESLint 8.57.0 or later, dropping support for earlier ESLint 8 versions.
fix
Upgrade ESLint to ^8.57.0 || ^9.0.0 || ^10.0.0.
affects: >=4.0.0
breakingConfig names changed in v4: classic configs are now under 'plugin:awscdk/classicRecommended' and 'plugin:awscdk/classicStrict', not 'plugin:awscdk/recommended'.
fix
For classic .eslintrc, use 'plugin:awscdk/classicRecommended' instead of 'plugin:awscdk/recommended'. For flat config, use cdkPlugin.configs.recommended.
affects: >=4.0.0
deprecatedThe package 'eslint-cdk-plugin' (v3.x) has been renamed to 'eslint-plugin-awscdk' (v4.x). v3.x is no longer maintained.
fix
Uninstall eslint-cdk-plugin and install eslint-plugin-awscdk@4. Update imports and config accordingly.
affects: >=3.0.0 <4.0.0
gotchaThe plugin uses TypeScript type information. Ensure you have parserOptions.project set in classic config or use typed linting with typescript-eslint.
fix
Configure parserOptions.project in .eslintrc or use typescript-eslint's typed configs in flat config.
affects: >=4.0.0
gotchaSome rules require type information and will not work without it, causing false positives or errors.
fix
Ensure you are using @typescript-eslint/parser with project option, or use only rules that do not require types.
affects: >=4.0.0
deprecatedRule 'no-construct-in-public-property-of-construct' renamed to 'no-construct-in-public-property' in v4.
fix
Use 'awscdk/no-construct-in-public-property' instead.
affects: >=4.0.0
Errors
Common errors & fixes
Error: Failed to load plugin 'awscdk' declared in '.eslintrc': Cannot find module 'eslint-plugin-awscdk'
Plugin not installed or not in node_modules.
fix
Run `npm install -D eslint-plugin-awscdk` or `pnpm install -D eslint-plugin-awscdk`.
TypeError: Cannot read properties of undefined (reading 'recommended')
Trying to access configs.recommended from a default import that is not the plugin object (e.g., wrong import style).
fix
Use `import cdkPlugin from 'eslint-plugin-awscdk'` and then `cdkPlugin.configs.recommended`. Do not use destructured import.
Error: 'eslint-plugin-awscdk' resolved in ESLint configuration to an unexpected value.
ESLint version mismatch or plugin not found due to flat config vs classic config confusion.
fix
Use the correct config format: for flat config, import the plugin; for classic config, use the string 'eslint-plugin-awscdk' in plugins array.
Parsing error: ESLint was configured to run on `<tsconfigRootDir>/file.ts` using `parserOptions.project` but it was not found.
parserOptions.project is not set or tsconfig.json path is incorrect.
fix
Set parserOptions.project to './tsconfig.json' (or the correct path) in your ESLint config.
Upgrade
Version history
4.3.2latest on npm
Audit
Dependencies
eslintoptionalPeer dependency: ESLint versions 8.57.0 or 9.x or 10.x required for plugin to function.
typescriptoptionalPeer dependency: TypeScript >=4.8.4 <6.1.0 required for type-aware rules.
Agent activity
8 hits · last 30 days
node
8
Resources