Skip to content

ren-yamanashi/eslint-cdk-plugin

Repository files navigation

ESLint plugin for AWS CDK logo

eslint-cdk-plugin

ESLint plugin for AWS CDK

NPM

📔 Documentation

Please refer to the website.

📦 Installation

# npm
npm install -D eslint-cdk-plugin

# yarn
yarn add -D eslint-cdk-plugin

# pnpm
pnpm install -D eslint-cdk-plugin

🚀 Usage

Note: This plugin uses typescript type information and must be used in conjunction with typescript-eslint.

When using recommended config

// eslint.config.mjs
import eslintCdkPlugin from "eslint-cdk-plugin";
import tsEslint from "typescript-eslint";

export default [
  ...tsEslint.configs.recommended,
  {
    files: ["lib/**/*.ts", "bin/*.ts"],
    languageOptions: {
      parserOptions: {
        projectService: true,
        project: "./tsconfig.json",
      },
    },
    // ✅ Add plugins
    plugins: {
      cdk: eslintCdkPlugin,
    },
    // ✅ Add rules (use recommended rules)
    rules: {
      ...eslintCdkPlugin.configs.recommended.rules,
    },
  },
];

When using custom config

// eslint.config.mjs
import tsEslint from "typescript-eslint";
import eslintCdkPlugin from "eslint-cdk-plugin";

export default [
  ...tsEslint.configs.recommended,
  {
    files: ["lib/**/*.ts", "bin/*.ts"],
    languageOptions: {
      parserOptions: {
        projectService: true,
        project: "./tsconfig.json",
      },
    },
    // ✅ Add plugins
    plugins: {
      cdk: eslintCdkPlugin,
    },
    // ✅ Add rules (use custom rules)
    rules: {
      "cdk/no-class-in-interface": "error",
      "cdk/no-construct-stack-suffix": "error",
      "cdk/no-parent-name-construct-id-match": "error",
    },
  },
];

❗ Issue

If you have any questions or suggestions, please open an issue.

💪 Contribution

Contributions are welcome! Please see Contribution Guide for more details.

⚓ Versioning Policy

Please see Versioning Policy.

©️ License

MIT