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 ability to easily run prettier from CLI #3397

Merged
merged 5 commits into from Dec 3, 2019

Conversation

jtomasek
Copy link

No description provided.

@openshift-ci-robot openshift-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Nov 14, 2019
@jtomasek
Copy link
Author

/retest

1 similar comment
@jtomasek
Copy link
Author

/retest

@@ -24,7 +24,8 @@
"test-suite": "ts-node -O '{\"module\":\"commonjs\"}' ./node_modules/.bin/protractor integration-tests/protractor.conf.ts",
"debug-test-suite": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' node -r ts-node/register --inspect-brk ./node_modules/.bin/protractor integration-tests/protractor.conf.ts",
"analyze": "NODE_ENV=production NODE_OPTIONS=--max-old-space-size=4096 ts-node -O '{\"module\":\"commonjs\"}' ./node_modules/.bin/webpack --mode=production --profile --json | awk '{if(NR>2)print}' > public/dist/stats.json && ts-node -O '{\"module\":\"commonjs\"}' ./node_modules/.bin/webpack-bundle-analyzer --mode static -r public/dist/report.html public/dist/stats.json",
"plugin-stats": "node ./plugin-stats.js"
"plugin-stats": "node ./plugin-stats.js",
"prettier": "prettier '**/*.{js,jsx,ts,tsx}'"
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems handy to me.

@christianvogt
Copy link
Contributor

Doesn't hurt anyone to have it. But prettier is run already with eslint. Although running just prettier I'm sure is faster.

Tested it in our repo. Running this command just output a lot of noise to the console. Not sure what you intended to it to do. It's not very useful like this.

Useful options are --check and --write.

@jtomasek
Copy link
Author

jtomasek commented Nov 20, 2019

Tested it in our repo. Running this command just output a lot of noise to the console. Not sure what you intended to it to do. It's not very useful like this.

My goal was to be able to easily do prettier formatting from CLI. I've thought that --write option was the default behaviour. Fixing...

@@ -24,7 +24,8 @@
"test-suite": "ts-node -O '{\"module\":\"commonjs\"}' ./node_modules/.bin/protractor integration-tests/protractor.conf.ts",
"debug-test-suite": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' node -r ts-node/register --inspect-brk ./node_modules/.bin/protractor integration-tests/protractor.conf.ts",
"analyze": "NODE_ENV=production NODE_OPTIONS=--max-old-space-size=4096 ts-node -O '{\"module\":\"commonjs\"}' ./node_modules/.bin/webpack --mode=production --profile --json | awk '{if(NR>2)print}' > public/dist/stats.json && ts-node -O '{\"module\":\"commonjs\"}' ./node_modules/.bin/webpack-bundle-analyzer --mode static -r public/dist/report.html public/dist/stats.json",
"plugin-stats": "node ./plugin-stats.js"
"plugin-stats": "node ./plugin-stats.js",
"prettier": "prettier --write '**/*.{js,jsx,ts,tsx}'"
Copy link
Author

Choose a reason for hiding this comment

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

Do we want to also format json? Doing so currently affects 23 files.

Copy link
Contributor

Choose a reason for hiding this comment

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

We should.
Can we update eslint to run against json files as well so it's enforced by our ci?
Then we fix them all up and can include json files w/ prettier here.

Copy link
Author

@jtomasek jtomasek Nov 27, 2019

Choose a reason for hiding this comment

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

I've added eslint-plugin-json for json linting and created json.js in our eslint-plugin-console package.

@openshift-ci-robot openshift-ci-robot added component/dev-console Related to dev-console component/kubevirt Related to kubevirt-plugin component/olm Related to OLM size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Nov 27, 2019
@jtomasek
Copy link
Author

/retest

@christianvogt
Copy link
Contributor

Looking good @jtomasek
Anything else you're still working on?

@jtomasek
Copy link
Author

Looking good @jtomasek
Anything else you're still working on?

I think it's complete now.

@christianvogt
Copy link
Contributor

@jtomasek I ran it and since it does not follow eslint-disable-next-line, I got a fix applied to create-bs.tsx
https://github.com/jtomasek/console/blob/a3a15d501c20e53719532ac9311962bbf46c04e0/frontend/packages/noobaa-storage-plugin/src/components/create-backingstore-page/create-bs.tsx#L559

I suggest you remove this line and run prettier again to commit all changes so that the next user doesn't find any changes when they run it.

@jtomasek
Copy link
Author

I've removed the eslint-disable-next-line comment, used dot notation to stop eslint complaining and added type to make typescript happy.

  • Rebased.

@jtomasek
Copy link
Author

jtomasek commented Dec 2, 2019

/retest

@jtomasek
Copy link
Author

jtomasek commented Dec 2, 2019

/retest

@jtomasek
Copy link
Author

jtomasek commented Dec 2, 2019

/test e2e-gcp-console

@christianvogt
Copy link
Contributor

/lgtm
/approve

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Dec 2, 2019
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: christianvogt, dtaylor113, jtomasek

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 2, 2019
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

8 similar comments
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit 38ce98b into openshift:master Dec 3, 2019
@spadgett spadgett added this to the v4.4 milestone Dec 3, 2019
@spadgett
Copy link
Member

spadgett commented Dec 3, 2019

This actually seems to have broken prettier on the CLI for me. I used to be able to do

$ yarn run prettier --write public/components/edit-yaml.jsx

Now it runs on all files always. Can we rename this to something like prettier-all?

@jtomasek jtomasek deleted the prettier branch December 4, 2019 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. component/dev-console Related to dev-console component/kubevirt Related to kubevirt-plugin component/noobaa Related to noobaa-storage-plugin component/olm Related to OLM lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants