@sun-asterisk/sunlint 1.0.7 → 1.1.3
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/.sunlint.json +35 -0
- package/CHANGELOG.md +30 -3
- package/CONTRIBUTING.md +235 -0
- package/PROJECT_STRUCTURE.md +60 -0
- package/README.md +73 -52
- package/cli.js +1 -0
- package/config/README.md +88 -0
- package/config/defaults/ai-rules-context.json +231 -0
- package/config/engines/engines.json +49 -0
- package/config/engines/eslint-rule-mapping.json +74 -0
- package/config/eslint-rule-mapping.json +126 -0
- package/config/integrations/eslint/base.config.js +125 -0
- package/config/integrations/eslint/simple.config.js +24 -0
- package/config/presets/strict.json +0 -1
- package/config/rule-analysis-strategies.js +74 -0
- package/config/{rules-registry.json → rules/rules-registry.json} +22 -0
- package/core/analysis-orchestrator.js +383 -591
- package/core/ast-modules/README.md +103 -0
- package/core/ast-modules/base-parser.js +90 -0
- package/core/ast-modules/index.js +97 -0
- package/core/ast-modules/package.json +37 -0
- package/core/ast-modules/parsers/eslint-js-parser.js +147 -0
- package/core/ast-modules/parsers/eslint-ts-parser.js +106 -0
- package/core/ast-modules/parsers/javascript-parser.js +187 -0
- package/core/ast-modules/parsers/typescript-parser.js +187 -0
- package/core/cli-action-handler.js +271 -255
- package/core/cli-program.js +18 -4
- package/core/config-manager.js +9 -3
- package/core/config-merger.js +40 -1
- package/core/config-validator.js +2 -2
- package/core/enhanced-rules-registry.js +331 -0
- package/core/file-targeting-service.js +92 -23
- package/core/interfaces/analysis-engine.interface.js +100 -0
- package/core/multi-rule-runner.js +0 -221
- package/core/output-service.js +1 -1
- package/core/rule-mapping-service.js +1 -1
- package/core/rule-selection-service.js +10 -2
- package/docs/AI.md +163 -0
- package/docs/ARCHITECTURE.md +78 -0
- package/docs/CI-CD-GUIDE.md +315 -0
- package/docs/COMMAND-EXAMPLES.md +256 -0
- package/docs/CONFIGURATION.md +414 -0
- package/docs/DEBUG.md +86 -0
- package/docs/DEPLOYMENT-STRATEGIES.md +270 -0
- package/docs/DISTRIBUTION.md +153 -0
- package/docs/ESLINT-INTEGRATION-STRATEGY.md +392 -0
- package/docs/ESLINT_INTEGRATION.md +238 -0
- package/docs/FOLDER_STRUCTURE.md +59 -0
- package/docs/HEURISTIC_VS_AI.md +113 -0
- package/docs/README.md +32 -0
- package/docs/RELEASE_GUIDE.md +230 -0
- package/engines/eslint-engine.js +601 -0
- package/engines/heuristic-engine.js +860 -0
- package/engines/openai-engine.js +374 -0
- package/engines/tree-sitter-parser.js +0 -0
- package/engines/universal-ast-engine.js +0 -0
- package/integrations/eslint/README.md +99 -0
- package/integrations/eslint/configs/.eslintrc.js +98 -0
- package/integrations/eslint/configs/eslint.config.js +133 -0
- package/integrations/eslint/configs/eslint.config.simple.js +24 -0
- package/integrations/eslint/package.json +23 -0
- package/integrations/eslint/plugin/index.js +164 -0
- package/integrations/eslint/plugin/package.json +13 -0
- package/integrations/eslint/plugin/rules/common/c002-no-duplicate-code.js +204 -0
- package/integrations/eslint/plugin/rules/common/c003-no-vague-abbreviations.js +246 -0
- package/integrations/eslint/plugin/rules/common/c006-function-name-verb-noun.js +216 -0
- package/integrations/eslint/plugin/rules/common/c010-limit-block-nesting.js +90 -0
- package/integrations/eslint/plugin/rules/common/c013-no-dead-code.js +78 -0
- package/integrations/eslint/plugin/rules/common/c014-abstract-dependency-preferred.js +38 -0
- package/integrations/eslint/plugin/rules/common/c017-limit-constructor-logic.js +146 -0
- package/integrations/eslint/plugin/rules/common/c018-no-generic-throw.js +335 -0
- package/integrations/eslint/plugin/rules/common/c023-no-duplicate-variable-name-in-scope.js +142 -0
- package/integrations/eslint/plugin/rules/common/c029-catch-block-logging.js +115 -0
- package/integrations/eslint/plugin/rules/common/c030-use-custom-error-classes.js +294 -0
- package/integrations/eslint/plugin/rules/common/c035-no-empty-catch.js +162 -0
- package/integrations/eslint/plugin/rules/common/c041-no-config-inline.js +122 -0
- package/integrations/eslint/plugin/rules/common/c042-boolean-name-prefix.js +406 -0
- package/integrations/eslint/plugin/rules/common/c043-no-console-or-print.js +300 -0
- package/integrations/eslint/plugin/rules/common/c047-no-duplicate-retry-logic.js +239 -0
- package/integrations/eslint/plugin/rules/common/c072-one-assert-per-test.js +184 -0
- package/integrations/eslint/plugin/rules/common/c075-explicit-function-return-types.js +168 -0
- package/integrations/eslint/plugin/rules/common/c076-single-behavior-per-test.js +254 -0
- package/integrations/eslint/plugin/rules/security/s001-fail-securely.js +381 -0
- package/integrations/eslint/plugin/rules/security/s002-idor-check.js +945 -0
- package/integrations/eslint/plugin/rules/security/s003-no-unvalidated-redirect.js +86 -0
- package/integrations/eslint/plugin/rules/security/s007-no-plaintext-otp.js +74 -0
- package/integrations/eslint/plugin/rules/security/s013-verify-tls-connection.js +47 -0
- package/integrations/eslint/plugin/rules/security/s047-secure-random-passwords.js +108 -0
- package/integrations/eslint/plugin/rules/security/s055-verification-rest-check-the-incoming-content-type.js +143 -0
- package/integrations/eslint/plugin/rules/typescript/t002-interface-prefix-i.js +42 -0
- package/integrations/eslint/plugin/rules/typescript/t003-ts-ignore-reason.js +48 -0
- package/integrations/eslint/plugin/rules/typescript/t004-no-empty-type.js +95 -0
- package/integrations/eslint/plugin/rules/typescript/t007-no-fn-in-constructor.js +52 -0
- package/integrations/eslint/plugin/rules/typescript/t010-no-nested-union-tuple.js +48 -0
- package/integrations/eslint/plugin/rules/typescript/t019-no-this-assign.js +81 -0
- package/integrations/eslint/plugin/rules/typescript/t020-no-default-multi-export.js +127 -0
- package/integrations/eslint/plugin/rules/typescript/t021-limit-nested-generics.js +150 -0
- package/integrations/eslint/test-c041-rule.js +87 -0
- package/integrations/eslint/tsconfig.json +27 -0
- package/package.json +29 -16
- package/rules/README.md +252 -0
- package/rules/common/C002_no_duplicate_code/analyzer.js +65 -0
- package/rules/common/C002_no_duplicate_code/config.json +23 -0
- package/rules/common/C003_no_vague_abbreviations/analyzer.js +418 -0
- package/rules/common/C003_no_vague_abbreviations/config.json +35 -0
- package/rules/{C006_function_naming → common/C006_function_naming}/analyzer.js +13 -2
- package/rules/common/C010_limit_block_nesting/analyzer.js +389 -0
- package/rules/common/C013_no_dead_code/analyzer.js +206 -0
- package/rules/common/C014_dependency_injection/analyzer.js +338 -0
- package/rules/common/C017_constructor_logic/analyzer.js +314 -0
- package/rules/{C019_log_level_usage → common/C019_log_level_usage}/analyzer.js +5 -2
- package/rules/{C029_catch_block_logging → common/C029_catch_block_logging}/analyzer.js +49 -15
- package/rules/common/C041_no_sensitive_hardcode/analyzer.js +292 -0
- package/rules/common/C042_boolean_name_prefix/analyzer.js +300 -0
- package/rules/common/C043_no_console_or_print/analyzer.js +304 -0
- package/rules/common/C047_no_duplicate_retry_logic/analyzer.js +351 -0
- package/rules/common/C075_explicit_return_types/analyzer.js +103 -0
- package/rules/common/C076_single_test_behavior/analyzer.js +121 -0
- package/rules/docs/C002_no_duplicate_code.md +57 -0
- package/rules/index.js +149 -0
- package/rules/migration/converter.js +385 -0
- package/rules/migration/mapping.json +164 -0
- package/rules/security/S026_json_schema_validation/analyzer.js +251 -0
- package/rules/security/S026_json_schema_validation/config.json +27 -0
- package/rules/security/S027_no_hardcoded_secrets/analyzer.js +263 -0
- package/rules/security/S027_no_hardcoded_secrets/config.json +29 -0
- package/rules/security/S029_csrf_protection/analyzer.js +264 -0
- package/rules/tests/C002_no_duplicate_code.test.js +50 -0
- package/rules/universal/C010/generic.js +0 -0
- package/rules/universal/C010/tree-sitter-analyzer.js +0 -0
- package/rules/utils/ast-utils.js +191 -0
- package/rules/utils/base-analyzer.js +98 -0
- package/rules/utils/pattern-matchers.js +239 -0
- package/rules/utils/rule-helpers.js +264 -0
- package/rules/utils/severity-constants.js +93 -0
- package/scripts/build-release.sh +117 -0
- package/scripts/ci-report.js +179 -0
- package/scripts/install.sh +196 -0
- package/scripts/manual-release.sh +338 -0
- package/scripts/merge-reports.js +424 -0
- package/scripts/pre-release-test.sh +175 -0
- package/scripts/prepare-release.sh +202 -0
- package/scripts/setup-github-registry.sh +42 -0
- package/scripts/test-scripts/README.md +22 -0
- package/scripts/test-scripts/test-c041-comparison.js +114 -0
- package/scripts/test-scripts/test-c041-eslint.js +67 -0
- package/scripts/test-scripts/test-eslint-rules.js +146 -0
- package/scripts/test-scripts/test-real-world.js +44 -0
- package/scripts/test-scripts/test-rules-on-real-projects.js +86 -0
- package/scripts/trigger-release.sh +285 -0
- package/scripts/validate-rule-structure.js +148 -0
- package/scripts/verify-install.sh +82 -0
- package/config/sunlint-schema.json +0 -159
- package/config/typescript/custom-rules.js +0 -9
- package/config/typescript/package-lock.json +0 -1585
- package/config/typescript/package.json +0 -13
- package/config/typescript/security-rules/index.js +0 -90
- package/config/typescript/tsconfig.json +0 -29
- package/core/ai-analyzer.js +0 -169
- package/core/eslint-engine-service.js +0 -312
- package/core/eslint-instance-manager.js +0 -104
- package/core/eslint-integration-service.js +0 -363
- package/core/sunlint-engine-service.js +0 -23
- package/core/typescript-analyzer.js +0 -262
- package/core/typescript-engine.js +0 -313
- /package/config/{default.json → defaults/default.json} +0 -0
- /package/config/{typescript/eslint.config.js → integrations/eslint/typescript.config.js} +0 -0
- /package/config/{typescript/custom-rules-new.js → schemas/sunlint-schema.json} +0 -0
- /package/config/{typescript → testing}/test-s005-working.ts +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s005-no-origin-auth.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s006-activation-recovery-secret-not-plaintext.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s008-crypto-agility.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s009-no-insecure-crypto.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s010-no-insecure-random-in-sensitive-context.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s011-no-insecure-uuid.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s012-hardcode-secret.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s014-insecure-tls-version.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s015-insecure-tls-certificate.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s016-sensitive-query-parameter.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s017-no-sql-injection.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s018-positive-input-validation.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s019-no-raw-user-input-in-email.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s020-no-eval-dynamic-execution.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s022-output-encoding.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s023-no-json-injection.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s025-server-side-input-validation.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s026-json-schema-validation.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s027-no-hardcoded-secrets.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s029-require-csrf-protection.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s030-no-directory-browsing.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s033-require-samesite-cookie.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s034-require-host-cookie-prefix.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s035-cookie-specific-path.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s036-no-unsafe-file-include.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s037-require-anti-cache-headers.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s038-no-version-disclosure.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s039-no-session-token-in-url.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s041-require-session-invalidate-on-logout.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s042-require-periodic-reauthentication.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s043-terminate-sessions-on-password-change.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s044-require-full-session-for-sensitive-operations.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s045-anti-automation-controls.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s046-secure-notification-on-auth-change.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s048-password-credential-recovery.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s050-session-token-weak-hash.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s052-secure-random-authentication-code.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s054-verification-default-account.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s057-utc-logging.js +0 -0
- /package/{config/typescript/security-rules → integrations/eslint/plugin/rules/security}/s058-no-ssrf.js +0 -0
- /package/rules/{C006_function_naming → common/C006_function_naming}/config.json +0 -0
- /package/rules/{C019_log_level_usage → common/C019_log_level_usage}/config.json +0 -0
- /package/rules/{C029_catch_block_logging → common/C029_catch_block_logging}/config.json +0 -0
- /package/rules/{C031_validation_separation → common/C031_validation_separation}/analyzer.js +0 -0
- /package/rules/{C031_validation_separation/README.md → docs/C031_validation_separation.md} +0 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
# 🎮 SunLint Command Examples & Demos
|
|
2
|
+
|
|
3
|
+
## 📋 **Tổng hợp đầy đủ các chức năng CLI đã hỗ trợ**
|
|
4
|
+
|
|
5
|
+
### ✅ **1. Phạm vi kiểm tra (Input Scope)**
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Kiểm tra 1 file cụ thể
|
|
9
|
+
node cli.js --all --input=cli.js --format=summary --no-ai
|
|
10
|
+
|
|
11
|
+
# Kiểm tra 1 folder/directory
|
|
12
|
+
node cli.js --all --input=core --format=summary --no-ai
|
|
13
|
+
|
|
14
|
+
# Kiểm tra toàn bộ project/workspace
|
|
15
|
+
node cli.js --all --input=. --format=summary --no-ai
|
|
16
|
+
|
|
17
|
+
# Kiểm tra nhiều folders (comma-separated)
|
|
18
|
+
node cli.js --all --input=core,rules --format=summary --no-ai
|
|
19
|
+
|
|
20
|
+
# Kiểm tra chỉ files đã thay đổi (Git integration)
|
|
21
|
+
node cli.js --all --changed-files --format=summary --no-ai
|
|
22
|
+
|
|
23
|
+
# Kiểm tra chỉ files đã staged (Pre-commit)
|
|
24
|
+
node cli.js --all --staged-files --format=summary --no-ai
|
|
25
|
+
|
|
26
|
+
# Kiểm tra files thay đổi so với branch cụ thể
|
|
27
|
+
node cli.js --all --changed-files --diff-base=origin/main --format=summary
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### ✅ **2. Lựa chọn Rules**
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# Kiểm tra 1 rule cụ thể
|
|
34
|
+
node cli.js --rule=C019 --input=. --format=summary --no-ai
|
|
35
|
+
|
|
36
|
+
# Kiểm tra nhiều rules cụ thể
|
|
37
|
+
node cli.js --rules=C019,C006,C029 --input=. --format=summary --no-ai
|
|
38
|
+
|
|
39
|
+
# Kiểm tra tất cả rules
|
|
40
|
+
node cli.js --all --input=. --format=summary --no-ai
|
|
41
|
+
|
|
42
|
+
# Kiểm tra theo category (quality rules)
|
|
43
|
+
node cli.js --quality --input=. --format=summary --no-ai
|
|
44
|
+
|
|
45
|
+
# Kiểm tra theo category (security rules)
|
|
46
|
+
node cli.js --security --input=. --format=summary --no-ai
|
|
47
|
+
|
|
48
|
+
# Loại trừ một số rules cụ thể
|
|
49
|
+
node cli.js --all --exclude-rules=C031 --input=. --format=summary --no-ai
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### ✅ **3. Phương pháp phân tích**
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Pattern-based analysis (free, fast)
|
|
56
|
+
node cli.js --all --input=. --format=summary --no-ai
|
|
57
|
+
|
|
58
|
+
# AI-powered analysis (cost, more accurate)
|
|
59
|
+
node cli.js --all --input=. --format=summary --ai
|
|
60
|
+
|
|
61
|
+
# Hybrid: AI cho rules cụ thể, pattern cho còn lại
|
|
62
|
+
node cli.js --rule=C019 --input=. --ai --format=summary
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### ✅ **4. Output Formats**
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# Human-readable summary
|
|
69
|
+
node cli.js --all --input=. --format=summary --no-ai
|
|
70
|
+
|
|
71
|
+
# ESLint-compatible JSON (for IDEs)
|
|
72
|
+
node cli.js --all --input=. --format=eslint --no-ai
|
|
73
|
+
|
|
74
|
+
# Structured JSON (for processing)
|
|
75
|
+
node cli.js --all --input=. --format=json --no-ai
|
|
76
|
+
|
|
77
|
+
# Table format (for reports)
|
|
78
|
+
node cli.js --all --input=. --format=table --no-ai
|
|
79
|
+
|
|
80
|
+
# GitHub Actions format (for CI)
|
|
81
|
+
node cli.js --all --input=. --format=github --no-ai
|
|
82
|
+
|
|
83
|
+
# Save to file
|
|
84
|
+
node cli.js --all --input=. --format=json --output=report.json --no-ai
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### ✅ **5. CI/CD Features**
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
# PR Mode: Chỉ check violations mới
|
|
91
|
+
node cli.js --all --changed-files --fail-on-new-violations --format=summary
|
|
92
|
+
|
|
93
|
+
# Baseline comparison
|
|
94
|
+
node cli.js --all --input=. --save-baseline=baseline.json --format=json --no-ai
|
|
95
|
+
node cli.js --all --changed-files --baseline=baseline.json --fail-on-new-violations
|
|
96
|
+
|
|
97
|
+
# Severity filtering
|
|
98
|
+
node cli.js --all --input=. --severity=error --format=summary --no-ai
|
|
99
|
+
|
|
100
|
+
# Language filtering
|
|
101
|
+
node cli.js --all --input=. --languages=typescript,javascript --format=summary
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### ✅ **6. Performance & Advanced Options**
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
# Control concurrent execution
|
|
108
|
+
node cli.js --all --input=. --max-concurrent=10 --format=summary --no-ai
|
|
109
|
+
|
|
110
|
+
# Set timeout for rules
|
|
111
|
+
node cli.js --all --input=. --timeout=60000 --format=summary --no-ai
|
|
112
|
+
|
|
113
|
+
# Disable caching
|
|
114
|
+
node cli.js --all --input=. --no-cache --format=summary --no-ai
|
|
115
|
+
|
|
116
|
+
# Verbose logging
|
|
117
|
+
node cli.js --all --input=. --verbose --format=summary --no-ai
|
|
118
|
+
|
|
119
|
+
# Quiet mode (errors only)
|
|
120
|
+
node cli.js --all --input=. --quiet --format=summary --no-ai
|
|
121
|
+
|
|
122
|
+
# Debug mode
|
|
123
|
+
node cli.js --all --input=. --debug --format=summary --no-ai
|
|
124
|
+
|
|
125
|
+
# Dry run (show what would be analyzed)
|
|
126
|
+
node cli.js --all --input=. --dry-run --format=summary --no-ai
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## 🚀 **Use Cases & Scenarios**
|
|
130
|
+
|
|
131
|
+
### **Local Development** 🏠
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
# Quick check before commit
|
|
135
|
+
node cli.js --all --staged-files --format=summary --no-ai
|
|
136
|
+
|
|
137
|
+
# Check current work
|
|
138
|
+
node cli.js --all --changed-files --format=summary --no-ai
|
|
139
|
+
|
|
140
|
+
# Focus on specific issue type
|
|
141
|
+
node cli.js --rule=C019 --input=. --format=summary --no-ai
|
|
142
|
+
|
|
143
|
+
# Deep analysis with AI
|
|
144
|
+
node cli.js --quality --input=src --ai --format=detailed
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### **Code Review** 👀
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
# Check PR changes
|
|
151
|
+
node cli.js --all --changed-files --diff-base=origin/main --format=github
|
|
152
|
+
|
|
153
|
+
# Focus on security for sensitive changes
|
|
154
|
+
node cli.js --security --changed-files --format=summary --no-ai
|
|
155
|
+
|
|
156
|
+
# New violations only
|
|
157
|
+
node cli.js --all --changed-files --baseline=baseline.json --fail-on-new-violations
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### **CI/CD Pipeline** 🔄
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
# Fast PR check
|
|
164
|
+
node cli.js --all --changed-files --format=github --no-ai --timeout=30000
|
|
165
|
+
|
|
166
|
+
# Full scan for main branch
|
|
167
|
+
node cli.js --all --input=. --format=json --output=report.json --no-ai
|
|
168
|
+
|
|
169
|
+
# Security-critical check
|
|
170
|
+
node cli.js --security --input=. --severity=error --format=summary --no-ai
|
|
171
|
+
|
|
172
|
+
# Quality gate
|
|
173
|
+
node cli.js --quality --changed-files --max-new-violations=5 --format=summary
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### **Project Health Monitoring** 📊
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
# Full project assessment
|
|
180
|
+
node cli.js --all --input=. --format=detailed --output=health-report.json --no-ai
|
|
181
|
+
|
|
182
|
+
# Trend analysis
|
|
183
|
+
node cli.js --all --input=. --baseline=last-month.json --format=trend --no-ai
|
|
184
|
+
|
|
185
|
+
# Focus areas
|
|
186
|
+
node cli.js --rules=C019,C029 --input=core --format=table --no-ai
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## 🎯 **Practical Examples**
|
|
190
|
+
|
|
191
|
+
### **Example 1: New Feature Development**
|
|
192
|
+
```bash
|
|
193
|
+
# Day 1: Start development
|
|
194
|
+
node cli.js --all --staged-files --format=summary --no-ai
|
|
195
|
+
|
|
196
|
+
# Day 2: Check progress
|
|
197
|
+
node cli.js --all --changed-files --format=summary --no-ai
|
|
198
|
+
|
|
199
|
+
# Day 3: Pre-review check
|
|
200
|
+
node cli.js --all --changed-files --diff-base=origin/main --format=github --no-ai
|
|
201
|
+
|
|
202
|
+
# Day 4: Final validation
|
|
203
|
+
node cli.js --all --changed-files --ai --format=detailed
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### **Example 2: Legacy Code Improvement**
|
|
207
|
+
```bash
|
|
208
|
+
# Step 1: Baseline assessment
|
|
209
|
+
node cli.js --all --input=legacy-module --save-baseline=legacy-baseline.json --no-ai
|
|
210
|
+
|
|
211
|
+
# Step 2: Focus on critical issues
|
|
212
|
+
node cli.js --security --input=legacy-module --severity=error --format=summary
|
|
213
|
+
|
|
214
|
+
# Step 3: Incremental improvement
|
|
215
|
+
node cli.js --rule=C019 --input=legacy-module --format=summary --no-ai
|
|
216
|
+
|
|
217
|
+
# Step 4: Track progress
|
|
218
|
+
node cli.js --all --input=legacy-module --baseline=legacy-baseline.json --format=trend
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### **Example 3: Team Onboarding**
|
|
222
|
+
```bash
|
|
223
|
+
# Level 1: Basic checks
|
|
224
|
+
node cli.js --rules=C006,C019 --input=. --format=summary --no-ai
|
|
225
|
+
|
|
226
|
+
# Level 2: Quality focus
|
|
227
|
+
node cli.js --quality --input=. --format=table --no-ai
|
|
228
|
+
|
|
229
|
+
# Level 3: Full analysis
|
|
230
|
+
node cli.js --all --input=. --format=detailed --no-ai
|
|
231
|
+
|
|
232
|
+
# Level 4: AI-assisted learning
|
|
233
|
+
node cli.js --all --input=. --ai --verbose --format=detailed
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
## 📝 **Command Cheat Sheet**
|
|
237
|
+
|
|
238
|
+
| Task | Command |
|
|
239
|
+
|------|---------|
|
|
240
|
+
| Quick pre-commit check | `node cli.js --all --staged-files --format=summary --no-ai` |
|
|
241
|
+
| PR review | `node cli.js --all --changed-files --diff-base=origin/main --format=github` |
|
|
242
|
+
| Full project scan | `node cli.js --all --input=. --format=json --output=report.json --no-ai` |
|
|
243
|
+
| Security audit | `node cli.js --security --input=. --severity=error --format=summary` |
|
|
244
|
+
| New violations only | `node cli.js --all --changed-files --baseline=baseline.json --fail-on-new-violations` |
|
|
245
|
+
| AI deep analysis | `node cli.js --quality --input=src --ai --format=detailed` |
|
|
246
|
+
| Performance test | `node cli.js --all --input=. --max-concurrent=1 --timeout=10000 --no-ai` |
|
|
247
|
+
| Debug issues | `node cli.js --rule=C019 --input=problematic-file.js --debug --verbose` |
|
|
248
|
+
|
|
249
|
+
## 💡 **Pro Tips**
|
|
250
|
+
|
|
251
|
+
1. **Start with `--no-ai`** for faster feedback, use `--ai` for complex issues
|
|
252
|
+
2. **Use `--changed-files`** in development, `--input=.` for comprehensive checks
|
|
253
|
+
3. **Save baselines** for large projects to track progress over time
|
|
254
|
+
4. **Combine `--severity=error`** with CI to focus on critical issues
|
|
255
|
+
5. **Use `--dry-run`** to understand what will be analyzed before running
|
|
256
|
+
6. **Set `--timeout`** appropriately based on project size and CI time limits
|
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
# SunLint Configuration Guide
|
|
2
|
+
|
|
3
|
+
This document provides a comprehensive guide to all SunLint configuration options.
|
|
4
|
+
|
|
5
|
+
## 📋 Quick Start
|
|
6
|
+
|
|
7
|
+
Create `.sunlint.json` in your project root:
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{
|
|
11
|
+
"extends": "@sun/sunlint/recommended",
|
|
12
|
+
"input": ["src"],
|
|
13
|
+
"exclude": ["**/*.test.*", "**/*.generated.*"],
|
|
14
|
+
"rules": {
|
|
15
|
+
"C019": "error",
|
|
16
|
+
"C006": "warn",
|
|
17
|
+
"S005": "error"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 📖 Complete Configuration Reference
|
|
23
|
+
|
|
24
|
+
Below is the full configuration schema with all available options and their descriptions:
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"//": "=== SunLint Full Configuration Example ===",
|
|
29
|
+
"//": "Copy this configuration and customize as needed",
|
|
30
|
+
|
|
31
|
+
"//extends": "Configuration preset to extend from",
|
|
32
|
+
"extends": "@sun/sunlint/recommended",
|
|
33
|
+
"//extends-options": [
|
|
34
|
+
"@sun/sunlint/recommended",
|
|
35
|
+
"@sun/sunlint/security",
|
|
36
|
+
"@sun/sunlint/quality",
|
|
37
|
+
"@sun/sunlint/beginner",
|
|
38
|
+
"@sun/sunlint/ci"
|
|
39
|
+
],
|
|
40
|
+
|
|
41
|
+
"//engine": "Analysis engine selection (future-proof for multi-engine support)",
|
|
42
|
+
"engine": "heuristic",
|
|
43
|
+
"//engine-options": ["heuristic", "eslint", "ai"],
|
|
44
|
+
|
|
45
|
+
"//input": "Default input paths when --input is not specified",
|
|
46
|
+
"input": ["src", "lib"],
|
|
47
|
+
|
|
48
|
+
"//include": "File patterns to include in analysis",
|
|
49
|
+
"include": [
|
|
50
|
+
"src/**/*.{js,ts,jsx,tsx}",
|
|
51
|
+
"lib/**/*.{js,ts,jsx,tsx}",
|
|
52
|
+
"api/**/*.{js,ts}",
|
|
53
|
+
"**/*.dart"
|
|
54
|
+
],
|
|
55
|
+
|
|
56
|
+
"//exclude": "File patterns to exclude from analysis",
|
|
57
|
+
"exclude": [
|
|
58
|
+
"**/*.test.*",
|
|
59
|
+
"**/*.spec.*",
|
|
60
|
+
"**/*.generated.*",
|
|
61
|
+
"**/*.d.ts",
|
|
62
|
+
"**/node_modules/**",
|
|
63
|
+
"**/dist/**",
|
|
64
|
+
"**/build/**",
|
|
65
|
+
"**/.git/**",
|
|
66
|
+
"**/coverage/**"
|
|
67
|
+
],
|
|
68
|
+
|
|
69
|
+
"//languages": "Language-specific configurations",
|
|
70
|
+
"languages": {
|
|
71
|
+
"typescript": {
|
|
72
|
+
"//": "TypeScript specific patterns and rules",
|
|
73
|
+
"include": ["**/*.ts", "**/*.tsx"],
|
|
74
|
+
"exclude": ["**/*.d.ts", "**/*.test.ts"],
|
|
75
|
+
"rules": {
|
|
76
|
+
"//": "Override rules for TypeScript files",
|
|
77
|
+
"C006": "error",
|
|
78
|
+
"C019": "warn"
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
"javascript": {
|
|
82
|
+
"include": ["**/*.js", "**/*.jsx"],
|
|
83
|
+
"exclude": ["**/*.test.js", "**/*.config.js"]
|
|
84
|
+
},
|
|
85
|
+
"dart": {
|
|
86
|
+
"include": ["**/*.dart"],
|
|
87
|
+
"exclude": ["**/*.g.dart", "**/*.freezed.dart"]
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
"//testPatterns": "Test file specific configurations",
|
|
92
|
+
"testPatterns": {
|
|
93
|
+
"include": [
|
|
94
|
+
"**/*.test.*",
|
|
95
|
+
"**/*.spec.*",
|
|
96
|
+
"**/tests/**",
|
|
97
|
+
"**/__tests__/**"
|
|
98
|
+
],
|
|
99
|
+
"rules": {
|
|
100
|
+
"//": "Rules often relaxed for test files",
|
|
101
|
+
"C006": "off",
|
|
102
|
+
"C007": "warn",
|
|
103
|
+
"S012": "off"
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
"//rules": "Rule-specific configurations",
|
|
108
|
+
"rules": {
|
|
109
|
+
"//": "=== Quality Rules ===",
|
|
110
|
+
"C005": "error", "//C005": "Single Responsibility Principle",
|
|
111
|
+
"C006": "warn", "//C006": "Function Naming Conventions",
|
|
112
|
+
"C007": "error", "//C007": "Comment Quality Standards",
|
|
113
|
+
"C012": "warn", "//C012": "Command Query Separation",
|
|
114
|
+
"C014": "error", "//C014": "Dependency Injection Patterns",
|
|
115
|
+
"C015": "warn", "//C015": "Domain Language Usage",
|
|
116
|
+
"C019": "error", "//C019": "Proper Log Level Usage",
|
|
117
|
+
"C031": "error", "//C031": "Validation Separation",
|
|
118
|
+
"C037": "warn", "//C037": "API Response Format Standards",
|
|
119
|
+
|
|
120
|
+
"//": "=== Security Rules (sample - 43+ total) ===",
|
|
121
|
+
"S001": "error", "//S001": "Fail Securely Access Control",
|
|
122
|
+
"S002": "error", "//S002": "Prevent IDOR Vulnerabilities",
|
|
123
|
+
"S005": "error", "//S005": "No Origin Header Authentication",
|
|
124
|
+
"S007": "error", "//S007": "Secure OTP Storage",
|
|
125
|
+
"S008": "error", "//S008": "Crypto Agility Requirements",
|
|
126
|
+
"S012": "error", "//S012": "No Hardcoded Secrets",
|
|
127
|
+
"S013": "error", "//S013": "Always Use TLS",
|
|
128
|
+
|
|
129
|
+
"//": "Rule severity levels: 'error', 'warn', 'off'"
|
|
130
|
+
},
|
|
131
|
+
|
|
132
|
+
"//output": "Output formatting and destination",
|
|
133
|
+
"output": {
|
|
134
|
+
"format": "summary",
|
|
135
|
+
"//format-options": ["summary", "detailed", "json", "junit", "sarif"],
|
|
136
|
+
"file": null,
|
|
137
|
+
"//file-example": "reports/sunlint-report.json",
|
|
138
|
+
"colors": true,
|
|
139
|
+
"//": "Enable colorized output (auto-detected in CI)"
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
"//git": "Git integration settings",
|
|
143
|
+
"git": {
|
|
144
|
+
"changedFiles": {
|
|
145
|
+
"//": "Default branch for comparison",
|
|
146
|
+
"baseBranch": "main",
|
|
147
|
+
"includeUntracked": false,
|
|
148
|
+
"includeStagedOnly": false
|
|
149
|
+
},
|
|
150
|
+
"commitHooks": {
|
|
151
|
+
"preCommit": true,
|
|
152
|
+
"//": "Enable pre-commit validation",
|
|
153
|
+
"failOnViolations": true
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
|
|
157
|
+
"//baseline": "Baseline comparison for CI/CD",
|
|
158
|
+
"baseline": {
|
|
159
|
+
"enabled": false,
|
|
160
|
+
"file": ".sunlint-baseline.json",
|
|
161
|
+
"//": "Store baseline violations to track new issues only",
|
|
162
|
+
"updateOnPass": false
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
"//performance": "Performance and analysis settings",
|
|
166
|
+
"performance": {
|
|
167
|
+
"maxFileSize": "5MB",
|
|
168
|
+
"//": "Skip files larger than this size",
|
|
169
|
+
"parallel": true,
|
|
170
|
+
"//": "Enable parallel analysis (auto-detected based on CPU cores)",
|
|
171
|
+
"timeout": 30000,
|
|
172
|
+
"//": "Timeout per file in milliseconds"
|
|
173
|
+
},
|
|
174
|
+
|
|
175
|
+
"//eslint": "ESLint integration settings",
|
|
176
|
+
"eslint": {
|
|
177
|
+
"enabled": false,
|
|
178
|
+
"//": "Enable ESLint integration (--eslint-integration flag)",
|
|
179
|
+
"configFile": null,
|
|
180
|
+
"//configFile-example": ".eslintrc.js",
|
|
181
|
+
"mergeReports": true,
|
|
182
|
+
"//": "Merge ESLint violations with SunLint report"
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
"//react": "React.js specific configuration",
|
|
186
|
+
"react": {
|
|
187
|
+
"version": "detect",
|
|
188
|
+
"//": "React version for rule compatibility",
|
|
189
|
+
"rules": {
|
|
190
|
+
"R001": "error", "//R001": "Function Component Definition Style",
|
|
191
|
+
"R002": "warn", "//R002": "Avoid Side Effects in Render",
|
|
192
|
+
"R003": "error", "//R003": "No Direct State Mutation",
|
|
193
|
+
"R004": "warn", "//R004": "Prefer Readonly Props",
|
|
194
|
+
"R005": "warn", "//R005": "Avoid Function Binding in JSX",
|
|
195
|
+
"R006": "error", "//R006": "Component Naming Conventions",
|
|
196
|
+
"R007": "error", "//R007": "Proper Hook Usage",
|
|
197
|
+
"R008": "warn", "//R008": "Effect Dependencies",
|
|
198
|
+
"R009": "error" "//R009": "Conditional Hook Usage"
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
|
|
202
|
+
"//ai": "AI analysis settings (future feature)",
|
|
203
|
+
"ai": {
|
|
204
|
+
"enabled": false,
|
|
205
|
+
"provider": "openai",
|
|
206
|
+
"//provider-options": ["openai", "anthropic", "local"],
|
|
207
|
+
"model": "gpt-4",
|
|
208
|
+
"confidence": 0.8,
|
|
209
|
+
"//": "Minimum confidence threshold for AI suggestions"
|
|
210
|
+
},
|
|
211
|
+
|
|
212
|
+
"//debug": "Debug and development settings",
|
|
213
|
+
"debug": {
|
|
214
|
+
"verbose": false,
|
|
215
|
+
"//": "Enable verbose logging",
|
|
216
|
+
"timing": false,
|
|
217
|
+
"//": "Show performance timing information",
|
|
218
|
+
"dryRun": false,
|
|
219
|
+
"//": "Show what would be analyzed without running"
|
|
220
|
+
},
|
|
221
|
+
|
|
222
|
+
"//cache": "Analysis caching for performance",
|
|
223
|
+
"cache": {
|
|
224
|
+
"enabled": true,
|
|
225
|
+
"//": "Enable analysis result caching",
|
|
226
|
+
"directory": ".sunlint-cache",
|
|
227
|
+
"ttl": 86400,
|
|
228
|
+
"//": "Cache TTL in seconds (24 hours)"
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## 🚨 Migration Notes
|
|
234
|
+
|
|
235
|
+
**BREAKING CHANGE**: `ignorePatterns` has been deprecated in favor of `exclude` for better consistency.
|
|
236
|
+
|
|
237
|
+
**Migration:**
|
|
238
|
+
- **Old:** `"ignorePatterns": ["**/*.test.*"]`
|
|
239
|
+
- **New:** `"exclude": ["**/*.test.*"]`
|
|
240
|
+
|
|
241
|
+
## 📋 Configuration Presets
|
|
242
|
+
|
|
243
|
+
### Available Presets
|
|
244
|
+
- `@sun/sunlint/recommended` - Balanced rules for all projects
|
|
245
|
+
- `@sun/sunlint/security` - Security-focused rules only
|
|
246
|
+
- `@sun/sunlint/quality` - Quality-focused rules only
|
|
247
|
+
- `@sun/sunlint/beginner` - Gentle introduction for new teams
|
|
248
|
+
- `@sun/sunlint/ci` - Optimized for CI/CD environments
|
|
249
|
+
|
|
250
|
+
### Engine Selection
|
|
251
|
+
- `heuristic` - SunLint's native analysis engine (default)
|
|
252
|
+
- `eslint` - ESLint-based analysis
|
|
253
|
+
- `ai` - AI-powered analysis (future feature)
|
|
254
|
+
|
|
255
|
+
## 🎯 Common Configuration Examples
|
|
256
|
+
|
|
257
|
+
### Frontend Project
|
|
258
|
+
```json
|
|
259
|
+
{
|
|
260
|
+
"extends": "@sun/sunlint/recommended",
|
|
261
|
+
"input": ["src"],
|
|
262
|
+
"include": ["src/**/*.{js,ts,jsx,tsx}"],
|
|
263
|
+
"exclude": ["**/*.test.*", "**/*.d.ts", "**/dist/**"],
|
|
264
|
+
"languages": {
|
|
265
|
+
"typescript": {
|
|
266
|
+
"rules": {
|
|
267
|
+
"C006": "error",
|
|
268
|
+
"C019": "warn"
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### React.js Project
|
|
276
|
+
```json
|
|
277
|
+
{
|
|
278
|
+
"extends": "@sun/sunlint/recommended",
|
|
279
|
+
"input": ["src"],
|
|
280
|
+
"include": ["src/**/*.{js,ts,jsx,tsx}"],
|
|
281
|
+
"exclude": ["**/*.test.*", "**/*.d.ts", "**/dist/**"],
|
|
282
|
+
"react": {
|
|
283
|
+
"version": "detect",
|
|
284
|
+
"rules": {
|
|
285
|
+
"R001": "error",
|
|
286
|
+
"R002": "warn",
|
|
287
|
+
"R003": "error",
|
|
288
|
+
"R006": "error"
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
"eslint": {
|
|
292
|
+
"enabled": true,
|
|
293
|
+
"mergeReports": true
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### Backend API Project
|
|
299
|
+
```json
|
|
300
|
+
{
|
|
301
|
+
"extends": "@sun/sunlint/security",
|
|
302
|
+
"input": ["src", "api"],
|
|
303
|
+
"rules": {
|
|
304
|
+
"S001": "error",
|
|
305
|
+
"S005": "error",
|
|
306
|
+
"S012": "error",
|
|
307
|
+
"C031": "error"
|
|
308
|
+
},
|
|
309
|
+
"git": {
|
|
310
|
+
"changedFiles": {
|
|
311
|
+
"baseBranch": "develop"
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
### CI/CD Optimized
|
|
318
|
+
```json
|
|
319
|
+
{
|
|
320
|
+
"extends": "@sun/sunlint/ci",
|
|
321
|
+
"input": ["."],
|
|
322
|
+
"exclude": ["**/node_modules/**", "**/dist/**", "**/*.test.*"],
|
|
323
|
+
"output": {
|
|
324
|
+
"format": "json",
|
|
325
|
+
"file": "reports/sunlint-report.json"
|
|
326
|
+
},
|
|
327
|
+
"baseline": {
|
|
328
|
+
"enabled": true,
|
|
329
|
+
"file": ".sunlint-baseline.json"
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
## 🔧 ESLint Integration Setup
|
|
335
|
+
|
|
336
|
+
SunLint can integrate with existing ESLint configurations for seamless adoption:
|
|
337
|
+
|
|
338
|
+
### Basic Setup
|
|
339
|
+
1. **Enable ESLint integration:**
|
|
340
|
+
```bash
|
|
341
|
+
npx sunlint --eslint-integration --input=src
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
2. **Configure in `.sunlint.json`:**
|
|
345
|
+
```json
|
|
346
|
+
{
|
|
347
|
+
"eslint": {
|
|
348
|
+
"enabled": true,
|
|
349
|
+
"mergeReports": true
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
### React.js Integration
|
|
355
|
+
For React projects, SunLint automatically maps React rules to ESLint equivalents:
|
|
356
|
+
|
|
357
|
+
```bash
|
|
358
|
+
# Example: Analyze React components with both SunLint and ESLint rules
|
|
359
|
+
npx sunlint --rules=R001,R002,R006 --eslint-integration --input=src
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
**Required dependencies:**
|
|
363
|
+
```bash
|
|
364
|
+
npm install --save-dev \
|
|
365
|
+
eslint \
|
|
366
|
+
@typescript-eslint/parser \
|
|
367
|
+
@typescript-eslint/eslint-plugin \
|
|
368
|
+
eslint-plugin-react \
|
|
369
|
+
eslint-plugin-react-hooks
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
**Example `.eslintrc.js` for React:**
|
|
373
|
+
```javascript
|
|
374
|
+
module.exports = {
|
|
375
|
+
parser: '@typescript-eslint/parser',
|
|
376
|
+
parserOptions: {
|
|
377
|
+
ecmaVersion: 2020,
|
|
378
|
+
sourceType: 'module',
|
|
379
|
+
ecmaFeatures: { jsx: true }
|
|
380
|
+
},
|
|
381
|
+
plugins: ['@typescript-eslint', 'react', 'react-hooks'],
|
|
382
|
+
extends: [
|
|
383
|
+
'eslint:recommended',
|
|
384
|
+
'plugin:react/recommended',
|
|
385
|
+
'plugin:react-hooks/recommended'
|
|
386
|
+
],
|
|
387
|
+
settings: {
|
|
388
|
+
react: { version: 'detect' }
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
### Rule Mapping
|
|
394
|
+
SunLint automatically maps its rules to ESLint equivalents:
|
|
395
|
+
|
|
396
|
+
| SunLint Rule | ESLint Rule(s) | Description |
|
|
397
|
+
|--------------|----------------|-------------|
|
|
398
|
+
| R001 | `react/function-component-definition` | Function component style |
|
|
399
|
+
| R002 | `react-hooks/rules-of-hooks`, `react-hooks/exhaustive-deps` | Hook usage patterns |
|
|
400
|
+
| R003 | `react/no-direct-mutation-state` | Prevent state mutation |
|
|
401
|
+
| R006 | `react/jsx-pascal-case` | Component naming |
|
|
402
|
+
|
|
403
|
+
### Multi-Engine Orchestration
|
|
404
|
+
SunLint intelligently selects the best engine for each rule:
|
|
405
|
+
|
|
406
|
+
```bash
|
|
407
|
+
# Verbose output shows engine selection
|
|
408
|
+
npx sunlint --rules=C010,R001,T003 --eslint-integration --verbose
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
Engine preferences:
|
|
412
|
+
- **R*** rules: ESLint → Heuristic → AI
|
|
413
|
+
- **C*** rules: Heuristic → ESLint → AI
|
|
414
|
+
- **T*** rules: ESLint → Heuristic → AI
|