@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
package/.sunlint.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": ["recommended"],
|
|
3
|
+
"rules": {
|
|
4
|
+
"C019": "warn",
|
|
5
|
+
"C006": "warn",
|
|
6
|
+
"C029": "error",
|
|
7
|
+
"C031": "warn",
|
|
8
|
+
"S001": "warn",
|
|
9
|
+
"S002": "warn",
|
|
10
|
+
"S007": "warn",
|
|
11
|
+
"S013": "warn",
|
|
12
|
+
"T019": "error",
|
|
13
|
+
"T020": "warn",
|
|
14
|
+
"T021": "error"
|
|
15
|
+
},
|
|
16
|
+
"include": ["**/*.js", "**/*.ts", "**/*.jsx", "**/*.tsx"],
|
|
17
|
+
"exclude": [
|
|
18
|
+
"node_modules/**",
|
|
19
|
+
"coverage/**",
|
|
20
|
+
"**/*.min.*",
|
|
21
|
+
".git/**",
|
|
22
|
+
"dist/**",
|
|
23
|
+
"build/**"
|
|
24
|
+
],
|
|
25
|
+
"engine": "eslint",
|
|
26
|
+
"languages": ["typescript", "javascript"],
|
|
27
|
+
"output": {
|
|
28
|
+
"format": "summary",
|
|
29
|
+
"console": true
|
|
30
|
+
},
|
|
31
|
+
"fileTargeting": {
|
|
32
|
+
"followSymlinks": false,
|
|
33
|
+
"maxDepth": 10
|
|
34
|
+
}
|
|
35
|
+
}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,34 @@
|
|
|
1
|
-
# 🎉 SunLint v1.0
|
|
1
|
+
# 🎉 SunLint v1.1.0 Release Notes
|
|
2
2
|
|
|
3
|
-
**Release Date**: July
|
|
4
|
-
**Type**: Minor Release (
|
|
3
|
+
**Release Date**: July 23, 2025
|
|
4
|
+
**Type**: Minor Release (AST Enhancement & CLI Options Fix)
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 🚀 **Key Improvements**
|
|
9
|
+
|
|
10
|
+
### 🧠 **AST-Enhanced Analysis**
|
|
11
|
+
- **Enhanced**: Heuristic engine now supports AST-based analysis using ESLint's parser infrastructure
|
|
12
|
+
- **Improved**: Rule C010 (block nesting) now uses AST for accurate detection
|
|
13
|
+
- **Modular**: AST modules integrated with silent fallback to regex when parsing fails
|
|
14
|
+
- **Performance**: ESLint-based parsers (@babel/parser, @typescript-eslint/parser) for JS/TS analysis
|
|
15
|
+
|
|
16
|
+
### 🎯 **CLI Options Fix**
|
|
17
|
+
- **Fixed**: `--quality` option now correctly selects quality rules (30 rules)
|
|
18
|
+
- **Fixed**: `--security` option now correctly selects security rules (41 rules)
|
|
19
|
+
- **Enhanced**: Rule selection service properly filters by category
|
|
20
|
+
- **Validated**: Both options tested and working correctly
|
|
21
|
+
|
|
22
|
+
### 📦 **Package Optimization**
|
|
23
|
+
- **Reduced**: Package size from 8MB to 243KB by excluding nested node_modules
|
|
24
|
+
- **Clean**: Updated .npmignore to exclude development files
|
|
25
|
+
- **Dependencies**: Moved AST parser dependencies to root package.json
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 📋 **Previous Changes (v1.0.7)**
|
|
30
|
+
|
|
31
|
+
### 🔧 **Configuration Cleanup**
|
|
5
32
|
|
|
6
33
|
---
|
|
7
34
|
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
# Contributing to Sun Lint
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to Sun Lint! 🌟
|
|
4
|
+
|
|
5
|
+
## 🚀 **Getting Started**
|
|
6
|
+
|
|
7
|
+
### **Prerequisites**
|
|
8
|
+
- Node.js 16+
|
|
9
|
+
- npm 8+
|
|
10
|
+
- Git
|
|
11
|
+
|
|
12
|
+
### **Setup Development Environment**
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
# Clone the repository
|
|
16
|
+
git clone https://github.com/sun-engineering/sunlint.git
|
|
17
|
+
cd sunlint
|
|
18
|
+
|
|
19
|
+
# Install dependencies
|
|
20
|
+
npm install
|
|
21
|
+
|
|
22
|
+
# Run tests
|
|
23
|
+
npm test
|
|
24
|
+
|
|
25
|
+
# Try the CLI locally
|
|
26
|
+
node cli.js --help
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## 📋 **Coding Standards**
|
|
30
|
+
|
|
31
|
+
When contributing to Sun Lint, please follow these coding rules:
|
|
32
|
+
|
|
33
|
+
### **Code Quality Rules**
|
|
34
|
+
- **Rule C005** – Each function should do one thing only
|
|
35
|
+
- **Rule C006** – Function names must be verb/verb-noun
|
|
36
|
+
- **Rule C007** – Avoid comments that just describe the code
|
|
37
|
+
- **Rule C012** – Separate Command and Query operations (CQS principle)
|
|
38
|
+
- **Rule C014** – Use Dependency Injection instead of direct instantiation
|
|
39
|
+
- **Rule C015** – Use domain language in class/function names
|
|
40
|
+
- **Rule C019** – Don't use `error` log level for non-critical errors
|
|
41
|
+
- **Rule C031** – Keep validation logic separate
|
|
42
|
+
- **Rule C032** – Don't call external APIs in constructors or static blocks
|
|
43
|
+
- **Rule C033** – Separate processing logic and data queries in service layer
|
|
44
|
+
- **Rule C034** – Limit direct access to global state in domain logic
|
|
45
|
+
- **Rule C035** – When handling errors, log complete relevant information
|
|
46
|
+
- **Rule C037** – API handlers should return standard response objects (not raw strings)
|
|
47
|
+
- **Rule C038** – Avoid logic depending on file/module loading order
|
|
48
|
+
- **Rule C040** – Don't scatter validation logic across multiple classes
|
|
49
|
+
|
|
50
|
+
## 🔧 **Development Workflow**
|
|
51
|
+
|
|
52
|
+
### **Adding a New Quality Rule**
|
|
53
|
+
|
|
54
|
+
1. **Create Rule Implementation**
|
|
55
|
+
```bash
|
|
56
|
+
# Create the rule directory
|
|
57
|
+
mkdir -p rules/quality/c042-new-rule
|
|
58
|
+
cd rules/quality/c042-new-rule
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
2. **Implement the Rule**
|
|
62
|
+
```javascript
|
|
63
|
+
// rules/quality/c042-new-rule/analyzer.js
|
|
64
|
+
class C042NewRuleAnalyzer {
|
|
65
|
+
analyze(code, filePath) {
|
|
66
|
+
// Implementation following Rule C005 (single responsibility)
|
|
67
|
+
return this.findViolations(code, filePath);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
findViolations(code, filePath) {
|
|
71
|
+
// Rule C031: Keep validation logic separate
|
|
72
|
+
const violations = [];
|
|
73
|
+
// Analysis logic here
|
|
74
|
+
return violations;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
module.exports = C042NewRuleAnalyzer;
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
3. **Add Configuration**
|
|
82
|
+
```json
|
|
83
|
+
// rules/quality/c042-new-rule/config.json
|
|
84
|
+
{
|
|
85
|
+
"id": "C042",
|
|
86
|
+
"name": "New Rule Name",
|
|
87
|
+
"category": "quality",
|
|
88
|
+
"severity": "error",
|
|
89
|
+
"description": "Description following Rule C015 (domain language)",
|
|
90
|
+
"languages": ["typescript", "dart", "kotlin"],
|
|
91
|
+
"tags": ["maintainability", "readability"]
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
4. **Update Registry**
|
|
96
|
+
```javascript
|
|
97
|
+
// Add to config/rules/rules-registry.json
|
|
98
|
+
{
|
|
99
|
+
"C042": {
|
|
100
|
+
"id": "C042",
|
|
101
|
+
"name": "New Rule Name",
|
|
102
|
+
"category": "quality",
|
|
103
|
+
"path": "./rules/quality/c042-new-rule",
|
|
104
|
+
"analyzer": "analyzer.js",
|
|
105
|
+
"config": "config.json"
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
5. **Add Tests**
|
|
111
|
+
```javascript
|
|
112
|
+
// test/fixtures/c042/valid.ts
|
|
113
|
+
// test/fixtures/c042/invalid.ts
|
|
114
|
+
// test/unit/rules/c042.test.js
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### **Adding a New Security Rule**
|
|
118
|
+
|
|
119
|
+
Same process but in `rules/security/` directory with `security` category.
|
|
120
|
+
|
|
121
|
+
## 🧪 **Testing**
|
|
122
|
+
|
|
123
|
+
### **Run All Tests**
|
|
124
|
+
```bash
|
|
125
|
+
npm test
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### **Run Specific Tests**
|
|
129
|
+
```bash
|
|
130
|
+
# Test specific rule
|
|
131
|
+
npm run test:c019
|
|
132
|
+
|
|
133
|
+
# Test multiple rules
|
|
134
|
+
npm run test:multi
|
|
135
|
+
|
|
136
|
+
# Test all quality rules
|
|
137
|
+
npm run test:quality
|
|
138
|
+
|
|
139
|
+
# Test all security rules
|
|
140
|
+
npm run test:security
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### **Test Your Changes**
|
|
144
|
+
```bash
|
|
145
|
+
# Test your new rule
|
|
146
|
+
node cli.js --rule=C042 --input=test/fixtures --format=eslint
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## 📊 **Code Review Process**
|
|
150
|
+
|
|
151
|
+
1. **Self-Review Checklist**
|
|
152
|
+
- [ ] Follows all Sun Lint coding rules (C005, C006, etc.)
|
|
153
|
+
- [ ] Rule C035: Error handling includes complete logging
|
|
154
|
+
- [ ] Rule C037: API responses use standard format
|
|
155
|
+
- [ ] Rule C040: Validation logic is centralized
|
|
156
|
+
- [ ] Tests pass and cover edge cases
|
|
157
|
+
- [ ] Documentation updated
|
|
158
|
+
|
|
159
|
+
2. **Submit Pull Request**
|
|
160
|
+
- Clear title and description
|
|
161
|
+
- Reference related issues
|
|
162
|
+
- Include test results
|
|
163
|
+
- Follow template
|
|
164
|
+
|
|
165
|
+
3. **Review Criteria**
|
|
166
|
+
- Code quality (follows our own rules!)
|
|
167
|
+
- Test coverage
|
|
168
|
+
- Documentation completeness
|
|
169
|
+
- Performance impact
|
|
170
|
+
- Backward compatibility
|
|
171
|
+
|
|
172
|
+
## 📝 **Documentation**
|
|
173
|
+
|
|
174
|
+
### **Update Documentation**
|
|
175
|
+
When adding features:
|
|
176
|
+
- Update `README.md`
|
|
177
|
+
- Add rule documentation
|
|
178
|
+
- Update configuration examples
|
|
179
|
+
- Add usage examples
|
|
180
|
+
|
|
181
|
+
### **Rule Documentation Template**
|
|
182
|
+
```markdown
|
|
183
|
+
## Rule C042: New Rule Name
|
|
184
|
+
|
|
185
|
+
**Category**: Quality
|
|
186
|
+
**Severity**: Error
|
|
187
|
+
**Languages**: TypeScript, Dart, Kotlin
|
|
188
|
+
|
|
189
|
+
### Description
|
|
190
|
+
Following Rule C015 (domain language), use clear business terms...
|
|
191
|
+
|
|
192
|
+
### Examples
|
|
193
|
+
|
|
194
|
+
**❌ Bad:**
|
|
195
|
+
```typescript
|
|
196
|
+
// Code that violates the rule
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
**✅ Good:**
|
|
200
|
+
```typescript
|
|
201
|
+
// Code that follows the rule
|
|
202
|
+
```
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## 🐛 **Bug Reports**
|
|
206
|
+
|
|
207
|
+
When reporting bugs:
|
|
208
|
+
1. Use clear, descriptive title
|
|
209
|
+
2. Include reproduction steps
|
|
210
|
+
3. Provide sample code
|
|
211
|
+
4. Include environment details
|
|
212
|
+
5. Include sunlint output
|
|
213
|
+
|
|
214
|
+
## 💡 **Feature Requests**
|
|
215
|
+
|
|
216
|
+
For new features:
|
|
217
|
+
1. Check existing issues first
|
|
218
|
+
2. Describe the use case
|
|
219
|
+
3. Provide examples
|
|
220
|
+
4. Consider implementation complexity
|
|
221
|
+
5. Think about backward compatibility
|
|
222
|
+
|
|
223
|
+
## 🤝 **Community**
|
|
224
|
+
|
|
225
|
+
- **Discord**: [Sun Engineering Discord](https://discord.gg/sun-engineering)
|
|
226
|
+
- **Issues**: [GitHub Issues](https://github.com/sun-engineering/sunlint/issues)
|
|
227
|
+
- **Discussions**: [GitHub Discussions](https://github.com/sun-engineering/sunlint/discussions)
|
|
228
|
+
|
|
229
|
+
## 📄 **License**
|
|
230
|
+
|
|
231
|
+
By contributing, you agree that your contributions will be licensed under the MIT License.
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
**Thank you for making Sun Lint better! ☀️**
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# SunLint Project Structure
|
|
2
|
+
|
|
3
|
+
## 📁 **Organized Directory Structure**
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
sunlint/
|
|
7
|
+
├── 📄 README.md # Main documentation (490 lines, focused)
|
|
8
|
+
├── 📄 CHANGELOG.md # Version history (concise)
|
|
9
|
+
├── 🚀 cli.js # Main CLI entry point
|
|
10
|
+
├── ⚙️ config/ # Configuration presets & schemas
|
|
11
|
+
├── 🔧 core/ # Core services & engines
|
|
12
|
+
├── 📖 docs/ # Detailed documentation
|
|
13
|
+
├── 🔗 integrations/ # External tool integrations
|
|
14
|
+
│ └── eslint/ # ESLint plugin & configurations
|
|
15
|
+
├── 📋 examples/ # Configuration examples & workflows
|
|
16
|
+
├── 🧪 test/ # Test projects & fixtures
|
|
17
|
+
├── 📦 release/ # Release artifacts
|
|
18
|
+
├── 🎯 rules/ # SunLint rule implementations
|
|
19
|
+
└── 🛠️ scripts/ # Build & deployment scripts
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 🎯 **Key Changes Made**
|
|
23
|
+
|
|
24
|
+
### ✅ **Files Removed**
|
|
25
|
+
- `CLI_STRUCTURE.md` - Temporary documentation (unnecessary)
|
|
26
|
+
|
|
27
|
+
### ✅ **Structure Reorganized**
|
|
28
|
+
- **examples/** - Now pure configuration examples & CI/CD workflows
|
|
29
|
+
- **test/** - All test projects consolidated here
|
|
30
|
+
- `sunlint-test-project/` - ESLint v9 integration test
|
|
31
|
+
- `conflict-test-project/` - ESLint v8 legacy test
|
|
32
|
+
- `examples/integration-project/` - Integration example
|
|
33
|
+
- `fixtures/` - Unit test files
|
|
34
|
+
- **project-test/** - Real projects (gitignored, separate from test suite)
|
|
35
|
+
|
|
36
|
+
### ✅ **Documentation Updated**
|
|
37
|
+
- **README.md** - Streamlined from 650 → 490 lines (25% reduction)
|
|
38
|
+
- **CHANGELOG.md** - Security rules section condensed
|
|
39
|
+
- **test/README.md** - Test project documentation
|
|
40
|
+
- **examples/README.md** - Configuration examples guide
|
|
41
|
+
|
|
42
|
+
## 🎉 **Benefits**
|
|
43
|
+
|
|
44
|
+
1. **Clear Separation**: Examples vs Tests vs Real Projects
|
|
45
|
+
2. **Reduced Duplication**: Single source of truth for each purpose
|
|
46
|
+
3. **Better Documentation**: Focused README + detailed CHANGELOG
|
|
47
|
+
4. **Cleaner Repository**: No redundant files, proper gitignore
|
|
48
|
+
5. **Developer Friendly**: Clear structure for contributors
|
|
49
|
+
|
|
50
|
+
## 🔍 **Quick Navigation**
|
|
51
|
+
|
|
52
|
+
- **Getting Started**: `README.md`
|
|
53
|
+
- **Version History**: `CHANGELOG.md`
|
|
54
|
+
- **Configuration Help**: `examples/`
|
|
55
|
+
- **Testing**: `test/`
|
|
56
|
+
- **Development**: `docs/ARCHITECTURE.md`
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
**Structure optimized for both users and contributors! 🚀**
|
package/README.md
CHANGED
|
@@ -7,10 +7,11 @@
|
|
|
7
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
|
-
- ✅ **
|
|
11
|
-
- ✅ **
|
|
10
|
+
- ✅ **97+ Coding Rules**: Quality (30), Security (47), TypeScript-specific
|
|
11
|
+
- ✅ **AST-Enhanced Analysis**: Superior accuracy with Babel/ESLint parsers
|
|
12
|
+
- ✅ **Multi-Engine Architecture**: Heuristic + ESLint + OpenAI integration
|
|
12
13
|
- ✅ **Git Integration**: `--changed-files`, `--staged-files`, `--pr-mode`
|
|
13
|
-
- ✅ **TypeScript Support**: Native TypeScript analysis
|
|
14
|
+
- ✅ **TypeScript Support**: Native TypeScript 5.8+ analysis
|
|
14
15
|
- ✅ **CI/CD Ready**: Baseline comparison, fail-on-new-violations
|
|
15
16
|
- ✅ **Advanced File Targeting**: Include/exclude patterns, language filtering
|
|
16
17
|
|
|
@@ -19,13 +20,18 @@ Sun Lint is a universal coding standards checker providing comprehensive code qu
|
|
|
19
20
|
# Install globally
|
|
20
21
|
npm install -g @sun-asterisk/sunlint
|
|
21
22
|
|
|
22
|
-
# Basic usage
|
|
23
|
+
# Basic usage (uses config file or default patterns)
|
|
24
|
+
sunlint --all
|
|
25
|
+
sunlint --rules=C019,C006
|
|
26
|
+
|
|
27
|
+
# Explicit input specification
|
|
23
28
|
sunlint --all --input=src
|
|
24
29
|
sunlint --rules=C019,C006 --input=src
|
|
25
30
|
sunlint --quality --input=src
|
|
31
|
+
sunlint --security --input=src
|
|
26
32
|
|
|
27
|
-
# ESLint integration
|
|
28
|
-
sunlint --
|
|
33
|
+
# ESLint integration (multi-engine analysis)
|
|
34
|
+
sunlint --rules=C010,C006 --eslint-integration --input=src
|
|
29
35
|
|
|
30
36
|
# Git integration
|
|
31
37
|
sunlint --all --changed-files
|
|
@@ -57,14 +63,25 @@ npm install --save-dev @sun-asterisk/sunlint
|
|
|
57
63
|
Seamlessly integrate with existing ESLint configurations:
|
|
58
64
|
|
|
59
65
|
```bash
|
|
60
|
-
# Analyze with both SunLint + existing ESLint rules
|
|
66
|
+
# Analyze with both SunLint + existing ESLint rules
|
|
61
67
|
sunlint --all --eslint-integration --input=src
|
|
68
|
+
|
|
69
|
+
# Mix ESLint and heuristic engines based on rule compatibility
|
|
70
|
+
sunlint --rules=C010,C006 --eslint-integration --input=src
|
|
62
71
|
```
|
|
63
72
|
|
|
64
|
-
|
|
73
|
+
**✅ Current Status:**
|
|
74
|
+
- ✅ **Multi-engine orchestration**: Rules automatically routed to optimal engine
|
|
75
|
+
- ✅ **ESLint v8/v9 compatibility**: Production-ready with both major versions
|
|
76
|
+
- ✅ **TypeScript support**: Full TS/TSX parsing with custom rule implementation
|
|
77
|
+
- ✅ **Custom rule integration**: 27+ SunLint custom rules via ESLint engine
|
|
78
|
+
- ✅ **Smart fallback**: Automatic engine fallback for maximum rule coverage
|
|
79
|
+
- ✅ **Production tested**: Successfully processes real projects with mixed violations
|
|
80
|
+
|
|
81
|
+
**Benefits:**
|
|
65
82
|
- ✅ **No workflow disruption**: Existing ESLint continues working
|
|
66
|
-
- ✅ **
|
|
67
|
-
- ✅ **Combined reporting**: Unified violation tracking
|
|
83
|
+
- ✅ **Engine flexibility**: Automatic best-engine selection per rule
|
|
84
|
+
- ✅ **Combined reporting**: Unified violation tracking from multiple engines
|
|
68
85
|
|
|
69
86
|
## 🔀 **Git Integration**
|
|
70
87
|
|
|
@@ -107,69 +124,59 @@ sunlint --all --only-source --input=src
|
|
|
107
124
|
|
|
108
125
|
## 📋 **Available Rules**
|
|
109
126
|
|
|
110
|
-
### **Quality Rules** ✨ (
|
|
127
|
+
### **Quality Rules** ✨ (30 rules)
|
|
111
128
|
| Rule ID | Name | Status |
|
|
112
129
|
|---------|------|--------|
|
|
113
|
-
| **
|
|
114
|
-
| **
|
|
115
|
-
| **
|
|
116
|
-
| **
|
|
130
|
+
| **C002** | No Duplicate Code | ✅ Stable |
|
|
131
|
+
| **C003** | No Vague Abbreviations | ✅ Stable |
|
|
132
|
+
| **C006** | Function Naming Convention | ✅ Stable |
|
|
133
|
+
| **C010** | Limit Block Nesting | ✅ Stable |
|
|
134
|
+
| **C013** | No Dead Code | ✅ Stable |
|
|
117
135
|
| **C014** | Dependency Injection | ✅ Stable |
|
|
118
|
-
| **
|
|
136
|
+
| **C017** | Limit Constructor Logic | ✅ Stable |
|
|
137
|
+
| **C018** | No Generic Throw | ✅ Stable |
|
|
119
138
|
| **C019** | Log Level Usage | ✅ Stable |
|
|
139
|
+
| **C023** | No Duplicate Variable Names | ✅ Stable |
|
|
140
|
+
| **C029** | Catch Block Logging | ✅ Stable |
|
|
141
|
+
| **C030** | Use Custom Error Classes | ✅ Stable |
|
|
120
142
|
| **C031** | Validation Separation | ✅ Stable |
|
|
121
|
-
| **
|
|
122
|
-
|
|
123
|
-
|
|
143
|
+
| **C041** | No Hardcoded Config | ✅ Stable |
|
|
144
|
+
| **C042** | Boolean Name Prefix | ✅ Stable |
|
|
145
|
+
| **C043** | No Console or Print | ✅ Stable |
|
|
146
|
+
| **C047** | No Duplicate Retry Logic | ✅ Stable |
|
|
147
|
+
| **C075** | Explicit Function Return Types | ✅ Stable |
|
|
148
|
+
| **C076** | Single Test Behavior | ✅ Stable |
|
|
149
|
+
| **T002-T021** | TypeScript-specific rules | ✅ Stable |
|
|
150
|
+
|
|
151
|
+
### **Security Rules** 🔒 (47 rules)
|
|
124
152
|
| Rule ID | Name | Status |
|
|
125
153
|
|---------|------|--------|
|
|
126
154
|
| **S001** | Fail Securely Access Control | ✅ Stable |
|
|
127
155
|
| **S002** | Prevent IDOR Vulnerabilities | ✅ Stable |
|
|
156
|
+
| **S003** | URL Redirect Validation | ✅ Stable |
|
|
128
157
|
| **S005** | No Origin Header Authentication | ✅ Stable |
|
|
158
|
+
| **S006** | Activation Recovery Not Plaintext | ✅ Stable |
|
|
129
159
|
| **S007** | Secure OTP Storage | ✅ Stable |
|
|
130
160
|
| **S008** | Crypto Agility | ✅ Stable |
|
|
161
|
+
| **S009** | No Insecure Crypto | ✅ Stable |
|
|
162
|
+
| **S010** | Secure Random Generation | ✅ Stable |
|
|
163
|
+
| **S011** | Secure UUID Generation | ✅ Stable |
|
|
131
164
|
| **S012** | No Hardcoded Secrets | ✅ Stable |
|
|
132
165
|
| **S013** | Always Use TLS | ✅ Stable |
|
|
133
|
-
| **S014
|
|
166
|
+
| **S014** | Secure TLS Version | ✅ Stable |
|
|
167
|
+
| **S015** | Valid TLS Certificate | ✅ Stable |
|
|
168
|
+
| **S016-S058** | *...Additional security rules* | ✅ Stable |
|
|
134
169
|
|
|
135
170
|
## ⚙️ **Configuration**
|
|
136
171
|
|
|
137
172
|
Create `.sunlint.json` in your project root:
|
|
138
173
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
### **Basic Configuration**
|
|
174
|
+
### **Quick Start Configuration**
|
|
142
175
|
```json
|
|
143
176
|
{
|
|
144
177
|
"extends": "@sun/sunlint/recommended",
|
|
145
|
-
"
|
|
146
|
-
"C019": "error",
|
|
147
|
-
"C006": "warn",
|
|
148
|
-
"S005": "error"
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
### **Advanced Configuration**
|
|
154
|
-
```json
|
|
155
|
-
{
|
|
156
|
-
"extends": "@sun/sunlint/recommended",
|
|
157
|
-
|
|
158
|
-
"include": ["src/**", "lib/**"],
|
|
178
|
+
"input": ["src"],
|
|
159
179
|
"exclude": ["**/*.test.*", "**/*.generated.*"],
|
|
160
|
-
|
|
161
|
-
"languages": {
|
|
162
|
-
"typescript": {
|
|
163
|
-
"include": ["**/*.ts", "**/*.tsx"],
|
|
164
|
-
"exclude": ["**/*.d.ts"]
|
|
165
|
-
}
|
|
166
|
-
},
|
|
167
|
-
|
|
168
|
-
"testPatterns": {
|
|
169
|
-
"include": ["**/*.test.*", "**/*.spec.*"],
|
|
170
|
-
"rules": { "C006": "off" }
|
|
171
|
-
},
|
|
172
|
-
|
|
173
180
|
"rules": {
|
|
174
181
|
"C019": "error",
|
|
175
182
|
"C006": "warn",
|
|
@@ -178,13 +185,26 @@ Create `.sunlint.json` in your project root:
|
|
|
178
185
|
}
|
|
179
186
|
```
|
|
180
187
|
|
|
181
|
-
### **
|
|
188
|
+
### **Available Presets**
|
|
182
189
|
- `@sun/sunlint/recommended` - Balanced rules for all projects
|
|
183
|
-
- `@sun/sunlint/security` - Security-focused rules only
|
|
190
|
+
- `@sun/sunlint/security` - Security-focused rules only
|
|
184
191
|
- `@sun/sunlint/quality` - Quality-focused rules only
|
|
185
192
|
- `@sun/sunlint/beginner` - Gentle introduction for new teams
|
|
186
193
|
- `@sun/sunlint/ci` - Optimized for CI/CD environments
|
|
187
194
|
|
|
195
|
+
### **Full Configuration Reference**
|
|
196
|
+
📖 **[View Complete Configuration Guide](./docs/CONFIGURATION.md)**
|
|
197
|
+
|
|
198
|
+
Complete reference with all available options:
|
|
199
|
+
- File targeting (`include`, `exclude`, `languages`)
|
|
200
|
+
- Rule configurations with detailed descriptions
|
|
201
|
+
- Git integration settings (`changedFiles`, `baseline`)
|
|
202
|
+
- ESLint integration options
|
|
203
|
+
- Performance and caching settings
|
|
204
|
+
- CI/CD optimizations
|
|
205
|
+
|
|
206
|
+
> **🚨 MIGRATION NOTE**: `ignorePatterns` is deprecated. Use `exclude` instead. Run `npx sunlint migrate-config` to auto-migrate.
|
|
207
|
+
|
|
188
208
|
## 🎮 **Usage Examples**
|
|
189
209
|
|
|
190
210
|
### **Development**
|
|
@@ -213,6 +233,7 @@ sunlint --all --staged-files --format=summary
|
|
|
213
233
|
|
|
214
234
|
## 📚 **Documentation**
|
|
215
235
|
|
|
236
|
+
- **[Configuration Guide](./docs/CONFIGURATION.md)** - Complete config options with examples
|
|
216
237
|
- [ESLint Integration Guide](./docs/ESLINT_INTEGRATION.md)
|
|
217
238
|
- [CI/CD Guide](./docs/CI-CD-GUIDE.md)
|
|
218
239
|
- [Architecture](./docs/ARCHITECTURE.md)
|
package/cli.js
CHANGED
package/config/README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# SunLint Configuration Structure
|
|
2
|
+
|
|
3
|
+
This folder contains all configuration files for SunLint, organized for clarity and maintainability.
|
|
4
|
+
|
|
5
|
+
## 📁 Structure Overview
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
config/
|
|
9
|
+
├── schemas/ # JSON schemas for validation
|
|
10
|
+
│ └── sunlint-schema.json # Main SunLint config schema
|
|
11
|
+
├── engines/ # Analysis engine configurations
|
|
12
|
+
│ ├── engines.json # Available engines (ESLint, TypeScript, etc.)
|
|
13
|
+
│ └── eslint-rule-mapping.json # ESLint rule mappings
|
|
14
|
+
├── presets/ # Pre-defined rule configurations
|
|
15
|
+
│ ├── beginner.json # Beginner-friendly preset
|
|
16
|
+
│ ├── ci.json # CI/CD optimized preset
|
|
17
|
+
│ ├── recommended.json # Recommended preset
|
|
18
|
+
│ └── strict.json # Strict coding standards
|
|
19
|
+
├── integrations/ # Integration-specific configs
|
|
20
|
+
│ └── eslint/
|
|
21
|
+
│ ├── base.config.js # Base ESLint configuration
|
|
22
|
+
│ ├── typescript.config.js # TypeScript ESLint config
|
|
23
|
+
│ └── simple.config.js # Simplified ESLint config
|
|
24
|
+
├── rules/ # Rule definitions and registry
|
|
25
|
+
│ └── rules-registry.json # Master rule registry
|
|
26
|
+
├── defaults/ # Default configurations
|
|
27
|
+
│ ├── default.json # Default SunLint settings
|
|
28
|
+
│ └── ai-rules-context.json # AI analysis context
|
|
29
|
+
└── testing/ # Test configurations and samples
|
|
30
|
+
└── test-s005-working.ts # Test file for S005 rule
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 🎯 Key Improvements
|
|
34
|
+
|
|
35
|
+
### ✅ Eliminated Duplicates
|
|
36
|
+
- **Before**: ESLint configs in both `config/typescript/` and `integrations/eslint/`
|
|
37
|
+
- **After**: All ESLint configs consolidated in `config/integrations/eslint/`
|
|
38
|
+
|
|
39
|
+
### ✅ Logical Organization
|
|
40
|
+
- **Schemas**: All JSON schemas in one place
|
|
41
|
+
- **Engines**: Engine-specific configurations separated
|
|
42
|
+
- **Presets**: User-facing preset configurations grouped
|
|
43
|
+
- **Integrations**: Third-party integration configs organized by tool
|
|
44
|
+
|
|
45
|
+
### ✅ Reduced Complexity
|
|
46
|
+
- **Before**: 10+ files scattered in root config/
|
|
47
|
+
- **After**: Organized into 6 logical categories
|
|
48
|
+
|
|
49
|
+
## 📋 Usage
|
|
50
|
+
|
|
51
|
+
### For ESLint Integration
|
|
52
|
+
```bash
|
|
53
|
+
# Use the consolidated TypeScript ESLint config
|
|
54
|
+
npx eslint --config config/integrations/eslint/typescript.config.js src/
|
|
55
|
+
|
|
56
|
+
# Use the base ESLint config
|
|
57
|
+
npx eslint --config config/integrations/eslint/base.config.js src/
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### For Rule Presets
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"extends": "config/presets/recommended.json"
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### For Schema Validation
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"$schema": "config/schemas/sunlint-schema.json"
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## 🔧 Migration Notes
|
|
75
|
+
|
|
76
|
+
- **Old `config/typescript/`**: ❌ Removed (duplicated functionality)
|
|
77
|
+
- **ESLint configs**: ✅ Moved to `config/integrations/eslint/`
|
|
78
|
+
- **Default configs**: ✅ Moved to `config/defaults/`
|
|
79
|
+
- **Engine configs**: ✅ Moved to `config/engines/`
|
|
80
|
+
|
|
81
|
+
## 🚀 Next Steps
|
|
82
|
+
|
|
83
|
+
1. Update documentation references to new paths
|
|
84
|
+
2. Update CI/CD scripts to use new config locations
|
|
85
|
+
3. Consider adding more integration-specific configs as needed
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
*Last updated: July 21, 2025 | SunLint Config Refactor*
|