GRNsight icon indicating copy to clipboard operation
GRNsight copied to clipboard

Integrade code formatting specifications into the GRNsight repo

Open dondi opened this issue 5 years ago • 2 comments

The latest code formatters are getting better at formatting code in a reliable and consistent manner. Some implications in case we adopt this for GRNsight:

  1. We will want to configure the code formatter in a manner that use a style that the team agrees upon
  2. There will be a “formatting-only” transition phase where the code formatter may need to make a wide array of edits in order to sync up the code to the latest style

Formatter for consideration: https://prettier.io

dondi avatar Oct 02 '20 18:10 dondi

Set up repo so that independently of the code editor being used. Might need to reckon with 4 spaces of indenting vs new standard for javascript which is 2 spaces of indenting. Could be implemented in the GitHub Actions workflow.

kdahlquist avatar Feb 06 '25 22:02 kdahlquist

Prettier has established itself as the de facto code-formatter for many repos, so we will just go with that. We will need a .prettierrc file (or similar mechanism) on the repo, and make sure that our editors are configured to use it

If we change format, step (2) in the original description may still need to take place

dondi avatar Feb 06 '25 22:02 dondi

With the merging of #1148 into beta, we now need to observe interactions between Prettier and ESLint and can finalize configurations based on that

dondi avatar Apr 23 '25 15:04 dondi

Prettier Integration

  • Created .prettierrc.js aligned with Grnsight's style: 4-space indentation Double quotes for strings Consistent semicolons Standardized object formatting

  • Then Integrated ESLint and Prettier to avoid style conflicts. Added prettier dependencies npm install --save-dev prettier eslint-config-prettier eslint-plugin-prettier Really cool --> eslint-config-prettier: Disables ESLint rules that conflict with Prettier eslint-plugin-prettier: Runs Prettier as an ESLint rule

  • Updated ESLint Config for Prettier Integration

  • Add formatting scripts to packjson

  • Added to the scripts (formatting)

"scripts": {
  "format": "prettier --write \"**/*.{js,jsx,json,md}\"",
  "format:check": "prettier --check \"**/*.{js,jsx,json,md}\"",
  "lint": "eslint \"**/*.js\"",
  "lint:fix": "eslint --fix \"**/*.js\""
}

Formatting

To format use the command npm run format To check for formatting issues use the command npm run format:check

Lastly I ran npm run lint and received errors regarding the depricated .eslintignore file and unused eslint-disable directives.

  • Updated eslint.config.js file to include all ignored files and removed eslintignore file
  • Cleaned up unused eslint-disable directives using npx eslint --fix .

On track to push the PR with these changes

akaiap avatar Apr 30 '25 07:04 akaiap

This ticket can also be closed alongside #1147 once that is verified

dondi avatar Sep 10 '25 17:09 dondi

Closing per comment above that it can be closed alongside #1147, which is now closed.

kdahlquist avatar Sep 24 '25 20:09 kdahlquist