@sun-asterisk/sunlint
Version:
☀️ SunLint - Multi-language static analysis tool for code quality and security | Sun* Engineering Standards
65 lines (64 loc) • 2.07 kB
JSON
{
"ruleId": "C020",
"name": "Unused Imports",
"description": "Không import các module hoặc symbol không sử dụng",
"category": "code-quality",
"severity": "warning",
"languages": ["typescript", "javascript"],
"version": "1.0.0",
"status": "stable",
"tags": ["imports", "cleanup", "unused-code"],
"config": {
"checkDefaultImports": true,
"checkNamedImports": true,
"checkNamespaceImports": true,
"ignoreTypeImports": false,
"allowedUnusedPatterns": [
"^_"
]
},
"examples": {
"violations": [
{
"language": "typescript",
"code": "import { Order } from './models/Order';\n\n// Order is never used",
"reason": "Imported 'Order' but never used in the code"
},
{
"language": "typescript",
"code": "import fs from 'fs';\nimport path from 'path';\n\n// Only path is used\nconsole.log(path.join('a', 'b'));",
"reason": "Imported 'fs' but never used"
},
{
"language": "typescript",
"code": "import * as utils from './utils';\n\n// utils namespace is never used",
"reason": "Imported namespace 'utils' but never used"
}
],
"valid": [
{
"language": "typescript",
"code": "import { User } from './models/User';\n\nconst user = new User();",
"reason": "User is imported and used"
},
{
"language": "typescript",
"code": "import type { Order } from './types';\n\nconst order: Order = { id: 1 };",
"reason": "Type import is used in type annotation"
},
{
"language": "typescript",
"code": "import { _debugHelper } from './utils';\n\n// Allowed: starts with underscore",
"reason": "Import starting with _ is allowed as intentionally unused"
}
]
},
"fixes": {
"autoFixable": true,
"suggestions": [
"Remove unused imports to keep code clean",
"Use IDE auto-import features to avoid manual imports",
"Prefix intentionally unused imports with underscore (_)"
]
}
}