spatie-javascript
Apply Spatie's JavaScript coding standards for any task that creates, edits, reviews, refactors, or formats JavaScript or TypeScript code; use for variable declarations, comparisons, functions, destructuring, and Prettier configuration to align with Spatie's JS conventions.
- License 许可
- MIT
- 最近更新
- 2026-07-30
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- spatie-javascript
- license
- MIT
- metadata
- { "author": "Spatie" }
- description
- Apply Spatie's JavaScript coding standards for any task that creates, edits, reviews, refactors, or formats JavaScript or TypeScript code; use for variable declarations, comparisons, functions, destructuring, and Prettier configuration to align with Spatie's JS conventions.
03 SKILL.md 正文
Spatie JavaScript Guidelines
Overview
Apply Spatie's JavaScript coding standards to keep JS/TS code consistent and readable.
When to Activate
- Activate this skill for any JavaScript or TypeScript coding work.
- Activate this skill when working on
.js,.ts,.jsx,.tsx, or.vuefiles. - Activate this skill when configuring Prettier or ESLint for a project.
Scope
- In scope: JavaScript, TypeScript, Vue single-file components, Prettier/ESLint configuration.
- Out of scope: PHP, Laravel, CSS-only files, server configuration.
Prettier Configuration
- Indentation: 4 spaces (via
.editorconfig, not Prettier default of 2) - Print width: 120 characters (not Prettier default of 80)
- Quote style: single quotes
Variable Declarations
- Prefer
constoverlet. Only useletwhen a variable will be reassigned. - Never use
var. - Reassigning object properties is fine with
const— the reference is not reassigned.
Variable Names
- Don't abbreviate variable names in multi-line functions. Use full, descriptive names.
- Exception: single-line arrow functions where context is obvious.
// Good — full names in multi-line functions
function saveUserSession(userSession) {
// ...
}
// Acceptable — short name in single-line arrow
userSessions.forEach(s => saveUserSession(s));
Comparisons
- Always use
===(strict equality). Never use==. - If unsure of the type, cast it first:
const number = parseInt(input);
if (number === 5) {
// ...
}
Functions
Function Declarations
- Use the
functionkeyword for named functions to clearly signal it's a function.
Arrow Functions
- Use for terse, single-line operations.
- Use for anonymous callbacks.
- Use in higher-order functions when it improves readability.
- Don't use arrow functions when you need
thiscontext (e.g., jQuery event handlers).
Object Methods
- Use shorthand method syntax:
// Good
const obj = {
handleClick(event) {
// ...
},
};
// Avoid
const obj = {
handleClick: function(event) {
// ...
},
};
Destructuring
- Prefer destructuring over manual property/index access:
// Good
const [hours, minutes] = '12:00'.split(':');
// Good — configuration objects with defaults
function createUser({ name, email, role = 'member' }) {
// ...
}
// Avoid
const parts = '12:00'.split(':');
const hours = parts[0];
const minutes = parts[1];
04 同仓库更多 Skills
spatie-version-control
Apply Spatie's version control conventions when creating commits, branches, pull requests, or managing Git repositories; use for naming repos, writing commit messages, choosing branch strategies, and merging code.
spatie-security
Apply Spatie's security guidelines when configuring applications, databases, or servers, or when reviewing code for security concerns; use for SSL setup, CSRF protection, password hashing, database permissions, and server hardening.
spatie-laravel-php
Apply Spatie's Laravel and PHP coding standards for any task that creates, edits, reviews, refactors, or formats Laravel/PHP code or Blade templates; use for controllers, Eloquent models, routes, config, validation, migrations, tests, and related files to align with Laravel conventions and PSR-12.
sluggable-development
Use when making a field on an Eloquent model sluggable, generating the migration for a slug column, switching to self-healing URLs, or resolving a model from its slug in a route. Trigger when the request mentions slugs, permalinks, the spatie/laravel-sluggable package, the HasSlug or HasTranslatableSlug trait, the #[Sluggable] attribute, SlugOptions, findBySlug, self-healing URLs, or stale slug redirects in a Laravel project. Covers choosing between the attribute and the trait, generating unique slugs, configuring separator/length/language/scope/uniqueness, preventing slug overwrites, translatable slugs via spatie/laravel-translatable, route model binding through the slug column, self-healing route keys, customizing the 308 redirect through the SelfHealing facade, and overriding the default actions via config/sluggable.php. Do not use for one-off URL-safe strings, signed URLs, or Laravel's built-in Str::slug helper when the result is not stored on a model.
olakunlevpn-filament-skills
Use when writing, reviewing, or refactoring Filament PHP v5 code -- resources, forms, tables, infolists, actions, widgets, panels, relation managers, multi-tenancy, testing, or plugin development. Always apply these standards to all Filament work.
medialibrary-development
Build and work with spatie/laravel-medialibrary features including associating files with Eloquent models, defining media collections and conversions, generating responsive images, and retrieving media URLs and paths.