Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/Objective-Arts/lens-dist --skill js-safety명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
SKILL.md 표시 중
SOC 직업 분류 기준
| name | js-safety |
| description | JS Good Parts |
Applying Douglas Crockford's defensive JavaScript philosophy from "JavaScript: The Good Parts" and JSLint. The language has good parts and bad parts—use only the good parts.
JavaScript has more bad parts than good parts. Professional JavaScript means knowing which parts to avoid entirely.
"JavaScript is the only language people feel they don't need to learn before using."
You don't need all of JavaScript. A disciplined subset produces better programs than the full language.
// BAD: Implicit global
function bad() {
x = 5; // Creates global!
}
// GOOD: Explicit scope
function good() {
const x = 5;
}
// BAD: Type coercion chaos
'' == '0' // false
0 == '' // true
0 == '0' // true
false == 'false' // false
false == '0' // true
// GOOD: Always use ===
if (value === expected) { ... }
// NEVER use with - ambiguous scope
with (obj) {
a = b; // Is this obj.a = obj.b? obj.a = b? a = obj.b?
}
// NEVER use eval - security and performance disaster
eval(userInput); // Code injection vulnerability
// Also avoid: new Function(), setTimeout with strings
setTimeout("doThing()", 100); // BAD
setTimeout(doThing, 100); // GOOD
// Avoid in most cases - rarely needed, often confused with logical
if (a & b) { } // Bitwise AND - probably meant &&
if (a | b) { } // Bitwise OR - probably meant ||
// Functions are values
const double = x => x * 2;
const numbers = [1, 2, 3].map(double);
// Closures for encapsulation
function counter() {
let count = 0;
return {
increment: () => ++count,
get: () => count
};
}
// Simple, readable object creation
const point = {
x: 10,
y: 20,
distance(other) {
return Math.sqrt(
Math.pow(this.x - other.x, 2) +
Math.pow(this.y - other.y, 2)
);
}
};
// Functional iteration - no manual loops
const adults = people
.filter(p => p.age >= 18)
.map(p => p.name)
.sort();
// Encapsulation through closures
const myModule = (function() {
// Private
let privateVar = 0;
function privateMethod() { }
// Public API
return {
publicMethod() {
privateMethod();
return privateVar;
}
};
})();
function divide(a, b) {
if (typeof a !== 'number' || typeof b !== 'number') {
throw new TypeError('Arguments must be numbers');
}
if (b === 0) {
throw new RangeError('Cannot divide by zero');
}
return a / b;
}
// Guard against undefined
function greet(name = 'Guest') {
return `Hello, ${name}`;
}
const CONFIG = Object.freeze({
API_URL: 'https://api.example.com',
TIMEOUT: 5000
});
// CONFIG.API_URL = 'x'; // Throws in strict mode
| Scenario | Apply Crockford |
|---|---|
| Legacy JS codebase | Yes - identify bad parts |
| Code review | Yes - flag dangerous patterns |
| New utility library | Yes - defensive style |
| Modern React/Vue | Partially - frameworks have own conventions |
| TypeScript | Less critical - types catch many issues |