-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
[BUG] The plugin does not pick up tailwind configs in projects nested within monorepos #241
Comments
Do you mind sharing your current I just fixed a similar issue and this worked for me: // .eslintrc.js
settings: {
tailwindcss: {
config: path.join(__dirname, './tailwind.config.js'),
},
}, |
I can confirm @Gomah 's solution works. |
It's fairly simple: {
"env": {
"browser": true,
"jest": true,
"node": false
},
"plugins": [
"tailwindcss"
],
"rules": {
"tailwindcss/classnames-order": [
"error"
],
"tailwindcss/enforces-negative-arbitrary-values": [
"error"
],
"tailwindcss/enforces-shorthand": [
"error"
],
"tailwindcss/migration-from-tailwind-2": [
"error"
],
"tailwindcss/no-arbitrary-value": [
"off"
],
"tailwindcss/no-contradicting-classname": [
"error"
],
"tailwindcss/no-custom-classname": [
"error",
]
},
"settings": {
"tailwindcss": {
"callees": [
"cn"
],
"config": "tailwind-config.js"
}
}
} In fact I can't use the workaround, since I use a JSON config. |
@quesabe did your commit provide a solution for your issue with JSON config ? |
@francoismassart However I'm not sure if it has a solution within the plugin repo - maybe it's a problem with eslint itself. |
After doing some digging, it looks like the vscode-eslint extension is not passing the context object to the rules when running from a higher level folder. You can confirm this yourself by being in your root project folder and running Apparently the solution is the // .vscode/settings.json
{
"eslint.workingDirectories": ["./your-package"],
} |
@lachieh Your suggested workaround with custom |
@maslennikov I didn't actually say that this file should be committed. I just provided a solution for correctly configuring the eslint extension. Whether it is practical or not is subjective and committing this file is a team decision. If your team has decided that shared workspace settings should actually not be shared, then perhaps you can find and suggest a different solution instead of just spreading your (unsolicited) opinion. For example, a common pattern is to add the |
Gomah thanks for the suggestion! Works 🚀 |
@quesabe Thank you for the solution! It was working for me |
I was also facing this problem in a Monorepo environment using Turborepo, but I tried the contents of microsoft/vscode-eslint#1706 (comment) I tried the contents of and it worked fine. |
I think the only way to solve this reliably is by searching for the config based on the location of the file that is being linted. |
it works in monorepo thank you soo much!! |
This works but I'm not using a monorepo. I'm using the base Vite template from This worked for me when my tailwindcss: {
config: path.join(import.meta.dirname, 'tailwind.config.js'),
} |
After trying some suggestions I found that vs code eslint run can be detected by checking if it is started from root dir
Then in specific package setup after adding below it works for VsEslint and when running script command
|
Just for people landing here who have a *.json eslint configuration and are working with a monorepo tool like Nx and wonder how to get this working. In my case I resolved it by referencing the tailwind-preset library in the monorepo top-level file .eslintrc.json.
|
Describe the bug
When a frontend project is nested within a monorepo, any linting process run not from the frontend folder does not see the tailwind config. This is especially apparent with VSCode intellisense - the eslint process is run at the project root level, while the tailwind config resides somewhere nested. Since the config is not found the plugin des not pick up any custom colours and other stuff.
To Reproduce
Assumed folder structure:
rootProject
folder thetailwind.config.js
is not found.frontend
folder thetailwind.config.js
is found.rootProject
and thus does not find thetailwind.config.js
.BTW, the eslint config is picked up and the rules from
eslint-plugin-tailwindcss
apply - they just don't use the custom theme and other settings.Expected behavior
Tailwind config is discoverable as long as it is in the same folder with the eslint config.
Environment (please complete the following information):
Additional context
Seems like this code is the reason for the behaviour:
https://github.com/francoismassart/eslint-plugin-tailwindcss/blob/master/lib/util/customConfig.js#L26
The
path.resolve()
resolves to therootProject
folder, while the config is atrootProject/frontend
.PS. I can make it work if I open the
frontend
folder in a separate editor window. However it is very inconvenient in a large project.The text was updated successfully, but these errors were encountered: