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

Fixes #89 - Add prettier support #105

Closed

Conversation

swarna-gopalan
Copy link

@swarna-gopalan swarna-gopalan commented Oct 1, 2020

fixes #89 Add prettier support and enforce with commit hook

@vegetabill
Copy link
Collaborator

Thanks for submitting. If you prefix the issue number with Fixes it will automatically link the issue.

@swarna-gopalan swarna-gopalan changed the title Add prettier support #89 - Add prettier support Oct 1, 2020
@swarna-gopalan swarna-gopalan changed the title #89 - Add prettier support Fixes #89 - Add prettier support Oct 1, 2020
Copy link
Collaborator

@vegetabill vegetabill left a comment

Choose a reason for hiding this comment

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

Thanks for submitting this!

When I tried testing this branch, and did a test commit, it looked like it ran a hook but the commit still appeared unformatted.

Can you add a command in package.json under scripts that lets a developer run the same command as the hook to test it out?

package.json Outdated
"eslint-config-airbnb": "^18.1.0",
"eslint-config-prettier": "^6.10.0",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
Copy link
Collaborator

@vegetabill vegetabill Oct 1, 2020

Choose a reason for hiding this comment

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

Can you remove the eslint-plugin-jsx-a11y package and make sure it's removed from package lock as well? JSX is only needed for React and we aren't currently using React.

Copy link
Author

@swarna-gopalan swarna-gopalan Oct 1, 2020

Choose a reason for hiding this comment

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

@vegetabill - "Can you add a command in package.json under scripts that lets a developer run the same command as the hook to test it out" - Not sure I follow this part.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure how to debug the hook but we can start with having an npm script that can lint all files. In package.json we can add something like:

"scripts": {
    ...
    "lint": "npx eslint ./JS/**/*.js ./public/scripts/**/*.js"
  },

So we can run the linting separate from commit hook. That might help debug the issue of why it doesn't seem to be working. When I added that, the linting wasn't working so that may be why the hook isn't working either.

Copy link
Author

Choose a reason for hiding this comment

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

How about just "lint": "eslint ./;" ? This is what I see in our repo and we use eslint.

Copy link
Author

Choose a reason for hiding this comment

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

Also @vegetabill - I'm running into more issues when I run "npm run lint"

Error: Failed to load parser 'babel-eslint' declared in '.eslintrc': Cannot find module 'babel-eslint'

But when I remove it, it says,

ESLint couldn't find the plugin "eslint-plugin-jsx-a11y".

So after adding that using npm install eslint-plugin-jsx-a11y@latest --save-dev, I get 401 problems (390 errors, 11 warnings) when I run linting. I think its looking at rules under /Users/swarna.gopalan/Hackathon/ghc/techtonica/keyboard-shortcuts-practice/node_modules/eslint-config-airbnb.
Screen Shot 2020-10-02 at 3 22 46 PM

package.json Outdated Show resolved Hide resolved
. prettierrc Outdated Show resolved Hide resolved
.eslintrc Outdated Show resolved Hide resolved
@alodahl
Copy link
Collaborator

alodahl commented Oct 2, 2020

hi @swarna-gopalan , are you still out there? Will you be able to make changes today?

@swarna-gopalan
Copy link
Author

swarna-gopalan commented Oct 2, 2020 via email

@vegetabill
Copy link
Collaborator

vegetabill commented Oct 8, 2020

As a simplification, we can drop all the linting aspects and just setup prettier config and commit hook. That would mostly cover what is important. @alodahl what do you think?

In retrospect, I probably picked an overly complicated blog 😕

@alodahl
Copy link
Collaborator

alodahl commented Oct 15, 2020

@vegetabill i guess, but what would that be eliminating? Maybe a different tutorial is necessary; I didn’t think it would be very complex, just the right configurations.

@vegetabill
Copy link
Collaborator

@alodahl it would just be adding a set prettier config so that anyone using something like vscode's formatting would all be using the same rules. Since the code is quite non-standard, eslint might be a tough transition at this point.

Either way, since this was mainly to make OSD easier (oops), I'd say let's just close this PR unmerged and just throw the issue back into the to-do list for someone who knows of a better setup. Sorry!

@alodahl alodahl closed this Oct 22, 2020
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.

Add prettier support and enforce with commit hook
3 participants