Skip to content

Fix tailwind ES modules warning in basic starter #2974

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

FranjoMindek
Copy link
Contributor

@FranjoMindek FranjoMindek commented Jul 17, 2025

As reported by Filip (internal message): https://discord.com/channels/686873244791210014/1351908377533354025/1395147983347257436

We received following warning message when using wasp start on new basic starter project.

image

This is because the tailwind.config.cjs was forced to use import instead of require by eslint rule.

We fix it by ignoring the rule.

NOTE1:
There is an option to enable require imports in eslint, but IMHO, I would rather make it error as to promote import syntax.
https://typescript-eslint.io/rules/no-require-imports/#allowasimport

NOTE2:
This does not remove the eslint error:

// @typescript-eslint/no-require-imports
const { resolveProjectPath } = require('wasp/dev')

This is enough by itself, but I want to leave the @typescript-eslint/no-require-imports to make it clear what the reason is for this.

// eslint-disable-next-line
const { resolveProjectPath } = require('wasp/dev')

@FranjoMindek FranjoMindek self-assigned this Jul 17, 2025
@@ -1,4 +1,5 @@
import { resolveProjectPath } from "wasp/dev";
// eslint-disable-next-line @typescript-eslint/no-require-imports
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can add additional comment as explanation for this.
Is this necessary? This will be in each basic starter.

Copy link
Contributor

@sodic sodic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the core issue here is that our ESLint config is wrong. It enforces the import syntax in CJS modules, which is contradictory. So let's fix that instead.

Or verify that I'm wrong :)

@FranjoMindek
Copy link
Contributor Author

FranjoMindek commented Jul 17, 2025

I'm aligned on the idea that we should promote ESM when possible, and make CJS an exception.
In that case disallowing it, and ignoring it in this specific case is the way to go

But that might not be the best for the framework.
I can do:

export default defineConfig([
  // ...old
  {
    "files": ["*.cjs"],
    "rules": {
      "@typescript-eslint/no-require-imports": ["off"]
    }
  }
]);

Where I turn off this rule for .cjs files.

It's also possible is to use: "@typescript-eslint/no-require-imports": ["error", { "allowAsImport": true }] instead of "off".
That would allows only for require imports in .cjs files, and no other require use cases.
I don't know how much freedom do you want to give.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants