Enforce formatting in repo#1338
Conversation
30c6d10 to
7ce5432
Compare
7ce5432 to
e6edd7b
Compare
gspencergoog
left a comment
There was a problem hiding this comment.
Thanks, this looks great!
We should be able to reuse this once we split into separate repos.
ditman
left a comment
There was a problem hiding this comment.
This looks great. Thanks for attempting this. I'd recommend you merge this ASAP (use my comments maybe as fast-follows).
PS: I'm surprised this PR does not touch any .py files. Is that expected? Were they being already formatted?
| if [ "$CHECK_ONLY" = true ]; then | ||
| dart format --output=none --set-exit-if-changed . | ||
| else | ||
| dart format . |
There was a problem hiding this comment.
It'd be nice that this script would echo a "run scripts/fix_format.sh" (or the github action) so failures to check are more actionable.
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| node_modules |
There was a problem hiding this comment.
Do we need things like .angular here as well? I remember having to add it to the gitignore earlier.
| indent_size = 2 | ||
| end_of_line = lf | ||
| charset = utf-8 | ||
| insert_final_newline = true |
There was a problem hiding this comment.
Any chance of enabling format-on-save or similar? Does the formatting config require running the formatting script, or can it be started from the IDE?
|
Increasing scope of the formatter for python in #1340 |
Enforce consistent formatting and linting across the repo
This PR implements the plan described in issue #1337 to address inconsistent formatting configurations that cause unnecessary whitespace diffs in PRs.
Proposed Changes
1. Infrastructure (Configs & Scripts)
.prettierrcand.prettierignoreto ensure consistent formatting for JS/TS/JSON/Markdown files..editorconfigto enforce basic rules like 2-space indentation repo-wide.scripts/fix_format.shto easily lint and format the entire repository using Prettier, Pyink (Python), and Dart format..github/workflows/enforce-formatting.ymlto automatically check formatting on all pushes and PRs.CONTRIBUTING.mdwith instructions on how to use the script and recommended VS Code extensions..vscode/settings.jsonto help developers use the correct formatters by default on save.2. Mechanical Formatting
Rationale for Choices
bracketSpacing: false, as it is preferred for consistency with Google standards.pyinkfor Python to adhere to Google's Python style.Reviewing Strategy
Ideally, the changes can be reviewed separately:
Fixes #1337