Loading...
Loading...
Next Friday code style rules for formatting, structure, and readability. Use when writing functions, conditionals, or organizing code.
npx skill4agent add next-friday/nextfriday-skills nextfriday-code-style// Bad:
function processData(data: Data | null): Item[] {
if (data) {
if (data.items) {
return data.items.map(formatItem);
}
}
return [];
}
// Good:
function processData(data: Data | null): Item[] {
if (!data) return [];
if (!data.items) return [];
return data.items.map(formatItem);
}// Bad:
const status = isLoading ? "loading" : hasError ? "error" : "success";
// Good:
function getStatus(): string {
if (isLoading) return "loading";
if (hasError) return "error";
return "success";
}.then()// Bad:
fetchData(url)
.then((response) => response.json())
.then((data) => setData(data));
// Good:
async function loadData(): Promise<void> {
const response = await fetchData(url);
const data = await response.json();
setData(data);
}.ts// Bad:
const formatDate = (date: Date): string => {
return date.toLocaleDateString();
};
// Good:
function formatDate(date: Date): string {
return date.toLocaleDateString();
}// Bad:
export function fetchData() {}
// Good:
function fetchData() {}
export { fetchData };// Bad:
if (!data) { return null; }
// Good:
if (!data) return null;// Bad:
return isActive ? "Active" : "Inactive";
processData(value ?? defaultValue);
// Good:
const label = isActive ? "Active" : "Inactive";
return label;
const data = value ?? defaultValue;
processData(data);// Good:
const config = {
baseUrl: process.env.API_URL,
timeout: 5000,
};
const item = items.find((item) => item.id === id);
return item;// Good:
const { count = 0, status = "active", id, name } = data;