@sun-asterisk/sunlint 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +119 -384
- package/core/cli-action-handler.js +169 -4
- package/core/cli-program.js +20 -4
- package/core/config-manager.js +84 -5
- package/core/file-targeting-service.js +386 -0
- package/core/multi-rule-runner.js +9 -27
- package/core/output-service.js +5 -6
- package/docs/FILE_TARGETING_COMPARISON.md +0 -0
- package/examples/README.md +56 -34
- package/examples/basic-typescript-demo/.eslintrc.json +18 -0
- package/examples/basic-typescript-demo/.next/cache/eslint/.cache_1othrmo +1 -0
- package/examples/basic-typescript-demo/.sunlint.json +29 -0
- package/examples/basic-typescript-demo/eslint.config.mjs +37 -0
- package/examples/basic-typescript-demo/next-env.d.ts +5 -0
- package/examples/basic-typescript-demo/next.config.mjs +4 -0
- package/examples/basic-typescript-demo/package-lock.json +5656 -0
- package/examples/basic-typescript-demo/package.json +34 -0
- package/examples/basic-typescript-demo/src/app/layout.tsx +18 -0
- package/examples/basic-typescript-demo/src/app/page.tsx +48 -0
- package/examples/basic-typescript-demo/src/config.ts +14 -0
- package/examples/basic-typescript-demo/src/good-practices.ts +58 -0
- package/examples/basic-typescript-demo/src/types.generated.ts +13 -0
- package/examples/basic-typescript-demo/src/user.test.ts +19 -0
- package/examples/basic-typescript-demo/src/violations.ts +61 -0
- package/examples/basic-typescript-demo/test-config-priority.sh +0 -0
- package/examples/basic-typescript-demo/test-file-targeting.sh +0 -0
- package/examples/basic-typescript-demo/tsconfig.json +27 -0
- package/examples/enhanced-config.json +0 -0
- package/examples/eslint-integration-demo/.eslintrc.js +38 -0
- package/examples/eslint-integration-demo/.sunlint.json +42 -0
- package/examples/eslint-integration-demo/next-env.d.ts +5 -0
- package/examples/eslint-integration-demo/next.config.js +8 -0
- package/examples/eslint-integration-demo/package-lock.json +5740 -0
- package/examples/eslint-integration-demo/package.json +37 -0
- package/examples/eslint-integration-demo/src/api.test.ts +20 -0
- package/examples/eslint-integration-demo/src/conflict-test.tsx +44 -0
- package/examples/eslint-integration-demo/src/naming-conflicts.ts +50 -0
- package/examples/eslint-integration-demo/test-file-targeting.sh +0 -0
- package/examples/eslint-integration-demo/tsconfig.json +26 -0
- package/examples/file-targeting-demo/global.d.ts +11 -0
- package/examples/file-targeting-demo/jest.config.js +8 -0
- package/examples/file-targeting-demo/sample.ts +53 -0
- package/examples/file-targeting-demo/src/server.js +11 -0
- package/examples/file-targeting-demo/src/server.test.js +11 -0
- package/examples/file-targeting-demo/src/types.d.ts +4 -0
- package/examples/file-targeting-demo/src/types.generated.ts +10 -0
- package/examples/file-targeting-demo/user-service.test.ts +15 -0
- package/examples/file-targeting-demo/user-service.ts +13 -0
- package/examples/file-targeting-demo/utils.js +15 -0
- package/examples/multi-language-project/.eslintrc.json +38 -0
- package/examples/multi-language-project/package.json +37 -0
- package/examples/multi-language-project/src/sample.ts +39 -0
- package/examples/rule-test-fixtures/README.md +67 -0
- package/examples/rule-test-fixtures/rules/C006_function_naming/clean/typescript-clean.ts +64 -0
- package/examples/rule-test-fixtures/rules/C006_function_naming/violations/dart-violations.dart +56 -0
- package/examples/rule-test-fixtures/rules/C006_function_naming/violations/typescript-violations.ts +47 -0
- package/examples/rule-test-fixtures/rules/C019_log_level_usage/clean/typescript-clean.ts +93 -0
- package/examples/rule-test-fixtures/rules/C019_log_level_usage/violations/dart-violations.dart +75 -0
- package/examples/rule-test-fixtures/rules/C019_log_level_usage/violations/typescript-violations.ts +84 -0
- package/examples/rule-test-fixtures/rules/C029_catch_block_logging/clean/typescript-clean.ts +0 -0
- package/examples/rule-test-fixtures/rules/C029_catch_block_logging/violations/typescript-violations.ts +37 -0
- package/package.json +2 -1
- package/eslint-integration/eslint-plugin-custom/c076-one-assert-per-test.js +0 -184
- package/examples/.sunlint.json +0 -42
- package/examples/package.json +0 -33
- /package/{eslint-integration/node_modules/eslint-plugin-custom/package.json → docs/ENHANCED_FILE_TARGETING.md} +0 -0
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
## 🎯 **Overview**
|
|
6
6
|
|
|
7
|
-
Sun Lint is a universal coding standards checker
|
|
7
|
+
Sun Lint is a universal coding standards checker providing comprehensive code quality and security analysis. Built by Sun* Engineering Team with integrated security rules from OWASP and industry best practices.
|
|
8
8
|
|
|
9
9
|
### **✨ Key Features**
|
|
10
10
|
- ✅ **93+ Coding Rules**: Quality, security, and best practices
|
|
@@ -12,479 +12,214 @@ Sun Lint is a universal coding standards checker that provides comprehensive cod
|
|
|
12
12
|
- ✅ **Git Integration**: `--changed-files`, `--staged-files`, `--pr-mode`
|
|
13
13
|
- ✅ **TypeScript Support**: Native TypeScript analysis engine
|
|
14
14
|
- ✅ **CI/CD Ready**: Baseline comparison, fail-on-new-violations
|
|
15
|
-
- ✅ **
|
|
16
|
-
- ✅ **Team Adoption**: Zero-disruption integration for existing workflows
|
|
15
|
+
- ✅ **Advanced File Targeting**: Include/exclude patterns, language filtering
|
|
17
16
|
|
|
18
17
|
### **🚀 Quick Start**
|
|
19
|
-
- ✅ **Run single rule**: `sunlint --rule=C019`
|
|
20
|
-
- ✅ **Run multiple rules**: `sunlint --rules=C019,C006,C021`
|
|
21
|
-
- ✅ **Run all rules**: `sunlint --all` (93 rules total)
|
|
22
|
-
- ✅ **Run by category**: `sunlint --quality` or `sunlint --security`
|
|
23
|
-
- ✅ **ESLint integration**: `sunlint --all --eslint-integration`
|
|
24
|
-
- ✅ **Git workflow**: `sunlint --all --changed-files`
|
|
25
|
-
|
|
26
|
-
## 📦 **Installation**
|
|
27
|
-
|
|
28
|
-
### **Method 1: Global Installation (Recommended)**
|
|
29
18
|
```bash
|
|
30
|
-
# Install globally
|
|
19
|
+
# Install globally
|
|
31
20
|
npm install -g @sun-asterisk/sunlint
|
|
32
21
|
|
|
33
|
-
#
|
|
34
|
-
sunlint --
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
*✨ **Why Global?** SunLint supports multiple languages (TypeScript, Dart, Kotlin, Java, Swift, etc.). Global installation provides universal access across all project types.*
|
|
38
|
-
|
|
39
|
-
### **Method 2: TypeScript Project Integration**
|
|
40
|
-
For TypeScript-specific projects that prefer project-level dependencies:
|
|
41
|
-
```bash
|
|
42
|
-
# Add to TypeScript project dependencies
|
|
43
|
-
npm install --save-dev @sun-asterisk/sunlint
|
|
22
|
+
# Basic usage
|
|
23
|
+
sunlint --all --input=src
|
|
24
|
+
sunlint --rules=C019,C006 --input=src
|
|
25
|
+
sunlint --quality --input=src
|
|
44
26
|
|
|
45
|
-
#
|
|
46
|
-
|
|
47
|
-
```
|
|
27
|
+
# ESLint integration
|
|
28
|
+
sunlint --all --eslint-integration --input=src
|
|
48
29
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
{
|
|
52
|
-
"scripts": {
|
|
53
|
-
"lint": "sunlint --typescript --input=src",
|
|
54
|
-
"lint:changed": "sunlint --typescript --changed-files",
|
|
55
|
-
"lint:eslint-integration": "sunlint --typescript --eslint-integration --input=src"
|
|
56
|
-
},
|
|
57
|
-
"devDependencies": {
|
|
58
|
-
"@sun-asterisk/sunlint": "^1.0.5"
|
|
59
|
-
}
|
|
60
|
-
}
|
|
30
|
+
# Git integration
|
|
31
|
+
sunlint --all --changed-files
|
|
61
32
|
```
|
|
62
33
|
|
|
63
|
-
|
|
64
|
-
**Future Roadmap**: SunLint will expand to support:
|
|
65
|
-
- ✅ **TypeScript** (Phase 1 - Current)
|
|
66
|
-
- 🔄 **Dart** (Phase 2 - Planned)
|
|
67
|
-
- 🔄 **Kotlin** (Phase 3 - Planned)
|
|
68
|
-
- 🔄 **Java** (Phase 4 - Planned)
|
|
69
|
-
- 🔄 **Swift** (Phase 5 - Planned)
|
|
70
|
-
|
|
71
|
-
**Global installation ensures**:
|
|
72
|
-
- ✅ **Cross-project compatibility**: One tool for all languages
|
|
73
|
-
- ✅ **Team standardization**: Consistent tool across different project types
|
|
74
|
-
- ✅ **CI/CD simplicity**: Single installation for polyglot repositories
|
|
34
|
+
## 📦 **Installation**
|
|
75
35
|
|
|
76
|
-
### **
|
|
36
|
+
### **Global Installation (Recommended)**
|
|
77
37
|
```bash
|
|
78
|
-
# 1. Setup GitHub Package Registry (one-time)
|
|
79
|
-
curl -fsSL https://raw.githubusercontent.com/sun-asterisk/engineer-excellence/main/coding-quality/extensions/sunlint/scripts/setup-github-registry.sh | GITHUB_TOKEN=your_token bash
|
|
80
|
-
|
|
81
|
-
# 2. Install SunLint globally
|
|
82
38
|
npm install -g @sun-asterisk/sunlint
|
|
83
|
-
|
|
84
|
-
# 3. Verify installation
|
|
85
39
|
sunlint --version
|
|
86
40
|
```
|
|
87
41
|
|
|
88
|
-
**
|
|
89
|
-
```bash
|
|
90
|
-
# Configure GitHub Package Registry
|
|
91
|
-
echo "@sun-asterisk:registry=https://npm.pkg.github.com" >> ~/.npmrc
|
|
92
|
-
echo "//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}" >> ~/.npmrc
|
|
93
|
-
|
|
94
|
-
# Install from GitHub Packages globally
|
|
95
|
-
npm install -g @sun-asterisk/sunlint
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
### **Method 4: Direct GitHub Release**
|
|
42
|
+
### **Project Installation**
|
|
99
43
|
```bash
|
|
100
|
-
|
|
101
|
-
npm install -g https://github.com/sun-asterisk/engineer-excellence/releases/download/sunlint-v1.0.5/sunlint-1.0.5.tgz
|
|
102
|
-
|
|
103
|
-
# Verify installation
|
|
104
|
-
sunlint --version
|
|
105
|
-
```
|
|
44
|
+
npm install --save-dev @sun-asterisk/sunlint
|
|
106
45
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
46
|
+
# Package.json scripts
|
|
47
|
+
{
|
|
48
|
+
"scripts": {
|
|
49
|
+
"lint": "sunlint --all --input=src",
|
|
50
|
+
"lint:changed": "sunlint --all --changed-files"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
114
53
|
```
|
|
115
54
|
|
|
116
|
-
## 🔗 **ESLint Integration**
|
|
55
|
+
## 🔗 **ESLint Integration**
|
|
117
56
|
|
|
118
|
-
|
|
57
|
+
Seamlessly integrate with existing ESLint configurations:
|
|
119
58
|
|
|
120
|
-
### **For Teams with Existing ESLint**
|
|
121
59
|
```bash
|
|
122
60
|
# Analyze with both SunLint + existing ESLint rules
|
|
123
61
|
sunlint --all --eslint-integration --input=src
|
|
124
|
-
|
|
125
|
-
# Works with git integration too
|
|
126
|
-
sunlint --all --eslint-integration --changed-files
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
### **Configuration**
|
|
130
|
-
```json
|
|
131
|
-
{
|
|
132
|
-
"sunlint": {
|
|
133
|
-
"eslintIntegration": {
|
|
134
|
-
"enabled": true,
|
|
135
|
-
"mergeRules": true,
|
|
136
|
-
"preserveUserConfig": true
|
|
137
|
-
},
|
|
138
|
-
"rules": {
|
|
139
|
-
"C006": "warn",
|
|
140
|
-
"C019": "error"
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
62
|
```
|
|
145
63
|
|
|
146
|
-
|
|
64
|
+
Benefits:
|
|
147
65
|
- ✅ **No workflow disruption**: Existing ESLint continues working
|
|
148
66
|
- ✅ **Single command**: Execute 93 SunLint + your existing ESLint rules
|
|
149
|
-
- ✅ **Conflict resolution**: Your ESLint rules take precedence
|
|
150
67
|
- ✅ **Combined reporting**: Unified violation tracking
|
|
151
68
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
[📖 **Read Full ESLint Integration Guide**](./docs/ESLINT_INTEGRATION.md)
|
|
69
|
+
## 🔀 **Git Integration**
|
|
155
70
|
|
|
156
|
-
|
|
71
|
+
Optimize CI/CD workflows with Git integration:
|
|
157
72
|
|
|
158
|
-
SunLint provides powerful Git integration for optimized CI/CD workflows and development processes.
|
|
159
|
-
|
|
160
|
-
### **Basic Git Commands**
|
|
161
73
|
```bash
|
|
162
|
-
# Analyze only changed files
|
|
74
|
+
# Analyze only changed files
|
|
163
75
|
sunlint --all --changed-files
|
|
164
76
|
|
|
165
|
-
#
|
|
77
|
+
# Pre-commit validation
|
|
166
78
|
sunlint --all --staged-files
|
|
167
79
|
|
|
168
|
-
# PR mode with custom base branch
|
|
169
|
-
sunlint --all --changed-files --diff-base=origin/develop
|
|
170
|
-
|
|
171
|
-
# Files changed since specific commit
|
|
172
|
-
sunlint --all --since=abc123
|
|
173
|
-
|
|
174
80
|
# PR mode with failure only on new violations
|
|
175
81
|
sunlint --all --pr-mode --fail-on-new-violations
|
|
176
82
|
```
|
|
177
83
|
|
|
178
|
-
|
|
179
|
-
```bash
|
|
180
|
-
# GitHub Actions - PR check
|
|
181
|
-
sunlint --all --changed-files --diff-base=origin/main --format=summary
|
|
182
|
-
|
|
183
|
-
# Pre-commit hook
|
|
184
|
-
sunlint --all --staged-files --format=summary --no-ai
|
|
84
|
+
## 🎯 **Advanced File Targeting**
|
|
185
85
|
|
|
186
|
-
|
|
187
|
-
sunlint --all --since=last-release --format=json --output=quality-report.json
|
|
188
|
-
```
|
|
86
|
+
Powerful file targeting capabilities:
|
|
189
87
|
|
|
190
|
-
### **Combined Git + ESLint Integration**
|
|
191
88
|
```bash
|
|
192
|
-
#
|
|
193
|
-
sunlint --all --
|
|
194
|
-
```
|
|
89
|
+
# Include specific patterns
|
|
90
|
+
sunlint --all --include="src/**/*.ts,lib/**/*.dart" --input=.
|
|
195
91
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
- ✅ **PR-focused**: Catch issues in changed code
|
|
199
|
-
- ✅ **Incremental**: Fail only on new violations
|
|
200
|
-
- ✅ **Flexible**: Support multiple Git workflows
|
|
92
|
+
# Exclude patterns
|
|
93
|
+
sunlint --all --exclude="**/*.test.*,**/*.generated.*" --input=src
|
|
201
94
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
# Install for specific project
|
|
205
|
-
npm install https://github.com/sun-asterisk/engineer-excellence/releases/download/sunlint-v1.0.0/sun-sunlint-1.0.0.tgz
|
|
95
|
+
# Language filtering
|
|
96
|
+
sunlint --all --languages=typescript,dart --input=src
|
|
206
97
|
|
|
207
|
-
#
|
|
208
|
-
|
|
98
|
+
# Source files only (exclude tests, configs)
|
|
99
|
+
sunlint --all --only-source --input=src
|
|
209
100
|
```
|
|
210
101
|
|
|
211
|
-
### **
|
|
212
|
-
|
|
213
|
-
sunlint
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
sunlint --help
|
|
217
|
-
# Shows full command options
|
|
218
|
-
```
|
|
102
|
+
### **Configuration Priority** (Highest to Lowest)
|
|
103
|
+
1. **CLI flags**: `--include`, `--exclude`, `--languages`
|
|
104
|
+
2. **Project config**: `.sunlint.json`
|
|
105
|
+
3. **Package.json**: `"sunlint"` field
|
|
106
|
+
4. **Default config**: Built-in patterns
|
|
219
107
|
|
|
220
|
-
##
|
|
108
|
+
## 📋 **Available Rules**
|
|
221
109
|
|
|
222
|
-
|
|
110
|
+
### **Quality Rules** ✨ (9 rules)
|
|
111
|
+
| Rule ID | Name | Status |
|
|
112
|
+
|---------|------|--------|
|
|
113
|
+
| **C005** | Single Responsibility | ✅ Stable |
|
|
114
|
+
| **C006** | Function Naming | ✅ Stable |
|
|
115
|
+
| **C007** | Comment Quality | ✅ Stable |
|
|
116
|
+
| **C012** | Command Query Separation | ✅ Stable |
|
|
117
|
+
| **C014** | Dependency Injection | ✅ Stable |
|
|
118
|
+
| **C015** | Domain Language | ✅ Stable |
|
|
119
|
+
| **C019** | Log Level Usage | ✅ Stable |
|
|
120
|
+
| **C031** | Validation Separation | ✅ Stable |
|
|
121
|
+
| **C037** | API Response Format | ✅ Stable |
|
|
223
122
|
|
|
224
|
-
### **
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
123
|
+
### **Security Rules** 🔒 (43 rules)
|
|
124
|
+
| Rule ID | Name | Status |
|
|
125
|
+
|---------|------|--------|
|
|
126
|
+
| **S005** | No Origin Header Authentication | ✅ Stable |
|
|
127
|
+
| **S008** | Crypto Agility | ✅ Stable |
|
|
128
|
+
| **S012** | No Hardcoded Secrets | ✅ Stable |
|
|
129
|
+
| **S014-S058** | *...40 additional security rules* | ✅ Stable |
|
|
228
130
|
|
|
229
|
-
|
|
230
|
-
sunlint --typescript --rules=C006,C019,S047 --input=src
|
|
231
|
-
|
|
232
|
-
# TypeScript + ESLint integration
|
|
233
|
-
sunlint --typescript --eslint-integration --input=src
|
|
131
|
+
## ⚙️ **Configuration**
|
|
234
132
|
|
|
235
|
-
|
|
236
|
-
sunlint --typescript --changed-files --format=summary
|
|
237
|
-
```
|
|
133
|
+
Create `.sunlint.json` in your project root:
|
|
238
134
|
|
|
239
|
-
### **
|
|
240
|
-
*Optional: If you prefer project-level dependencies*
|
|
135
|
+
### **Basic Configuration**
|
|
241
136
|
```json
|
|
242
137
|
{
|
|
243
|
-
"
|
|
244
|
-
|
|
245
|
-
"
|
|
246
|
-
"
|
|
247
|
-
|
|
248
|
-
"devDependencies": {
|
|
249
|
-
"@sun-asterisk/sunlint": "^1.0.5",
|
|
250
|
-
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
251
|
-
"@typescript-eslint/parser": "^6.0.0"
|
|
138
|
+
"extends": "@sun/sunlint/recommended",
|
|
139
|
+
"rules": {
|
|
140
|
+
"C019": "error",
|
|
141
|
+
"C006": "warn",
|
|
142
|
+
"S005": "error"
|
|
252
143
|
}
|
|
253
144
|
}
|
|
254
145
|
```
|
|
255
146
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
### **Features**
|
|
259
|
-
- ✅ **Native AST Analysis**: TypeScript parser integration
|
|
260
|
-
- ✅ **ESLint Bridge**: Seamless integration with existing ESLint rules
|
|
261
|
-
- ✅ **Type Checking**: Leverage TypeScript compiler for advanced analysis
|
|
262
|
-
- ✅ **Performance**: Optimized for TypeScript codebases
|
|
263
|
-
|
|
264
|
-
## �📋 **Available Rules**
|
|
265
|
-
|
|
266
|
-
### **Quality Rules** ✨
|
|
267
|
-
| Rule ID | Name | Category | Languages | Status |
|
|
268
|
-
|---------|------|----------|-----------|--------|
|
|
269
|
-
| **C005** | Single Responsibility | quality | TS, Dart, Kotlin | ✅ Stable |
|
|
270
|
-
| **C006** | Function Naming | quality | TS, Dart, Kotlin | ✅ Stable |
|
|
271
|
-
| **C007** | Comment Quality | quality | TS, Dart, Kotlin | ✅ Stable |
|
|
272
|
-
| **C012** | Command Query Separation | quality | TS, Dart, Kotlin | ✅ Stable |
|
|
273
|
-
| **C014** | Dependency Injection | quality | TS, Dart, Kotlin | ✅ Stable |
|
|
274
|
-
| **C015** | Domain Language | quality | TS, Dart, Kotlin | ✅ Stable |
|
|
275
|
-
| **C019** | Log Level Usage | quality | TS, Dart, Kotlin | ✅ Stable |
|
|
276
|
-
| **C031** | Validation Separation | quality | TS, Dart, Kotlin | ✅ Stable |
|
|
277
|
-
| **C037** | API Response Format | quality | TS, Dart, Kotlin | ✅ Stable |
|
|
278
|
-
|
|
279
|
-
### **Security Rules** 🔒 *(New in v1.0.4)*
|
|
280
|
-
| Rule ID | Name | Category | Languages | Status |
|
|
281
|
-
|---------|------|----------|-----------|--------|
|
|
282
|
-
| **S005** | No Origin Header Authentication | security | TS, JS | ✅ Stable |
|
|
283
|
-
| **S006** | Activation Recovery Secret Not Plaintext | security | TS, JS | ✅ Stable |
|
|
284
|
-
| **S008** | Crypto Agility | security | TS, JS | ✅ Stable |
|
|
285
|
-
### **Security Rules** 🔒 *(43 rules total)*
|
|
286
|
-
| Rule ID | Name | Category | Languages | Status |
|
|
287
|
-
|---------|------|----------|-----------|--------|
|
|
288
|
-
| **S005** | No Origin Header Authentication | security | TS, JS | ✅ Stable |
|
|
289
|
-
| **S008** | Crypto Agility | security | TS, JS | ✅ Stable |
|
|
290
|
-
| **S012** | No Hardcoded Secrets | security | TS, JS | ✅ Stable |
|
|
291
|
-
| **S014-S058** | *...40 additional security rules* | security | TS, JS | ✅ Stable |
|
|
292
|
-
|
|
293
|
-
*Complete list available in CHANGELOG.md*
|
|
294
|
-
|
|
295
|
-
## 🎮 **Usage Examples**
|
|
296
|
-
|
|
297
|
-
### **Basic Usage**
|
|
298
|
-
```bash
|
|
299
|
-
# Run all rules (93 total: quality + security)
|
|
300
|
-
sunlint --all --typescript --input=src/
|
|
301
|
-
|
|
302
|
-
# Check specific category
|
|
303
|
-
sunlint --security --typescript --input=src/
|
|
304
|
-
sunlint --quality --typescript --input=src/
|
|
305
|
-
|
|
306
|
-
# Check specific rules
|
|
307
|
-
sunlint --rules=C019,S005 --typescript --input=src/
|
|
308
|
-
```
|
|
309
|
-
|
|
310
|
-
### **Complete Analysis** 🎯
|
|
311
|
-
```bash
|
|
312
|
-
# Run all rules (quality + security = 44 rules)
|
|
313
|
-
sunlint --all --typescript --input=src/
|
|
314
|
-
|
|
315
|
-
# Local development scan
|
|
316
|
-
sunlint --typescript --input=. --format=summary
|
|
317
|
-
|
|
318
|
-
# Check single file
|
|
319
|
-
sunlint --all --typescript --input=components/Button.tsx
|
|
320
|
-
```
|
|
321
|
-
|
|
322
|
-
### **CI/CD Integration** 🚀
|
|
323
|
-
```bash
|
|
324
|
-
# Full project scan (main branch)
|
|
325
|
-
sunlint --all --input=. --format=json --output=sunlint-report.json
|
|
326
|
-
|
|
327
|
-
# Changed files only (PR checks)
|
|
328
|
-
sunlint --all --changed-files --format=summary
|
|
329
|
-
|
|
330
|
-
# With ESLint integration
|
|
331
|
-
sunlint --all --eslint-integration --changed-files
|
|
332
|
-
```
|
|
333
|
-
|
|
334
|
-
## ⚙️ **Configuration**
|
|
335
|
-
|
|
336
|
-
Create `.sunlint.json` in your project root:
|
|
337
|
-
|
|
147
|
+
### **Advanced Configuration**
|
|
338
148
|
```json
|
|
339
149
|
{
|
|
340
150
|
"extends": "@sun/sunlint/recommended",
|
|
151
|
+
|
|
152
|
+
"include": ["src/**", "lib/**"],
|
|
153
|
+
"exclude": ["**/*.test.*", "**/*.generated.*"],
|
|
154
|
+
|
|
155
|
+
"languages": {
|
|
156
|
+
"typescript": {
|
|
157
|
+
"include": ["**/*.ts", "**/*.tsx"],
|
|
158
|
+
"exclude": ["**/*.d.ts"]
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
|
|
162
|
+
"testPatterns": {
|
|
163
|
+
"include": ["**/*.test.*", "**/*.spec.*"],
|
|
164
|
+
"rules": { "C006": "off" }
|
|
165
|
+
},
|
|
166
|
+
|
|
341
167
|
"rules": {
|
|
342
168
|
"C019": "error",
|
|
343
169
|
"C006": "warn",
|
|
344
170
|
"S005": "error"
|
|
345
|
-
}
|
|
346
|
-
"categories": ["quality", "security"],
|
|
347
|
-
"ignorePatterns": ["node_modules/**", "dist/**"]
|
|
171
|
+
}
|
|
348
172
|
}
|
|
349
173
|
```
|
|
174
|
+
|
|
175
|
+
### **Preset Configurations**
|
|
176
|
+
- `@sun/sunlint/recommended` - Balanced rules for all projects
|
|
350
177
|
- `@sun/sunlint/security` - Security-focused rules only
|
|
351
178
|
- `@sun/sunlint/quality` - Quality-focused rules only
|
|
179
|
+
- `@sun/sunlint/beginner` - Gentle introduction for new teams
|
|
180
|
+
- `@sun/sunlint/ci` - Optimized for CI/CD environments
|
|
352
181
|
|
|
353
|
-
##
|
|
354
|
-
|
|
355
|
-
```bash
|
|
356
|
-
# ESLint-compatible JSON
|
|
357
|
-
sunlint --format=eslint --input=src
|
|
358
|
-
|
|
359
|
-
# Human-readable summary
|
|
360
|
-
sunlint --format=summary --input=src
|
|
361
|
-
|
|
362
|
-
# Detailed report
|
|
363
|
-
sunlint --format=detailed --input=src
|
|
364
|
-
|
|
365
|
-
# GitHub Actions format
|
|
366
|
-
sunlint --format=github --input=src
|
|
367
|
-
```
|
|
368
|
-
|
|
369
|
-
## 🚀 **CI/CD Strategy & Best Practices**
|
|
370
|
-
|
|
371
|
-
### **Vấn đề về Performance và Cost**
|
|
372
|
-
|
|
373
|
-
| Approach | Ưu điểm | Nhược điểm | Khi nào sử dụng |
|
|
374
|
-
|----------|---------|------------|-----------------|
|
|
375
|
-
| **Full Scan** | Phát hiện hết tất cả issues, consistent | Chậm, tốn resource, nhiều noise | Main branch, weekly reports |
|
|
376
|
-
| **Changed Files Only** | Nhanh, relevant, cost-effective | Miss issues từ dependency changes | PR checks, pre-commit |
|
|
377
|
-
| **Baseline Comparison** | Balance giữa performance và coverage | Setup phức tạp hơn | Large projects |
|
|
378
|
-
|
|
379
|
-
### **Recommended CI/CD Strategy**
|
|
380
|
-
|
|
381
|
-
## 📊 **Output Formats**
|
|
182
|
+
## 🎮 **Usage Examples**
|
|
382
183
|
|
|
184
|
+
### **Development**
|
|
383
185
|
```bash
|
|
384
|
-
#
|
|
385
|
-
sunlint --
|
|
186
|
+
# Run all rules
|
|
187
|
+
sunlint --all --input=src
|
|
386
188
|
|
|
387
|
-
#
|
|
388
|
-
sunlint --
|
|
189
|
+
# Check specific rules
|
|
190
|
+
sunlint --rules=C019,S005 --input=src
|
|
389
191
|
|
|
390
|
-
#
|
|
391
|
-
sunlint --
|
|
192
|
+
# ESLint + Git integration
|
|
193
|
+
sunlint --all --eslint-integration --changed-files
|
|
392
194
|
```
|
|
393
195
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
### **Recommended Strategy**
|
|
196
|
+
### **CI/CD**
|
|
397
197
|
```bash
|
|
398
|
-
#
|
|
399
|
-
sunlint --all --
|
|
198
|
+
# Full project scan
|
|
199
|
+
sunlint --all --input=. --format=json --output=report.json
|
|
400
200
|
|
|
401
|
-
#
|
|
402
|
-
sunlint --all --
|
|
403
|
-
```
|
|
404
|
-
|
|
405
|
-
**Performance**: Changed files (~10-30s) vs Full scan (~2-5min)
|
|
406
|
-
|
|
407
|
-
## 🛠 **CI/CD Integration**
|
|
408
|
-
|
|
409
|
-
**GitHub Actions (PR Mode):**
|
|
410
|
-
```yaml
|
|
411
|
-
name: Code Quality Check
|
|
412
|
-
on:
|
|
413
|
-
pull_request:
|
|
414
|
-
branches: [main, develop]
|
|
415
|
-
|
|
416
|
-
jobs:
|
|
417
|
-
sunlint:
|
|
418
|
-
runs-on: ubuntu-latest
|
|
419
|
-
steps:
|
|
420
|
-
- uses: actions/checkout@v3
|
|
421
|
-
with:
|
|
422
|
-
fetch-depth: 0 # Fetch full history for diff comparison
|
|
423
|
-
|
|
424
|
-
- name: Setup Node.js
|
|
425
|
-
uses: actions/setup-node@v3
|
|
426
|
-
with:
|
|
427
|
-
node-version: '18'
|
|
428
|
-
|
|
429
|
-
- name: Install SunLint
|
|
430
|
-
**GitHub Actions Example:**
|
|
431
|
-
```yaml
|
|
432
|
-
name: Code Quality Check
|
|
433
|
-
on:
|
|
434
|
-
pull_request:
|
|
435
|
-
branches: [main]
|
|
436
|
-
|
|
437
|
-
jobs:
|
|
438
|
-
sunlint:
|
|
439
|
-
runs-on: ubuntu-latest
|
|
440
|
-
steps:
|
|
441
|
-
- uses: actions/checkout@v3
|
|
442
|
-
with:
|
|
443
|
-
fetch-depth: 0
|
|
444
|
-
|
|
445
|
-
- name: Setup Node.js
|
|
446
|
-
uses: actions/setup-node@v3
|
|
447
|
-
with:
|
|
448
|
-
node-version: '18'
|
|
449
|
-
|
|
450
|
-
- name: Install SunLint
|
|
451
|
-
run: npm install -g @sun-asterisk/sunlint
|
|
452
|
-
|
|
453
|
-
- name: Run SunLint on Changed Files
|
|
454
|
-
run: |
|
|
455
|
-
sunlint --all --changed-files --diff-base=origin/main \
|
|
456
|
-
--format=github --fail-on-new-violations
|
|
457
|
-
```
|
|
458
|
-
with:
|
|
459
|
-
name: sunlint-baseline
|
|
460
|
-
path: sunlint-baseline.json
|
|
461
|
-
```
|
|
201
|
+
# PR validation
|
|
202
|
+
sunlint --all --changed-files --fail-on-new-violations
|
|
462
203
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
sunlint:pr:
|
|
466
|
-
stage: code-quality
|
|
467
|
-
rules:
|
|
468
|
-
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
|
469
|
-
script:
|
|
204
|
+
# Pre-commit hook
|
|
205
|
+
sunlint --all --staged-files --format=summary
|
|
470
206
|
```
|
|
471
207
|
|
|
472
208
|
## 📚 **Documentation**
|
|
473
209
|
|
|
474
|
-
-
|
|
475
|
-
-
|
|
476
|
-
-
|
|
210
|
+
- [ESLint Integration Guide](./docs/ESLINT_INTEGRATION.md)
|
|
211
|
+
- [CI/CD Guide](./docs/CI-CD-GUIDE.md)
|
|
212
|
+
- [Architecture](./docs/ARCHITECTURE.md)
|
|
213
|
+
- [Examples](./examples/README.md)
|
|
477
214
|
|
|
478
|
-
##
|
|
215
|
+
## 🤝 **Contributing**
|
|
479
216
|
|
|
480
|
-
|
|
217
|
+
See [CONTRIBUTING.md](./CONTRIBUTING.md) for development guidelines.
|
|
481
218
|
|
|
482
|
-
##
|
|
219
|
+
## 📄 **License**
|
|
483
220
|
|
|
484
|
-
-
|
|
485
|
-
- **Issues**: [GitHub Issues](https://github.com/sun-engineering/sunlint/issues)
|
|
486
|
-
- **Changelog**: [CHANGELOG.md](./CHANGELOG.md)
|
|
221
|
+
MIT License - see [LICENSE](./LICENSE) for details.
|
|
487
222
|
|
|
488
223
|
---
|
|
489
224
|
|
|
490
|
-
**Built with
|
|
225
|
+
**Built with ❤️ by Sun* Engineering Team**
|