google-javascript-best-practices

Google JavaScript Best Practices

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "google-javascript-best-practices" with this command: npx skills add pproenca/dot-skills/pproenca-dot-skills-google-javascript-best-practices

Google JavaScript Best Practices

Comprehensive JavaScript style and best practices guide based on Google's official JavaScript Style Guide, designed for AI agents and LLMs. Contains 47 rules across 8 categories, prioritized by impact to guide automated refactoring and code generation.

When to Apply

Reference these guidelines when:

  • Writing new JavaScript or ES6+ code

  • Structuring modules and managing imports/exports

  • Adding JSDoc type annotations and documentation

  • Reviewing code for naming and style consistency

  • Refactoring existing JavaScript code

Rule Categories by Priority

Priority Category Impact Prefix

1 Module System & Imports CRITICAL module-

2 Language Features CRITICAL lang-

3 Type Safety & JSDoc HIGH type-

4 Naming Conventions HIGH naming-

5 Control Flow & Error Handling MEDIUM-HIGH control-

6 Functions & Parameters MEDIUM func-

7 Objects & Arrays MEDIUM data-

8 Formatting & Style LOW format-

Quick Reference

  1. Module System & Imports (CRITICAL)
  • module-avoid-circular-dependencies

  • Prevent loading failures from circular imports

  • module-file-extension-in-imports

  • Include .js extension in import paths

  • module-named-exports-over-default

  • Prefer named exports for consistency

  • module-no-duplicate-imports

  • Import from same file only once

  • module-no-import-aliasing

  • Keep original export names

  • module-source-file-structure

  • Follow standard file structure order

  1. Language Features (CRITICAL)
  • lang-const-over-let-over-var

  • Use const by default, never var

  • lang-es6-classes-over-prototypes

  • Use class syntax over prototype manipulation

  • lang-explicit-semicolons

  • Always use explicit semicolons

  • lang-no-eval

  • Never use eval or Function constructor

  • lang-no-modify-builtins

  • Never modify built-in prototypes

  • lang-no-non-standard-features

  • Use only standard ECMAScript features

  • lang-no-primitive-wrappers

  • Never use primitive wrapper objects

  • lang-no-with-statement

  • Never use the with statement

  1. Type Safety & JSDoc (HIGH)
  • type-cast-with-parentheses

  • Use parentheses for type casts

  • type-enum-annotations

  • Annotate enums with static literal values

  • type-explicit-nullability

  • Use explicit nullability modifiers

  • type-jsdoc-required-for-exports

  • Require JSDoc for exported functions

  • type-template-parameters

  • Always specify template parameters

  • type-typedef-for-complex-types

  • Use typedef for complex object types

  1. Naming Conventions (HIGH)
  • naming-constant-case-for-constants

  • Use CONSTANT_CASE for immutable values

  • naming-descriptive-over-brief

  • Prefer descriptive names over brevity

  • naming-file-naming-conventions

  • Use lowercase with dashes or underscores

  • naming-lowercamelcase-for-methods

  • Use lowerCamelCase for methods and variables

  • naming-no-dollar-prefix

  • Avoid dollar sign prefix in identifiers

  • naming-uppercamelcase-for-classes

  • Use UpperCamelCase for classes

  1. Control Flow & Error Handling (MEDIUM-HIGH)
  • control-comment-empty-catch

  • Document empty catch blocks

  • control-for-of-over-for-in

  • Prefer for-of over for-in

  • control-strict-equality

  • Use strict equality except for null checks

  • control-switch-default-last

  • Always include default case in switch

  • control-throw-error-objects

  • Always throw Error objects

  1. Functions & Parameters (MEDIUM)
  • func-arrow-functions-for-nested

  • Prefer arrow functions for nested functions

  • func-arrow-parentheses

  • Always use parentheses around arrow params

  • func-default-parameters

  • Use default parameters instead of conditionals

  • func-rest-parameters-over-arguments

  • Use rest parameters over arguments

  • func-spread-over-apply

  • Use spread operator instead of apply

  1. Objects & Arrays (MEDIUM)
  • data-array-literals-over-constructor

  • Use array literals over Array constructor

  • data-destructuring-for-multiple-values

  • Use destructuring for multiple properties

  • data-no-mixing-quoted-unquoted-keys

  • Never mix quoted and unquoted keys

  • data-object-literals-over-constructor

  • Use object literals over constructor

  • data-spread-over-concat-slice

  • Use spread over concat and slice

  • data-trailing-commas

  • Use trailing commas in multi-line literals

  1. Formatting & Style (LOW)
  • format-braces-required

  • Always use braces for control structures

  • format-column-limit

  • Limit lines to 80 characters

  • format-one-statement-per-line

  • Place one statement per line

  • format-single-quotes

  • Use single quotes for string literals

  • format-two-space-indent

  • Use two-space indentation

How to Use

Read individual reference files for detailed explanations and code examples:

  • Section definitions - Category structure and impact levels

  • Rule template - Template for adding new rules

Full Compiled Document

For a complete compiled guide with all rules, see AGENTS.md.

Reference Files

File Description

AGENTS.md Complete compiled guide with all rules

references/_sections.md Category definitions and ordering

assets/templates/_template.md Template for new rules

metadata.json Version and reference information

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

zod

No summary provided by upstream source.

Repository SourceNeeds Review
General

clean-architecture

No summary provided by upstream source.

Repository SourceNeeds Review
General

emilkowal-animations

No summary provided by upstream source.

Repository SourceNeeds Review
General

nuqs

No summary provided by upstream source.

Repository SourceNeeds Review