Skip to content

Commit 59caa75

Browse files
authored
Merge pull request #114 from mxlint/config-file
Config file
2 parents a2144d8 + aef0dd9 commit 59caa75

20 files changed

Lines changed: 1884 additions & 213 deletions

‎.github/workflows/ci.yml‎

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,17 @@ jobs:
9696
- name: Test subcommand export-model mpr-v1
9797
run: |
9898
chmod +x ./bin/mxlint
99-
bin/mxlint export-model --mode basic -i resources/app-mpr-v1 -o resources/modelsource-v1
99+
mkdir -p .ci
100+
cat > .ci/export-v1.yaml << 'EOF'
101+
projectDirectory: resources/app-mpr-v1
102+
modelsource: resources/modelsource-v1
103+
export:
104+
mode: basic
105+
filter: ".*"
106+
raw: false
107+
appstore: false
108+
EOF
109+
./bin/mxlint --config .ci/export-v1.yaml export-model
100110
git diff --exit-code resources/modelsource-v1
101111
102112
test_export_model_v2:
@@ -117,7 +127,17 @@ jobs:
117127
- name: Test subcommand export-model mpr-v2
118128
run: |
119129
chmod +x ./bin/mxlint
120-
bin/mxlint export-model --mode basic -i resources/app-mpr-v2 -o resources/modelsource-v2
130+
mkdir -p .ci
131+
cat > .ci/export-v2.yaml << 'EOF'
132+
projectDirectory: resources/app-mpr-v2
133+
modelsource: resources/modelsource-v2
134+
export:
135+
mode: basic
136+
filter: ".*"
137+
raw: false
138+
appstore: false
139+
EOF
140+
./bin/mxlint --config .ci/export-v2.yaml export-model
121141
git diff --exit-code resources/modelsource-v2
122142
123143
test_lint:
@@ -138,7 +158,31 @@ jobs:
138158
- name: Test subcommand lint
139159
run: |
140160
chmod +x ./bin/mxlint
141-
./bin/mxlint lint --xunit-report report.xml --rules ./resources/rules -m resources/app-mpr-v1
161+
mkdir -p .ci
162+
cat > .ci/lint.yaml << 'EOF'
163+
rules:
164+
path: ./resources/rules
165+
modelsource: resources/modelsource-v1
166+
lint:
167+
xunitReport: report.xml
168+
skip:
169+
MyFirstModule/DomainModels$DomainModel:
170+
- rule: "002_0009"
171+
reason: CI fixture intentionally keeps a default value for rule coverage
172+
MyFirstModule/Home_Web.Forms$Page:
173+
- rule: "004_0001"
174+
reason: CI fixture intentionally uses inline style for rule coverage
175+
- rule: "004_0004"
176+
reason: CI fixture intentionally has heading order issue for rule coverage
177+
MyFirstModule/BadPage.Forms$Page:
178+
- rule: "004_0002"
179+
reason: CI fixture intentionally omits image alt text for rule coverage
180+
- rule: "004_0003"
181+
reason: CI fixture intentionally uses multiple h1 tags for rule coverage
182+
- rule: "004_0004"
183+
reason: CI fixture intentionally has heading order issue for rule coverage
184+
EOF
185+
./bin/mxlint --config .ci/lint.yaml lint
142186
143187
144188
test_rules:
@@ -159,4 +203,9 @@ jobs:
159203
- name: Test subcommand test-rules
160204
run: |
161205
chmod +x ./bin/mxlint
162-
./bin/mxlint test-rules --rules ./resources/rules
206+
mkdir -p .ci
207+
cat > .ci/test-rules.yaml << 'EOF'
208+
rules:
209+
path: ./resources/rules
210+
EOF
211+
./bin/mxlint --config .ci/test-rules.yaml test-rules

‎README.md‎

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ Do you want to create your own policies? Please refer to our guide [Create new p
4545

4646
## Subcommands Reference
4747

48+
> Configuration-driven commands: subcommand-specific options are read from merged config (`default.yaml` + system `mxlint.yaml` + project `mxlint.yaml`). You can also pass `--config <path>` to apply a specific config file with the highest precedence. Use global `--verbose` on the root command to enable debug logging for any subcommand.
49+
50+
Global verbose examples:
51+
52+
```bash
53+
mxlint-cli --verbose lint
54+
mxlint-cli -v export-model
55+
mxlint-cli -v serve
56+
```
57+
4858
### export-model
4959

5060
Export Mendix model to yaml files. The output is a text representation of the model. It is a one-way conversion that aims to keep the semantics yet readable for humans and computers.
@@ -65,6 +75,48 @@ mxlint-cli export-model [flags]
6575
| `--appstore` | | `false` | If set, appstore modules will be included in the output |
6676
| `--verbose` | | `false` | Turn on for debug logs |
6777

78+
#### Configuration file (`mxlint.yaml`)
79+
80+
The `lint` command supports configuration files loaded in this order:
81+
82+
1. Default config: `default.yaml` baked into the executable at compile time
83+
2. System config:
84+
- Windows: `%USERPROFILE%/mxlint.yaml`
85+
- Unix/Linux/macOS: `~/.config/mxlint.yaml`
86+
- Optional override: `MXLINT_SYSTEM_CONFIG`
87+
3. `$PROJECT/mxlint.yaml` (current working directory)
88+
4. Optional explicit config via `--config <path>` (highest precedence, file must exist)
89+
90+
Project config has higher precedence than system config, and `--config` has the highest precedence.
91+
92+
Example:
93+
94+
```yaml
95+
rules:
96+
path: .mendix-cache/rules
97+
rulesets:
98+
- file://rules
99+
- https://example.com/rules.zip
100+
- git://github.com/mxlint/mxlint-rules
101+
lint:
102+
skip:
103+
example/doc:
104+
- rule: 001_002
105+
reason: some reason
106+
date: 2026-02-27 11:00:00Z
107+
export:
108+
output: modelsource
109+
input: .
110+
mode: basic
111+
filter: "*"
112+
```
113+
114+
Notes:
115+
- `rules.path` is used as the default rules directory when `--rules` is not provided.
116+
- If `rules.rulesets` are configured, they are synchronized into `rules.path` before linting.
117+
- `lint.skip` supports skipping by document path (relative to `modelsource`) and rule number.
118+
- `export.*` is used as defaults for `export-model`, and `export.output` is used as the default `lint --modelsource`.
119+
68120
---
69121

70122
### lint
@@ -89,6 +141,17 @@ mxlint-cli lint [flags]
89141

90142
---
91143

144+
### config
145+
146+
Show the active merged configuration and where config sources were found/used.
147+
148+
**Usage:**
149+
```bash
150+
mxlint-cli config
151+
```
152+
153+
---
154+
92155
### serve
93156

94157
Run a server that exports model and lints whenever the input MPR file changes. Works in standalone mode and via integration with the Mendix Studio Pro extension.

‎default.yaml‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
rules:
2+
path: .mendix-cache/rules
3+
rulesets:
4+
- https://github.com/mxlint/mxlint-rules/releases/download/v3.3.0/rules-v3.3.0.zip
5+
lint:
6+
xunitReport: ""
7+
jsonFile: ""
8+
ignoreNoqa: false
9+
noCache: false
10+
skip: {}
11+
modelsource: modelsource
12+
projectDirectory: .
13+
export:
14+
mode: basic
15+
filter: ".*"
16+
raw: false
17+
appstore: false
18+
serve:
19+
port: 8082
20+
debounce: 500

0 commit comments

Comments
 (0)