dts-linter 0.0.0-beta8 → 0.1.0
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 +153 -1
- package/dist/dts-linter.js +137 -56
- package/dist/server.js +205 -210
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -2,4 +2,156 @@
|
|
|
2
2
|
|
|
3
3
|
# DTS Linter
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
A comprehensive DeviceTree linter and formatter that provides syntax checking, formatting, and diagnostic capabilities for DeviceTree Source (.dts), DeviceTree Source Include (.dtsi), and overlay files.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Formatting**: Automatically format DeviceTree files with proper indentation and style
|
|
10
|
+
- **Diagnostics**: Comprehensive syntax and semantic error checking
|
|
11
|
+
- **CI/CD Integration**: Designed to work seamlessly with GitHub Actions
|
|
12
|
+
- **Batch Processing**: Process multiple files efficiently
|
|
13
|
+
- **Diff Output**: Generate patch files for formatting changes
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install -g --ignore-scripts dts-linter
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
### Basic Usage
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# Lint and format specific files
|
|
27
|
+
dts-linter --files file1.dts --files file2.dtsi --format
|
|
28
|
+
|
|
29
|
+
# Auto-discover and process all DTS files in current directory
|
|
30
|
+
dts-linter --format
|
|
31
|
+
|
|
32
|
+
# Apply formatting changes directly to files
|
|
33
|
+
dts-linter --formatFixAll
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Command Line Options
|
|
37
|
+
|
|
38
|
+
| Option | Type | Default | Description |
|
|
39
|
+
| ----------------------- | --------------- | --------------- | ---------------------------------------------------------------------------------------------------- |
|
|
40
|
+
| `--files` | string | Auto-discover | List of input files (can be repeated) |
|
|
41
|
+
| `--cwd` | string | `process.cwd()` | Set the current working directory |
|
|
42
|
+
| `--includes` | string | `[]` | Paths to resolve includes (absolute or relative to CWD, can be repeated) |
|
|
43
|
+
| `--bindings` | string | `[]` | Zephyr binding root directories (absolute or relative to CWD, can be repeated) |
|
|
44
|
+
| `--logLevel` | `none\|verbose` | `none` | Set the logging verbosity |
|
|
45
|
+
| `--format` | boolean | `false` | Format the specified files (automatically set to true when formatFixAll) |
|
|
46
|
+
| `--formatFixAll` | boolean | `false` | Apply formatting changes directly to files |
|
|
47
|
+
| `--processIncludes` | boolean | `false` | Process includes for formatting or diagnostics (automatically set to true when diagnosticsFull) |
|
|
48
|
+
| `--diagnostics` | boolean | `false` | Show basic syntax diagnostics |
|
|
49
|
+
| `--diagnosticsFull` | boolean | `false` | Show full diagnostics including semantic analysis (requires --includes, --bindings for proper usage) |
|
|
50
|
+
| `--showInfoDiagnostics` | boolean | `false` | Show information-level diagnostics |
|
|
51
|
+
| `--outFile` | string | - | Write formatting diff output to file |
|
|
52
|
+
| `--help` | boolean | `false` | Show help information |
|
|
53
|
+
|
|
54
|
+
### Examples
|
|
55
|
+
|
|
56
|
+
#### Check formatting without making changes
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
dts-linter --format --files my-board.dts
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
#### Auto-fix formatting issues
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
dts-linter --formatFixAll --files my-board.dts --files my-overlay.dtsi
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
#### Full diagnostic check with include processing
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
dts-linter --diagnosticsFull --includes ./include --bindings ./zephyr/dts/bindings
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
#### Generate diff file for review
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
dts-linter --format --outFile changes.patch
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## File Discovery
|
|
81
|
+
|
|
82
|
+
When no `--files` option is provided, the linter automatically searches for DeviceTree files using the pattern `**/*.{dts,dtsi,overlay}` or `**/*.{dts}` when using `--diagnosticsFull` in the current working directory.
|
|
83
|
+
|
|
84
|
+
## Output Formats
|
|
85
|
+
|
|
86
|
+
### Standard Output
|
|
87
|
+
|
|
88
|
+
- ✅ Success messages with file counts
|
|
89
|
+
- ⚠️ Warnings for formatting issues
|
|
90
|
+
- ❌ Errors for syntax problems
|
|
91
|
+
|
|
92
|
+
### CI/CD Output
|
|
93
|
+
|
|
94
|
+
When running in CI environments (GitHub Actions, GitLab CI, etc.), the tool automatically formats output using platform-specific annotations:
|
|
95
|
+
|
|
96
|
+
- `::notice` for information
|
|
97
|
+
- `::warning` for formatting issues
|
|
98
|
+
- `::error` for syntax errors
|
|
99
|
+
- File locations and line numbers included
|
|
100
|
+
|
|
101
|
+
### Diff Output
|
|
102
|
+
|
|
103
|
+
When using `--outFile`, generates unified diff format showing all formatting changes:
|
|
104
|
+
|
|
105
|
+
```diff
|
|
106
|
+
--- a/my-board.dts
|
|
107
|
+
+++ b/my-board.dts
|
|
108
|
+
@@ -10,7 +10,7 @@
|
|
109
|
+
/ {
|
|
110
|
+
- model = "My Board";
|
|
111
|
+
+ model = "My Board";
|
|
112
|
+
compatible = "vendor,my-board";
|
|
113
|
+
};
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Diagnostic Levels
|
|
117
|
+
|
|
118
|
+
The linter supports multiple diagnostic severity levels:
|
|
119
|
+
|
|
120
|
+
- **Error**: Syntax errors that prevent compilation
|
|
121
|
+
- **Warning**: Potential issues that should be reviewed
|
|
122
|
+
- **Information**: Informational messages (shown with `--showInfoDiagnostics`)
|
|
123
|
+
- **Hint**: Style suggestions
|
|
124
|
+
|
|
125
|
+
## Integration with Language Server
|
|
126
|
+
|
|
127
|
+
This linter uses the DeviceTree Language Server for accurate parsing and validation. It supports:
|
|
128
|
+
|
|
129
|
+
- Context-aware validation
|
|
130
|
+
- Include path resolution
|
|
131
|
+
- Zephyr binding validation
|
|
132
|
+
- Workspace-wide analysis
|
|
133
|
+
|
|
134
|
+
## Exit Codes
|
|
135
|
+
|
|
136
|
+
- `0`: Success - all files processed without errors
|
|
137
|
+
- `1`: Failure - formatting errors or diagnostic issues found
|
|
138
|
+
|
|
139
|
+
## Requirements
|
|
140
|
+
|
|
141
|
+
- Node.js 16+
|
|
142
|
+
|
|
143
|
+
## Contributing
|
|
144
|
+
|
|
145
|
+
1. Fork the repository
|
|
146
|
+
2. Create a feature branch
|
|
147
|
+
3. Make your changes
|
|
148
|
+
4. Add tests if applicable
|
|
149
|
+
5. Submit a pull request
|
|
150
|
+
|
|
151
|
+
## License
|
|
152
|
+
|
|
153
|
+
Apache License, Version 2.0
|
|
154
|
+
|
|
155
|
+
## Changelog
|
|
156
|
+
|
|
157
|
+
See [CHANGELOG.md](CHANGELOG.md) for version history and changes.
|