
Javascript
- 2 installs
- 8 repo stars
- Updated February 25, 2026
- testdino-hq/google-styleguides-skills
Applies Google's official ES6+ JavaScript style guide for const/let, arrow functions, modules, naming, and JSDoc.
About
Google's official JavaScript style guide for ES6+ covering const/let, arrow functions, template literals, destructuring, modules, and JSDoc. A developer uses it to write and review modern, consistent JavaScript.
- Google's official ES6+ JavaScript style guide
- Covers const/let, arrow functions, modules, JSDoc, and naming
Javascript by the numbers
- 2 all-time installs (skills.sh)
- Ranked #1,862 of 2,245 Frontend Development skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/testdino-hq/google-styleguides-skills --skill javascriptAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 2 |
|---|---|
| repo stars | ★ 8 |
| Last updated | February 25, 2026 |
| Repository | testdino-hq/google-styleguides-skills ↗ |
What it does
Applies Google's official ES6+ JavaScript style guide for const/let, arrow functions, modules, naming, and JSDoc.
Files
Google JavaScript Style Guide
Official Google JavaScript coding standards for ES6+ code.
Golden Rules
1. Use `const` by default — let only when reassignment needed, never var 2. Arrow functions for callbacks — traditional functions for methods 3. Template literals for string interpolation 4. Destructuring where it improves readability 5. Named exports over default exports 6. JSDoc for public APIs — document parameters and return types 7. 2-space indentation — consistent formatting
Quick Reference
Naming Conventions
| Element | Convention | Example |
|---|---|---|
| Classes | UpperCamelCase | UserService |
| Functions/Methods | lowerCamelCase | getUserById |
| Variables | lowerCamelCase | userCount |
| Constants | UPPER_SNAKE_CASE | MAX_SIZE |
| Private fields | #privateField | #userId |
| Files | lower-kebab-case | user-service.js |
Variables
// ✓ CORRECT
const greeting = 'Hello';
let count = 0;
// ✗ INCORRECT
var greeting = 'Hello'; // never use varFunctions
// ✓ CORRECT - arrow functions for callbacks
const double = (x) => x * 2;
array.map(item => item.id);
// ✓ CORRECT - traditional functions for methods
class User {
getName() {
return this.name;
}
}
// ✓ CORRECT - default parameters
function greet(name, greeting = 'Hello') {
return `${greeting}, ${name}!`;
}Strings
// ✓ CORRECT - template literals
const name = 'Alice';
const greeting = `Hello, ${name}!`;
// ✗ INCORRECT
const greeting = 'Hello, ' + name + '!';Destructuring
// ✓ CORRECT - object destructuring
const {id, name} = user;
const {x, y, ...rest} = coordinates;
// ✓ CORRECT - array destructuring
const [first, second] = items;
const [head, ...tail] = list;
// ✓ CORRECT - function parameters
function processUser({id, name, email}) {
// ...
}Modules
// ✓ CORRECT - named exports
export function myFunction() { /* ... */ }
export class MyClass { /* ... */ }
// ✓ CORRECT - named imports
import {myFunction, MyClass} from './my-module.js';
// ✗ INCORRECT - default exports (avoid)
export default function() { /* ... */ }Classes
// ✓ CORRECT
class Animal {
#name; // private field
constructor(name) {
this.#name = name;
}
speak() {
return `${this.#name} makes a sound.`;
}
}JSDoc
/**
* Fetches user data from the API.
* @param {number} userId - The user ID to fetch.
* @param {Object} options - Optional configuration.
* @param {number} options.timeout - Request timeout in ms.
* @return {Promise<Object>} The user data.
*/
function fetchUser(userId, {timeout = 5000} = {}) {
// ...
}Promises and Async/Await
// ✓ CORRECT - async/await
async function fetchUser(id) {
const response = await fetch(`/api/users/${id}`);
if (!response.ok) {
throw new Error(`HTTP error: ${response.status}`);
}
return response.json();
}
// ✓ CORRECT - error handling
try {
const user = await fetchUser(1);
} catch (error) {
console.error('Failed to fetch user:', error);
}Common Mistakes
| Mistake | Correct Approach |
|---|---|
Using var | Use const / let |
| String concatenation | Use template literals |
| Default exports | Use named exports |
| Missing JSDoc | Document public APIs |
| Traditional functions for callbacks | Use arrow functions |
| Ignoring destructuring | Use where it helps readability |
When to Use This Guide
- Writing new JavaScript code
- Refactoring existing JavaScript
- Code reviews
- Setting up ESLint rules
- Onboarding new team members
Install
npx skills add testdino-hq/google-styleguides-skills/javascriptFull Guide
See javascript.md for complete details, examples, and edge cases.
Google JavaScript Style Guide
Source: https://google.github.io/styleguide/jsguide.html
Golden Rules
1. Use `const` and `let` — never var 2. Use ES6+ features — arrow functions, destructuring, template literals 3. Semicolons are required at end of every statement 4. 2-space indentation — no tabs 5. Single quotes for strings (except JSON) 6. Always use `===` — never == 7. No unused variables
---
1. Variables
// CORRECT
const PI = 3.14159;
let count = 0;
// INCORRECT
var name = 'Alice'; // never use varDestructuring
const [first, second] = array;
const { name, age } = user;
const { name: userName } = user; // with renaming
const { timeout = 5000 } = options; // with defaults---
2. Strings
// CORRECT - single quotes
const name = 'Alice';
// CORRECT - template literals for interpolation
const greeting = `Hello, ${name}!`;
// INCORRECT
const greeting = 'Hello, ' + name + '!'; // use template literals---
3. Functions
// CORRECT - named function declaration
function processData(data) {
return data.filter(Boolean);
}
// CORRECT - arrow functions for callbacks
const doubled = numbers.map(n => n * 2);
// CORRECT - default parameters
function greet(name, greeting = 'Hello') {
return `${greeting}, ${name}!`;
}
// CORRECT - rest parameters
function sum(...numbers) {
return numbers.reduce((a, b) => a + b, 0);
}---
4. Classes
// CORRECT
class Animal {
#name; // private field
constructor(name) {
this.#name = name;
}
speak() {
return `${this.#name} makes a sound.`;
}
}
// INCORRECT
function Animal(name) { // use class syntax
this.name = name;
}---
5. Modules
// CORRECT - named exports
export function processData(data) { return data; }
export const MAX_SIZE = 100;
// CORRECT - imports
import { processData } from './data-processor.js';---
6. Arrays
// CORRECT - array methods over loops
const evens = numbers.filter(n => n % 2 === 0);
const doubled = numbers.map(n => n * 2);
const total = numbers.reduce((acc, n) => acc + n, 0);
// CORRECT - spread
const combined = [...arr1, ...arr2];
const copy = [...original];---
7. Async/Await
// CORRECT
async function fetchUser(id) {
const response = await fetch(`/api/users/${id}`);
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
return response.json();
}
// CORRECT - parallel operations
const [users, posts] = await Promise.all([fetchUsers(), fetchPosts()]);---
8. Naming Conventions
| Element | Convention | Example |
|---|---|---|
| Variables/Functions | lowerCamelCase | getUserById |
| Classes | UpperCamelCase | UserService |
| Constants | UPPER_SNAKE_CASE | MAX_RETRIES |
| Private fields | #name (ES2022) | #privateField |
| Files | lower-kebab-case | user-service.js |
---
Common Mistakes
| Mistake | Correct Approach |
|---|---|
var | Use const/let |
== equality | Use === strict equality |
| String concatenation | Use template literals |
.bind(this) | Use arrow functions |
arguments object | Use rest parameters |
for loops | Use for...of or array methods |
| Missing semicolons | Add semicolons |