Utilizing TypeScript for Edge Computing Applications
Learn how to develop and deploy TypeScript applications optimized for edge computing environments.
0 likes
182 views
Rule Content
{
"title": "Utilizing TypeScript for Edge Computing Applications",
"description": "Develop and deploy TypeScript applications optimized for edge computing environments.",
"category": "TypeScript Cursor Rules",
"rules": [
{
"name": "strict-type-checking",
"description": "Enable strict type checking to ensure type safety and prevent runtime errors.",
"applyTo": "tsconfig.json",
"settings": {
"compilerOptions": {
"strict": true,
"strictNullChecks": true,
"noImplicitAny": true,
"noImplicitThis": true,
"alwaysStrict": true
}
}
},
{
"name": "avoid-any-type",
"description": "Prohibit the use of the 'any' type to maintain type safety.",
"applyTo": "src/**/*.ts",
"prohibitedPatterns": ["any"]
},
{
"name": "use-interfaces",
"description": "Define clear interfaces for data structures to enhance code readability and maintainability.",
"applyTo": "src/**/*.ts",
"enforcePatterns": [
{
"pattern": "interface [A-Za-z0-9]+ {",
"message": "Define interfaces for data structures."
}
]
},
{
"name": "modular-code-structure",
"description": "Organize code into small, reusable modules to improve maintainability and scalability.",
"applyTo": "src/**/*.ts",
"enforcePatterns": [
{
"pattern": "export (const|function|class) [A-Za-z0-9]+",
"message": "Ensure modules export reusable components."
}
]
},
{
"name": "error-handling",
"description": "Implement proper error handling using try-catch blocks to enhance application reliability.",
"applyTo": "src/**/*.ts",
"enforcePatterns": [
{
"pattern": "try {",
"message": "Use try-catch blocks for error handling."
}
]
},
{
"name": "code-formatting",
"description": "Enforce consistent code formatting using Prettier to maintain code readability.",
"applyTo": "src/**/*.ts",
"settings": {
"prettier": {
"semi": true,
"singleQuote": true,
"trailingComma": "all",
"tabWidth": 2
}
}
},
{
"name": "naming-conventions",
"description": "Follow consistent naming conventions: camelCase for variables and functions, PascalCase for classes and interfaces.",
"applyTo": "src/**/*.ts",
"enforcePatterns": [
{
"pattern": "const [a-z][A-Za-z0-9]* =",
"message": "Use camelCase for variable names."
},
{
"pattern": "function [a-z][A-Za-z0-9]*\\(",
"message": "Use camelCase for function names."
},
{
"pattern": "class [A-Z][A-Za-z0-9]*",
"message": "Use PascalCase for class names."
},
{
"pattern": "interface [A-Z][A-Za-z0-9]*",
"message": "Use PascalCase for interface names."
}
]
},
{
"name": "async-await",
"description": "Prefer async/await syntax over Promises for asynchronous operations to improve code readability.",
"applyTo": "src/**/*.ts",
"enforcePatterns": [
{
"pattern": "async function [A-Za-z0-9]+\\(",
"message": "Use async functions for asynchronous operations."
},
{
"pattern": "await [A-Za-z0-9]+\\(",
"message": "Use await for handling Promises."
}
]
},
{
"name": "logging",
"description": "Implement structured logging to facilitate debugging and monitoring.",
"applyTo": "src/**/*.ts",
"enforcePatterns": [
{
"pattern": "console\\.(log|error|warn|info)\\(",
"message": "Use console methods for logging."
}
]
},
{
"name": "documentation",
"description": "Provide JSDoc comments for all functions and classes to enhance code maintainability.",
"applyTo": "src/**/*.ts",
"enforcePatterns": [
{
"pattern": "/\\*\\*\\s*\\n\\s*\\* [A-Za-z0-9 ]+\\n\\s*\\*/\\n\\s*(export )?(const|function|class) [A-Za-z0-9]+",
"message": "Ensure functions and classes have JSDoc comments."
}
]
}
]
}