[PR #62] [MERGED] feat: add custom dylint lint to enforce node_kinds constants usage #212

Closed
opened 2026-03-15 11:53:40 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/awslabs/iam-policy-autopilot/pull/62
Author: @adpaco-aws
Created: 12/9/2025
Status: Merged
Merged: 12/9/2025
Merged by: @adpaco-aws

Base: mainHead: custom-dylint-node-kinds


📝 Commits (4)

  • 471ca2d feat: add custom dylint lint to enforce node_kinds constants usage
  • 4ecd65b docs: explain need of nightly and clippy version matching
  • 31861fc fix: additionally check type on kind() receiver
  • f1ba24f fix: make lint trigger errors instead of warnings

📊 Changes

13 files changed (+390 additions, -6 deletions)

View changed files

📝 .github/workflows/pr-checks.yml (+32 -0)
📝 Cargo.toml (+1 -0)
dylint.toml (+4 -0)
iam-policy-autopilot-lints/.cargo/config.toml (+6 -0)
iam-policy-autopilot-lints/Cargo.toml (+23 -0)
iam-policy-autopilot-lints/README.md (+76 -0)
iam-policy-autopilot-lints/rust-toolchain (+6 -0)
iam-policy-autopilot-lints/src/lib.rs (+14 -0)
iam-policy-autopilot-lints/src/node_kind_literal.rs (+113 -0)
iam-policy-autopilot-lints/ui/main.rs (+80 -0)
iam-policy-autopilot-lints/ui/main.stderr (+35 -0)
📝 iam-policy-autopilot-policy-generation/src/extraction/go/node_kinds.rs (+0 -3)
📝 iam-policy-autopilot-policy-generation/src/extraction/python/node_kinds.rs (+0 -3)

📄 Description

Issue #, if available: Resolves #60

Description of changes: Adds a custom dylint lint that enforces the use of node_kinds constants instead of string literals when comparing Tree-sitter node types. The lint detects any pattern where .kind() is compared with a string literal (e.g., node.kind() == "composite_literal") and suggests defining a constant in a node_kinds module.

This is enforced automatically in CI via a new custom-lints job that runs on every PR, preventing regressions from the recent node kinds constants refactor.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/awslabs/iam-policy-autopilot/pull/62 **Author:** [@adpaco-aws](https://github.com/adpaco-aws) **Created:** 12/9/2025 **Status:** ✅ Merged **Merged:** 12/9/2025 **Merged by:** [@adpaco-aws](https://github.com/adpaco-aws) **Base:** `main` ← **Head:** `custom-dylint-node-kinds` --- ### 📝 Commits (4) - [`471ca2d`](https://github.com/awslabs/iam-policy-autopilot/commit/471ca2d8c0a61adf0311f3c64749753c2f4aa5ee) feat: add custom dylint lint to enforce node_kinds constants usage - [`4ecd65b`](https://github.com/awslabs/iam-policy-autopilot/commit/4ecd65be3b28a1c3c8182b54fceea33715918f33) docs: explain need of nightly and clippy version matching - [`31861fc`](https://github.com/awslabs/iam-policy-autopilot/commit/31861fc7ba09b545c17a2a75c8dcc092701de9a3) fix: additionally check type on `kind()` receiver - [`f1ba24f`](https://github.com/awslabs/iam-policy-autopilot/commit/f1ba24f60eb8860b3d687c43042735798f053aca) fix: make lint trigger errors instead of warnings ### 📊 Changes **13 files changed** (+390 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/pr-checks.yml` (+32 -0) 📝 `Cargo.toml` (+1 -0) ➕ `dylint.toml` (+4 -0) ➕ `iam-policy-autopilot-lints/.cargo/config.toml` (+6 -0) ➕ `iam-policy-autopilot-lints/Cargo.toml` (+23 -0) ➕ `iam-policy-autopilot-lints/README.md` (+76 -0) ➕ `iam-policy-autopilot-lints/rust-toolchain` (+6 -0) ➕ `iam-policy-autopilot-lints/src/lib.rs` (+14 -0) ➕ `iam-policy-autopilot-lints/src/node_kind_literal.rs` (+113 -0) ➕ `iam-policy-autopilot-lints/ui/main.rs` (+80 -0) ➕ `iam-policy-autopilot-lints/ui/main.stderr` (+35 -0) 📝 `iam-policy-autopilot-policy-generation/src/extraction/go/node_kinds.rs` (+0 -3) 📝 `iam-policy-autopilot-policy-generation/src/extraction/python/node_kinds.rs` (+0 -3) </details> ### 📄 Description *Issue #, if available:* Resolves #60 *Description of changes:* Adds a custom dylint lint that enforces the use of `node_kinds` constants instead of string literals when comparing Tree-sitter node types. The lint detects any pattern where `.kind()` is compared with a string literal (e.g., `node.kind() == "composite_literal"`) and suggests defining a constant in a `node_kinds` module. This is enforced automatically in CI via a new `custom-lints` job that runs on every PR, preventing regressions from the recent node kinds constants refactor. By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-15 11:53:40 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/iam-policy-autopilot#212
No description provided.