Angular 代码味道“要么删除此导入,要么将其添加为依赖项."使用我写的接口时.如何使我的代码合规? [英] 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?

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

问题描述

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

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

import { IPopUpOptions, IPopUpButton } from 'src/app/modals/pop-up-modal/pop-up-options-interface';

我的 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.

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

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