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

Add reformat-files:css script #32351

Closed
wants to merge 1 commit into from
Closed

Conversation

simison
Copy link
Member

@simison simison commented Apr 17, 2019

Adds reformat-files:css script that runs stylelint --fix on files.

There's this note in the docs:

It's an experimental feature. It currently does not respect special comments for disabling stylelint within sources (e. g. /* stylelint-disable */). Autofixing will be applied regardless of these comments.

If you're using both these special comments and autofixing, please run stylelint twice as a temporary solution. On the first run, some violations could be missed, or some violations might be reported incorrectly.

Solution might be not run this together with reformat-files command and let folks run this only manually.

Changes proposed in this Pull Request

  • Add new reformat-files:css script which always exists with 0 — otherwise if there are errors left, --fix will exit with 2 and make it seem like reformat-files failed. -c in reformat-files is meant to let reformat-files:js finish even if :css would exit with non-0 earlier, so I'm fine also changing it to throw an error at the end.
  • Add .json to config file so that it'll get run through Prettier (docs about .json support)
  • Run some files through it.

Testing instructions

Run:

  • npm run reformat-files
    • Observe reformat-files:js finish even if :css finishes earlier
    • Linter throws some errors/warnings about stuff it cannot autofix but doesn't fail the NPM script with error.
    • A bunch of files have changed (happy to include these in the PR, but I made a separate: Fix stylelint errors in scss files #32386)
  • npm run reformat-files:css

@matticbot
Copy link
Contributor

@matticbot
Copy link
Contributor

matticbot commented Apr 17, 2019

This PR does not affect the size of JS and CSS bundles shipped to the user's browser.

Generated by performance advisor bot at iscalypsofastyet.com.

@simison simison added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] In Progress labels Apr 18, 2019
@blowery
Copy link
Contributor

blowery commented Jun 11, 2019

rebased this and resolved the conflicts in package.json::scripts

While at it, rename Stylelint config to `.stylelintrc.json` to get it automatically formatted by Prettier as well.

See https://stylelint.io/user-guide/configuration/#loading-the-configuration-object for more about config file names.

Run reformat-files:* in series, not in parallel

Always happy exit

reorganise
@simison
Copy link
Member Author

simison commented Dec 13, 2019

Rebased. Still not sure if this is helpful or too risky (see the warning I added in description).

This would be handy if we'd switch e.g. to this from our custom Stylelint config:

{
	"extends": "stylelint-config-wordpress/scss"
}

@scinos
Copy link
Contributor

scinos commented Aug 1, 2020

This PR has been open for a while. Is it still relevant?

@sarayourfriend sarayourfriend changed the base branch from master to trunk November 20, 2020 16:15
@github-actions
Copy link

github-actions bot commented May 5, 2021

This PR has been marked as stale due to lack of activity within the last 30 days.

@simison
Copy link
Member Author

simison commented Jun 7, 2021

Autofixer might be now safe enough to use: stylelint/stylelint#2643

@simison
Copy link
Member Author

simison commented Jun 7, 2021

Considered closing this, but checked with Team Calypso (p1623060403258400-slack-team-calypso) and I think we can keep open until someone picks the stylelint work at some point. This will work as a good starting off point:

fine to keep open by me. Running stylelint as part of CI is something I’d like to do eventually

@simison simison added [Status] Blocked / Hold [Status] Needs Rebase and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. [Status] Stale labels Jun 7, 2021
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jun 7, 2021
@simison simison removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. [Type] Janitorial labels Jun 7, 2021
@simison
Copy link
Member Author

simison commented Sep 9, 2022

@noahtallen is this PR needed for the recent stylelint work or shall I close? Feel free to just hit close button yourself! :-)

@noahtallen
Copy link
Member

Yeah, I think it's worth closing!

@noahtallen noahtallen closed this Sep 9, 2022
@noahtallen
Copy link
Member

I didn't add a reformat files script, but that'd be incredibly easy to add if we need it. And just adding --fix to yarn lint:css is very easy too

@worldomonation worldomonation deleted the update/reformat-files-css branch September 27, 2022 05:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants