我已经移植到 eslint-webpack-plugin 并且我收到错误“ESLint 不是构造函数”,相关的代码片段是:
const ESLintPlugin = require('eslint-webpack-plugin');
const plugins = [
new webpack.DefinePlugin(productionEnvironmentVariables),
new ESLintPlugin({
overrideConfigFile: path.resolve(configPath, '.eslintrc.json')
})
];
Run Code Online (Sandbox Code Playgroud)
知道出了什么问题吗?我也尝试过使用 new ESLintPlugin() 和 ESLintPlugin({})。
Webpack 版本是 ^4.44.2 Eslint 版本是 ^6.8.0 eslint-webpack-plugin 是 ^2.1.0
预先感谢您并问候。
Enums
我正在尝试在 SQLAlchemy 2.0 中使用mapped_column
. 到目前为止,我有以下代码(取自另一个问题):
from sqlalchemy.dialects.postgresql import ENUM as pgEnum
import enum
class CampaignStatus(str, enum.Enum):
activated = "activated"
deactivated = "deactivated"
CampaignStatusType: pgEnum = pgEnum(
CampaignStatus,
name="campaignstatus",
create_constraint=True,
metadata=Base.metadata,
validate_strings=True,
)
class Campaign(Base):
__tablename__ = "campaign"
id: Mapped[UUID] = mapped_column(primary_key=True, default=uuid4)
created_at: Mapped[dt.datetime] = mapped_column(default=dt.datetime.now)
status: Mapped[CampaignStatusType] = mapped_column(nullable=False)
Run Code Online (Sandbox Code Playgroud)
然而,这会在类本身的构造上产生以下错误 Campaign
。
Traceback (most recent call last):
File "<stdin>", line 27, in <module>
class Campaign(Base):
...
AttributeError: 'ENUM' object has no attribute '__mro__'
Run Code Online (Sandbox Code Playgroud)
关于如何进行这项工作有任何提示吗?
我正在尝试让 VSCode 与我的 React 项目顺利配合。我指的是单击组件并进入内部、查看组件或建议自动完成(智能感知)的功能。
到目前为止我有这个:
{
"compilerOptions": {
"module": "es6",
"target": "es2019",
"jsx": "react",
"baseUrl": ".",
"paths": {
"@Reducers/*": ["./src/reducers/*"],
"@Selectors/*": ["./src/selectors/*"],
"@Components/*": ["./src/components/*"],
"@App/*": ["./src/components/App/*"],
"@Footer/*": ["./src/components/Footer/*"],
"@Header/*": ["./src/components/Header/*"],
}
},
"include" : ["src/**/*"],
"exclude": ["node_modules", "dist", "config", ".vscode"]
}
Run Code Online (Sandbox Code Playgroud)
我不使用 CRA。
知道为什么不起作用吗?任何帮助,将不胜感激。预先感谢您并致以问候
编辑:似乎使用 module:commonjs 而不是 es6 效果更好,知道为什么吗?我正在使用 es6 导入!
edit2:原因解释如下: https: //github.com/Microsoft/vscode/issues/24715
我的 .tsx 文件中有以下代码:
import L from 'leaflet';
import icon from 'leaflet/dist/images/marker-icon.png';
import iconShadow from 'leaflet/dist/images/marker-shadow.png';
Run Code Online (Sandbox Code Playgroud)
Typescript 正在抱怨第二行和第三行。不仅是 linter,还有 TS 编译器本身。
具体来说,linter 表示“它找不到模块‘blabla/icon.png’或其相应的类型声明。但是,导入 L 是可以的。
任何人都知道为什么会发生这种情况以及如何解决这个问题?
我的 tsconfig 文件如下所示:
{
"compilerOptions": {
"outDir": "./dist/", // path to output directory
"sourceMap": true, // allow sourcemap support
"strictNullChecks": true, // enable strict null checks as a best practice
"module": "esnext", // specify module code generation
"jsx": "react", // use typescript to transpile jsx to js
"target": "es5", // specify ECMAScript target version
"allowJs": …
Run Code Online (Sandbox Code Playgroud) 我正在尝试执行以下教程:https : //itnext.io/docker-mongodb-authentication-kubernetes-node-js-75ff995151b6
但是,在那里,它们使用位于 docker-entrypoint-initdb.d 文件夹中的 mongo init.js 文件的原始值。
我想使用来自我的 CI/CD 系统 (Gitlab) 的环境变量。有谁知道如何将环境变量传递给 init.js 文件?我已经尝试了几种方法,例如使用 init.sh 代替 shell,但没有任何成功。
如果我手动运行 init shell 版本,我可以让它工作,因为我用 --eval 调用 mongo 并传递值,但是,docker-entrypoint-blabla 是自动调用的,所以我无法控制它是如何调用的我不知道我能做些什么来实现我想要的。
预先感谢您并问候。
我想在所有测试用例之前只运行一些东西一次。因此,我创建了一个全局函数,并在 jest 配置中指定了globalSetup字段:
globalSetup: path.resolve(srcPath, 'TestUtils', 'globalSetup.ts'),
Run Code Online (Sandbox Code Playgroud)
然而,在globalSetup中,我使用了一些别名 @ ,而 Jest 抱怨它找不到它们。
一旦别名被整理出来,我如何运行globalSetup ?
我的 Jest 配置如下:
module.exports = {
rootDir: rootPath,
coveragePathIgnorePatterns: ['/node_modules/'],
preset: 'ts-jest',
setupFiles: [path.resolve(__dirname, 'env.testing.ts')],
setupFilesAfterEnv: [path.resolve(srcPath, 'TestUtils', 'testSetup.ts')],
globalSetup: path.resolve(srcPath, 'TestUtils', 'globalSetup.ts'),
globals: {},
testEnvironment: 'node',
moduleFileExtensions: ['js', 'ts', 'json'],
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '<rootDir>/' })
};
Run Code Online (Sandbox Code Playgroud)
当我在每次测试之前运行testSetup时,它可以正常运行别名,但globalSetup不会发生这种情况。
知道我能做什么吗?
我想知道是否可以使用通配符模拟某些 URL,例如所有以/auth
. 我可以做类似的事情/auth*
吗?
javascript ×2
typescript ×2
axios ×1
database ×1
docker ×1
eslint ×1
fastapi ×1
intellisense ×1
jestjs ×1
kubernetes ×1
leaflet ×1
mongodb ×1
mongoose ×1
postgresql ×1
python ×1
reactjs ×1
sqlalchemy ×1
testing ×1
ts-jest ×1
webpack ×1