Skip to content

Commit 746be4d

Browse files
authored
Merge pull request #282247 from mumian/0725-linter-module-version
New linter rule on using recent module versions
2 parents 0994dcc + e7b0aad commit 746be4d

File tree

5 files changed

+52
-2
lines changed

5 files changed

+52
-2
lines changed

articles/azure-resource-manager/bicep/bicep-config-linter.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Linter settings for Bicep config
33
description: Describes how to customize configuration values for the Bicep linter
44
ms.topic: conceptual
55
ms.custom: devx-track-bicep
6-
ms.date: 07/19/2024
6+
ms.date: 07/30/2024
77
---
88

99
# Add linter settings in the Bicep config file
@@ -115,6 +115,9 @@ The following example shows the rules that are available for configuration.
115115
"level": "warning",
116116
"maxAllowedAgeInDays": 730
117117
},
118+
"use-recent-module-versions": {
119+
"level": "warning",
120+
},
118121
"use-resource-id-functions": {
119122
"level": "warning"
120123
},
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
title: Linter rule - use recent module versions
3+
description: Linter rule - use recent module versions
4+
ms.topic: reference
5+
ms.custom: devx-track-bicep
6+
ms.date: 07/30/2024
7+
---
8+
9+
# Linter rule - use recent module versions
10+
11+
This rule looks for old [public module](./modules.md#public-module-registry) versions. It's best to use the most recent module versions.
12+
13+
> [!NOTE]
14+
> This rule is off by default, change the level in [bicepconfig.json](./bicep-config-linter.md) to enable it.
15+
16+
## Linter rule code
17+
18+
To customize rule settings, use the following value in the [Bicep configuration file](bicep-config-linter.md) :
19+
20+
`use-recent-module-versions`
21+
22+
## Solution
23+
24+
The following example fails this test because an older module version is used:
25+
26+
```bicep
27+
module storage 'br/public:avm/res/storage/storage-account:0.6.0' = {
28+
name: 'myStorage'
29+
params: {
30+
name: 'store${resourceGroup().name}'
31+
}
32+
}
33+
```
34+
35+
Use the most recent module version.
36+
37+
Use **Quick Fix** to use the latest module versions:
38+
39+
:::image type="content" source="./media/linter-rule-use-recent-module-versions/linter-rule-use-recent-module-versions-quick-fix.png" alt-text="The screenshot of Simplify interpolation linter rule quick fix.":::
40+
41+
## Next steps
42+
43+
For more information about the linter, see [Use Bicep linter](./linter.md).

articles/azure-resource-manager/bicep/linter.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Use Bicep linter
33
description: Learn how to use Bicep linter.
44
ms.topic: how-to
55
ms.custom: devx-track-bicep
6-
ms.date: 07/19/2024
6+
ms.date: 07/30/2024
77
---
88

99
# Use Bicep linter
@@ -48,6 +48,7 @@ The default set of linter rules is minimal and taken from [arm-ttk test cases](.
4848
- [use-parent-property](./linter-rule-use-parent-property.md)
4949
- [use-protectedsettings-for-commandtoexecute-secrets](./linter-rule-use-protectedsettings-for-commandtoexecute-secrets.md)
5050
- [use-recent-api-versions](./linter-rule-use-recent-api-versions.md)
51+
- [use-recent-module-versions](./linter-rule-use-recent-module-versions.md)
5152
- [use-resource-id-functions](./linter-rule-use-resource-id-functions.md)
5253
- [use-resource-symbol-reference](./linter-rule-use-resource-symbol-reference.md)
5354
- [use-safe-access](./linter-rule-use-safe-access.md)
Loading

articles/azure-resource-manager/bicep/toc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,9 @@
544544
- name: Use recent API versions
545545
displayName: linter
546546
href: linter-rule-use-recent-api-versions.md
547+
- name: Use recent module versions
548+
displayName: linter
549+
href: linter-rule-use-recent-module-versions.md
547550
- name: Use resource ID functions
548551
displayName: linter
549552
href: linter-rule-use-resource-id-functions.md

0 commit comments

Comments
 (0)