Skip to content

Commit 6e46bb6

Browse files
committed
Infrastructure: Add formatting configs and scripts
1 parent fea74df commit 6e46bb6

11 files changed

Lines changed: 209 additions & 53 deletions

File tree

.editorconfig

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright 2026 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
root = true
16+
17+
[*]
18+
indent_style = space
19+
indent_size = 2
20+
end_of_line = lf
21+
charset = utf-8
22+
insert_final_newline = true
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright 2026 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Enforce Formatting
16+
17+
on:
18+
push:
19+
branches: [main]
20+
pull_request:
21+
22+
jobs:
23+
enforce-formatting:
24+
runs-on: ubuntu-latest
25+
26+
steps:
27+
- uses: actions/checkout@v6
28+
29+
- name: Set up Node.js
30+
uses: actions/setup-node@v6
31+
with:
32+
node-version: "22"
33+
34+
- name: Set up Python
35+
uses: actions/setup-python@v6
36+
with:
37+
python-version: "3.x"
38+
39+
- name: Install `uv` globally
40+
run: |
41+
python -m pip install --upgrade pip
42+
pip install uv
43+
44+
- name: Run enforce-formatting script
45+
run: ./scripts/fix_format.sh --check

.prettierignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright 2026 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
node_modules
16+
dist
17+
build
18+
.git
19+
.dart_tool
20+
.venv
21+
*.min.js
22+
agent_sdks/conformance/test_data/**
23+
**/pnpm-lock.yaml

.prettierrc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"printWidth": 100,
3+
"singleQuote": true,
4+
"semi": true,
5+
"tabWidth": 2,
6+
"trailingComma": "all",
7+
"bracketSpacing": false,
8+
"jsxSingleQuote": false,
9+
"arrowParens": "avoid",
10+
"overrides": [
11+
{
12+
"files": "*.html",
13+
"options": {
14+
"parser": "angular"
15+
}
16+
},
17+
{
18+
"files": ["*.yaml", "*.yml"],
19+
"options": {
20+
"singleQuote": false
21+
}
22+
}
23+
]
24+
}

.vscode/settings.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
11
{
2-
"dart.projectSearchDepth": 10
2+
"dart.projectSearchDepth": 10,
3+
"editor.formatOnSave": true,
4+
"editor.defaultFormatter": "esbenp.prettier-vscode",
5+
"[python]": {
6+
"editor.defaultFormatter": "ms-python.black-formatter"
7+
},
8+
"black-formatter.path": ["pyink"],
9+
"[dart]": {
10+
"editor.defaultFormatter": "Dart-Code.dart-code"
11+
}
312
}

CONTRIBUTING.md

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ You may follow these steps to contribute:
4141
3. **Work on your forked repository's feature branch.** This is where you will make your changes to the code.
4242
4. **Commit your updates on your forked repository's feature branch.** This will save your changes to your copy of the repository.
4343
5. **Submit a pull request to the official repository's main branch.** This will request that your changes be merged into the official repository.
44-
6. **Resolve any linting errors.** This will ensure that your changes are formatted correctly.
44+
6. **Resolve any linting and formatting errors.** Run `./scripts/fix_format.sh` to fix formatting issues.
4545

4646
Here are some additional things to keep in mind during the process:
4747

@@ -50,12 +50,36 @@ Here are some additional things to keep in mind during the process:
5050

5151
## Coding Style
5252

53-
To keep our codebase consistent and maintainable, we follow specific coding standards for Python and TypeScript.
53+
To keep our codebase consistent and maintainable, we follow specific coding standards and use automated formatters.
5454

55-
Please refer to the following guidelines for detailed information on:
56-
* **Python**: [Google Python Style Guide](https://google.github.io/styleguide/pyguide.html).
57-
* **TypeScript**: usage of [`gts`](https://github.com/google/gts) and [Google TypeScript Style Guide](https://google.github.io/styleguide/tsguide.html).
58-
* **License Headers**: required copyright notices.
55+
### Formatters
56+
57+
- **JavaScript / TypeScript / JSON / Markdown / CSS**: [Prettier](https://prettier.io/)
58+
- **Python**: [Pyink](https://github.com/google/pyink) (Google style Black)
59+
- **Dart**: `dart format`
60+
61+
You can use the provided script to format the entire repo or check formatting:
62+
63+
```bash
64+
./scripts/fix_format.sh
65+
./scripts/fix_format.sh --check
66+
```
67+
68+
### IDE Recommendations (VS Code)
69+
70+
We recommend using [VS Code](https://code.visualstudio.com/) for development. To help enforce formatting, please install the following extensions:
71+
72+
- **Prettier - Code formatter** (`esbenp.prettier-vscode`)
73+
- **Black Formatter** (`ms-python.black-formatter`) - configured to use `pyink` in workspace settings.
74+
- **Dart** (`Dart-Code.dart-code`)
75+
76+
Workspace settings are provided in `.vscode/settings.json` to use these formatters by default on save.
77+
78+
Please refer to the following guidelines for detailed information on styles:
79+
80+
- **Python**: [Google Python Style Guide](https://google.github.io/styleguide/pyguide.html).
81+
- **TypeScript**: [Google TypeScript Style Guide](https://google.github.io/styleguide/tsguide.html).
82+
- **License Headers**: required copyright notices.
5983

6084
We expect all contributors to adhere to these styles.
6185

renderers/markdown/.prettierrc

Lines changed: 0 additions & 4 deletions
This file was deleted.

renderers/react/.prettierrc

Lines changed: 0 additions & 9 deletions
This file was deleted.

renderers/web_core/.prettierrc.js

Lines changed: 0 additions & 21 deletions
This file was deleted.

samples/mcp/a2ui-in-mcpapps/client/.prettierrc

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)