Search code examples
node.jstypescripttsc

Stop Typescript compiler putting semicolons in src


I am creating a Node/Express API using Microsoft's Typescript Node Starter Project - https://github.com/microsoft/TypeScript-Node-Starter

When I build the project it's inserting semicolons in all my code. Not the compiled code in /dist, but the source code in /src which I don't want semicolons in.

The package.json has the following scripts (abbreviated)

"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",
    ...
},

This is the content of my 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/**/*"
    ]
}

Is there a flag I can use to switch this behavior off?


Solution

  • In .eslintrc file change the rule semi to

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