@sfdxy/mule-lint 1.7.2 → 1.8.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/README.md +35 -0
- package/dist/bin/mule-lint-mcp.d.ts +3 -0
- package/dist/bin/mule-lint-mcp.d.ts.map +1 -0
- package/dist/bin/mule-lint-mcp.js +13 -0
- package/dist/bin/mule-lint-mcp.js.map +1 -0
- package/dist/package.json +6 -3
- package/dist/src/core/ComplexityCalculator.d.ts.map +1 -1
- package/dist/src/core/ComplexityCalculator.js +8 -8
- package/dist/src/core/ComplexityCalculator.js.map +1 -1
- package/dist/src/core/FileScanner.d.ts.map +1 -1
- package/dist/src/core/FileScanner.js +11 -12
- package/dist/src/core/FileScanner.js.map +1 -1
- package/dist/src/core/XPathHelper.d.ts.map +1 -1
- package/dist/src/core/XPathHelper.js +23 -23
- package/dist/src/core/XPathHelper.js.map +1 -1
- package/dist/src/core/XmlParser.js +1 -1
- package/dist/src/core/XmlParser.js.map +1 -1
- package/dist/src/core/YamlParser.d.ts.map +1 -1
- package/dist/src/core/YamlParser.js +1 -1
- package/dist/src/core/YamlParser.js.map +1 -1
- package/dist/src/engine/LintEngine.d.ts.map +1 -1
- package/dist/src/engine/LintEngine.js +6 -4
- package/dist/src/engine/LintEngine.js.map +1 -1
- package/dist/src/formatters/CsvFormatter.d.ts.map +1 -1
- package/dist/src/formatters/CsvFormatter.js +6 -4
- package/dist/src/formatters/CsvFormatter.js.map +1 -1
- package/dist/src/formatters/HtmlFormatter.d.ts.map +1 -1
- package/dist/src/formatters/HtmlFormatter.js +12 -7
- package/dist/src/formatters/HtmlFormatter.js.map +1 -1
- package/dist/src/formatters/SarifFormatter.d.ts.map +1 -1
- package/dist/src/formatters/SarifFormatter.js +20 -10
- package/dist/src/formatters/SarifFormatter.js.map +1 -1
- package/dist/src/formatters/TableFormatter.d.ts.map +1 -1
- package/dist/src/formatters/TableFormatter.js +1 -1
- package/dist/src/formatters/TableFormatter.js.map +1 -1
- package/dist/src/mcp/index.d.ts +13 -0
- package/dist/src/mcp/index.d.ts.map +1 -0
- package/dist/src/mcp/index.js +375 -0
- package/dist/src/mcp/index.js.map +1 -0
- package/dist/src/rules/api-led/ApiLedRules.d.ts.map +1 -1
- package/dist/src/rules/api-led/ApiLedRules.js +3 -1
- package/dist/src/rules/api-led/ApiLedRules.js.map +1 -1
- package/dist/src/rules/base/BaseRule.d.ts.map +1 -1
- package/dist/src/rules/base/BaseRule.js +1 -1
- package/dist/src/rules/base/BaseRule.js.map +1 -1
- package/dist/src/rules/complexity/FlowComplexityRule.d.ts.map +1 -1
- package/dist/src/rules/complexity/FlowComplexityRule.js +3 -5
- package/dist/src/rules/complexity/FlowComplexityRule.js.map +1 -1
- package/dist/src/rules/dataweave/DataWeaveRules.d.ts.map +1 -1
- package/dist/src/rules/dataweave/DataWeaveRules.js +5 -5
- package/dist/src/rules/dataweave/DataWeaveRules.js.map +1 -1
- package/dist/src/rules/dataweave/Java17DWErrorHandlingRule.d.ts +21 -0
- package/dist/src/rules/dataweave/Java17DWErrorHandlingRule.d.ts.map +1 -0
- package/dist/src/rules/dataweave/Java17DWErrorHandlingRule.js +162 -0
- package/dist/src/rules/dataweave/Java17DWErrorHandlingRule.js.map +1 -0
- package/dist/src/rules/documentation/FlowDescriptionRule.d.ts.map +1 -1
- package/dist/src/rules/documentation/FlowDescriptionRule.js +1 -1
- package/dist/src/rules/documentation/FlowDescriptionRule.js.map +1 -1
- package/dist/src/rules/documentation/MissingDocNameRule.d.ts.map +1 -1
- package/dist/src/rules/documentation/MissingDocNameRule.js +1 -1
- package/dist/src/rules/documentation/MissingDocNameRule.js.map +1 -1
- package/dist/src/rules/error-handling/CorrelationIdRule.d.ts.map +1 -1
- package/dist/src/rules/error-handling/CorrelationIdRule.js +1 -1
- package/dist/src/rules/error-handling/CorrelationIdRule.js.map +1 -1
- package/dist/src/rules/error-handling/GenericErrorRule.d.ts.map +1 -1
- package/dist/src/rules/error-handling/GenericErrorRule.js +2 -5
- package/dist/src/rules/error-handling/GenericErrorRule.js.map +1 -1
- package/dist/src/rules/error-handling/GlobalErrorHandlerRule.d.ts.map +1 -1
- package/dist/src/rules/error-handling/GlobalErrorHandlerRule.js +1 -1
- package/dist/src/rules/error-handling/GlobalErrorHandlerRule.js.map +1 -1
- package/dist/src/rules/error-handling/HttpStatusRule.d.ts.map +1 -1
- package/dist/src/rules/error-handling/HttpStatusRule.js +1 -1
- package/dist/src/rules/error-handling/HttpStatusRule.js.map +1 -1
- package/dist/src/rules/error-handling/MissingErrorHandlerRule.d.ts.map +1 -1
- package/dist/src/rules/error-handling/MissingErrorHandlerRule.js +1 -1
- package/dist/src/rules/error-handling/MissingErrorHandlerRule.js.map +1 -1
- package/dist/src/rules/experimental/ExperimentalRules.d.ts.map +1 -1
- package/dist/src/rules/experimental/ExperimentalRules.js +1 -1
- package/dist/src/rules/experimental/ExperimentalRules.js.map +1 -1
- package/dist/src/rules/http/HttpContentTypeRule.d.ts.map +1 -1
- package/dist/src/rules/http/HttpContentTypeRule.js +1 -1
- package/dist/src/rules/http/HttpContentTypeRule.js.map +1 -1
- package/dist/src/rules/http/HttpTimeoutRule.d.ts.map +1 -1
- package/dist/src/rules/http/HttpTimeoutRule.js +1 -1
- package/dist/src/rules/http/HttpTimeoutRule.js.map +1 -1
- package/dist/src/rules/http/HttpUserAgentRule.d.ts.map +1 -1
- package/dist/src/rules/http/HttpUserAgentRule.js +1 -1
- package/dist/src/rules/http/HttpUserAgentRule.js.map +1 -1
- package/dist/src/rules/index.d.ts +1 -1
- package/dist/src/rules/index.d.ts.map +1 -1
- package/dist/src/rules/index.js +7 -5
- package/dist/src/rules/index.js.map +1 -1
- package/dist/src/rules/logging/LoggerCategoryRule.js +2 -2
- package/dist/src/rules/logging/LoggerCategoryRule.js.map +1 -1
- package/dist/src/rules/logging/LoggerInUntilSuccessfulRule.js +1 -1
- package/dist/src/rules/logging/LoggerInUntilSuccessfulRule.js.map +1 -1
- package/dist/src/rules/logging/LoggerPayloadRule.d.ts.map +1 -1
- package/dist/src/rules/logging/LoggerPayloadRule.js +3 -3
- package/dist/src/rules/logging/LoggerPayloadRule.js.map +1 -1
- package/dist/src/rules/naming/FlowCasingRule.d.ts.map +1 -1
- package/dist/src/rules/naming/FlowCasingRule.js +1 -1
- package/dist/src/rules/naming/FlowCasingRule.js.map +1 -1
- package/dist/src/rules/naming/FlowNamingRule.d.ts.map +1 -1
- package/dist/src/rules/naming/FlowNamingRule.js +3 -1
- package/dist/src/rules/naming/FlowNamingRule.js.map +1 -1
- package/dist/src/rules/naming/VariableNamingRule.d.ts.map +1 -1
- package/dist/src/rules/naming/VariableNamingRule.js +3 -3
- package/dist/src/rules/naming/VariableNamingRule.js.map +1 -1
- package/dist/src/rules/performance/AsyncErrorHandlerRule.d.ts.map +1 -1
- package/dist/src/rules/performance/AsyncErrorHandlerRule.js +1 -1
- package/dist/src/rules/performance/AsyncErrorHandlerRule.js.map +1 -1
- package/dist/src/rules/performance/LargeChoiceBlockRule.d.ts.map +1 -1
- package/dist/src/rules/performance/LargeChoiceBlockRule.js +1 -1
- package/dist/src/rules/performance/LargeChoiceBlockRule.js.map +1 -1
- package/dist/src/rules/performance/ScatterGatherRoutesRule.d.ts.map +1 -1
- package/dist/src/rules/performance/ScatterGatherRoutesRule.js +1 -1
- package/dist/src/rules/performance/ScatterGatherRoutesRule.js.map +1 -1
- package/dist/src/rules/security/HardcodedCredentialsRule.d.ts.map +1 -1
- package/dist/src/rules/security/HardcodedCredentialsRule.js +2 -2
- package/dist/src/rules/security/HardcodedCredentialsRule.js.map +1 -1
- package/dist/src/rules/security/HardcodedHttpRule.d.ts.map +1 -1
- package/dist/src/rules/security/HardcodedHttpRule.js +2 -6
- package/dist/src/rules/security/HardcodedHttpRule.js.map +1 -1
- package/dist/src/rules/security/InsecureTlsRule.d.ts.map +1 -1
- package/dist/src/rules/security/InsecureTlsRule.js +2 -2
- package/dist/src/rules/security/InsecureTlsRule.js.map +1 -1
- package/dist/src/rules/standards/ChoiceAntiPatternRule.d.ts.map +1 -1
- package/dist/src/rules/standards/ChoiceAntiPatternRule.js +2 -2
- package/dist/src/rules/standards/ChoiceAntiPatternRule.js.map +1 -1
- package/dist/src/rules/standards/DeprecatedComponentRule.d.ts.map +1 -1
- package/dist/src/rules/standards/DeprecatedComponentRule.js +1 -1
- package/dist/src/rules/standards/DeprecatedComponentRule.js.map +1 -1
- package/dist/src/rules/standards/DwlStandardsRule.d.ts.map +1 -1
- package/dist/src/rules/standards/DwlStandardsRule.js +1 -1
- package/dist/src/rules/standards/DwlStandardsRule.js.map +1 -1
- package/dist/src/rules/structure/StructureRules.d.ts.map +1 -1
- package/dist/src/rules/structure/StructureRules.js +6 -9
- package/dist/src/rules/structure/StructureRules.js.map +1 -1
- package/dist/src/rules/yaml/YamlRules.d.ts.map +1 -1
- package/dist/src/rules/yaml/YamlRules.js +13 -9
- package/dist/src/rules/yaml/YamlRules.js.map +1 -1
- package/dist/src/types/Config.d.ts.map +1 -1
- package/dist/src/types/Config.js +1 -5
- package/dist/src/types/Config.js.map +1 -1
- package/docs/README.md +95 -0
- package/docs/best-practices/documentation-standards.md +82 -0
- package/docs/best-practices/folder-structure.md +61 -0
- package/docs/best-practices/mulesoft-best-practices.md +902 -0
- package/docs/best-practices/rules-catalog.md +736 -0
- package/docs/linter/architecture.md +294 -0
- package/docs/linter/extending.md +426 -0
- package/docs/linter/folder-structure.md +251 -0
- package/docs/linter/images/html-report-dashboard.png +0 -0
- package/docs/linter/naming-conventions.md +300 -0
- package/docs/linter/rule-engine.md +532 -0
- package/docs/mcp-design.md +80 -0
- package/package.json +7 -4
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
# Folder Structure
|
|
2
|
+
|
|
3
|
+
> **Rationale:** This structure follows Node.js/TypeScript best practices and ensures clear separation of concerns.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
mule-lint/
|
|
9
|
+
├── bin/ # CLI entry points
|
|
10
|
+
│ └── mule-lint.ts # Main CLI executable
|
|
11
|
+
├── src/ # Source code
|
|
12
|
+
│ ├── core/ # Core utilities
|
|
13
|
+
│ │ ├── XmlParser.ts # XML parsing with error handling
|
|
14
|
+
│ │ ├── XPathHelper.ts # Namespace-aware XPath utilities
|
|
15
|
+
│ │ ├── YamlParser.ts # YAML parsing utilities
|
|
16
|
+
│ │ ├── FileScanner.ts # File discovery with glob patterns
|
|
17
|
+
│ │ └── ComplexityCalculator.ts
|
|
18
|
+
│ ├── engine/ # Lint engine
|
|
19
|
+
│ │ ├── LintEngine.ts # Main orchestrator
|
|
20
|
+
│ │ └── types.ts # Engine-specific types
|
|
21
|
+
│ ├── rules/ # Rule implementations (40 rules)
|
|
22
|
+
│ │ ├── index.ts # Rule registry/exports
|
|
23
|
+
│ │ ├── base/ # Base classes for rules
|
|
24
|
+
│ │ │ └── BaseRule.ts # Abstract rule with utilities
|
|
25
|
+
│ │ ├── api-led/ # API-Led connectivity patterns
|
|
26
|
+
│ │ │ └── ApiLedRules.ts (API-001, 002, 003)
|
|
27
|
+
│ │ ├── complexity/ # Complexity analysis
|
|
28
|
+
│ │ │ └── FlowComplexityRule.ts (MULE-801)
|
|
29
|
+
│ │ ├── dataweave/ # DataWeave file validation
|
|
30
|
+
│ │ │ └── DataWeaveRules.ts (DW-001, 002, 003)
|
|
31
|
+
│ │ ├── documentation/ # Documentation requirements
|
|
32
|
+
│ │ │ ├── FlowDescriptionRule.ts (MULE-601)
|
|
33
|
+
│ │ │ └── MissingDocNameRule.ts (MULE-604)
|
|
34
|
+
│ │ ├── error-handling/ # Error handling rules
|
|
35
|
+
│ │ │ ├── GlobalErrorHandlerRule.ts (MULE-001)
|
|
36
|
+
│ │ │ ├── MissingErrorHandlerRule.ts (MULE-003)
|
|
37
|
+
│ │ │ ├── HttpStatusRule.ts (MULE-005)
|
|
38
|
+
│ │ │ ├── CorrelationIdRule.ts (MULE-007)
|
|
39
|
+
│ │ │ └── GenericErrorRule.ts (MULE-009)
|
|
40
|
+
│ │ ├── experimental/ # Beta rules
|
|
41
|
+
│ │ │ └── ExperimentalRules.ts (EXP-001, 002, 003)
|
|
42
|
+
│ │ ├── http/ # HTTP configuration
|
|
43
|
+
│ │ │ ├── HttpUserAgentRule.ts (MULE-401)
|
|
44
|
+
│ │ │ ├── HttpContentTypeRule.ts (MULE-402)
|
|
45
|
+
│ │ │ └── HttpTimeoutRule.ts (MULE-403)
|
|
46
|
+
│ │ ├── logging/ # Logging rules
|
|
47
|
+
│ │ │ ├── LoggerCategoryRule.ts (MULE-006)
|
|
48
|
+
│ │ │ ├── LoggerPayloadRule.ts (MULE-301)
|
|
49
|
+
│ │ │ └── LoggerInUntilSuccessfulRule.ts (MULE-303)
|
|
50
|
+
│ │ ├── naming/ # Naming conventions
|
|
51
|
+
│ │ │ ├── FlowNamingRule.ts (MULE-002)
|
|
52
|
+
│ │ │ ├── FlowCasingRule.ts (MULE-101)
|
|
53
|
+
│ │ │ └── VariableNamingRule.ts (MULE-102)
|
|
54
|
+
│ │ ├── performance/ # Performance anti-patterns
|
|
55
|
+
│ │ │ ├── ScatterGatherRoutesRule.ts (MULE-501)
|
|
56
|
+
│ │ │ ├── AsyncErrorHandlerRule.ts (MULE-502)
|
|
57
|
+
│ │ │ └── LargeChoiceBlockRule.ts (MULE-503)
|
|
58
|
+
│ │ ├── security/ # Security rules
|
|
59
|
+
│ │ │ ├── HardcodedHttpRule.ts (MULE-004)
|
|
60
|
+
│ │ │ ├── HardcodedCredentialsRule.ts (MULE-201)
|
|
61
|
+
│ │ │ └── InsecureTlsRule.ts (MULE-202)
|
|
62
|
+
│ │ ├── standards/ # Best practices
|
|
63
|
+
│ │ │ ├── ChoiceAntiPatternRule.ts (MULE-008)
|
|
64
|
+
│ │ │ ├── DwlStandardsRule.ts (MULE-010)
|
|
65
|
+
│ │ │ └── DeprecatedComponentRule.ts (MULE-701)
|
|
66
|
+
│ │ ├── structure/ # Project structure
|
|
67
|
+
│ │ │ └── StructureRules.ts (MULE-802, 803, 804)
|
|
68
|
+
│ │ └── yaml/ # YAML validation
|
|
69
|
+
│ │ └── YamlRules.ts (YAML-001, 003, 004)
|
|
70
|
+
│ ├── formatters/ # Output formatters
|
|
71
|
+
│ │ ├── index.ts # Formatter factory
|
|
72
|
+
│ │ ├── TableFormatter.ts
|
|
73
|
+
│ │ ├── JsonFormatter.ts
|
|
74
|
+
│ │ ├── SarifFormatter.ts
|
|
75
|
+
│ │ └── HtmlFormatter.ts
|
|
76
|
+
│ ├── config/ # Configuration handling
|
|
77
|
+
│ │ ├── ConfigLoader.ts # Load .mulelintrc.json
|
|
78
|
+
│ │ ├── defaults.ts # Default configuration
|
|
79
|
+
│ │ └── schema.ts # Config validation schema
|
|
80
|
+
│ └── types/ # Shared type definitions
|
|
81
|
+
│ ├── index.ts # Re-exports
|
|
82
|
+
│ ├── Rule.ts # Rule interface
|
|
83
|
+
│ ├── Issue.ts # Issue/violation types
|
|
84
|
+
│ ├── Config.ts # Configuration types
|
|
85
|
+
│ └── Report.ts # Report types
|
|
86
|
+
├── tests/ # Test suite
|
|
87
|
+
│ ├── fixtures/ # Test XML files
|
|
88
|
+
│ │ ├── valid/ # Valid Mule configurations
|
|
89
|
+
│ │ ├── invalid/ # Invalid configurations
|
|
90
|
+
│ │ └── edge-cases/ # Edge case scenarios
|
|
91
|
+
│ ├── unit/ # Unit tests
|
|
92
|
+
│ │ ├── rules/ # Rule-specific tests
|
|
93
|
+
│ │ └── core/ # Core utility tests
|
|
94
|
+
│ ├── integration/ # Integration tests
|
|
95
|
+
│ └── setup.ts # Test configuration
|
|
96
|
+
├── docs/ # Documentation
|
|
97
|
+
│ ├── README.md # Documentation index
|
|
98
|
+
│ ├── architecture.md # System design
|
|
99
|
+
│ ├── folder-structure.md # This file
|
|
100
|
+
│ ├── naming-conventions.md
|
|
101
|
+
│ ├── rule-engine.md # Rule engine internals
|
|
102
|
+
│ ├── rules-catalog.md # All rules documented
|
|
103
|
+
│ └── extending.md # Custom rules guide
|
|
104
|
+
├── .mulelintrc.json # Default configuration
|
|
105
|
+
├── package.json
|
|
106
|
+
├── tsconfig.json
|
|
107
|
+
├── jest.config.js
|
|
108
|
+
├── .eslintrc.js
|
|
109
|
+
├── .prettierrc
|
|
110
|
+
├── CHANGELOG.md
|
|
111
|
+
├── CONTRIBUTING.md
|
|
112
|
+
├── LICENSE
|
|
113
|
+
└── README.md
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Directory Details
|
|
119
|
+
|
|
120
|
+
### `/bin`
|
|
121
|
+
|
|
122
|
+
**Purpose:** CLI entry points that get installed globally via npm.
|
|
123
|
+
|
|
124
|
+
```json
|
|
125
|
+
// package.json
|
|
126
|
+
{
|
|
127
|
+
"bin": {
|
|
128
|
+
"mule-lint": "./dist/bin/mule-lint.js"
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### `/src/core`
|
|
134
|
+
|
|
135
|
+
**Purpose:** Low-level utilities that don't depend on business logic.
|
|
136
|
+
|
|
137
|
+
| File | Responsibility |
|
|
138
|
+
|------|----------------|
|
|
139
|
+
| `XmlParser.ts` | Parse XML string to DOM, handle errors gracefully |
|
|
140
|
+
| `XPathHelper.ts` | Namespace-aware XPath queries |
|
|
141
|
+
| `YamlParser.ts` | Parse YAML files, detect sensitive keys |
|
|
142
|
+
| `FileScanner.ts` | Discover `.xml` and `.yaml` files using glob patterns |
|
|
143
|
+
| `ComplexityCalculator.ts` | Calculate cyclomatic complexity of flows |
|
|
144
|
+
|
|
145
|
+
### `/src/rules`
|
|
146
|
+
|
|
147
|
+
**Purpose:** All validation rules, organized by category.
|
|
148
|
+
|
|
149
|
+
**Rule Families (40 total):**
|
|
150
|
+
|
|
151
|
+
| Family | Directory | Rules |
|
|
152
|
+
|--------|-----------|-------|
|
|
153
|
+
| API-Led | `api-led/` | API-001, 002, 003 |
|
|
154
|
+
| Complexity | `complexity/` | MULE-801 |
|
|
155
|
+
| DataWeave | `dataweave/` | DW-001, 002, 003 |
|
|
156
|
+
| Documentation | `documentation/` | MULE-601, 604 |
|
|
157
|
+
| Error Handling | `error-handling/` | MULE-001, 003, 005, 007, 009 |
|
|
158
|
+
| Experimental | `experimental/` | EXP-001, 002, 003 |
|
|
159
|
+
| HTTP | `http/` | MULE-401, 402, 403 |
|
|
160
|
+
| Logging | `logging/` | MULE-006, 301, 303 |
|
|
161
|
+
| Naming | `naming/` | MULE-002, 101, 102 |
|
|
162
|
+
| Performance | `performance/` | MULE-501, 502, 503 |
|
|
163
|
+
| Security | `security/` | MULE-004, 201, 202 |
|
|
164
|
+
| Standards | `standards/` | MULE-008, 010, 701 |
|
|
165
|
+
| Structure | `structure/` | MULE-802, 803, 804 |
|
|
166
|
+
| YAML | `yaml/` | YAML-001, 003, 004 |
|
|
167
|
+
|
|
168
|
+
**Convention:** Each rule file exports one or more classes implementing `Rule`.
|
|
169
|
+
|
|
170
|
+
### `/src/formatters`
|
|
171
|
+
|
|
172
|
+
**Purpose:** Transform `LintReport` to various output formats.
|
|
173
|
+
|
|
174
|
+
| Formatter | Use Case |
|
|
175
|
+
|-----------|----------|
|
|
176
|
+
| `TableFormatter.ts` | Human-readable CLI output |
|
|
177
|
+
| `JsonFormatter.ts` | Script/automation consumption |
|
|
178
|
+
| `SarifFormatter.ts` | AI agents and IDE integration |
|
|
179
|
+
| `HtmlFormatter.ts` | Standalone HTML reports |
|
|
180
|
+
|
|
181
|
+
### `/src/config`
|
|
182
|
+
|
|
183
|
+
**Purpose:** Handle `.mulelintrc.json` loading and validation.
|
|
184
|
+
|
|
185
|
+
### `/tests/fixtures`
|
|
186
|
+
|
|
187
|
+
**Purpose:** Sample XML files for testing rules.
|
|
188
|
+
|
|
189
|
+
**Naming Convention:**
|
|
190
|
+
- Prefix with rule ID: `MULE-001-global-error-handler.xml`
|
|
191
|
+
- Or use descriptive names: `flow-with-missing-category.xml`
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## Import Paths
|
|
196
|
+
|
|
197
|
+
Use TypeScript path aliases for clean imports:
|
|
198
|
+
|
|
199
|
+
```json
|
|
200
|
+
// tsconfig.json
|
|
201
|
+
{
|
|
202
|
+
"compilerOptions": {
|
|
203
|
+
"baseUrl": "./src",
|
|
204
|
+
"paths": {
|
|
205
|
+
"@core/*": ["core/*"],
|
|
206
|
+
"@rules/*": ["rules/*"],
|
|
207
|
+
"@formatters/*": ["formatters/*"],
|
|
208
|
+
"@types/*": ["types/*"]
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
**Example Usage:**
|
|
215
|
+
|
|
216
|
+
```typescript
|
|
217
|
+
import { Rule } from '@types/Rule';
|
|
218
|
+
import { XPathHelper } from '@core/XPathHelper';
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## File Naming
|
|
224
|
+
|
|
225
|
+
| Type | Convention | Example |
|
|
226
|
+
|------|------------|---------|
|
|
227
|
+
| Rule class | PascalCase + `Rule` suffix | `FlowNamingRule.ts` |
|
|
228
|
+
| Multi-rule file | Feature + `Rules` suffix | `YamlRules.ts` |
|
|
229
|
+
| Utility class | PascalCase | `XPathHelper.ts` |
|
|
230
|
+
| Type definition | PascalCase | `Issue.ts` |
|
|
231
|
+
| Test file | Match source + `.test.ts` | `FlowNamingRule.test.ts` |
|
|
232
|
+
| Config | lowercase with dots | `jest.config.js` |
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## Distribution
|
|
237
|
+
|
|
238
|
+
After build, the `/dist` folder mirrors `/src`:
|
|
239
|
+
|
|
240
|
+
```
|
|
241
|
+
dist/
|
|
242
|
+
├── bin/
|
|
243
|
+
│ └── mule-lint.js
|
|
244
|
+
├── core/
|
|
245
|
+
├── engine/
|
|
246
|
+
├── rules/
|
|
247
|
+
├── formatters/
|
|
248
|
+
└── types/
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
Only `/dist` is published to npm (configured in `package.json` files array).
|
|
Binary file
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
# Naming Conventions
|
|
2
|
+
|
|
3
|
+
> **Scope:** This document covers naming conventions for the mule-lint codebase and the MuleSoft projects being validated.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Rule Naming
|
|
8
|
+
|
|
9
|
+
### Rule IDs
|
|
10
|
+
|
|
11
|
+
mule-lint uses multiple rule prefixes to organize rules by domain:
|
|
12
|
+
|
|
13
|
+
| Prefix | Format | Domain | Example |
|
|
14
|
+
|--------|--------|--------|---------|
|
|
15
|
+
| `MULE` | `MULE-NNN` | Core MuleSoft XML validation | `MULE-001` |
|
|
16
|
+
| `YAML` | `YAML-NNN` | YAML properties validation | `YAML-001` |
|
|
17
|
+
| `DW` | `DW-NNN` | DataWeave file validation | `DW-001` |
|
|
18
|
+
| `API` | `API-NNN` | API-Led patterns | `API-001` |
|
|
19
|
+
| `EXP` | `EXP-NNN` | Experimental rules | `EXP-001` |
|
|
20
|
+
|
|
21
|
+
### MULE ID Ranges
|
|
22
|
+
|
|
23
|
+
| Range | Category | Description |
|
|
24
|
+
|-------|----------|-------------|
|
|
25
|
+
| 001-099 | Error Handling | Error handler configuration and patterns |
|
|
26
|
+
| 100-199 | Naming | Naming conventions for flows, variables |
|
|
27
|
+
| 200-299 | Security | Security vulnerabilities, hardcoded values |
|
|
28
|
+
| 300-399 | Logging | Logging standards and structured logging |
|
|
29
|
+
| 400-499 | HTTP | HTTP configuration and headers |
|
|
30
|
+
| 500-599 | Performance | Performance anti-patterns |
|
|
31
|
+
| 600-699 | Documentation | Documentation requirements |
|
|
32
|
+
| 700-799 | Standards | General coding standards |
|
|
33
|
+
| 800-899 | Complexity/Structure | Code complexity and project structure |
|
|
34
|
+
|
|
35
|
+
### Rule Names
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
// ✅ Good - Concise, action-oriented
|
|
39
|
+
name = 'Flow Naming Convention';
|
|
40
|
+
name = 'Missing Error Handler';
|
|
41
|
+
name = 'Hardcoded HTTP URLs';
|
|
42
|
+
|
|
43
|
+
// ❌ Bad - Too long, passive
|
|
44
|
+
name = 'This rule checks if flow names follow the naming convention';
|
|
45
|
+
name = 'Error handler is missing from flow';
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Rule Descriptions
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
// ✅ Good - What + Why
|
|
52
|
+
description = 'Flows must end with "-flow" for consistent identification';
|
|
53
|
+
description = 'Error handlers must set httpStatus for proper API responses';
|
|
54
|
+
|
|
55
|
+
// ❌ Bad - Just what, no why
|
|
56
|
+
description = 'Checks flow names';
|
|
57
|
+
description = 'Finds missing error handlers';
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Source File Naming
|
|
63
|
+
|
|
64
|
+
### Source Files
|
|
65
|
+
|
|
66
|
+
| Type | Convention | Example |
|
|
67
|
+
|------|------------|---------|
|
|
68
|
+
| Rule class | PascalCase + `Rule` suffix | `FlowNamingRule.ts` |
|
|
69
|
+
| Multi-rule file | Feature + `Rules` suffix | `YamlRules.ts`, `ApiLedRules.ts` |
|
|
70
|
+
| Base class | PascalCase + `Base` prefix | `BaseRule.ts` |
|
|
71
|
+
| Utility/Helper | PascalCase + `Helper`/`Utils` | `XPathHelper.ts` |
|
|
72
|
+
| Type definitions | PascalCase, singular | `Issue.ts`, `Rule.ts` |
|
|
73
|
+
| Constants | PascalCase or SCREAMING_SNAKE | `Defaults.ts` |
|
|
74
|
+
| Index/barrel files | Lowercase `index.ts` | `index.ts` |
|
|
75
|
+
|
|
76
|
+
### Test Files
|
|
77
|
+
|
|
78
|
+
| Convention | Example |
|
|
79
|
+
|------------|---------|
|
|
80
|
+
| Unit test | `{ClassName}.test.ts` | `FlowNamingRule.test.ts` |
|
|
81
|
+
| Integration test | `{feature}.integration.test.ts` | `engine.integration.test.ts` |
|
|
82
|
+
| Fixture | Descriptive kebab-case | `flow-with-error-handler.xml` |
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Code Naming
|
|
87
|
+
|
|
88
|
+
### Classes
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
// ✅ Good - PascalCase, descriptive
|
|
92
|
+
class FlowNamingRule { }
|
|
93
|
+
class XPathHelper { }
|
|
94
|
+
class SarifFormatter { }
|
|
95
|
+
|
|
96
|
+
// ❌ Bad
|
|
97
|
+
class flowrule { }
|
|
98
|
+
class Helper { } // Too generic
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Interfaces
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
// ✅ Good - PascalCase, noun-based
|
|
105
|
+
interface Rule { }
|
|
106
|
+
interface ValidationContext { }
|
|
107
|
+
interface LintReport { }
|
|
108
|
+
|
|
109
|
+
// ❌ Bad - I-prefix (not TypeScript convention)
|
|
110
|
+
interface IRule { }
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Type Aliases
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
// ✅ Good - PascalCase
|
|
117
|
+
type Severity = 'error' | 'warning' | 'info';
|
|
118
|
+
type RuleCategory = 'naming' | 'security';
|
|
119
|
+
|
|
120
|
+
// ❌ Bad
|
|
121
|
+
type severity = string;
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Constants
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
// ✅ Good - SCREAMING_SNAKE for true constants
|
|
128
|
+
const DEFAULT_SEVERITY = 'warning';
|
|
129
|
+
const MULE_NAMESPACE = 'http://www.mulesoft.org/schema/mule/core';
|
|
130
|
+
|
|
131
|
+
// ✅ Also acceptable - Object of related constants
|
|
132
|
+
const ExitCodes = {
|
|
133
|
+
Success: 0,
|
|
134
|
+
Error: 1,
|
|
135
|
+
} as const;
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Functions & Methods
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
// ✅ Good - camelCase, verb-based
|
|
142
|
+
function validateDocument(doc: Document): Issue[] { }
|
|
143
|
+
function getLineNumber(node: Node): number { }
|
|
144
|
+
function loadConfiguration(): Config { }
|
|
145
|
+
|
|
146
|
+
// ✅ Good - boolean getters with is/has/should prefix
|
|
147
|
+
function isEnabled(rule: Rule): boolean { }
|
|
148
|
+
function hasErrorHandler(flow: Node): boolean { }
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Variables
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
// ✅ Good - camelCase, descriptive
|
|
155
|
+
const filePath = '/path/to/file.xml';
|
|
156
|
+
const errorCount = 0;
|
|
157
|
+
const validationResults: Issue[] = [];
|
|
158
|
+
|
|
159
|
+
// ❌ Bad - single letters, abbreviations
|
|
160
|
+
const f = '/path/to/file.xml';
|
|
161
|
+
const ec = 0;
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## MuleSoft Project Naming (Validated by Rules)
|
|
167
|
+
|
|
168
|
+
These are the conventions that mule-lint rules enforce:
|
|
169
|
+
|
|
170
|
+
### Flow Names (MULE-002, MULE-101)
|
|
171
|
+
|
|
172
|
+
```xml
|
|
173
|
+
<!-- ✅ Good - kebab-case with suffix -->
|
|
174
|
+
<flow name="process-order-flow">
|
|
175
|
+
<sub-flow name="validate-input-subflow">
|
|
176
|
+
|
|
177
|
+
<!-- ❌ Bad - no suffix, wrong casing -->
|
|
178
|
+
<flow name="processOrder">
|
|
179
|
+
<sub-flow name="ValidateInput">
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Variable Names (MULE-102)
|
|
183
|
+
|
|
184
|
+
```xml
|
|
185
|
+
<!-- ✅ Good - camelCase -->
|
|
186
|
+
<set-variable variableName="orderId" />
|
|
187
|
+
<set-variable variableName="customerData" />
|
|
188
|
+
|
|
189
|
+
<!-- ❌ Bad -->
|
|
190
|
+
<set-variable variableName="order_id" />
|
|
191
|
+
<set-variable variableName="OrderId" />
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### YAML Properties (YAML-003)
|
|
195
|
+
|
|
196
|
+
```yaml
|
|
197
|
+
# ✅ Good - category.property format
|
|
198
|
+
db.host: localhost
|
|
199
|
+
api.timeout: 30000
|
|
200
|
+
http.request.port: 8081
|
|
201
|
+
|
|
202
|
+
# ❌ Bad
|
|
203
|
+
DBHOST: localhost
|
|
204
|
+
ApiTimeout: 30000
|
|
205
|
+
DB_HOST: localhost
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### DataWeave Files (DW-002)
|
|
209
|
+
|
|
210
|
+
```
|
|
211
|
+
# ✅ Good - kebab-case
|
|
212
|
+
transform-order.dwl
|
|
213
|
+
validate-input.dwl
|
|
214
|
+
common-utils.dwl
|
|
215
|
+
|
|
216
|
+
# ❌ Bad
|
|
217
|
+
transformOrder.dwl
|
|
218
|
+
ValidateInput.dwl
|
|
219
|
+
COMMON_UTILS.dwl
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Connector Configs (EXP-002)
|
|
223
|
+
|
|
224
|
+
```xml
|
|
225
|
+
<!-- ✅ Good - PascalCase with underscores -->
|
|
226
|
+
<http:request-config name="HTTP_Request_Config" />
|
|
227
|
+
<db:config name="Database_Config" />
|
|
228
|
+
|
|
229
|
+
<!-- ❌ Bad -->
|
|
230
|
+
<http:request-config name="httpConfig" />
|
|
231
|
+
<db:config name="db-config" />
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## Documentation Naming
|
|
237
|
+
|
|
238
|
+
### Files
|
|
239
|
+
|
|
240
|
+
| Type | Convention | Example |
|
|
241
|
+
|------|------------|---------|
|
|
242
|
+
| Main docs | lowercase-kebab | `rule-engine.md` |
|
|
243
|
+
| Rule docs | Rule ID | `MULE-001.md` |
|
|
244
|
+
| Guides | lowercase-kebab | `getting-started.md` |
|
|
245
|
+
|
|
246
|
+
### Sections
|
|
247
|
+
|
|
248
|
+
Use sentence case for headers:
|
|
249
|
+
|
|
250
|
+
```markdown
|
|
251
|
+
# Getting started
|
|
252
|
+
## How to install
|
|
253
|
+
### Running in CI/CD
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## Git Conventions
|
|
259
|
+
|
|
260
|
+
### Branch Names
|
|
261
|
+
|
|
262
|
+
```
|
|
263
|
+
feature/MULE-001-flow-naming-rule
|
|
264
|
+
fix/sarif-output-line-numbers
|
|
265
|
+
docs/update-readme
|
|
266
|
+
chore/upgrade-dependencies
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### Commit Messages
|
|
270
|
+
|
|
271
|
+
Follow Conventional Commits:
|
|
272
|
+
|
|
273
|
+
```
|
|
274
|
+
feat(rules): add MULE-011 API versioning rule
|
|
275
|
+
fix(parser): handle malformed XML gracefully
|
|
276
|
+
docs: update rule engine documentation
|
|
277
|
+
test: add integration tests for SARIF output
|
|
278
|
+
chore: upgrade xmldom to 0.9.0
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
## Summary Table
|
|
284
|
+
|
|
285
|
+
| Entity | Convention | Example |
|
|
286
|
+
|--------|------------|---------|
|
|
287
|
+
| File (rule class) | PascalCase + Rule | `FlowNamingRule.ts` |
|
|
288
|
+
| File (multi-rule) | Feature + Rules | `YamlRules.ts` |
|
|
289
|
+
| File (test) | {Class}.test.ts | `FlowNamingRule.test.ts` |
|
|
290
|
+
| Class | PascalCase | `class FlowNamingRule` |
|
|
291
|
+
| Interface | PascalCase | `interface Rule` |
|
|
292
|
+
| Type | PascalCase | `type Severity` |
|
|
293
|
+
| Constant | SCREAMING_SNAKE | `const MAX_FILES` |
|
|
294
|
+
| Function | camelCase, verb | `validateDocument()` |
|
|
295
|
+
| Variable | camelCase | `const filePath` |
|
|
296
|
+
| Rule ID (MULE) | MULE-NNN | `MULE-001` |
|
|
297
|
+
| Rule ID (YAML) | YAML-NNN | `YAML-001` |
|
|
298
|
+
| Rule ID (DW) | DW-NNN | `DW-001` |
|
|
299
|
+
| Rule ID (API) | API-NNN | `API-001` |
|
|
300
|
+
| Rule ID (EXP) | EXP-NNN | `EXP-001` |
|