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 proposal app skeleton for styling configs handling #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ecugol
Copy link
Collaborator

@ecugol ecugol commented Jun 8, 2020

@RamezIssac Hello Ramez. Here's what i am thinking of for our styling app inside kn_defaults. Basically we can have overwritable linters/stylers configs and use a command to copy those into project's root.

Also there should be a check to ensure pre-commit app is installed, so all those linters/stylers will work once user installs pre-commit hook.

Current configs are stolen from Odoo project, and we need to discuss them.

@RamezIssac
Copy link
Contributor

I love the idea.
Can you add like a fast guide on how this will be used by the developer? As a developer, What do i need to do other then having the styling app added to the project installed apps? How will i know that a certain file needs styling ? Is that a bypass-able warning or a blocking error ? What will happen if i don't address the styling issues on the spot ? These are just examples and you can expand in the guide as you see fit.

@ecugol
Copy link
Collaborator Author

ecugol commented Jun 8, 2020

@RamezIssac

The idea behind this is to make code styling unified between all developers without big efforts. It's done by pre-commit app which installs pre-commit hook and then on each commit, runs a set of tools to reformat code and fix common mistakes.

Tools used in this proposal are:

  • pre-commit for installing pre-commit hook with following tools:
  • black for all python files except migrations
  • prettier for js/html/css files
  • eslint to fix js errors and have js linting in editor
  • flake8 for python files linting in editor and flake8-bugbear for highlighting common bugs in python code + checks cyclomatic complexity
  • isort for automatic sorting of python imports
  • pyupgrade upgrades syntax

To use all this, first develop needs to install pre-commit:
pip install pre-commit

Then:

  1. Add kn_defaults.styling to INSTALLED_APPS.
  2. Run manage.py copy_styling_conf to copy default configs to project's root.
  3. Run pre-commit install to install pre-commit hook.
  4. If added to existing project, dev can run pre-commit run --all-files to run hook once for all files.

That should be it. Now on commits all staged files will be checked and, if needed, reformatted. In case of any errors, pre-commit will show them to user and abort the commit.

Eslint and flake8 will help dev to avoid issues at development time by showing errors/warnings in the editor (all majors are supporting eslint and flake8).

@ecugol
Copy link
Collaborator Author

ecugol commented Jun 15, 2020

@jab3z your comments are welcome

@jab3z
Copy link
Collaborator

jab3z commented Jun 15, 2020

@ecugol tsconfig.json, maybe?

@ecugol
Copy link
Collaborator Author

ecugol commented Jun 15, 2020

@ecugol tsconfig.json, maybe?

@jab3z yeah that is good idea

@jab3z
Copy link
Collaborator

jab3z commented Nov 18, 2020

migration files should be excluded from any linter

@ecugol
Copy link
Collaborator Author

ecugol commented Nov 18, 2020

@jab3z i think they are excluded on all python-related stuff. Is eslint trying to find there something?

@jab3z
Copy link
Collaborator

jab3z commented Nov 18, 2020

@ecugol i said just an added measure, don't know if they are excluded by default.

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.

3 participants