Enforces strict code quality standards using Ultracite (Biome preset) for TypeScript/React projects with emphasis on type safety, accessibility, and modern patterns.
This skill has safety concerns that you should review before use. Some patterns were detected that may pose a risk.Safety score: 75/100.
KillerSkills scans all public content for safety. Use caution before installing or executing flagged content.
This skill enforces strict code quality standards using **Ultracite**, a zero-config Biome preset. It provides comprehensive guidelines for writing accessible, performant, type-safe, and maintainable TypeScript and React code.
Ultracite leverages Biome's Rust-based engine for extremely fast linting and formatting. Most issues are automatically fixable, allowing you to focus on higher-level code quality concerns.
When working with Ultracite in a project:
Follow these principles when writing or reviewing code:
**Example:**
```typescript
// Good - explicit types and named constants
const MAX_RETRIES = 3;
function fetchData(url: string): Promise<Response> {
return fetch(url);
}
// Avoid - magic numbers and implicit types
function fetchData(url) {
if (retries > 3) return;
return fetch(url);
}
```
**Example:**
```typescript
// Good - modern patterns
const userName = user?.profile?.name ?? 'Anonymous';
for (const item of items) {
console.log(`Processing ${item.name}`);
}
// Avoid - old patterns
var userName = user && user.profile && user.profile.name || 'Anonymous';
items.forEach((item, i) => {
console.log('Processing ' + items[i].name);
});
```
**Example:**
```typescript
// Good - proper async/await with error handling
async function loadUserData(id: string) {
try {
const response = await fetch(`/api/users/${id}`);
const data = await response.json();
return data;
} catch (error) {
console.error('Failed to load user:', error);
throw error;
}
}
// Avoid - unhandled promises and chains
function loadUserData(id: string) {
fetch(`/api/users/${id}`)
.then(response => response.json());
}
```
**Example:**
```typescript
// Good - proper React patterns
function UserList({ users }: { users: User[] }) {
const [filter, setFilter] = useState('');
const filteredUsers = useMemo(
() => users.filter(u => u.name.includes(filter)),
[users, filter]
);
return (
<ul>
{filteredUsers.map(user => (
<li key={user.id}>{user.name}</li>
))}
</ul>
);
}
// Avoid - defining components inside, missing dependencies
function UserList({ users }) {
const [filter, setFilter] = useState('');
const filteredUsers = useMemo(
() => users.filter(u => u.name.includes(filter)),
[users] // Missing 'filter' dependency
);
function UserItem({ user }) { // Don't define components inside
return <li>{user.name}</li>;
}
return <ul>{filteredUsers.map((user, i) => <UserItem key={i} user={user} />)}</ul>;
}
```
Use semantic HTML and ARIA attributes for accessible interfaces:
**Example:**
```typescript
// Good - accessible form
<form>
<label htmlFor="email">Email address</label>
<input id="email" type="email" required />
<button type="submit">Submit</button>
</form>
// Avoid - inaccessible form
<div>
<input type="email" placeholder="Email" />
<div onClick={handleSubmit}>Submit</div>
</div>
```
**Example:**
```typescript
// Good - proper error handling with early returns
function processOrder(order: Order): ProcessedOrder {
if (!order.items.length) {
throw new Error('Order must contain at least one item');
}
if (!order.customerId) {
throw new Error('Order must have a customer ID');
}
return {
id: order.id,
total: calculateTotal(order.items)
};
}
// Avoid - nested conditionals and string errors
function processOrder(order) {
if (order.items.length > 0) {
if (order.customerId) {
return {
id: order.id,
total: calculateTotal(order.items)
};
} else {
throw 'No customer ID';
}
} else {
throw 'No items';
}
}
```
**Example:**
```typescript
// Good - clear, focused function with early returns
function canUserEditPost(user: User, post: Post): boolean {
if (!user) return false;
const isAuthor = post.authorId === user.id;
const isAdmin = user.role === 'admin';
const isWithinEditWindow = Date.now() - post.createdAt < 3600000;
return isAuthor && isWithinEditWindow || isAdmin;
}
// Avoid - nested conditionals
function canUserEditPost(user, post) {
if (user) {
if (post.authorId === user.id) {
if (Date.now() - post.createdAt < 3600000) {
return true;
}
} else if (user.role === 'admin') {
return true;
}
}
return false;
}
```
**Example:**
```typescript
// Good - secure external link
<a href="https://example.com" target="_blank" rel="noopener noreferrer">
External Link
</a>
// Avoid - security risk
<a href="https://example.com" target="_blank">External Link</a>
```
**Example:**
```typescript
// Good - efficient accumulation
const result = items.reduce((acc, item) => {
acc.push(item.value);
return acc;
}, [] as string[]);
// Avoid - inefficient spread in loop
const result = items.reduce((acc, item) => [...acc, item.value], []);
```
**Example:**
```typescript
// Good - clean async test
it('should fetch user data', async () => {
const data = await fetchUserData('123');
expect(data.name).toBe('John Doe');
});
// Avoid - done callback
it('should fetch user data', (done) => {
fetchUserData('123').then(data => {
expect(data.name).toBe('John Doe');
done();
});
});
```
Focus your manual review attention on:
1. **Business logic correctness** - Biome can't validate your algorithms
2. **Meaningful naming** - Use descriptive names for functions, variables, and types
3. **Architecture decisions** - Component structure, data flow, and API design
4. **Edge cases** - Handle boundary conditions and error states
5. **User experience** - Accessibility, performance, and usability considerations
6. **Documentation** - Add comments for complex logic, but prefer self-documenting code
Before committing code:
```bash
npx ultracite fix
npx ultracite check
```
Consider adding these as pre-commit hooks to ensure compliance automatically.
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/ultracite-code-standards-for-typescriptreact/raw