terriajs icon indicating copy to clipboard operation
terriajs copied to clipboard

Prettier v2

Open zoran995 opened this issue 2 years ago • 4 comments

What this PR does

Enables fix of #5420

This is pretty big change for terriajs codebase but version 2 of prettier came out 2 and half years and it would be pretty good to upgrade to it. It also allows us to use import just type and some other modern syntax that was erroring on old versions.

If decided to merge it should be done the same way as the last time, by creating two new tags pre-prettier-v2 and post-prettier-v2

Checklist

  • ~[ ] There are unit tests to verify my changes are correct or unit tests aren't applicable (if so, write quick reason why unit tests don't exist)~
  • ~[ ] I've updated relevant documentation in doc/.~
  • [ ] I've updated CHANGES.md with what I changed.
  • ~[ ] I've provided instructions in the PR description on how to test this PR.~

zoran995 avatar Jul 09 '22 11:07 zoran995

We should extend this to also apply prettier to more files in the repo (e.g. gulpfile.js, everything in buildprocess, markdown files). Maybe even change our prettierignore file to ignore certain files rather than only include some directories.

tephenavies avatar Jul 27 '22 06:07 tephenavies

@steve9164 I have updated prettierignore to include more files

zoran995 avatar Jul 31 '22 16:07 zoran995

That's better. I think we should also format:

  • *.yml files
  • architecture
  • plenty of things in wwwroot/ (probably most things that aren't .gitignored, third party code or generated files that are never partially modified)
  • .github

I was thinking of changing .prettierignore to almost match .gitignore, plus add a few extra lines.

.prettierignore:


# =====================
# From .gitignore. Update this list when .gitignore changes

docs/
node_modules/
.idea/
build/
error.log
output.log
npm-debug.log
.DS_Store
terria.lib.js
terriajs-server.log
terriajs.pid
/wwwroot/doc/
/wwwroot/schema/
/wwwroot/user-guide/
/coverage/
package-lock.json
*.swp
dist
.history/

# Catalog index generation files
catalog-index*.json

# End of .gitignore copy
# =====================

# These are auto-generated by css-modules-typescript-loader
**/*.scss.d.ts

# Generated files
/wwwroot/data/regionids

/wwwroot/third_party

# Reignore some files
doc/acknowledgements/attributions.md

And change the package.json scripts to "prettier --write ." and "prettier --check .". That'll circumvent the problem where prettier is trying to format files it doesn't recognise when the ignore file is reversed.

tephenavies avatar Aug 01 '22 17:08 tephenavies

Merging on 22nd August.

tephenavies avatar Aug 03 '22 03:08 tephenavies