From cc396b8ac10c052080059999e4e8d45fefcef3d2 Mon Sep 17 00:00:00 2001 From: Remmy Cat Stock Date: Sat, 5 Nov 2022 22:45:00 +0100 Subject: [PATCH] Add configs for better support of different development environments (#1092) * Add prettierrc and editorconfig * Updated README with `npm run cf` steps & also a git command that will fix a line ending error * Added reference * Prettier ;_; * Add gitattributes to make sure git uses core.autocrlf on windows Co-authored-by: William Lam --- .editorconfig | 7 +++++++ .gitattributes | 2 ++ .prettierrc.js | 6 ++++++ README.md | 13 +++++++++++++ 4 files changed, 28 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .prettierrc.js diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..b3dfee7af --- /dev/null +++ b/.editorconfig @@ -0,0 +1,7 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 2 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..4cab1f4d2 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Set the default behavior, in case people don't have core.autocrlf set. +* text=auto diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 000000000..2ca56d8f0 --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1,6 @@ +/** + * @type {import('prettier').Config} + */ +module.exports = { + // defaults only so far +}; diff --git a/README.md b/README.md index db59a053d..ab0c2d668 100644 --- a/README.md +++ b/README.md @@ -118,3 +118,16 @@ Note: This is only useful if you have access to a production running on Render.c 2. Copy generated files from output folder to gear-ids.ts file 3. Get .png from Lean's repository 4. Generate .avif image + +### Fix errors from the CI Pipeline + +If you change any files and the CI pipeline errors out on certain formatting/linting steps (e.g. the `Prettier` or `Stylelint` step), run this command in the repo's root directory: + +```sh +npm run cf +``` + +Before committing, if for some reason you see an abnormally high amount of files changed, simply run `git add --renormalize .` and it will fix the error. + +- Background info: this is caused by the line endings on your local repo not matching those with the remote repo's, which should remove the vast majority of unstaged files that appears to have no changes at all. +- Reference: https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings