Skip to content

[ADD] xml-tag-position: enforce id, t-if/t-else/t-elif and class positioning attribute rules#190

Merged
moylop260 merged 1 commit into
OCA:mainfrom
vauxoo-dev:main-t-if-first-moy
Jun 17, 2026
Merged

[ADD] xml-tag-position: enforce id, t-if/t-else/t-elif and class positioning attribute rules#190
moylop260 merged 1 commit into
OCA:mainfrom
vauxoo-dev:main-t-if-first-moy

Conversation

@moylop260

@moylop260 moylop260 commented May 19, 2026

Copy link
Copy Markdown
Collaborator
Rename the check xml-id-position-first to xml-tag-position to support a more general set of attribute positioning constraints.

Specifically:
- t-if, t-else, and t-elif must always be the first attribute in any XML tag.
- id, t-att-id, t-attf-id must be the second attribute
- class, t-att-class, t-attf-class must be the third attribute

Changes:
- Refactor checks_odoo_module_xml.py to use a single check_xml_tag_position visitor and a unified autofix.
- Update rewrite_start_tag in node_xml.py to accept a list of ordered attribute names, maintaining the specified sequence at the beginning of the tag.
- Update test cases in test_repo/broken_module/template1.xml to cover these formatting rules.
- Update tests/test_checks.py and tests/test_node_xml.py to adapt check names and check counts.
- Regenerate README.md to document the new check and update examples.

@moylop260 moylop260 self-assigned this May 19, 2026
@moylop260 moylop260 force-pushed the main-t-if-first-moy branch from f1ebf25 to 8fe73dd Compare May 22, 2026 19:09
@moylop260 moylop260 changed the title [ADD] xml-tag-position: enforce t-if/t-else/t-elif and id positioning rules [ADD] xml-tag-position: enforce id, t-if/t-else/t-elif and class positioning attribute rules May 22, 2026
Comment thread src/oca_pre_commit_hooks/checks_odoo_module_xml.py Outdated
Comment thread src/oca_pre_commit_hooks/checks_odoo_module_xml.py Outdated
Comment thread src/oca_pre_commit_hooks/checks_odoo_module_xml.py
Comment thread src/oca_pre_commit_hooks/global_parser.py Outdated
Comment thread src/oca_pre_commit_hooks/global_parser.py
…tioning attribute rules

Rename the check xml-id-position-first to xml-tag-position to support a more general set of attribute positioning constraints.

Specifically:
- t-if, t-else, and t-elif must always be the first attribute in any XML tag.
- id, t-att-id, t-attf-id must be the second attribute
- class, t-att-class, t-attf-class must be the third attribute

Changes:
- Refactor checks_odoo_module_xml.py to use a single check_xml_tag_position visitor and a unified autofix.
- Update rewrite_start_tag in node_xml.py to accept a list of ordered attribute names, maintaining the specified sequence at the beginning of the tag.
- Update test cases in test_repo/broken_module/template1.xml to cover these formatting rules.
- Update tests/test_checks.py and tests/test_node_xml.py to adapt check names and check counts.
- Regenerate README.md to document the new check and update examples.
@moylop260 moylop260 force-pushed the main-t-if-first-moy branch from a9f178a to 84674a0 Compare June 17, 2026 19:08
@moylop260 moylop260 merged commit d4a12e9 into OCA:main Jun 17, 2026
17 of 20 checks passed
@moylop260 moylop260 deleted the main-t-if-first-moy branch June 17, 2026 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants