membermatters / MemberMatters

An open source membership, access and payments portal for makerspaces and community groups.
https://membermatters.org
MIT License
41 stars 23 forks source link

Manually linting without pre-commit hook #129

Closed dtbaker closed 3 years ago

dtbaker commented 3 years ago

Hey are there some example commands to run for checking linting rather than relying on the pre-commit hook?

backend:

When I try black --check . it wants to change a whole bunch of files, and then the pre-commit hook changes some of them back. It's like there's a different configuration for when it's run in pre-commit mode vs manually.

Is black the only linter / testing tool for the backend at the moment?

frontend

I read in one of the readme's that prettier was used, but cannot see it as a script in package.json, only eslint. Is prettier still used?

And when I run npm run lint it throws an error on update-ios-version.js, just checking if this is an expected error or I've done something wrong. Should workflow or pre-commit hooks be configured to check eslint as well?

jabelone commented 3 years ago

When I try black --check . it wants to change a whole bunch of files, and then the pre-commit hook changes some of them back. It's like there's a different configuration for when it's run in pre-commit mode vs manually.

That's very strange. One of the great things about black is that it's 0 config, so the config should only change between versions. Maybe try installing the same version that's in memberportal/requirements.txt outside of your virtual environment too. Maybe when the pre-commit hooks are being ran, it's not running in the virtual environment and using a different version?

P.s. I also updated a few of the dependencies in my latest commit so make sure to run pip3 install requirements.txt and npm install again.

I read in one of the readme's that prettier was used, but cannot see it as a script in package.json, only eslint. Is prettier still used?

We use prettier as an eslint plugin/rule so by running eslint, you also get prettier. :)

And when I run npm run lint it throws an error on update-ios-version.js, just checking if this is an expected error or I've done something wrong.

This is not expected, good catch. :) I've fixed the eslint error in that file.

Should workflow or pre-commit hooks be configured to check eslint as well?

I've just spent the last few hours doing that, so hopefully eslint/prettier is also run in both the pre-commit hooks and GitHub actions from now on. You'll have to run npm install from the root of this repo to get the new setup running. There's a new package.json that should setup all the pre-commit stuff on npm install. I also added a note about this here.

dtbaker commented 3 years ago

Nice :+1: Thanks!! looks awesome.