Skip to content

Rules

Rules Reference

Using the recommended settings will enables this rule
🔧
Problems reported by this rule can be fixed automatically with the --fix command line option

Currently we support the following rules:

Recommended rules for code correctness that you can drop in without additional configuration.
when use recommended rules, configure as follows.

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

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

Strict Rules

Strict Rules provides all available rules to improve code quality and consistency.
When using strict rules, configure as follows.

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

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