Chuyển đến nội dung
Skillpedia
Website và giao diện (frontend)40k · #7413

salesforce-component-standards

Skill này làm gì

Hướng dẫn này giúp tạo các component giao diện người dùng Salesforce an toàn, dễ tiếp cận và tuân theo các thực hành tốt nhất. Nó đảm bảo các component hoạt động tốt với hệ thống thiết kế Salesforce (SLDS) và dễ sử dụng.

Khi nào nên dùng

  • ✓Khi xây dựng các phần giao diện mới (component) cho Salesforce.
  • ✓Khi rà soát các component hiện có để đảm bảo chúng an toàn và hiệu quả.
  • ✓Khi bạn muốn các component tuân theo tiêu chuẩn chất lượng của Salesforce.

Liên kết skill

https://github.com/github/awesome-copilot/blob/main/skills/salesforce-component-standards/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/github/awesome-copilot/blob/main/skills/salesforce-component-standards/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Làm thế nào để đảm bảo Lightning Web component của tôi có thể được mọi người dùng tiếp cận?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Hướng dẫn nêu chi tiết các quy tắc cụ thể cho từng loại component (LWC, Aura, Visualforce). Nó giải thích cách xử lý dữ liệu, bảo mật, kiểu dáng và kiểm thử, đảm bảo mọi thứ tuân theo tiêu chuẩn đã đặt ra.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Salesforce Component Quality Standards

Apply these checks to every LWC, Aura component, and Visualforce page you write or review.

Section 1 — LWC Quality Standards

1.1 Data Access Pattern Selection

Choose the right data access pattern before writing JavaScript controller code:

Use case Pattern Why
Read a single record reactively (follows navigation) @wire(getRecord, { recordId, fields }) Lightning Data Service — cached, reactive
Standard CRUD form for a single object <lightning-record-form> or <lightning-record-edit-form> Built-in FLS, CRUD, and accessibility
Complex server query or filtered list @wire(apexMethodName, { param }) on a cacheable=true method Allows caching; wire re-fires on param change
User-triggered action, DML, or non-cacheable server call Imperative apexMethodName(params).then(...).catch(...) Required for DML — wired methods cannot be @AuraEnabled without cacheable=true
Cross-component communication (no shared parent) Lightning Message Service (LMS) Decoupled, works across DOM boundaries
Multi-object graph relationships GraphQL @wire(gql, { query, variables }) Single round-trip for complex related data

1.2 Security Rules

Rule Enforcement
No raw user data in innerHTML Use {expression} binding in the template — the framework auto-escapes. Never use this.template.querySelector('.el').innerHTML = userValue
Apex @AuraEnabled methods enforce CRUD/FLS Use WITH USER_MODE in SOQL or explicit Schema.sObjectType checks
No hardcoded org-specific IDs in component JavaScript Query or pass as a prop — never embed record IDs in source
@api properties from parent: validate before use A parent can pass anything — validate type and range before using as a query parameter

1.3 SLDS 2 and Styling Standards

  • Never hardcode colours: color: #FF3366 → use color: var(--slds-c-button-brand-color-background) or a semantic SLDS token.
  • Never override SLDS classes with !important — compose with custom CSS properties.
  • Use <lightning-*> base components wherever they exist: lightning-button, lightning-input, lightning-datatable, lightning-card, etc.
  • Base components include built-in SLDS 2, dark mode, and accessibility — avoid reimplementing their behaviour.
  • If using custom CSS, test in both light mode and dark mode before declaring done.

1.4 Accessibility Requirements (WCAG 2.1 AA)

Every LWC component must pass all of these before it is considered done:

  • All form inputs have <label> or aria-label — never use placeholder as the only label
  • All icon-only buttons have alternative-text or aria-label describing the action
  • All interactive elements are reachable and operable by keyboard (Tab, Enter, Space, Escape)
  • Colour is not the only means of conveying status — pair with text, icon, or aria-* attributes
  • Error messages are associated with their input via aria-describedby
  • Focus management is correct in modals — focus moves into the modal on open and back on close

1.5 Component Communication Rules

Direction Mechanism
Parent → Child @api property or calling a @api method
Child → Parent CustomEvent — this.dispatchEvent(new CustomEvent('eventname', { detail: data }))
Sibling / unrelated components Lightning Message Service (LMS)
Never use document.querySelector, window.*, or Pub/Sub libraries

For Flow screen components:

  • Events that need to reach the Flow runtime must set bubbles: true and composed: true.
  • Expose @api value for two-way binding with the Flow variable.

1.6 JavaScript Performance Rules

  • No side effects in connectedCallback: it runs on every DOM attach — avoid DML, heavy computation, or rendering state mutations here.
  • Guard renderedCallback: always use a boolean guard to prevent infinite render loops.
  • Avoid reactive property traps: setting a reactive property inside renderedCallback causes a re-render — use it only when necessary and guarded.
  • Do not store large datasets in component state — paginate or stream large results instead.

1.7 Jest Test Requirements

Every component that handles user interaction or retrieves Apex data must have a Jest test:

// Minimum test coverage expectations

…
Câu hỏi thường gặp

LWC, Aura và Visualforce là gì?

Đây là các công nghệ khác nhau dùng để xây dựng giao diện người dùng trong Salesforce.

SLDS 2 là gì?

Đây là hệ thống thiết kế của Salesforce, quy định diện mạo và cảm giác của các component để giữ sự nhất quán về giao diện.

“Accessibility” (khả năng tiếp cận) WCAG 2.1 AA nghĩa là gì?

Nghĩa là các component phải được mọi người sử dụng, kể cả người khiếm thị, khiếm thính hoặc khiếm khuyết vận động, theo một tiêu chuẩn quốc tế.

Chi tiết

Mô tả gốc của tác giả

Quality standards for Salesforce Lightning Web Components (LWC), Aura components, and Visualforce pages. Covers SLDS 2 compliance, accessibility (WCAG 2.1 AA), data access pattern selection, component communication rules, XSS prevention, CSRF enforcement, FLS/CRUD in AuraEnabled methods, view state management, and Jest test requirements. Use this skill when building or reviewing any Salesforce UI

repo: github/awesome-copilot

Độ phổ biến

Sao GitHub
40k
Vị trí xếp hạng
#7413
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự