23.3Naming Conventions / PascalCase

PascalCaseはコンストラクタ/クラスに

コンストラクタまたはクラスの命名にはPascalCaseのみを使用します。

クラス名(または古いスタイルのコンストラクタ関数)を `PascalCase` で命名することで、それが `new` キーワードでインスタンス化されるべきものであることを視覚的に示します。これにより、通常の関数と区別しやすくなり、誤った使い方を防ぐのに役立ちます。

❌ Bad
// bad
function user(options) {
  this.name = options.name;
}

const bad = new user({
  name: 'nope',
});
✅ Good
// good
class User {
  constructor(options) {
    this.name = options.name;
  }
}

const good = new User({
  name: 'yup',
});