你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
此规则查找在 Bicep 文件中的任何位置未引用的 导入别名 。
Linter 规则代码
请在 Bicep 配置文件中使用以下值自定义规则设置:
no-unused-imports
解决方案
若要减少 Bicep 文件中的混淆,请删除已定义但未使用的任何导入。 此测试查找模板中的任何位置都未使用的所有导入。
以下示例未能通过此测试,因为 myImports
Bicep 文件中未使用该 myObjectType
测试:
import * as myImports from 'exports.bicep'
import {myObjectType, sayHello} from 'exports.bicep'
output greeting string = sayHello('Bicep user')
可以通过删除和更新语句来修复此问题 import
。
import {sayHello} from 'exports.bicep'
output greeting string = sayHello('Bicep user')
使用 快速修复 删除未使用的导入:
后续步骤
有关 Linter 的详细信息,请参阅使用 Bicep Linter。