From f87212719645f4f4ccbb768f034043e511f1c0b7 Mon Sep 17 00:00:00 2001
From: angie <148928168+angielee0304@users.noreply.github.com>
Date: Mon, 28 Jul 2025 17:49:07 +0900
Subject: [PATCH 01/55] =?UTF-8?q?feat:=20=EC=BB=A4=EC=84=9C=EB=A3=B0=20?=
=?UTF-8?q?=EC=B6=94=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.cursor/rules/clean-code.mdc | 96 +++++++
.cursorrules | 96 +++++++
src/main.original.js | 477 ++++++++++++++++++++++-------------
3 files changed, 498 insertions(+), 171 deletions(-)
create mode 100644 .cursor/rules/clean-code.mdc
create mode 100644 .cursorrules
diff --git a/.cursor/rules/clean-code.mdc b/.cursor/rules/clean-code.mdc
new file mode 100644
index 000000000..b70a21c2f
--- /dev/null
+++ b/.cursor/rules/clean-code.mdc
@@ -0,0 +1,96 @@
+---
+alwaysApply: false
+---
+
+# Clean Code Writing Rules
+
+## MANDATORY CODE WRITING RULES
+
+You MUST follow these rules when writing any code:
+
+### CORE DESIGN PRINCIPLES
+
+- **DRY**: NEVER repeat the same code
+- **KISS**: Write code as simply as possible
+- **YAGNI**: Do NOT write unnecessary code
+- **Single Responsibility**: Functions MUST be under 20 lines and have ONE clear responsibility
+
+### CODE ORGANIZATION RULES
+
+Apply these 4 organization principles:
+
+- **Proximity**: Group related elements with blank lines
+- **Commonality**: Group related functionality into functions
+- **Similarity**: Use similar names and positions for similar roles
+- **Continuity**: Arrange code in dependency order
+
+### NAMING REQUIREMENTS
+
+#### Naming Principles (ALL MUST BE FOLLOWED)
+
+1. **Predictable**: Name must allow prediction of value, type, and return value
+2. **Contextual**: Add descriptive adjectives or nouns for context
+3. **Clear**: Remove unnecessary words while maintaining clear meaning
+4. **Concise**: Brief yet clearly convey role and purpose
+5. **Consistent**: Use identical terms for identical intentions across entire codebase
+
+#### REQUIRED Naming Patterns
+
+**Action Functions - USE THESE PATTERNS:**
+
+```
+// Creation: create~(), add~(), push~(), insert~(), new~(), append~(), spawn~(), make~(), build~(), generate~()
+// Retrieval: get~(), fetch~(), query~()
+// Transformation: parse~(), split~(), transform~(), serialize~()
+// Modification: update~(), mutation~()
+// Deletion: delete~(), remove~()
+// Communication: put~(), send~(), dispatch~(), receive~()
+// Validation: validate~(), check~()
+// Calculation: calc~(), compute~()
+// Control: init~(), configure~(), start~(), stop~()
+// Storage: save~(), store~()
+// Logging: log~(), record~()
+```
+
+**Data Variables - USE THESE PATTERNS:**
+
+```
+// Quantities: count~, sum~, num~, min~, max~, total
+// State: is~, has~, current~, selected~
+// Progressive/Past: ~ing, ~ed
+// Information: ~name, ~title, ~desc, ~text, ~data
+// Identifiers: ~ID, ~code, ~index, ~key
+// Time: ~at, ~date
+// Type: ~type
+// Collections: ~s
+// Others: item, temp, params, error
+// Conversion: from(), of()
+```
+
+### ABSTRACTION RULES
+
+- **Data Abstraction**: Simplify data structure and processing methods
+- **Process Abstraction**: Encapsulate complex logic into simple interfaces
+- **Appropriate Level**: Do NOT over-abstract or under-abstract
+
+### MANDATORY CHECKLIST
+
+Before finalizing ANY code, you MUST verify:
+
+1. ✅ **Applied standard naming patterns** from above
+2. ✅ **Organized code using 4 organization principles**
+3. ✅ **Split complex logic into small functions**
+4. ✅ **Code expresses intent without comments** (comments only when absolutely necessary)
+5. ✅ **Maintained consistent formatting**
+
+### FORBIDDEN PRACTICES
+
+- ❌ Do NOT mix similar terms (`display` vs `show`)
+- ❌ Do NOT write functions longer than 20 lines
+- ❌ Do NOT repeat code patterns
+- ❌ Do NOT use unclear or ambiguous names
+- ❌ Do NOT violate naming consistency across codebase
+
+## COMPLIANCE REQUIREMENT
+
+ALL code output MUST comply with these rules. No exceptions.
diff --git a/.cursorrules b/.cursorrules
new file mode 100644
index 000000000..7f2645968
--- /dev/null
+++ b/.cursorrules
@@ -0,0 +1,96 @@
+---
+alwaysApply: true
+---
+
+# Clean Code Writing Rules
+
+## MANDATORY CODE WRITING RULES
+
+You MUST follow these rules when writing any code:
+
+### CORE DESIGN PRINCIPLES
+
+- **DRY**: NEVER repeat the same code
+- **KISS**: Write code as simply as possible
+- **YAGNI**: Do NOT write unnecessary code
+- **Single Responsibility**: Functions MUST be under 20 lines and have ONE clear responsibility
+
+### CODE ORGANIZATION RULES
+
+Apply these 4 organization principles:
+
+- **Proximity**: Group related elements with blank lines
+- **Commonality**: Group related functionality into functions
+- **Similarity**: Use similar names and positions for similar roles
+- **Continuity**: Arrange code in dependency order
+
+### NAMING REQUIREMENTS
+
+#### Naming Principles (ALL MUST BE FOLLOWED)
+
+1. **Predictable**: Name must allow prediction of value, type, and return value
+2. **Contextual**: Add descriptive adjectives or nouns for context
+3. **Clear**: Remove unnecessary words while maintaining clear meaning
+4. **Concise**: Brief yet clearly convey role and purpose
+5. **Consistent**: Use identical terms for identical intentions across entire codebase
+
+#### REQUIRED Naming Patterns
+
+**Action Functions - USE THESE PATTERNS:**
+
+```
+// Creation: create~(), add~(), push~(), insert~(), new~(), append~(), spawn~(), make~(), build~(), generate~()
+// Retrieval: get~(), fetch~(), query~()
+// Transformation: parse~(), split~(), transform~(), serialize~()
+// Modification: update~(), mutation~()
+// Deletion: delete~(), remove~()
+// Communication: put~(), send~(), dispatch~(), receive~()
+// Validation: validate~(), check~()
+// Calculation: calc~(), compute~()
+// Control: init~(), configure~(), start~(), stop~()
+// Storage: save~(), store~()
+// Logging: log~(), record~()
+```
+
+**Data Variables - USE THESE PATTERNS:**
+
+```
+// Quantities: count~, sum~, num~, min~, max~, total
+// State: is~, has~, current~, selected~
+// Progressive/Past: ~ing, ~ed
+// Information: ~name, ~title, ~desc, ~text, ~data
+// Identifiers: ~ID, ~code, ~index, ~key
+// Time: ~at, ~date
+// Type: ~type
+// Collections: ~s
+// Others: item, temp, params, error
+// Conversion: from(), of()
+```
+
+### ABSTRACTION RULES
+
+- **Data Abstraction**: Simplify data structure and processing methods
+- **Process Abstraction**: Encapsulate complex logic into simple interfaces
+- **Appropriate Level**: Do NOT over-abstract or under-abstract
+
+### MANDATORY CHECKLIST
+
+Before finalizing ANY code, you MUST verify:
+
+1. ✅ **Applied standard naming patterns** from above
+2. ✅ **Organized code using 4 organization principles**
+3. ✅ **Split complex logic into small functions**
+4. ✅ **Code expresses intent without comments** (comments only when absolutely necessary)
+5. ✅ **Maintained consistent formatting**
+
+### FORBIDDEN PRACTICES
+
+- ❌ Do NOT mix similar terms (`display` vs `show`)
+- ❌ Do NOT write functions longer than 20 lines
+- ❌ Do NOT repeat code patterns
+- ❌ Do NOT use unclear or ambiguous names
+- ❌ Do NOT violate naming consistency across codebase
+
+## COMPLIANCE REQUIREMENT
+
+ALL code output MUST comply with these rules. No exceptions.
diff --git a/src/main.original.js b/src/main.original.js
index 0fd12e7c9..95741dc31 100644
--- a/src/main.original.js
+++ b/src/main.original.js
@@ -1,17 +1,17 @@
-var prodList
-var bonusPts = 0
-var stockInfo
-var itemCnt
-var lastSel
-var sel
-var addBtn
-var totalAmt = 0
-var PRODUCT_ONE = 'p1'
-var p2 = 'p2'
-var product_3 = 'p3'
-var p4 = "p4"
-var PRODUCT_5 = `p5`
-var cartDisp
+var prodList;
+var bonusPts = 0;
+var stockInfo;
+var itemCnt;
+var lastSel;
+var sel;
+var addBtn;
+var totalAmt = 0;
+var PRODUCT_ONE = "p1";
+var p2 = "p2";
+var product_3 = "p3";
+var p4 = "p4";
+var PRODUCT_5 = `p5`;
+var cartDisp;
function main() {
var root;
var header;
@@ -27,10 +27,42 @@ function main() {
itemCnt = 0;
lastSel = null;
prodList = [
- {id: PRODUCT_ONE, name: '버그 없애는 키보드', val: 10000, originalVal: 10000, q: 50, onSale: false, suggestSale: false},
- {id: p2, name: '생산성 폭발 마우스', val: 20000, originalVal: 20000, q: 30, onSale: false, suggestSale: false},
- {id: product_3, name: "거북목 탈출 모니터암", val: 30000, originalVal: 30000, q: 20, onSale: false, suggestSale: false},
- {id: p4, name: "에러 방지 노트북 파우치", val: 15000, originalVal: 15000, q: 0, onSale: false, suggestSale: false},
+ {
+ id: PRODUCT_ONE,
+ name: "버그 없애는 키보드",
+ val: 10000,
+ originalVal: 10000,
+ q: 50,
+ onSale: false,
+ suggestSale: false,
+ },
+ {
+ id: p2,
+ name: "생산성 폭발 마우스",
+ val: 20000,
+ originalVal: 20000,
+ q: 30,
+ onSale: false,
+ suggestSale: false,
+ },
+ {
+ id: product_3,
+ name: "거북목 탈출 모니터암",
+ val: 30000,
+ originalVal: 30000,
+ q: 20,
+ onSale: false,
+ suggestSale: false,
+ },
+ {
+ id: p4,
+ name: "에러 방지 노트북 파우치",
+ val: 15000,
+ originalVal: 15000,
+ q: 0,
+ onSale: false,
+ suggestSale: false,
+ },
{
id: PRODUCT_5,
name: `코딩할 때 듣는 Lo-Fi 스피커`,
@@ -38,42 +70,45 @@ function main() {
originalVal: 25000,
q: 10,
onSale: false,
- suggestSale: false
- }
- ]
- var root = document.getElementById('app')
- header = document.createElement('div');
- header.className = 'mb-8'
+ suggestSale: false,
+ },
+ ];
+ var root = document.getElementById("app");
+ header = document.createElement("div");
+ header.className = "mb-8";
header.innerHTML = `
Shopping Cart
🛍️ 0 items in cart
`;
- sel = document.createElement('select');
- sel.id = 'product-select';
- gridContainer = document.createElement('div');
+ sel = document.createElement("select");
+ sel.id = "product-select";
+ gridContainer = document.createElement("div");
leftColumn = document.createElement("div");
- leftColumn['className'] = 'bg-white border border-gray-200 p-8 overflow-y-auto'
- selectorContainer = document.createElement('div');
- selectorContainer.className = 'mb-6 pb-6 border-b border-gray-200';
- sel.className = 'w-full p-3 border border-gray-300 rounded-lg text-base mb-3';
- gridContainer.className = 'grid grid-cols-1 lg:grid-cols-[1fr_360px] gap-6 flex-1 overflow-hidden';
- addBtn = document.createElement('button');
- stockInfo = document.createElement('div');
- addBtn.id = 'add-to-cart';
- stockInfo.id = 'stock-status';
- stockInfo.className = 'text-xs text-red-500 mt-3 whitespace-pre-line';
- addBtn.innerHTML = 'Add to Cart';
- addBtn.className = 'w-full py-3 bg-black text-white text-sm font-medium uppercase tracking-wider hover:bg-gray-800 transition-all';
+ leftColumn["className"] =
+ "bg-white border border-gray-200 p-8 overflow-y-auto";
+ selectorContainer = document.createElement("div");
+ selectorContainer.className = "mb-6 pb-6 border-b border-gray-200";
+ sel.className = "w-full p-3 border border-gray-300 rounded-lg text-base mb-3";
+ gridContainer.className =
+ "grid grid-cols-1 lg:grid-cols-[1fr_360px] gap-6 flex-1 overflow-hidden";
+ addBtn = document.createElement("button");
+ stockInfo = document.createElement("div");
+ addBtn.id = "add-to-cart";
+ stockInfo.id = "stock-status";
+ stockInfo.className = "text-xs text-red-500 mt-3 whitespace-pre-line";
+ addBtn.innerHTML = "Add to Cart";
+ addBtn.className =
+ "w-full py-3 bg-black text-white text-sm font-medium uppercase tracking-wider hover:bg-gray-800 transition-all";
selectorContainer.appendChild(sel);
selectorContainer.appendChild(addBtn);
selectorContainer.appendChild(stockInfo);
leftColumn.appendChild(selectorContainer);
- cartDisp = document.createElement('div');
+ cartDisp = document.createElement("div");
leftColumn.appendChild(cartDisp);
- cartDisp.id = 'cart-items';
- rightColumn = document.createElement('div');
- rightColumn.className = 'bg-black text-white p-8 flex flex-col';
+ cartDisp.id = "cart-items";
+ rightColumn = document.createElement("div");
+ rightColumn.className = "bg-black text-white p-8 flex flex-col";
rightColumn.innerHTML = `
@@ -103,28 +138,31 @@ function main() {
Earn loyalty points with purchase.
`;
- sum = rightColumn.querySelector('#cart-total');
- manualToggle = document.createElement('button');
+ sum = rightColumn.querySelector("#cart-total");
+ manualToggle = document.createElement("button");
manualToggle.onclick = function () {
- manualOverlay.classList.toggle('hidden');
- manualColumn.classList.toggle('translate-x-full');
+ manualOverlay.classList.toggle("hidden");
+ manualColumn.classList.toggle("translate-x-full");
};
- manualToggle.className = 'fixed top-4 right-4 bg-black text-white p-3 rounded-full hover:bg-gray-900 transition-colors z-50';
+ manualToggle.className =
+ "fixed top-4 right-4 bg-black text-white p-3 rounded-full hover:bg-gray-900 transition-colors z-50";
manualToggle.innerHTML = `
`;
- manualOverlay = document.createElement('div');
- manualOverlay.className = 'fixed inset-0 bg-black/50 z-40 hidden transition-opacity duration-300';
+ manualOverlay = document.createElement("div");
+ manualOverlay.className =
+ "fixed inset-0 bg-black/50 z-40 hidden transition-opacity duration-300";
manualOverlay.onclick = function (e) {
if (e.target === manualOverlay) {
- manualOverlay.classList.add('hidden');
- manualColumn.classList.add('translate-x-full');
+ manualOverlay.classList.add("hidden");
+ manualColumn.classList.add("translate-x-full");
}
};
- manualColumn = document.createElement('div');
- manualColumn.className = 'fixed right-0 top-0 h-full w-80 bg-white shadow-2xl p-6 overflow-y-auto z-50 transform translate-x-full transition-transform duration-300';
+ manualColumn = document.createElement("div");
+ manualColumn.className =
+ "fixed right-0 top-0 h-full w-80 bg-white shadow-2xl p-6 overflow-y-auto z-50 transform translate-x-full transition-transform duration-300";
manualColumn.innerHTML = `