在Angular和Angular CLI更新到v6之后,我的lint配置每次尝试运行时都会引发以下错误ng lint --type-check
:
具有多个目标的Architect命令不能指定替代。'lint'将在以下项目上运行:atlas-fe,atlas-fe-e2e
错误:具有多个目标的Architect命令无法指定替代。'lint'将在以下项目上运行:
att -fe,atlas-fe-e2e at LintCommand.validate(/ home / nroma / workspace / atlas / proto-fe / node_modules / @ angular / cli / models / architect-command .js:75:23)
位于/home/nroma/workspace/atlas/proto-fe/node_modules/@angular/cli/models/command-runner.js:274:39 位于/ home / nroma的
Generator.next()
/workspace/atlas/proto-fe/node_modules/@angular/cli/models/command-runner.js:7:71
在
__awaiter(/ home / nroma / workspace / atlas / proto-fe / node_modules / @ angular / cli / models / command-runner.js:3:12)
在Object的 validateAndRunCommand(/home/nroma/workspace/atlas/proto-fe/node_modules/@angular/cli/models/command-runner.js:273:12)中。(/home/nroma/workspace/atlas/proto-fe/node_modules/@angular/cli/models/command-runner.js:100:26)
在Generator.next()
处已实现(/ home / nroma / workspace / atlas /proto-fe/node_modules/@angular/cli/models/command-runner.js:4:58)
我正在使用节点v9.9.0(npm v6.0.1)。
这是我的package.json …
我理解为什么当一个类是超类的子类时使用了super(),但是什么是未指定子类参数中的超类的类的超类?这是我的代码:
import random
class Sneaky:
sneaky = True
def __init__(self, sneaky=True, *args, **kwargs):
super().__init__(*args, **kwargs)
self.sneaky = sneaky
def hide(self, light_level):
return self.sneaky and light_level < 10
class Agile:
agile = True
def __init__(self, agile=True, *args, **kwargs):
super().__init__(*args, **kwargs)
self.agile = agile
def evade(self):
return self.agile and random.randint(0, 1)
Run Code Online (Sandbox Code Playgroud) 我有以下 TS 接口
export interface Item {
product: string | Product;
}
Run Code Online (Sandbox Code Playgroud)
当我想遍历项目数组时,我必须消除类型。换句话说
items = Items[];
items.forEach(item => {
item.product._id
})
Run Code Online (Sandbox Code Playgroud)
不起作用,因为属性不适用于字符串。因此我必须预先检查类型,即:
items = Items[];
items.forEach(item => {
if (typeof item.product === 'object') item.product._id
})
Run Code Online (Sandbox Code Playgroud)
我真的不喜欢它的样子。你如何处理这种情况?
我正在准备考试,目前正在阅读有关观察者模式的内容。然后我想知道观察者模式遵循或违反了哪些SOLID原则?
我将Angular项目更新为Angular 6,并且不知道如何进行http获取请求.这就是我在Angular 5中的表现:
get(chessId: string): Observable<string> {
this.loadingPanelService.text = 'Loading...';
this.loadingPanelService.isLoading = true;
const url = `${this.apiPathService.getbaseUrl()}api/chess/${chessId}/rating`;
return this.http.get<string>(url)
.catch((error) => {
console.error('API error: ', error);
this.loadingPanelService.isLoading = false;
this.notificationService.showErrorMessage(error.message);
return Observable.of(null);
})
.share()
.finally(() => {
this.loadingPanelService.isLoading = false;
});
Run Code Online (Sandbox Code Playgroud)
这就是我现在正在做的事情.这是应该如何在Angular 6中完成的吗?
...
return this.http.get<string>(url)
.pipe(
catchError(this.handleError),
share(),
finalize(() =>{this.loadingPanelService.isLoading = false})
);
private handleError(error: HttpErrorResponse) {
console.error('API error: ', error);
this.loadingPanelService.isLoading = false;
this.notificationService.showErrorMessage(error.message);
// return an observable with a user-facing error message
return throwError(
'Something bad happened; …
Run Code Online (Sandbox Code Playgroud) 我一直在研究 React Typescript 存储库,并且遇到了一个恼人的问题,即开玩笑时无法解析相对于根目录的导入。
Cannot find module '~lib/dates' from 'utils.ts'
Run Code Online (Sandbox Code Playgroud)
这就是组件/实用程序中导入的样子
import { abc } from '~lib/dates'; // this fails to run
Run Code Online (Sandbox Code Playgroud)
如果我将其更改为相对路径,玩笑测试将按预期运行
import { abc } from '../../lib/dates'; // this runs as expected
Run Code Online (Sandbox Code Playgroud)
同样的路径适用于其他一些目录,我有点困惑
import { xyz } from '~components/home/constants'; // jest resolves it
import { abc } from '~lib/dates'; // ERR
Run Code Online (Sandbox Code Playgroud)
我尝试将其包含moduleNameWrapper
在 jestConfig 中,看看它是否可以正确解析导入,但没有帮助。
包.json
"jest": {
...
"moduleNameWrapper": {
"^~(.*)$": "<rootDir>/src/$1"
}
}
Run Code Online (Sandbox Code Playgroud)
我肯定可以更新 VS 代码设置,以便自动导入相对于文件而不是根目录进行解析,但这已经困扰我一段时间了。如果有人能指导如何最好地解决这个问题,那就太好了。
我在一个具有以下目录结构的 monorepo 上
repo
server
client
src
components
lib …
Run Code Online (Sandbox Code Playgroud) 我有一个直接的反应补偿。我想根据反应状态测试样式。该 comp 如下所示:
const Backdrop = ({ showBackdrop }) => {
const backdropRef = useRef();
function getBackdropHeight() {
if (typeof window !== 'undefined') {
return `calc(${document.body.clientHeight}px -
${backdropRef.current?.offsetTop || 0}px)`;
}
return 0;
}
return (
<div
data-testid="backdrop"
className={classNames(styles.backdrop, showBackdrop ? styles.show : styles.hide)}
ref={backdropRef}
style={{ height: getBackdropHeight() }}
/>
);
};
Run Code Online (Sandbox Code Playgroud)
.backdrop {
width: 100%;
position: absolute;
left: 0;
right: 0;
top: 156px;
background-color: rgba(0, 0, 0, 0.7);
z-index: 3;
...
}
.show {
opacity: 0;
visibility: …
Run Code Online (Sandbox Code Playgroud) javascript reactjs jestjs react-test-renderer react-testing-library
我正在使用 ESLint 及其 VS Code 扩展来格式化我的代码。
在某些时候,它会停止在保存时自动格式化代码。我卸载了所有内容并重新安装:VS Code、ESLint 和 VS Code 的 ESLint 扩展。
我想我已经接近让格式化程序正常工作了,但是当我尝试保存带有 linting 错误的文件时,ESLint 会将其记录在 VS Code 中:
2020-10-10T10:41:45.345Z eslint:source-code-fixer shouldFix parameter was false, not attempting fixes
Run Code Online (Sandbox Code Playgroud)
我想如果我找到该shouldFix
参数并将其设置为true
它会起作用,但是它在哪里?
突然纱线不工作了。Npm 工作正常,但只能运行yarn -v,任何其他命令(例如yarn、yarn test 或yarn watch)都会显示此错误
Arguments:
/home/my.user/.nvm/versions/node/v14.15.4/bin/node /home/my.user/.nvm/versions/node/v14.15.4/bin/yarn
PATH:
/home/my.user/.nvm/versions/node/v14.15.4/bin:/home/my.user/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
Yarn version:
1.22.10
Node version:
14.15.4
Platform:
linux x64
Trace:
Error: EISDIR: illegal operation on a directory, read
npm manifest:
{
"name": "one",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo 'hello'"
},
"keywords": [],
"author": "",
"license": "ISC"
}
yarn manifest:
No manifest
Lockfile:
No lockfile
Run Code Online (Sandbox Code Playgroud) 每当我尝试在我的虚拟主机中的 Ubuntu 中安装 pm2 时,我都会遇到错误。
命令:
sudo npm install pm2@latest -g
Run Code Online (Sandbox Code Playgroud)
错误:
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
Run Code Online (Sandbox Code Playgroud)
我应该怎么办?
angular ×3
javascript ×3
typescript ×3
angular6 ×2
jestjs ×2
node.js ×2
angular-cli ×1
deployment ×1
eslint ×1
lint ×1
npm ×1
pm2 ×1
python ×1
reactjs ×1
ubuntu ×1
yarnpkg ×1