停止 Typescript 编译器将分号放入 src

Stop Typescript compiler putting semicolons in src

我正在使用 Microsoft 的 Typescript Node Starter 项目创建 Node/Express API - https://github.com/microsoft/TypeScript-Node-Starter

当我构建项目时,它会在我的所有代码中插入分号。不是 /dist 中的编译代码,而是 /src 中的源代码,我不想在其中使用分号。

package.json有以下脚本(略)

"scripts": {
    ...
    "build": "npm run build-ts && npm run lint && npm run copy-static-assets",
    "build-ts": "tsc",
    "copy-static-assets": "ts-node copyStaticAssets.ts",
    "lint": "tsc --noEmit && eslint \"**/*.{js,ts}\" --quiet --fix",
    ...
},

这是我tsconfig.json

的内容
{
    "compilerOptions": {
        "module": "commonjs",
        "esModuleInterop": true,
        "allowSyntheticDefaultImports": true,
        "target": "es6",
        "lib": ["es2019", "dom"],
        "noImplicitAny": true,
        "moduleResolution": "node",
        "sourceMap": true,
        "outDir": "dist",
        "baseUrl": ".",
        "paths": {
            "*": [
                "node_modules/*",
                "src/types/*"
            ]
        }
    },
    "include": [
        "src/**/*"
    ]
}

是否有可以用来关闭此行为的标志?

不是 TypeScript 编译器,可能是 eslint 的 --fix 标志(在 lint 脚本中)。参见semi rule in the file .eslintrc。您可以将其更改为 ["error", "never"].

.eslintrc 文件中将规则半更改为

"rules" : {
  ...,
  "semi": ["error", "never"],
}