Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
JakeCirino opened this issue Jan 22, 2025 · 1 comment
Open

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

JakeCirino opened this issue Jan 22, 2025 · 1 comment
Labels
info-needed Issue requires more information from poster

Comments

@JakeCirino
Copy link

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

@dbaeumer
Copy link
Member

Does formatting work correctly for you in the terminal using the --fix option?

If so can you please provide me with a GitHub repository I can clone with a minimal repro that demos what you are seeing. That will help me investigate the issue.

@dbaeumer dbaeumer added the info-needed Issue requires more information from poster label Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

2 participants