Innovate-group

js-style-guide

0
0
# Install this skill:
npx skills add Innovate-group/claude-tools --skill "js-style-guide"

Install specific skill from multi-skill repository

# Description

|

# SKILL.md


name: js-style-guide
description: |
JavaScript code style guidelines. Apply these rules when generating, editing,
or reviewing JavaScript code. Triggers: "javascript", "js", "genera cΓ³digo js",
"crea funciΓ³n", "escribe javascript", any JS/TS file creation or modification.


JavaScript Style Guide

Apply these rules to ALL JavaScript code generated or modified.

Core Rules

No Semicolons

// βœ— Bad
const name = "John";

// βœ“ Good
const name = "John"

Comments in English

// βœ— Bad
// Obtener el usuario actual

// βœ“ Good
// Get current user

No jQuery

Use vanilla JS or modern frameworks. Never use jQuery.

// βœ— Bad
$(".btn").click(fn)

// βœ“ Good
document.querySelector(".btn").addEventListener("click", fn)

Arrow Functions

Prefer arrow functions. Parentheses only when multiple parameters.

// βœ— Bad
function double(n) { return n * 2 }
array.map((x) => x * 2)

// βœ“ Good
const double = n => n * 2
array.map(x => x * 2)
array.reduce((acc, item) => acc + item, 0)

Formatting

Rule Value
Indentation Tabs
Quotes Double (")
Trailing commas No
// βœ“ Correct formatting
const user = {
    name: "John",
    age: 30
}

const colors = [
    "red",
    "blue",
    "green"
]

Variables

  • Use let by default
  • Use const only for true constants (config values, magic numbers)
  • Use UPPER_SNAKE_CASE for constants, camelCase for everything else
const MAX_RETRIES = 3
const API_URL = "https://api.example.com"

let userName = "John"
let isLoading = false

Modern JS Features

Always use the latest JavaScript features.

ES Modules

// βœ“ Good
import { getData } from "./api.js"
export const helper = () => {}

// βœ— Bad
const { getData } = require("./api")
module.exports = { helper }

Async/Await

// βœ“ Good
const fetchUser = async id => {
    const response = await fetch(`/users/${id}`)
    return response.json()
}

// βœ— Bad
const fetchUser = id => {
    return fetch(`/users/${id}`)
        .then(response => response.json())
}

Template Literals

Use for string interpolation.

// βœ“ Good
const message = `Hello, ${name}!`

// βœ— Bad
const message = "Hello, " + name + "!"

Optional Chaining & Nullish Coalescing

const city = user?.address?.city ?? "Unknown"

Destructuring

Use when it improves readability.

// βœ“ Good - improves clarity
const { name, email } = user
const [first, second] = items

// βœ“ Also good - simple access is fine
const name = user.name

Quick Reference

import { api } from "./services.js"

const MAX_ITEMS = 100

let items = []
let isLoading = false

// Fetch all items from API
const fetchItems = async () => {
    isLoading = true
    const response = await api.get("/items")
    items = response.data ?? []
    isLoading = false
}

// Filter items by category
const filterByCategory = category => {
    return items.filter(item => item.category === category)
}

// Process multiple items
const processItems = (items, callback) => {
    items.forEach(item => callback(item))
}

# Supported AI Coding Agents

This skill is compatible with the SKILL.md standard and works with all major AI coding agents:

Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.