Commit e31ff2a
committed
feat(pre-commit): add internal-import alias check
- Add an AST-based hook enforcing code style guide §3.3: public modules must alias symbols imported from a private module with a `_` prefix; private modules must not
- On commit it fails and reports each violation with a suggested fix, but does not edit files — run the script with `--fix` to apply fixes manually (kept opt-in so its rewrites don't get entangled with the formatter/linter hooks)
- Detect absolute, relative, and aliased plain imports, plus custom aliases; preserve comments and handle multibyte source via byte offsets; skip cases that are unsafe to rename (shadowed or rebound names)
- Add a (before, after) test suite under `tests/devtools/` covering every case1 parent 012f399 commit e31ff2a
4 files changed
Lines changed: 985 additions & 0 deletions
File tree
- docs/contributing
- scripts/pre_commit
- tests/devtools
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
305 | 305 | | |
306 | 306 | | |
307 | 307 | | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
308 | 322 | | |
309 | 323 | | |
310 | 324 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
330 | 331 | | |
331 | 332 | | |
332 | 333 | | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
333 | 345 | | |
334 | 346 | | |
335 | 347 | | |
| |||
0 commit comments