@salesforce/webapp-template-feature-react-file-upload-experimental 1.106.0 → 1.106.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.a4drules/{webapp-webapplication.md → skills/webapp-metadata-and-config/SKILL.md} +2 -3
- package/dist/.a4drules/webapp-code-quality.md +28 -0
- package/dist/.a4drules/webapp-react-typescript.md +0 -154
- package/dist/.a4drules/webapp-react.md +9 -129
- package/dist/.a4drules/webapp-skills-first.md +1 -4
- package/dist/CHANGELOG.md +22 -0
- package/dist/package.json +1 -1
- package/package.json +2 -2
- package/dist/.a4drules/webapp-cli-commands.md +0 -88
- package/dist/.a4drules/webapp-react-code-quality.md +0 -136
- /package/dist/.a4drules/{webapp.md → skills/webapp-creation/SKILL.md} +0 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Code quality and build validation standards
|
|
3
|
+
paths:
|
|
4
|
+
- "**/webapplications/**/*"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Code Quality & Build Validation
|
|
8
|
+
|
|
9
|
+
Enforces ESLint, TypeScript, and build validation for consistent, maintainable code.
|
|
10
|
+
|
|
11
|
+
## MANDATORY Quality Gates
|
|
12
|
+
|
|
13
|
+
**Before completing any coding session** (from the web app directory `force-app/main/default/webapplications/<appName>/`):
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm run lint # MUST result in 0 errors
|
|
17
|
+
npm run build # MUST succeed (includes TypeScript check)
|
|
18
|
+
npm run graphql:coden # MUST succeed (verifies graphql queries)
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Must Pass:**
|
|
22
|
+
- `npm run build` completes successfully
|
|
23
|
+
- No TypeScript compilation errors
|
|
24
|
+
- No critical ESLint errors (0 errors)
|
|
25
|
+
|
|
26
|
+
**Can Be Warnings:**
|
|
27
|
+
- ESLint warnings (fix when convenient)
|
|
28
|
+
- Minor TypeScript warnings
|
|
@@ -4,79 +4,12 @@ paths:
|
|
|
4
4
|
- "**/webapplications/**/*"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
# TypeScript Standards
|
|
8
|
-
|
|
9
|
-
## MANDATORY Configuration
|
|
10
|
-
- `strict: true` - Enable all strict type checking
|
|
11
|
-
- `noUncheckedIndexedAccess: true` - Prevent unsafe array/object access
|
|
12
|
-
- `noUnusedLocals: true` - Report unused variables
|
|
13
|
-
- `noUnusedParameters: true` - Report unused parameters
|
|
14
|
-
|
|
15
|
-
## Function Return Types (REQUIRED)
|
|
16
|
-
```typescript
|
|
17
|
-
// Always specify return types
|
|
18
|
-
function fetchUserData(id: string): Promise<User> {
|
|
19
|
-
return api.get(`/users/${id}`);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const calculateTotal = (items: Item[]): number => {
|
|
23
|
-
return items.reduce((sum, item) => sum + item.price, 0);
|
|
24
|
-
};
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Interface Definitions (REQUIRED)
|
|
28
|
-
```typescript
|
|
29
|
-
// Data structures
|
|
30
|
-
interface User {
|
|
31
|
-
id: string;
|
|
32
|
-
name: string;
|
|
33
|
-
email: string;
|
|
34
|
-
createdAt: Date;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// React component props
|
|
38
|
-
interface ButtonProps {
|
|
39
|
-
variant: 'primary' | 'secondary';
|
|
40
|
-
onClick: () => void;
|
|
41
|
-
disabled?: boolean;
|
|
42
|
-
children: React.ReactNode;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export const Button: React.FC<ButtonProps> = ({ variant, onClick, disabled, children }) => {
|
|
46
|
-
// Implementation
|
|
47
|
-
};
|
|
48
|
-
```
|
|
49
|
-
|
|
50
7
|
## Type Safety Rules
|
|
51
8
|
|
|
52
9
|
### Never Use `any`
|
|
53
10
|
```typescript
|
|
54
11
|
// FORBIDDEN
|
|
55
12
|
const data: any = await fetchData();
|
|
56
|
-
|
|
57
|
-
// REQUIRED: Proper typing
|
|
58
|
-
interface ApiResponse {
|
|
59
|
-
data: User[];
|
|
60
|
-
status: 'success' | 'error';
|
|
61
|
-
}
|
|
62
|
-
const response: ApiResponse = await fetchData();
|
|
63
|
-
|
|
64
|
-
// ACCEPTABLE: Unknown when type is truly unknown
|
|
65
|
-
const parseJson = (input: string): unknown => JSON.parse(input);
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
### Null Safety
|
|
69
|
-
```typescript
|
|
70
|
-
// Handle null/undefined explicitly
|
|
71
|
-
interface UserProfile {
|
|
72
|
-
user: User | null;
|
|
73
|
-
loading: boolean;
|
|
74
|
-
error: string | null;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Use optional chaining and nullish coalescing
|
|
78
|
-
const displayName = user?.name ?? 'Anonymous';
|
|
79
|
-
const avatarUrl = user?.profile?.avatar ?? '/default-avatar.png';
|
|
80
13
|
```
|
|
81
14
|
|
|
82
15
|
## React TypeScript Patterns
|
|
@@ -86,53 +19,12 @@ const avatarUrl = user?.profile?.avatar ?? '/default-avatar.png';
|
|
|
86
19
|
const handleSubmit = (event: React.FormEvent<HTMLFormElement>): void => {
|
|
87
20
|
event.preventDefault();
|
|
88
21
|
};
|
|
89
|
-
|
|
90
|
-
const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>): void => {
|
|
91
|
-
setInputValue(event.target.value);
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
const handleClick = (event: React.MouseEvent<HTMLButtonElement>): void => {
|
|
95
|
-
console.log('Button clicked');
|
|
96
|
-
};
|
|
97
22
|
```
|
|
98
23
|
|
|
99
24
|
### State and Hooks
|
|
100
25
|
```typescript
|
|
101
26
|
// Type useState properly
|
|
102
27
|
const [user, setUser] = useState<User | null>(null);
|
|
103
|
-
const [loading, setLoading] = useState<boolean>(false);
|
|
104
|
-
const [errors, setErrors] = useState<string[]>([]);
|
|
105
|
-
|
|
106
|
-
// Type custom hooks
|
|
107
|
-
interface UseApiResult<T> {
|
|
108
|
-
data: T | null;
|
|
109
|
-
loading: boolean;
|
|
110
|
-
error: string | null;
|
|
111
|
-
refetch: () => Promise<void>;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function useApi<T>(url: string): UseApiResult<T> {
|
|
115
|
-
const [data, setData] = useState<T | null>(null);
|
|
116
|
-
const [loading, setLoading] = useState<boolean>(false);
|
|
117
|
-
const [error, setError] = useState<string | null>(null);
|
|
118
|
-
|
|
119
|
-
return { data, loading, error, refetch };
|
|
120
|
-
}
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
## API Types
|
|
124
|
-
|
|
125
|
-
### Salesforce Records
|
|
126
|
-
```typescript
|
|
127
|
-
interface SalesforceRecord {
|
|
128
|
-
Id: string;
|
|
129
|
-
attributes: { type: string; url: string };
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
interface Account extends SalesforceRecord {
|
|
133
|
-
Name: { value: string };
|
|
134
|
-
Industry?: { value: string | null };
|
|
135
|
-
}
|
|
136
28
|
```
|
|
137
29
|
|
|
138
30
|
### GraphQL via DataSDK
|
|
@@ -143,24 +35,6 @@ See **webapp-react.md** for DataSDK usage patterns. Type your GraphQL responses:
|
|
|
143
35
|
const response = await sdk.graphql?.<GetAccountsQuery>(QUERY, variables);
|
|
144
36
|
```
|
|
145
37
|
|
|
146
|
-
## Error Handling Types
|
|
147
|
-
```typescript
|
|
148
|
-
interface ApiError {
|
|
149
|
-
message: string;
|
|
150
|
-
status: number;
|
|
151
|
-
code?: string;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
class CustomError extends Error {
|
|
155
|
-
constructor(message: string, public readonly status: number, public readonly code?: string) {
|
|
156
|
-
super(message);
|
|
157
|
-
this.name = 'CustomError';
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
## Anti-Patterns (FORBIDDEN)
|
|
163
|
-
|
|
164
38
|
### Type Assertions
|
|
165
39
|
```typescript
|
|
166
40
|
// FORBIDDEN: Unsafe assertions
|
|
@@ -175,31 +49,3 @@ if (isUser(data)) {
|
|
|
175
49
|
console.log(data.name); // Now safely typed
|
|
176
50
|
}
|
|
177
51
|
```
|
|
178
|
-
|
|
179
|
-
### Missing Return Types
|
|
180
|
-
```typescript
|
|
181
|
-
// FORBIDDEN: No return type
|
|
182
|
-
const fetchData = async (id: string) => {
|
|
183
|
-
return await api.get(`/data/${id}`);
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
// REQUIRED: Explicit return type
|
|
187
|
-
const fetchData = async (id: string): Promise<ApiResponse> => {
|
|
188
|
-
return await api.get(`/data/${id}`);
|
|
189
|
-
};
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
## Quality Checklist
|
|
193
|
-
Before completing TypeScript code:
|
|
194
|
-
1. All functions have explicit return types
|
|
195
|
-
2. All interfaces are properly defined
|
|
196
|
-
3. No `any` types used (use `unknown` if necessary)
|
|
197
|
-
4. Null/undefined handling is explicit
|
|
198
|
-
5. React components are properly typed
|
|
199
|
-
6. API calls have proper type definitions
|
|
200
|
-
7. `tsc -b` compiles without errors
|
|
201
|
-
|
|
202
|
-
## Enforcement
|
|
203
|
-
- TypeScript errors MUST be fixed before any commit
|
|
204
|
-
- NEVER disable TypeScript strict mode
|
|
205
|
-
- Code reviews MUST check for proper typing
|
|
@@ -6,149 +6,29 @@ paths:
|
|
|
6
6
|
|
|
7
7
|
# React Web App (SFDX)
|
|
8
8
|
|
|
9
|
-
React-specific guidelines for data access, component library, and Salesforce integration.
|
|
10
|
-
|
|
11
9
|
For layout, navigation, and generation rules, see **webapp.md**.
|
|
12
10
|
|
|
13
|
-
## Project Structure
|
|
14
|
-
|
|
15
|
-
- Web app root: `force-app/main/default/webapplications/<appName>/`
|
|
16
|
-
- Entry: `src/app.tsx`
|
|
17
|
-
- Layout shell: `src/appLayout.tsx`
|
|
18
|
-
- Dev server: `npm run dev`
|
|
19
|
-
- Build: `npm run build`
|
|
20
|
-
|
|
21
11
|
## Routing (React Router)
|
|
22
12
|
|
|
23
|
-
Use a **single** router package for the app. When using `createBrowserRouter` and `RouterProvider` from `react-router`, all routing imports
|
|
24
|
-
|
|
25
|
-
- ✅ `import { createBrowserRouter, RouterProvider, Link, useNavigate, useLocation, Outlet } from 'react-router';`
|
|
26
|
-
- ❌ `import { Link } from 'react-router-dom';` when the app uses `RouterProvider` from `react-router`
|
|
27
|
-
|
|
28
|
-
Mixing packages causes "Cannot destructure property 'basename' of ... as it is null" because `Link`/hooks from `react-router-dom` read a different context than the one provided by `RouterProvider` from `react-router`.
|
|
29
|
-
|
|
30
|
-
## Component Library (MANDATORY)
|
|
31
|
-
|
|
32
|
-
Use **shadcn/ui** for UI components:
|
|
33
|
-
|
|
34
|
-
```typescript
|
|
35
|
-
import { Button } from '@/components/ui/button';
|
|
36
|
-
import { Card, CardHeader, CardContent } from '@/components/ui/card';
|
|
37
|
-
import { Input } from '@/components/ui/input';
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
## Icons & No Emojis (MANDATORY)
|
|
41
|
-
|
|
42
|
-
- **Icons:** Use **lucide-react** only. Do not use Heroicons, Simple Icons, or other icon libraries in the web app.
|
|
43
|
-
- ✅ `import { Menu, Settings, Bell } from 'lucide-react';` then `<Menu className="w-5 h-5" />`
|
|
44
|
-
- ❌ Any emoji character as an icon or visual element (e.g. 🎨 🚀 ⚙️ 🔔)
|
|
45
|
-
- ❌ Other icon libraries (e.g. `@heroicons/react`, `react-icons`, custom SVG icon sets)
|
|
46
|
-
- **No emojis ever:** Do not use emojis anywhere in the app: no emojis in UI labels, buttons, headings, empty states, tooltips, or any user-facing text. Use words and lucide-react icons instead.
|
|
47
|
-
- ✅ "Settings" with `<Settings />` icon
|
|
48
|
-
- ❌ "⚙️ Settings" or "Settings 🔧"
|
|
49
|
-
- For icon usage patterns and naming, see the **designing-webapp-ui-ux** skill (`.a4drules/skills/designing-webapp-ui-ux/`, especially `data/icons.csv`).
|
|
50
|
-
|
|
51
|
-
## Editing UI — Source Files Only (CRITICAL)
|
|
52
|
-
|
|
53
|
-
When asked to edit the home page, a section, or any on-screen UI:
|
|
54
|
-
|
|
55
|
-
- **Always edit the actual React/TSX source files.** Never output, paste, or generate raw HTML. The UI is built from components; the agent must locate the component file(s) that render the target area and change **JSX in those files**.
|
|
56
|
-
- **Do not** replace JSX with HTML strings, and do not copy browser-rendered DOM (e.g. expanded `<div>`, `data-slot`, long class strings) into the codebase. That is the output of React + shadcn; the source is `.tsx` with `<Card>`, `<Input>`, etc.
|
|
57
|
-
- **Edit inside the component that owns the UI.** If the element to change is rendered by a **child component** (e.g. `<GlobalSearchInput />` in `Home.tsx`), make the edit **inside that component's file** (e.g. `GlobalSearchInput.tsx`). Do **not** only wrap the component with extra elements in the parent (e.g. adding a `<section>` or `<div>` around `<GlobalSearchInput />`). The parent composes components; the visual/content change belongs in the component that actually renders that part of the UI.
|
|
58
|
-
- **Where to edit:**
|
|
59
|
-
- **Home page content:** `src/pages/Home.tsx` — but if the target is inside a child (e.g. `<GlobalSearchInput />`), edit the child's file, not the parent.
|
|
60
|
-
- **Layout, header, nav:** `src/appLayout.tsx`.
|
|
61
|
-
- **Feature-specific UI (e.g. search, list):** open the **specific component file** that renders the target (e.g. `GlobalSearchInput.tsx` for the search input UI).
|
|
62
|
-
- **Steps:** (1) Identify which **component** owns the section (follow the import: e.g. `GlobalSearchInput` → its file). (2) Open that component's file and modify the JSX there. (3) Only change the parent (e.g. `Home.tsx`) if the change is layout/ordering of components, not the internals of a child. Do not emit a standalone HTML snippet as the “edit.”
|
|
13
|
+
Use a **single** router package for the app. When using `createBrowserRouter` and `RouterProvider` from `react-router`, all routing imports MUST come from **`react-router`** — not from `react-router-dom`.
|
|
63
14
|
|
|
64
|
-
##
|
|
65
|
-
|
|
66
|
-
When adding a navigation menu that includes a hamburger (or Menu icon) for mobile:
|
|
67
|
-
|
|
68
|
-
- **Do not** add a hamburger/Menu icon that does nothing. The icon must **toggle a visible mobile menu**.
|
|
69
|
-
- **Required implementation:**
|
|
70
|
-
1. **State:** e.g. `const [isOpen, setIsOpen] = useState(false);`
|
|
71
|
-
2. **Toggle button:** The hamburger/Menu button must have `onClick={() => setIsOpen(!isOpen)}` and `aria-label="Toggle menu"` (or equivalent).
|
|
72
|
-
3. **Conditional panel:** A mobile-only menu panel that renders when `isOpen` is true, e.g. `{isOpen && ( <div className="..."> ... nav links ... </div> )}`. Use responsive classes (e.g. `md:hidden`) so the panel is shown only on small screens if the desktop nav is separate.
|
|
73
|
-
4. **Close on navigation:** Each nav link in the mobile panel should call `onClick={() => setIsOpen(false)}` (or similar) so the menu closes when the user navigates.
|
|
74
|
-
- Implement this in `appLayout.tsx` (or the component that owns the header/nav). See existing apps for the full pattern (state + button + conditional panel + link onClick).
|
|
75
|
-
|
|
76
|
-
## Styling
|
|
15
|
+
## Component Library + Styling (MANDATORY)
|
|
77
16
|
|
|
17
|
+
- Use **shadcn/ui** for UI components: `import { Button } from '@/components/ui/button';`
|
|
78
18
|
- Use **Tailwind CSS** utility classes
|
|
79
|
-
- Follow consistent spacing, color, and typography conventions
|
|
80
19
|
|
|
81
20
|
## Module & Platform Restrictions
|
|
82
21
|
|
|
83
|
-
React apps must NOT import Salesforce platform modules
|
|
84
|
-
|
|
85
|
-
- ❌ `@salesforce/*` (except `@salesforce/sdk-data`)
|
|
86
|
-
- ❌ `lightning/*`
|
|
87
|
-
- ❌ `@wire` (LWC-only)
|
|
88
|
-
|
|
89
|
-
Use standard web APIs and npm packages only.
|
|
22
|
+
React apps must NOT import Salesforce platform modules like `lightning/*` or `@wire` (LWC-only)
|
|
90
23
|
|
|
91
24
|
## Data Access (CRITICAL)
|
|
92
25
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
## Error Handling
|
|
96
|
-
|
|
97
|
-
```typescript
|
|
98
|
-
async function safeFetch<T>(fn: () => Promise<T>): Promise<T> {
|
|
99
|
-
try {
|
|
100
|
-
return await fn();
|
|
101
|
-
} catch (err) {
|
|
102
|
-
console.error('API Error:', err);
|
|
103
|
-
throw err;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
### Authentication Errors
|
|
109
|
-
|
|
110
|
-
On 401/403 response, trigger page refresh to redirect to login:
|
|
111
|
-
```typescript
|
|
112
|
-
window.location.reload();
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
## Security Standards
|
|
116
|
-
|
|
117
|
-
- Validate user permissions before data operations
|
|
118
|
-
- Respect record sharing rules and field-level security
|
|
119
|
-
- Never hardcode credentials or secrets
|
|
120
|
-
- Sanitize all user inputs
|
|
121
|
-
- Use HTTPS for all API calls
|
|
122
|
-
|
|
123
|
-
## Performance
|
|
124
|
-
|
|
125
|
-
- Use React Query or RTK Query for caching API data
|
|
126
|
-
- Use `React.memo`, `useMemo`, `useCallback` where appropriate
|
|
127
|
-
- Implement loading and error states
|
|
26
|
+
All Salesforce API calls **must** go through the DataSDK (`@salesforce/sdk-data`). Do NOT use `axios` or raw `fetch` — the SDK handles authentication and CSRF.
|
|
128
27
|
|
|
129
|
-
|
|
28
|
+
### GraphQL (Preferred)
|
|
130
29
|
|
|
131
|
-
-
|
|
132
|
-
- ❌ Using `axios` or raw `fetch` for Salesforce APIs
|
|
133
|
-
- ❌ Direct DOM manipulation in React
|
|
134
|
-
- ❌ Using LWC patterns (`@wire`, LDS) in React
|
|
135
|
-
- ❌ Hardcoded Salesforce IDs or URLs
|
|
136
|
-
- ❌ Missing error handling for async operations
|
|
137
|
-
- ❌ Mixing `react-router` and `react-router-dom` (e.g. `RouterProvider` from `react-router` but `Link` from `react-router-dom`) — use one package for all routing imports
|
|
138
|
-
- ❌ Using emojis anywhere in the app (labels, icons, empty states, headings, tooltips)
|
|
139
|
-
- ❌ Using any icon library other than **lucide-react** (no Heroicons, react-icons, or emoji-as-icon)
|
|
140
|
-
- ❌ Outputting or pasting raw HTML when editing UI — always edit the React/TSX source files (e.g. `Home.tsx`, `appLayout.tsx`, feature components)
|
|
141
|
-
- ❌ Adding a hamburger or Menu icon for mobile nav without implementing toggle state, conditional menu panel, and close-on-navigate
|
|
30
|
+
For queries and mutations, follow the **`salesforce-data-access`** skill. It covers schema exploration, query patterns, codegen, type generation, and guardrails.
|
|
142
31
|
|
|
143
|
-
|
|
32
|
+
### UI API (Fallback)
|
|
144
33
|
|
|
145
|
-
|
|
146
|
-
- [ ] Uses shadcn/ui and Tailwind
|
|
147
|
-
- [ ] Icons from **lucide-react** only; no emojis anywhere in UI or user-facing text
|
|
148
|
-
- [ ] UI changes made by editing .tsx source files (never by pasting raw HTML)
|
|
149
|
-
- [ ] If mobile hamburger exists: it has toggle state, conditional menu panel, and close on link click
|
|
150
|
-
- [ ] All routing imports from same package as router (e.g. `react-router` only)
|
|
151
|
-
- [ ] DataSDK used for all Salesforce API calls
|
|
152
|
-
- [ ] Proper error handling with try/catch
|
|
153
|
-
- [ ] Loading and error states implemented
|
|
154
|
-
- [ ] No hardcoded credentials or IDs
|
|
34
|
+
When GraphQL cannot cover the use case, use `sdk.fetch!(/services/data/v62.0/ui-api/records/<recordId>)` for UI API endpoints:
|
|
@@ -6,10 +6,7 @@ paths:
|
|
|
6
6
|
|
|
7
7
|
# Skills-First Protocol (MUST FOLLOW)
|
|
8
8
|
|
|
9
|
-
**Before
|
|
10
|
-
|
|
11
|
-
## Core Directive
|
|
12
|
-
Before planning, executing a task, generating code, or running terminal commands, you MUST explicitly check if an existing Skill is available to handle the request. Do not default to manual implementation if a specialized domain Skill exists.
|
|
9
|
+
**Before planning, executing any task, generating code, or running terminal commands**, you MUST explicitly check if an existing Skill is available to handle the request. Do not default to manual implementation if a specialized domain Skill exists.
|
|
13
10
|
|
|
14
11
|
## Pre-Task Sequence
|
|
15
12
|
1. **Skill Discovery:** Review the names and descriptions of all available/loaded Skills in your current context.
|
package/dist/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.106.2](https://github.com/salesforce-experience-platform-emu/webapps/compare/v1.106.1...v1.106.2) (2026-03-17)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* attempt to make rules more concise ([#298](https://github.com/salesforce-experience-platform-emu/webapps/issues/298)) ([69b3dab](https://github.com/salesforce-experience-platform-emu/webapps/commit/69b3dab574caf140e549ef092fa8b8ac1819afd8))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [1.106.1](https://github.com/salesforce-experience-platform-emu/webapps/compare/v1.106.0...v1.106.1) (2026-03-17)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Reverts
|
|
21
|
+
|
|
22
|
+
* Revert "chore: rename salesforce-* skills to verb-based names without prefix" ([79d439a](https://github.com/salesforce-experience-platform-emu/webapps/commit/79d439a8f1b8000568b7d16c3ad586025b790397))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
# [1.106.0](https://github.com/salesforce-experience-platform-emu/webapps/compare/v1.105.1...v1.106.0) (2026-03-17)
|
|
7
29
|
|
|
8
30
|
|
package/dist/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/webapp-template-feature-react-file-upload-experimental",
|
|
3
|
-
"version": "1.106.
|
|
3
|
+
"version": "1.106.2",
|
|
4
4
|
"description": "File upload feature with a component to upload files to core",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"author": "",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@salesforce/webapp-experimental": "^1.106.
|
|
44
|
+
"@salesforce/webapp-experimental": "^1.106.2",
|
|
45
45
|
"@types/react": "^19.2.7",
|
|
46
46
|
"@types/react-dom": "^19.2.3",
|
|
47
47
|
"nodemon": "^3.1.0",
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: CLI command generation rules — no node -e one-liners; safe quoting and scripts
|
|
3
|
-
paths:
|
|
4
|
-
- "**/webapplications/**/*"
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# A4D Enforcement: CLI Command Generation & No `node -e` One-Liners
|
|
8
|
-
|
|
9
|
-
When **generating any CLI/shell commands** (for the user or for automation), follow the rules below. Default shell is **Zsh** (macOS); commands must work there without Bash-only syntax.
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
## 1. Never Use Complex `node -e` One-Liners
|
|
14
|
-
|
|
15
|
-
**Forbidden:** `node -e` (or `node -p`, `node --eval`) for file manipulation, string replacement, reading/writing configs, or multi-line logic.
|
|
16
|
-
|
|
17
|
-
**Why:** In Zsh, `node -e '...'` **silently breaks** due to:
|
|
18
|
-
- **`!` (history expansion):** Zsh expands `!` in double-quoted strings → `event not found` or wrong output.
|
|
19
|
-
- **Backticks:** `` ` `` is command substitution; the shell runs it before Node sees the string.
|
|
20
|
-
- **Nested quoting:** Escaping differs between Bash and Zsh; multi-line JS in one string is fragile.
|
|
21
|
-
|
|
22
|
-
**Allowed:** Trivial one-line only if it has **no** backticks, no `!`, no nested quotes, no multi-line, no `fs` usage. Example: `node -e "console.log(1+1)"`. If in doubt, **use a script file**.
|
|
23
|
-
|
|
24
|
-
---
|
|
25
|
-
|
|
26
|
-
## 2. How To Generate CLI Commands Correctly
|
|
27
|
-
|
|
28
|
-
### Run Node scripts by path, not inline code
|
|
29
|
-
|
|
30
|
-
- **Do:** `node scripts/setup-cli.mjs --target-org myorg`
|
|
31
|
-
- **Do:** `node path/to/script.mjs arg1 arg2`
|
|
32
|
-
- **Do not:** `node -e "require('fs').writeFileSync(...)"` or any non-trivial inline JS.
|
|
33
|
-
|
|
34
|
-
### For file edits or transforms
|
|
35
|
-
|
|
36
|
-
1. **Prefer IDE/agent file tools** (StrReplace, Write, etc.) — they avoid the shell.
|
|
37
|
-
2. **Otherwise:** write a **temporary `.js` or `.mjs` file**, run it, then remove it. Use a **heredoc with quoted delimiter** so the shell does not interpret `$`, `` ` ``, or `!`:
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
cat > /tmp/_transform.js << 'SCRIPT'
|
|
41
|
-
const fs = require('fs');
|
|
42
|
-
const data = JSON.parse(fs.readFileSync('package.json', 'utf8'));
|
|
43
|
-
data.name = 'my-app';
|
|
44
|
-
fs.writeFileSync('package.json', JSON.stringify(data, null, 2) + '\n');
|
|
45
|
-
SCRIPT
|
|
46
|
-
node /tmp/_transform.js && rm /tmp/_transform.js
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
3. **Simple replacements:** `sed -i '' 's/old/new/g' path/to/file` (macOS: `-i ''`).
|
|
50
|
-
4. **JSON:** `jq '.name = "my-app"' package.json > tmp.json && mv tmp.json package.json`.
|
|
51
|
-
|
|
52
|
-
### Quoting and shell safety
|
|
53
|
-
|
|
54
|
-
- Use **single quotes** around the outer shell string when the inner content has `$`, `` ` ``, or `!`.
|
|
55
|
-
- For heredocs that must be literal, use **`<< 'END'`** (quoted delimiter) so the body is not expanded.
|
|
56
|
-
- **Do not** generate commands that rely on Bash-only features (e.g. `[[ ]]` is fine in Zsh; avoid `source` vs `.` if you need POSIX).
|
|
57
|
-
|
|
58
|
-
### Paths and working directory
|
|
59
|
-
|
|
60
|
-
- **State where to run from** when it matters, e.g. "From project root" or "From `force-app/main/default/webapplications/<appName>`".
|
|
61
|
-
- Prefer **explicit paths** or `cd <dir> && ...` so the command is copy-paste safe.
|
|
62
|
-
- This project: setup is `node scripts/setup-cli.mjs --target-org <alias>` from **project root**. Web app commands (`npm run dev`, `npm run build`, `npm run lint`) run from the **web app directory** (e.g. `force-app/main/default/webapplications/<appName>` or `**/webapplications/<appName>`).
|
|
63
|
-
|
|
64
|
-
### npm / npx
|
|
65
|
-
|
|
66
|
-
- Use **exact package names** (e.g. `npx @salesforce/webapps-features-experimental list`).
|
|
67
|
-
- For app-specific scripts, **cd to the web app directory first**, then run `npm run <script>` or `npm install ...`.
|
|
68
|
-
- Chain steps with `&&`; one logical command per line is clearer than one giant line.
|
|
69
|
-
|
|
70
|
-
### Summary checklist when generating a command
|
|
71
|
-
|
|
72
|
-
- [ ] No `node -e` / `node -p` / `node --eval` with complex or multi-line code.
|
|
73
|
-
- [ ] If Node logic is needed, use `node path/to/script.mjs` or a temp script with heredoc `<< 'SCRIPT'`.
|
|
74
|
-
- [ ] No unescaped `!`, `` ` ``, or `$` in double-quoted strings in Zsh.
|
|
75
|
-
- [ ] Working directory and required args (e.g. `--target-org`) are clear.
|
|
76
|
-
- [ ] Prefer file-editing tools over shell one-liners when editing project files.
|
|
77
|
-
|
|
78
|
-
---
|
|
79
|
-
|
|
80
|
-
## 3. Violation Handling
|
|
81
|
-
|
|
82
|
-
- If a generated command used a complex `node -e` one-liner, **revert and redo** using a script file, `sed`/`jq`, or IDE file tools.
|
|
83
|
-
- If the user sees `event not found`, `unexpected token`, or garbled output, **check for**:
|
|
84
|
-
- `node -e` with special characters,
|
|
85
|
-
- Double-quoted strings containing `!` or backticks,
|
|
86
|
-
- Wrong working directory or missing args.
|
|
87
|
-
|
|
88
|
-
**Cross-reference:** **webapp.md** (MUST FOLLOW #1) summarizes the no–`node -e` rule; this file is the full reference for CLI command generation and alternatives.
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Code quality and build validation standards
|
|
3
|
-
paths:
|
|
4
|
-
- "**/webapplications/**/*"
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Code Quality & Build Validation
|
|
8
|
-
|
|
9
|
-
Enforces ESLint, TypeScript, and build validation for consistent, maintainable code.
|
|
10
|
-
|
|
11
|
-
## MANDATORY Quality Gates
|
|
12
|
-
|
|
13
|
-
**Before completing any coding session** (from the web app directory `force-app/main/default/webapplications/<appName>/`):
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
npm run lint # MUST result in 0 errors
|
|
17
|
-
npm run build # MUST succeed (includes TypeScript check)
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## Requirements
|
|
21
|
-
|
|
22
|
-
**Must Pass:**
|
|
23
|
-
- `npm run build` completes successfully
|
|
24
|
-
- No TypeScript compilation errors
|
|
25
|
-
- No critical ESLint errors (0 errors)
|
|
26
|
-
|
|
27
|
-
**Can Be Warnings:**
|
|
28
|
-
- ESLint warnings (fix when convenient)
|
|
29
|
-
- Minor TypeScript warnings
|
|
30
|
-
|
|
31
|
-
## Key Commands
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
npm run dev # Start development server (vite)
|
|
35
|
-
npm run lint # Run ESLint
|
|
36
|
-
npm run build # TypeScript + Vite build; check deployment readiness
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## Error Priority
|
|
40
|
-
|
|
41
|
-
**Fix Immediately:**
|
|
42
|
-
- TypeScript compilation errors
|
|
43
|
-
- Import/export errors
|
|
44
|
-
- Syntax errors
|
|
45
|
-
|
|
46
|
-
**Fix When Convenient:**
|
|
47
|
-
- ESLint warnings
|
|
48
|
-
- Unused variables
|
|
49
|
-
|
|
50
|
-
## Import Order (MANDATORY)
|
|
51
|
-
|
|
52
|
-
```typescript
|
|
53
|
-
// 1. React ecosystem
|
|
54
|
-
import { useState, useEffect } from 'react';
|
|
55
|
-
|
|
56
|
-
// 2. External libraries (alphabetical)
|
|
57
|
-
import clsx from 'clsx';
|
|
58
|
-
|
|
59
|
-
// 3. UI components (alphabetical)
|
|
60
|
-
import { Button } from '@/components/ui/button';
|
|
61
|
-
import { Card } from '@/components/ui/card';
|
|
62
|
-
|
|
63
|
-
// 4. Internal utilities (alphabetical)
|
|
64
|
-
import { useAuth } from '../hooks/useAuth';
|
|
65
|
-
import { formatDate } from '../utils/dateUtils';
|
|
66
|
-
|
|
67
|
-
// 5. Relative imports
|
|
68
|
-
import { ComponentA } from './ComponentA';
|
|
69
|
-
|
|
70
|
-
// 6. Type imports (separate, at end)
|
|
71
|
-
import type { User, ApiResponse } from '../types';
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
## Naming Conventions
|
|
75
|
-
|
|
76
|
-
```typescript
|
|
77
|
-
// PascalCase: Components, classes
|
|
78
|
-
const UserProfile = () => {};
|
|
79
|
-
|
|
80
|
-
// camelCase: Variables, functions, properties
|
|
81
|
-
const userName = 'john';
|
|
82
|
-
const fetchUserData = async () => {};
|
|
83
|
-
|
|
84
|
-
// SCREAMING_SNAKE_CASE: Constants
|
|
85
|
-
const API_BASE_URL = 'https://api.example.com';
|
|
86
|
-
|
|
87
|
-
// kebab-case: Files
|
|
88
|
-
// user-profile.tsx, api-client.ts
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
## React Component Structure
|
|
92
|
-
|
|
93
|
-
```typescript
|
|
94
|
-
interface ComponentProps {
|
|
95
|
-
// Props interface first
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const Component: React.FC<ComponentProps> = ({ prop1, prop2 }) => {
|
|
99
|
-
// 1. Hooks
|
|
100
|
-
// 2. Computed values
|
|
101
|
-
// 3. Event handlers
|
|
102
|
-
// 4. JSX return
|
|
103
|
-
|
|
104
|
-
return <div />;
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
export default Component;
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
## Anti-Patterns (FORBIDDEN)
|
|
111
|
-
|
|
112
|
-
```typescript
|
|
113
|
-
// NEVER disable ESLint without justification
|
|
114
|
-
// eslint-disable-next-line
|
|
115
|
-
|
|
116
|
-
// NEVER mutate state directly
|
|
117
|
-
state.items.push(newItem); // Wrong
|
|
118
|
-
setItems(prev => [...prev, newItem]); // Correct
|
|
119
|
-
|
|
120
|
-
// NEVER use magic numbers/strings
|
|
121
|
-
setTimeout(() => {}, 5000); // Wrong
|
|
122
|
-
const DEBOUNCE_DELAY = 5000; // Correct
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
## Troubleshooting
|
|
126
|
-
|
|
127
|
-
**Import Errors:**
|
|
128
|
-
```bash
|
|
129
|
-
npm install # Check missing dependencies
|
|
130
|
-
# Verify: file exists, case sensitivity, export/import match
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
**Build Failures:**
|
|
134
|
-
1. Run `npm run lint` to identify issues
|
|
135
|
-
2. Fix TypeScript/ESLint errors
|
|
136
|
-
3. Retry `npm run build`
|
|
File without changes
|