Skip to content

Format does not work for packages with type "commonjs" #1974

Open
@JakeCirino

Description

@JakeCirino

I have multiple projects in my workspace, two of the projects have type "module" and one is commonjs. The projects with module are able to format on save properly, however the project with the "commonjs" type gives the following error:

"FormattingExtension 'ESLint' is configured as formatter but it cannot format 'TypeScript'-files"
Image

My package.json:

{
  "name": "server",
  "version": "1.0.0",
  "type": "commonjs",
  "main": "index.js",
  "scripts": {
    "lint": "eslint .",
    "build": "tsc -p tsconfig.json",
    "start": "pnpm run build && node dist/app.js",
    "clean": "rm -rf node_modules && rm package-lock.json && rm -rf dist",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "dependencies": {
    "argon2": "0.41.1",
    "body-parser": "^1.20.3",
    "cors": "2.8.5",
    "express": "4.21.2",
    "infra": "workspace:^",
    "jsonwebtoken": "9.0.2",
    "pg": "8.13.1",
    "validator": "13.12.0",
    "ws": "8.18.0"
  },
  "devDependencies": {
    "@types/body-parser": "^1.19.5",
    "@types/cors": "2.8.17",
    "@types/express": "5.0.0",
    "@types/jsonwebtoken": "^9.0.7",
    "@types/node": "22.10.6",
    "@types/pg": "8.11.10",
    "@types/validator": "13.12.2",
    "eslint": "9.18.0",
    "@types/ws": "8.5.13",
    "typescript": "5.7.3"
  },
  "pnpm": {}
}

tsconfig:

{
  "compilerOptions": {
    "target": "ES2018",
    "module": "CommonJS" /* Specify what module code is generated. */,
    "moduleResolution": "node" /* Specify how TypeScript looks up a file from a given module specifier. */,
    "baseUrl": "." /* Specify the base directory to resolve non-relative module names. */,
    "paths": {
      "*": ["node_modules/*", "./*"]
    },
    "allowJs": true /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */,
    "sourceMap": true /* Create source map files for emitted JavaScript files. */ /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */,
    "outDir": "dist" /* Specify an output folder for all emitted files. */,
    "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
    "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
    "strict": true /* Enable all strict type-checking options. */,
    "noImplicitAny": true /* Enable error reporting for expressions and declarations with an implied 'any' type. */,
    "skipLibCheck": true /* Skip type checking all .d.ts files. */
  },
  "include": ["./src/**/*"]
}

eslint version 9.18.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    info-neededIssue requires more information from poster

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions