Skip to content

enforce code formatting and linting#175

Draft
JPadovano1483 wants to merge 1 commit into
skupperproject:mainfrom
JPadovano1483:james-code-formatting
Draft

enforce code formatting and linting#175
JPadovano1483 wants to merge 1 commit into
skupperproject:mainfrom
JPadovano1483:james-code-formatting

Conversation

@JPadovano1483

Copy link
Copy Markdown
Contributor

Overview

Introduces Prettier for code formatting, ESLint for code quality, and Husky to run Prettier and ESLint as a pre-commit hook. The intent is to enforce coding standards in the repo to create uniform styling and enhance code quality.

Setup

  1. Install the following three extensions:
    1. Prettier - esbenp.prettier-vscode
    2. ESLint - dbaeumer.vscode-eslint
    3. EditorConfig - EditorConfig.EditorConfig
  2. Run pnpm install from root
  3. To run Prettier formatter, run pnpm format (`pnpm format:check to see what files WOULD be changed)
  4. To run ESLint's linter, run pnpm lint:fix (pnpm lint to see what errors exist without fixing them)

Husky takes care of running these two scripts as a pre-commit hook, blocking the commit and reporting the problems if ESLint throws errors. ESLint will automatically fix any linting issues (in staged files) that have auto-fixes for them (typically small things like making a variable a const if it is never reassigned). It will then report what the other issues are, and block the commit. If the issues are deemed as acceptable, the hook can be bypassed with git commit -n, though this should be done sparingly.

Some of the values here were set by looking at what the convention seems to be in the controller code (things like 4 space tab width and semicolon usage). Other values were chosen somewhat arbitrarily, like max line length or arrow function parentheses. If you have any strong preferences, let me know and I'll change those.

Leaving this as a draft until an initial pass has been done to fix linting errors (this will block almost every commit until these errors are addressed.

Fixes #170

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.

enforce code formatting and linting

1 participant