Add no-module-name linter rule to enforce omitting explicit module names#19556
Conversation
Agent-Logs-Url: https://github.com/Azure/bicep/sessions/a5e60229-a7e9-4051-bc54-3963785984e5 Co-authored-by: anthony-c-martin <38542602+anthony-c-martin@users.noreply.github.com>
no-module-name linter rule to enforce omitting explicit module names
|
Test this change out locally with the following install scripts (Action run 25180881312) VSCode
Azure CLI
|
|
@copilot fix the tests pls |
…on tests Agent-Logs-Url: https://github.com/Azure/bicep/sessions/520ebcc3-5d88-499b-8394-b2e9f1a95a0b Co-authored-by: anthony-c-martin <38542602+anthony-c-martin@users.noreply.github.com>
Fixed in e20d1bf. The baseline integration tests were failing because Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
anthony-c-martin
left a comment
There was a problem hiding this comment.
@copilot please address feedback
…date description text Agent-Logs-Url: https://github.com/Azure/bicep/sessions/bb4d9091-57d8-45f5-824b-a4215fb6f3cc Co-authored-by: anthony-c-martin <38542602+anthony-c-martin@users.noreply.github.com>
Done in b2c8936. Three things addressed:
|
|
@copilot see latest feedback |
…rty pattern Agent-Logs-Url: https://github.com/Azure/bicep/sessions/13065bc1-d90f-42db-abef-ed54995bc8dc Co-authored-by: anthony-c-martin <38542602+anthony-c-martin@users.noreply.github.com>
Bicep supports omitting the
nameproperty on module declarations, generating a deterministic name automatically. This adds an opt-in linter rule to enforce that pattern, preventing accidental deployment name collisions between nested modules.New rule:
no-module-namebicepconfig.jsonname:propertyFlagged:
Expected:
Enable via
bicepconfig.json:{ "analyzers": { "core": { "rules": { "no-module-name": { "level": "warning" } } } } }Changes
NoModuleNameRule.cs— rule implementation with code fix (SyntaxModifier.TryRemoveProperty)CoreResources.resx/CoreResources.Designer.cs— description and fix title stringsbicepconfig.schema.json— schema entry withrule-def-level-offdefaultNoModuleNameRuleTests.cs— unit tests for diagnostics and code fixExplicitValuesForLocationParamsRuleTests,WhatIfShortCircuitingRuleTests,NoHardcodedLocationRuleTeststo remove explicit modulename:properties that would now trigger the rule when all analyzers are enabled in tests