Rules
Rules Reference
recommended 設定を使用した場合に有効になるルールです
--fix オプションを使用して自動的に修正できるルールです
現在は、以下のルールをサポートしております。
- construct-constructor-propertyCDK Construct の constructor が 'scope, id' または 'scope, id, props' というプロパティ名を持つことを強制します
- no-construct-in-interfaceinterface のプロパティに指定する型として、書き込み可能な CDK Construct 型 (例: Bucket) の代わりに読み取り専用リソースのための interface (例: IBucket) を指定することを強制します
- no-construct-in-public-property-of-constructCDK Construct の public プロパティに指定する型として、書き込み可能な CDK Construct 型 (例: Bucket) の代わりに読み取り専用リソースのための interface (例: IBucket) を指定することを強制します
- no-construct-stack-suffixConstruct ID および Stack ID に 'Construct' または 'Stack' という文字列を含めることを禁止します
- no-import-private異なる階層レベルの private ディレクトリからの import を禁止します
- no-mutable-property-of-props-interfaceProps (interface) のプロパティに readonly 修飾子を指定することを強制します
- no-mutable-public-property-of-constructCDK Construct の public プロパティに readonly 修飾子を指定することを強制します
- no-parent-name-construct-id-matchConstruct ID に 親クラスの名前を指定することを禁止します
- no-unused-propsCDK Construct の Props (interface) で定義された未使用のプロパティを検出します
- no-variable-construct-idConstruct ID に変数を使用することを禁止します
- pascal-case-construct-idConstruct ID を PascalCase で記述することを強制します
- prefer-grants-propertygrant* メソッドではなく grants プロパティを使用することを強制します
- prevent-construct-id-collisionConstruct ID 衝突の防止のため、ループ内で Construct ID にリテラル文字列を使用することを禁止します
- props-name-conventionProps (interface) 名が ${ConstructName}Props の形式に従うことを強制します
- require-jsdocProps (interface) のプロパティと CDK Construct の public プロパティに JSDoc の記載を強制します
- require-passing-thisCDK Construct のコンストラクタの第一引数に this を渡すことを強制します
- require-props-default-docProps (interface) のオプショナルなプロパティに '@default' JSDoc を書くことを強制します
Recommended Rules
recommended ルールは、コードを正しく保つための推奨ルールです。
このルールを使用する場合は、以下のように設定します。
js
// 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,
// ✅ Add plugins
cdkPlugin.configs.recommended,
],
// ... some configs
},
]);Strict Rules
strict ルールは、利用可能なすべてのルールを提供します。
このルールを使用する場合は、以下のように設定します。
js
// 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,
// ✅ Add plugins
cdkPlugin.configs.strict,
],
// ... some configs
},
]);