Loading...
Loading...
Use when writing any code - enforces clean architecture with descriptive names, real implementations, no backward compatibility concerns, and no lint suppressions
npx skill4agent add yuann3/skills code-quality-standardsconst id = getUserId();
const val = calculateTotal();
const tmp = data.filter(x => x.active);
const i = items[0];
const user1 = getUser();
const data2 = processData();
const result3 = calculate();const currentUserId = getUserId();
const orderTotal = calculateTotal();
const activeCustomers = data.filter(customer => customer.active);
const firstItem = items[0];
const primaryUser = getUser();
const processedCustomerData = processData();
const finalCalculationResult = calculate();urliduser1data2temp3function processOrder(order: Order) {
// TODO: Implement validation
// Validate order here
/* Implementation goes here */
return true;
}
const handleSubmit = () => {
// To be implemented
};function processOrder(order: Order): ProcessedOrder {
if (!order.items || order.items.length === 0) {
throw new Error('Order must contain at least one item');
}
if (order.total <= 0) {
throw new Error('Order total must be greater than zero');
}
const validatedOrder = {
...order,
validatedAt: new Date(),
status: 'validated',
};
return validatedOrder;
}
const handleSubmit = async (formData: FormData) => {
const validatedData = validateFormData(formData);
await saveToDatabase(validatedData);
navigateToSuccessPage();
};// Keep old function for backward compatibility
function getUser(id: string) {
return getUserById(id);
}
function getUserById(userId: string) {
// New implementation
}
// Support both old and new parameter names
function createOrder(params: { id?: string; orderId?: string }) {
const actualOrderId = params.orderId || params.id;
}// Just use the better name
function getUserById(userId: string) {
// Implementation
}
function createOrder(orderId: string) {
// Implementation
}// eslint-disable-next-line @typescript-eslint/no-explicit-any
function process(data: any) {
return data;
}
// biome-ignore lint/suspicious/noExplicitAny: legacy code
function processLegacy(data: any) {
return data;
}
// @ts-ignore
const result = unsafeOperation();
/* eslint-disable */
function legacyCode() {
// Bad code here
}
/* eslint-enable */function processUserData(userData: UserData): ProcessedUserData {
return {
userId: userData.id,
userName: userData.name,
processedAt: new Date(),
};
}
function performSafeOperation(): OperationResult {
const validatedInput = validateInput();
return executeOperation(validatedInput);
}
function modernImplementation(customer: Customer): Invoice {
const invoiceItems = customer.orders.map(createInvoiceItem);
return generateInvoice(invoiceItems);
}any@ts-ignoreeslint-disable@ts-ignorebiome-ignore// Code that has type errors
function processData(data) { // Missing type annotation
return data.map(item => item.value); // No type safety
}
// Code that fails Biome checks
const unused = 'variable'; // Unused variable
let x = 1; x = 2; // Unnecessary let when const would work
// Committing without running checks
// git commit -m "quick fix"// Code with proper types
interface DataItem {
value: string;
}
function processData(data: DataItem[]): string[] {
return data.map(item => item.value);
}
// Clean code that passes all checks
const processedResults = calculateResults();
const finalValue = processedResults.total;
// Always verify before committing
// npm run typecheck ✓
// npm run biome:check ✓tsc --noEmitany# TypeScript type check
npm run typecheck
# or
tsc --noEmit
# Biome check (lint + format)
npx biome check .
# or
npm run biome:checkif (user.role === 'admin') { }
const timeout = 5000;
const apiUrl = 'https://api.example.com';
const maxRetries = 3;const USER_ROLE_ADMIN = 'admin';
const REQUEST_TIMEOUT_MILLISECONDS = 5000;
const API_BASE_URL = process.env.API_BASE_URL;
const MAXIMUM_RETRY_ATTEMPTS = 3;
if (user.role === USER_ROLE_ADMIN) { }// Bad
const d = new Date();
const arr = getData();
const temp = process(data);
const user1 = getUser();
const item2 = getItem();
// Good
const currentTimestamp = new Date();
const userAccounts = getData();
const processedCustomerData = process(data);
const primaryUser = getUser();
const secondaryItem = getItem();// Bad
function get() { }
function process() { }
function handle() { }
// Good
function getUserById(userId: string) { }
function processPaymentTransaction(transaction: Transaction) { }
function handleFormSubmission(formData: FormData) { }// Bad
const max = 100;
const url = 'https://...';
// Good
const MAXIMUM_UPLOAD_SIZE_BYTES = 100;
const PAYMENT_GATEWAY_API_URL = process.env.PAYMENT_GATEWAY_API_URL;// Bad
interface Props { }
type Data = { };
// Good
interface UserProfileComponentProps { }
type CustomerOrderData = { };user1data2temp3eslint-disable@ts-ignorebiome-ignoreanydatavalueitemtemp| Excuse | Reality |
|---|---|
| "Long names are verbose" | Descriptive names prevent bugs |
| "We'll implement this later" | Write complete code now or don't write it |
| "Need backward compatibility" | Clean breaks are better than tech debt |
| "Just this one lint suppression" | Fix the code, don't suppress the warning |
| "Everyone knows what this magic number means" | They don't - use a named constant |
| "It's just a temporary variable" | Temporary doesn't mean unclear |
| "I'll run the checks later" | Run checks before committing, always |
| "TypeScript is too strict" | Strict types prevent runtime errors |
user1data2eslint-disable@ts-ignorebiome-ignoretsc --noEmitnpm run typechecknpx biome check .npm run biome:checkanyfunction getData(id: string) {
// TODO: Add validation
const url = 'https://api.example.com/users';
// @ts-ignore
const res = fetch(`${url}/${id}`);
return res;
}
const val = getData('123');
const x = val.map(i => i.name);const USER_API_BASE_URL = process.env.USER_API_BASE_URL;
interface UserApiResponse {
userId: string;
userName: string;
userEmail: string;
}
async function fetchUserById(userId: string): Promise<UserApiResponse> {
if (!userId || userId.trim().length === 0) {
throw new Error('User ID is required and cannot be empty');
}
const response = await fetch(`${USER_API_BASE_URL}/users/${userId}`);
if (!response.ok) {
throw new Error(`Failed to fetch user: ${response.statusText}`);
}
const userData = await response.json();
return userData;
}
const userResponse = await fetchUserById('123');
const userNames = userResponse.map(user => user.userName);tsc --noEmitnpx biome check .tsc --noEmitnpx biome check .Every line of code must be:
1. Clearly named with verbose, descriptive identifiers
2. Fully implemented with no placeholders
3. Breaking changes are fine - no backward compatibility
4. Passing all linters without suppressions
5. Free of hardcoded values
6. Pass TypeScript type checks
7. Pass Biome checks (lint + format)# 1. TypeScript type check
npm run typecheck
# or
tsc --noEmit
# 2. Biome check (lint + format)
npx biome check .
# or
npm run biome:check
# 3. If any errors, FIX them - never suppress or skip