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

Prettier and eslint improvements (no dependency upgrades yet) #574

Conversation

mattpocock
Copy link
Contributor

@mattpocock mattpocock commented Aug 20, 2024

  • Make prettier run on the entire repo, not just the source files
  • Remove prettier from eslint configs
  • Made the CI check that code is formatted correctly

Copy link

changeset-bot bot commented Aug 20, 2024

⚠️ No Changeset found

Latest commit: 8b55bb7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@mattpocock mattpocock changed the title Prettier and eslint improvements (no upgrades yet) Prettier and eslint improvements (no dependency upgrades yet) Aug 20, 2024
@mattpocock mattpocock mentioned this pull request Aug 20, 2024
10 tasks
@@ -41,8 +42,6 @@
"@typescript-eslint/parser": "4.28.1",
"babel-jest": "27.5.1",
"eslint": "7.30.0",
"eslint-config-prettier": "7.1.0",
Copy link

Choose a reason for hiding this comment

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

[Non-blocker] Is there a reason to avoid eslint-config-prettier? I thought it's meant to prevent conflicting rules

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link

Choose a reason for hiding this comment

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

Thanks for the link

Copy link
Contributor

Choose a reason for hiding this comment

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

I also agree with removing eslint-config-prettier and the prettier docs advise to essentially do the same (i.e. let linters lint, and formatters format)

see: https://prettier.io/docs/en/comparison

package.json Outdated
Comment on lines 14 to 16
"lint": "eslint ./src --ext .ts",
"format": "prettier --write 'src/**/*.ts?(x)' && npm run lint -- --fix",
"format": "prettier --write . && npm run lint -- --fix",
"format-check": "prettier --check .",
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets utilize prettier and eslint's cacheing options

Suggested change
"lint": "eslint ./src --ext .ts",
"format": "prettier --write 'src/**/*.ts?(x)' && npm run lint -- --fix",
"format": "prettier --write . && npm run lint -- --fix",
"format-check": "prettier --check .",
"lint": "eslint ./src --ext .ts --cache --cache-location 'node_modules/.cache/eslintcache",
"format": "prettier --write --cache --cache-location='node_modules/.cache/prettiercache' . && npm run lint -- --fix",
"format-check": "prettier --check --cache --cache-location='node_modules/.cache/prettiercache' .",

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Getting this warning from Prettier:

[warn] Ignored unknown option --cache.
[warn] Ignored unknown option --cache-location=node_modules/.cache/prettiercache.

@@ -41,8 +42,6 @@
"@typescript-eslint/parser": "4.28.1",
"babel-jest": "27.5.1",
"eslint": "7.30.0",
"eslint-config-prettier": "7.1.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

I also agree with removing eslint-config-prettier and the prettier docs advise to essentially do the same (i.e. let linters lint, and formatters format)

see: https://prettier.io/docs/en/comparison

supermacro
supermacro previously approved these changes Sep 6, 2024
Copy link
Owner

@supermacro supermacro left a comment

Choose a reason for hiding this comment

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

lgtm 👍 last things:

@mattpocock

This comment was marked as outdated.

@mattpocock mattpocock mentioned this pull request Sep 6, 2024
@mattpocock

This comment was marked as outdated.

type ExpecteResult = Result<[ string, number, boolean ], (string | number | boolean)[]>
const heterogenousList: HeterogenousList = [okAsync('Yooooo'), okAsync(123), okAsync(true)]

type ExpecteResult = Result<[string, number, boolean], [string, number, boolean]>
Copy link

Choose a reason for hiding this comment

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

Is this change intentional?

Copy link

Choose a reason for hiding this comment

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

@mattpocock Isn't that the reason tests are failing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Apparently not intentional, let me check

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like I was pulling from origin/master instead of upstream/master, my bad. Fixed.

@mattpocock mattpocock closed this Sep 6, 2024
@mattpocock
Copy link
Contributor Author

This PR is getting a bit out of hand. I am having real trouble rebasing every time a new change is merged. I'll create a new PR which adds the ability to run prettier, but doesn't format the whole repo. Once that's merged we can format the repo properly.

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.

4 participants