角度代码闻到“要么删除此导入,要么将其添加为依赖项".当使用我写的接口时.如何使我的代码合规? [英] Angular code smell "Either remove this import or add it as a dependency." when using an interface I wrote. How can I make my code compliant?

查看:141
本文介绍了角度代码闻到“要么删除此导入,要么将其添加为依赖项".当使用我写的接口时.如何使我的代码合规?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是UI开发的新手,所以如果这不是棱角的话,请原谅我.我在这里使用Angular 8和打字稿.无论如何,我创建了一个弹出模式,我不想在我的整个网站上使用它.看起来不错,但是当我将其插入这样的组件中

I'm new to UI development so forgive me if this isn't angular. I'm using Angular 8 and typescript here. Anyways I created a pop-up modal that I wan't to use throughout my website. It looks great but when I plug it into my components like this

从'src/app/modals/pop-up-modal/pop-up-options-interface'导入{IPopUpOptions,IPopUpButton};

我的SonarQube CI/CD管道说:要么删除此导入,要么将其添加为依赖项.应在package.json文件中明确列出依赖项.导入未声明为依赖项的模块使其成为隐式的,并且必然会造成问题."这是什么意思?如何正确使用弹出窗口,使其遵守此规则?

My SonarQube CI/CD pipeline says "Either remove this import or add it as a dependency. Dependencies should be explicitly listed in the package.json file. Importing a module that is not declared as a dependency makes it an implicit one and is bound to create problems." What does this mean? How can I use my pop-up properly so that it abides by this rule?

推荐答案

尝试将'./'添加到您的导入路径:'./src/app/modals/pop-...'.否则,它可能被视为依赖项导入(即从node_modules导入),而不是文件系统导入.

Try adding './' to your import path: './src/app/modals/pop-...'. Without that, it might be seen as a dependency import (i.e., from node_modules) rather than a file system import.

这篇关于角度代码闻到“要么删除此导入,要么将其添加为依赖项".当使用我写的接口时.如何使我的代码合规?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆