Rules
Rules Reference
recommended 設定を使用した場合に有効になるルールです
--fix オプションを使用して自動的に修正できるルールです
現在は、以下のルールをサポートしております。
- construct-constructor-propertyCDK Construct の constructor が 'scope, id' または 'scope, id, props' というプロパティ名を持つことを強制します
- no-construct-in-interfaceinterface のプロパティに CDK Construct 型 (例: Bucket) を指定することを禁止します
- no-construct-in-public-property-of-constructCDK Construct の public プロパティに Construct 型 (例: Bucket) を指定することを禁止します
- 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-constructConstruct の public プロパティに readonly を指定することを強制します
- no-parent-name-construct-id-matchConstruct ID に 親クラスの名前を指定することを禁止します
- no-variable-construct-idConstruct ID に変数を使用しないように強制します
- pascal-case-construct-idConstruct ID に PascalCase を強制します
- props-name-conventionProps(interface) 名が ${ConstructName}Props の形式に従うことを強制します
- require-jsdocinterface のプロパティと Construct の public プロパティに JSDoc の記載を必須とします
- require-passing-thisConstruct のコンストラクタに this を渡すように強制します
- require-props-default-docProps(interface) のオプショナルなプロパティに '@default' JSDoc を書くことを強制します
Recommended Rules
recommended
ルールは、コードを正しく保つための推奨ルールです。
このルールを使用する場合は、以下のように設定します。
js
// eslint.config.mjs
import cdkPlugin from "eslint-cdk-plugin";
import tsEslint from "typescript-eslint";
export default [
...tsEslint.configs.recommended,
// ✅ Add plugins
cdkPlugin.configs.recommended,
{
files: ["lib/**/*.ts", "bin/*.ts"],
// ... some configs
},
];
Strict Rules
strict
ルールは、利用可能なすべてのルールを提供します。
このルールを使用する場合は、以下のように設定します。
js
// eslint.config.mjs
import cdkPlugin from "eslint-cdk-plugin";
import tsEslint from "typescript-eslint";
export default [
...tsEslint.configs.recommended,
// ✅ Add plugins
cdkPlugin.configs.strict,
{
files: ["lib/**/*.ts", "bin/*.ts"],
// ... some configs
},
];