Instruction file imported from miiitch/azurepricing.mcp (
.github/instructions/base-typescript.instructions.md). Copyright stays with the author.
Base TypeScript Rules
Note: These base rules apply to all TypeScript files. More specific rules may override these for certain file types.
ESLint Configuration
{
'@typescript-eslint/no-unused-vars': 'error', // Unused params must start with _
'@typescript-eslint/no-explicit-any': 'warn', // Prefer specific types
'@typescript-eslint/no-floating-promises': 'error', // Always await or handle promises
'no-console': 'warn', // Use console.log/warn/error only
'prefer-const': 'error', // Use const when not reassigning
'no-var': 'error' // Never use var
}
Quick Fixes
| Issue | Fix |
|---|---|
| Unused parameter | Prefix with _: (_config) => ... |
| Floating promise | Add await or .catch() |
| Wrong console method | Use console.log/warn/error |
| var keyword | Change to const or let |
| Missing const | Change let to const if not reassigned |
Code Patterns
Unused Parameters
// ✅ CORRECT
extractSku: (_config) => 'Standard'
// ❌ WRONG - ESLint error
extractSku: (config) => 'Standard'
Promise Handling
// ✅ CORRECT
await fetchPrices(filter);
fetchPrices(filter).catch(console.error);
// ❌ WRONG - Floating promise
fetchPrices(filter);
Type Safety
// ✅ CORRECT
function getPrices(): Promise<PriceItem[]>
// ⚠️ WARNING - Avoid when possible
function getPrices(): Promise<any>
Immutability
// ✅ CORRECT
const baseUrl = 'https://api.azure.com';
let retryCount = 0; // OK - will be reassigned
// ❌ WRONG
var oldStyle = 'bad';
Error Context
Always include context in errors:
// ✅ GOOD
throw new Error(`Failed to fetch ${serviceName} in ${region}: ${error.message}`);
// ❌ BAD
throw new Error('Failed');