はじめに
※プロジェクトによってのルールがある場合もあります
言語によってファイルの命名規則がちがい、何にどんな命名をすればいいのかわからなくなったので、一度まとめます。
そもそもの命名について
| 命名規則 | 例 | 由来 |
|---|---|---|
| キャメルケース | camelCase | "ラクダ"のこぶに由来 |
| パスカルケース | PascalCase | "パスカル"というプログラミング言語に由来 |
| スネークケース | snake_case | "蛇"が這うような形状に由来 |
| ケバブケース | kebab-case | "ケバブ"の串刺しに見える形状に由来 |
各言語の命名規則表
| ディレクトリ/ファイル | 変数 | 関数 | 定数 | クラス | |
|---|---|---|---|---|---|
| JavaScript | ケバブケース (user-profile) |
キャメルケース (userName) |
キャメルケース (getUserName()) |
大文字スネークケース (MAX_COUNT) |
パスカルケース (UserProfile) |
| Python | スネークケース (user_profile) |
スネークケース (user_name) |
スネークケース (get_user_name()) |
大文字スネークケース (MAX_COUNT) |
パスカルケース (UserProfile) |
| Java | パスカルケース (UserProfile) |
キャメルケース (userName) |
キャメルケース (getUserName()) |
大文字スネークケース (MAX_COUNT) |
パスカルケース (UserProfile) |
| Ruby | スネークケース (user_profile) |
スネークケース (user_name) |
スネークケース (get_user_name()) |
大文字スネークケース (MAX_COUNT) |
パスカルケース (UserProfile) |
| PHP | パスカルケース (UserProfile) |
スネークケース (user_name) |
スネークケース (get_user_name()) |
大文字スネークケース (MAX_COUNT) |
パスカルケース (UserProfile) |
| C# | パスカルケース (UserProfile) |
キャメルケース (userName) |
パスカルケース (GetUserName()) |
大文字スネークケース (MAX_COUNT) |
パスカルケース (UserProfile) |
JavaScriptフレームワークごとの命名規則表
| フレームワーク | ディレクトリ/ファイル | 変数 | 関数 | 定数 | クラス |
|---|---|---|---|---|---|
| JavaScript (Vanilla) | ケバブケース (user-profile) |
キャメルケース (userName) |
キャメルケース (getUserName()) |
大文字スネークケース (MAX_COUNT) |
パスカルケース (UserProfile) |
| React.js | パスカルケース (UserProfile) |
キャメルケース (userName) |
キャメルケース (getUserName()) |
大文字スネークケース (MAX_COUNT) |
パスカルケース (UserProfile) |
| Vue.js | パスカルケース (UserProfile) |
キャメルケース (userName) |
キャメルケース (getUserName()) |
大文字スネークケース (MAX_COUNT) |
パスカルケース (UserProfile) |
| Angular | ケバブケース (user-profile) |
キャメルケース (userName) |
キャメルケース (getUserName()) |
大文字スネークケース (MAX_COUNT) |
パスカルケース (UserProfile) |
| Ember.js | ケバブケース (user-profile) |
キャメルケース (userName) |
キャメルケース (getUserName()) |
大文字スネークケース (MAX_COUNT) |
パスカルケース (UserProfile) |
注意
GPT4.0にて作成してます。正確な情報が欲しい場合は検索してください。
最後に
迷ったら、この記事を見ます。