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

Configure eslint and prettiier #35

Merged
merged 10 commits into from
May 26, 2024
Merged

Configure eslint and prettiier #35

merged 10 commits into from
May 26, 2024

Conversation

technophile-04
Copy link
Collaborator

@technophile-04 technophile-04 commented May 23, 2024

Description :

  • Configured prettier inline with SE-2 repo config
  • Formatted files with prettier
  • Configured ESlint v9 and typescript-eslint
  • Both prettier and eslint ignores templates dir
  • Fixed eslint issues
  • Configured pre-commit hooks with husky and lint-staged

Tried keeping typescript-eslint rules inline with SE-2.

To test :

  1. Install dependencies :
yarn install
  1. Add const x = 5 in src/cli.ts and try running :
git add . && git commit -m "this should fail"

This will run pre-commit and hopefully it should fail (since x is unused variable)

cc @Pabl0cks, could you please test this on windows also once, because I remmember in SE-2 while configuring husky it was not working properly especially for windows.

New Commands :

To run lint :

yarn lint

or to fix all fixable errors: yarn lint --fix

To format files with prettier :

yarn format

@carletex
Copy link
Member

carletex commented May 23, 2024

This is great @technophile-04 , thank you!! I feel cleaner already haha

Everything works great, except Husky. It's not working for me (I tried deleting node_modules and also doing a fresh install in a new folder). Is it because we are missing these scripts in package.json??

    "postinstall": "husky install",
    "precommit": "lint-staged",

I see you added the prepare one, but doesn't seem to be working for me.

@rin-st
Copy link
Collaborator

rin-st commented May 23, 2024

Everything works great, except Husky. It's not working for me (I tried deleting node_modules and also doing a fresh install in a new folder). Is it because we are missing these scripts in package.json??

Doesn't work for me too, also added

"postinstall": "husky install",

It installs script but still no error when commiting

@rin-st
Copy link
Collaborator

rin-st commented May 23, 2024

I tried to commit using vscode ui button and it didn't work. But after running git add . && git commit -m "this should fail" in cli it started to work (without "precommit": "lint-staged",)

looks like it runs script from .linstagedrc.json on commit

@carletex
Copy link
Member

image

Started to work for me too... but not sure how it happened haha I always use the CLI (not my IDE) for git stuff. But somehow, tried again and now it's showing the lintstaged stuff 🤷

@carletex
Copy link
Member

Tried in a fresh clone (clone + yarn install + tweak cli.ts + git add + git commit) and not working

image

@technophile-04
Copy link
Collaborator Author

Just pushed 2df5d82, could you all please try again

Yarn v3 does not support "prepare" script, so we need to use "postinstall" as mentioned typicode/husky#1371

notice I didn't used "husky install" instead used just "husky" since v9 they updated this

I just tried clone + yarn install + tweak cli.ts + git add + git commit and it worked in first try

@rin-st
Copy link
Collaborator

rin-st commented May 23, 2024

I just tried clone + yarn install + tweak cli.ts + git add + git commit and it worked in first try

Thanks! It worked for me too

Note: I tried to do the same here , not sure why it didn't work. Probably it's because of prepare script you deleted or husky install but I'm not sure

Copy link
Collaborator

@rin-st rin-st left a comment

Choose a reason for hiding this comment

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

Great job!

@carletex
Copy link
Member

Working for me too!! Thanks.

Let's wait until @Pabl0cks can do a quick run on Windows.

Copy link
Collaborator

@damianmarti damianmarti left a comment

Choose a reason for hiding this comment

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

Working fine!!

/ssd/workspace/create-eth/src/cli.ts
8:7 error 'x' is assigned a value but never used @typescript-eslint/no-unused-vars

✖ 1 problem (1 error, 0 warnings)

Thanks!!

Copy link
Collaborator

@Pabl0cks Pabl0cks left a comment

Choose a reason for hiding this comment

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

All commands worked nicely on Windows, GJ @technophile-04

And got the error nicely when trying to commit:

image

@technophile-04
Copy link
Collaborator Author

Thanks all ! Merging this 🙌

@technophile-04 technophile-04 merged commit c17a7f0 into main May 26, 2024
@technophile-04 technophile-04 deleted the eslitn-prettier branch May 26, 2024 09:34
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.

None yet

5 participants