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

tailwindcss ui: Add tailwindcss prettier rules #5812

Merged
merged 3 commits into from
Jul 22, 2022

Conversation

Morishiri
Copy link
Contributor

@Morishiri Morishiri commented Jun 23, 2022

Closes #5795

Standard scenarios:

Before:

module.exports = {
  "trailingComma": "es5",
  "bracketSpacing": true,
  "tabWidth": 2,
  "semi": false,
  "singleQuote": true,
  "arrowParens": "always",
  "overrides": [
    {
      "files": "Routes.*",
      "options": {
        "printWidth": 999
      }
    }
  ],
}

After:

module.exports = {
  "trailingComma": "es5",
  "bracketSpacing": true,
  "tabWidth": 2,
  "semi": false,
  "singleQuote": true,
  "arrowParens": "always",
  "overrides": [
    {
      "files": "Routes.*",
      "options": {
        "printWidth": 999
      }
    }
  ],
  "tailwindConfig": "./web/config/tailwind.config.js",
  "plugins": [
    require('prettier-plugin-tailwindcss'),
  ],
}

After with --force (no changes):

module.exports = {
  "trailingComma": "es5",
  "bracketSpacing": true,
  "tabWidth": 2,
  "semi": false,
  "singleQuote": true,
  "arrowParens": "always",
  "overrides": [
    {
      "files": "Routes.*",
      "options": {
        "printWidth": 999
      }
    }
  ],
  "tailwindConfig": "./web/config/tailwind.config.js",
  "plugins": [
    require('prettier-plugin-tailwindcss'),
  ],
}

Scenario when user has something in plugins already:

Before:

module.exports = {
  "trailingComma": "es5",
  "bracketSpacing": true,
  "tabWidth": 2,
  "semi": false,
  "singleQuote": true,
  "arrowParens": "always",
  "overrides": [
    {
      "files": "Routes.*",
      "options": {
        "printWidth": 999
      }
    }
  ],
  "plugins": [
    require('some-other-plugin'),
  ],
}

After:

module.exports = {
  "trailingComma": "es5",
  "bracketSpacing": true,
  "tabWidth": 2,
  "semi": false,
  "singleQuote": true,
  "arrowParens": "always",
  "overrides": [
    {
      "files": "Routes.*",
      "options": {
        "printWidth": 999
      }
    }
  ],
  "plugins": [
    require('prettier-plugin-tailwindcss'),
    require('some-other-plugin'),
  ],
  "tailwindConfig": "./web/config/tailwind.config.js",
}

@netlify
Copy link

netlify bot commented Jun 23, 2022

Deploy Preview for redwoodjs-docs canceled.

Name Link
🔨 Latest commit 61f0ab4
🔍 Latest deploy log https://app.netlify.com/sites/redwoodjs-docs/deploys/62daca34e70b6500093a6752

Copy link
Collaborator

@simoncrypta simoncrypta left a comment

Choose a reason for hiding this comment

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

@Morishiri Thanks again for doing this, this plugin is a big productivity boost while working with TailwindCSS. 😄

When I tested it, I got 2 problems.
First, in the export object, the key don't have quote and value have single quote like this :

 module.exports = {
  trailingComma: 'es5',
  bracketSpacing: true,
  ...
  }

You can check the default file https://github.com/redwoodjs/redwood/blob/main/packages/create-redwood-app/template/prettier.config.js

Secondly, like in the example you wrote, tailwindConfig and plugins should be in the bottom of the file, but I get it inside the overrides option. You probably need to test your regex from a new project.

Tell me what you think :)

@Morishiri
Copy link
Contributor Author

I will check that out.

@Morishiri
Copy link
Contributor Author

@simoncrypta please take a look again

@Morishiri Morishiri force-pushed the issue-5795 branch 2 times, most recently from fa25c47 to d325d41 Compare June 28, 2022 18:34
@Morishiri Morishiri requested a review from simoncrypta June 28, 2022 18:34
'postcss-loader',
'tailwindcss',
'autoprefixer',
'prettier-plugin-tailwindcss',
Copy link
Collaborator

Choose a reason for hiding this comment

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

@Morishiri It's looking good ! Last thing, I think prettier-plugin-tailwindcss should be in the package.json on the root, otherwise that will cause error on the output console for Prettier on VS Code.

Copy link
Collaborator

@simoncrypta simoncrypta Jul 2, 2022

Choose a reason for hiding this comment

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

That's probably mean 2 different installation process.

@simoncrypta
Copy link
Collaborator

Hey @Morishiri
Just check-in, see if everything is all right or if you need help :)
No pressure !

@Morishiri
Copy link
Contributor Author

Hey @Morishiri Just check-in, see if everything is all right or if you need help :) No pressure !

Yes,
planning to take on all the unfinished PRs I have opened here over the weekend. Didn't have much time recently.

@Morishiri Morishiri force-pushed the issue-5795 branch 2 times, most recently from 1395da3 to f26daad Compare July 16, 2022 15:18
@Morishiri
Copy link
Contributor Author

@simoncrypta done I think ;)

@simoncrypta simoncrypta self-requested a review July 20, 2022 16:37
@nx-cloud
Copy link

nx-cloud bot commented Jul 22, 2022

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 61f0ab4. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 14 targets

Sent with 💌 from NxCloud.

Copy link
Collaborator

@simoncrypta simoncrypta left a comment

Choose a reason for hiding this comment

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

Everything look perfect !
Sorry for the delay, and thank you very much for this ! 😄

@simoncrypta simoncrypta enabled auto-merge (squash) July 22, 2022 16:04
@simoncrypta simoncrypta merged commit 0646c9c into redwoodjs:main Jul 22, 2022
@redwoodjs-bot redwoodjs-bot bot added this to the next-release milestone Jul 22, 2022
jtoar pushed a commit that referenced this pull request Jul 23, 2022
Co-authored-by: Simon Gagnon <git@simoncrypta.dev>
@jtoar jtoar modified the milestones: next-release, v2.2.0 Jul 23, 2022
jtoar pushed a commit that referenced this pull request Jul 28, 2022
Co-authored-by: Simon Gagnon <git@simoncrypta.dev>
dac09 added a commit to dthyresson/redwood that referenced this pull request Jul 28, 2022
…onfig-plugins

* 'main' of github.com:redwoodjs/redwood: (78 commits)
  fix(cli): Modify existence check of jest.config to check for both .js and .ts extensions in rw test (redwoodjs#6074)
  Tutorial 6.4: Add type generics to mockGraphQLMutation (redwoodjs#6046)
  Tutorial 6.2: Add generics type hint to CellSuccessProps (redwoodjs#6042)
  fix(deps): update graphql-tools monorepo (redwoodjs#6066)
  fix(deps): update dependency @types/node to v16.11.46 (redwoodjs#6065)
  chore(deps): update dependency @okta/okta-auth-js to v6.7.3 (redwoodjs#6068)
  chore(deps): update dependency @types/react to v17.0.48 (redwoodjs#6069)
  CLI responsiveness (redwoodjs#6028)
  Copy changes from "Make Jest Debugging a No-Brainer" (5296) (redwoodjs#6070)
  fix(deps): update dependency @graphql-codegen/cli to v2.11.0 (redwoodjs#6067)
  Update yarn.lock
  Version docs to 2.2
  Update all contributors
  Update yarn.lock
  v2.2.0
  Dedupe yarn.lock
  Show correct env filename on serverless firstrun deploy (redwoodjs#6023)
  chore(deps): update dependency firebase to v9.9.1 (redwoodjs#6020)
  tailwindcss ui: Add tailwindcss prettier rules (redwoodjs#5812)
  fix(deps): update dependency eslint-plugin-jsx-a11y to v6.6.1 (redwoodjs#6017)
  ...
@vincentri
Copy link

Hi, looks like this one fail. I cannot install tailwind.

Uploading Screenshot 2022-08-03 at 5.58.00 PM.png…

@vincentri
Copy link

Screenshot 2022-08-03 at 5 58 32 PM

@Morishiri
Copy link
Contributor Author

Morishiri commented Aug 3, 2022

Strange, but it succeeds for me without issues, maybe differences in yarn version?

Command failed with exit code 1: yarn add -W -D prettier-plugin-tailwindcss
Unknown Syntax Error: Unsupported option name ("-W").

@Morishiri
Copy link
Contributor Author

Morishiri commented Aug 3, 2022

@simoncrypta I think we're using yarn v3, is it some new fact? Was it on yarn v1 before?

https://github.com/redwoodjs/redwood/blob/main/.yarnrc.yml#L19

@simoncrypta
Copy link
Collaborator

@Morishiri Yes we use yarn v3 since the V1, it was V1 before and is still possible to have yarn v1 inside the project.
It weirds that I didn't see this issue, is it happen with Yarn V1 or V3 ?

@simoncrypta
Copy link
Collaborator

I guessed we will need to check the yarn version and add the -W flag on the V1 (or V3) only ?

@Morishiri
Copy link
Contributor Author

Morishiri commented Aug 4, 2022

is it happen with Yarn V1 or V3 ?

happens on v1

@simoncrypta #6119

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:feature This PR introduces a new feature topic/cli
Projects
Status: Archived
Development

Successfully merging this pull request may close these issues.

tailwindcss ui: Add tailwindcss prettier rules
4 participants