Skip to content

Commit 7fa3e14

Browse files
authored
Add common configuration files for linters and other programs (#721)
1 parent 448e2bb commit 7fa3e14

File tree

7 files changed

+361
-0
lines changed

7 files changed

+361
-0
lines changed

.clang-format

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright 2025 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+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16+
# Basic clang-format config for this project.
17+
# See https://clang.llvm.org/docs/ClangFormatStyleOptions.html for more info.
18+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19+
---
20+
Language: Cpp
21+
BasedOnStyle: Google
22+
ColumnLimit: 80
23+
AlignAfterOpenBracket: AlwaysBreak
24+
IncludeCategories:
25+
- Regex: '^<.*>$'
26+
Priority: 1
27+
- Regex: '^"gtest/.*"$'
28+
Priority: 2
29+
- Regex: '^".*"$'
30+
Priority: 3
31+
IncludeIsMainRegex: '([.](test|benchmark))?$'
32+
---
33+
Language: Proto
34+
BasedOnStyle: Google
35+
...

.editorconfig

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Copyright 2025 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+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16+
# Common editor configurations for this project.
17+
#
18+
# EditorConfig is a file format for specifying some common style parameters.
19+
# Many IDEs & editors read .editorconfig files, either natively or via plugins.
20+
# We mostly follow Google's style guides (https://google.github.io/styleguide/)
21+
# with only a few deviations for line length and indentation in some files.
22+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23+
24+
root = true
25+
26+
# IMPORTANT: some of the other config files (.markdownlintrc, .jsonlintrc.yaml,
27+
# etc.) also have settings for indent and line length. When making changes to
28+
# this file, make sure to update the other files to match.
29+
30+
[*]
31+
charset = utf-8
32+
indent_style = space
33+
insert_final_newline = true
34+
spelling_language = en-US
35+
trim_trailing_whitespace = true
36+
max_line_length = 80
37+
38+
[{BUILD,*.BUILD,*.bzl,*.bazel,.bazelrc}]
39+
indent_size = 4
40+
41+
[{*.cc,*.h}]
42+
indent_size = 2
43+
44+
[*.json]
45+
indent_size = 2
46+
47+
[*.py]
48+
indent_size = 4
49+
50+
[*.sh]
51+
indent_size = 2
52+
53+
[{*.yaml,*.yml}]
54+
indent_size = 2

.hadolint.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright 2025 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+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16+
# Hadolint (a Dockerfile linter) used in this project's CI checks.
17+
# Info about options can be found at https://github.com/hadolint/hadolint/.
18+
# Rule/error numbers are described at https://github.com/hadolint/hadolint/wiki
19+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20+
21+
format: tty
22+
no-color: false
23+
no-fail: false
24+
failure-threshold: error
25+
ignored:
26+
# Multiple consecutive RUN stmts are usually deliberate. Don't flag that.
27+
- DL3059

.jsonlintrc.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright 2025 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+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16+
# Project configuration for jsonlint (https://github.com/prantlf/jsonlint).
17+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18+
19+
comments: false
20+
compact: true
21+
continue: true
22+
endOfLine: lf
23+
indent: 2
24+
log-files: false
25+
no-duplicate-keys: true
26+
patterns:
27+
- '**/*.json'
28+
- '!**/node_modules'
29+
singleQuote: false
30+
trailing-commas: false

.markdownlintrc

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
{ // -*- jsonc -*-
2+
// Copyright 2025 Google LLC
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// https://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17+
// Markdownlint linter configuration for this project.
18+
//
19+
// Note: there are multiple programs programs named "markdownlint". We use
20+
// https://github.com/igorshubovych/markdownlint-cli/, which is the one you
21+
// get with "brew install markdownlint" on MacOS.
22+
//
23+
// These settings try to stay close to the Google Markdown Style as
24+
// described at https://google.github.io/styleguide/docguide/style.html
25+
// with very few differences.
26+
//
27+
// For a list of possible configuration options, see the following page:
28+
// https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md
29+
// (Beware that the above looks similar but is NOT the same as the page
30+
// https://github.com/markdownlint/markdownlint/blob/main/docs/RULES.md.)
31+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32+
33+
"$schema": "https://raw.githubusercontent.com/DavidAnson/markdownlint/main/schema/markdownlint-config-schema.json",
34+
35+
// Require ATX-style headings.
36+
// https://google.github.io/styleguide/docguide/style.html#atx-style-headings
37+
"headings": {
38+
"style": "atx"
39+
},
40+
41+
// Google style does not require that the first line of a file is a heading
42+
// for the title; it only states that the first heading should be a level 1.
43+
// https://google.github.io/styleguide/docguide/style.html#document-layout
44+
"first-line-heading": false,
45+
46+
// The Google style does not define what to do about trailing punctuation in
47+
// headings. The markdownlint default disallows exclamation points, which
48+
// seems likely to be more annoying than useful – I have definitely seen
49+
// people use exclamation points in headings in README files on GitHub.
50+
// This setting removes exclamation point from the banned characters.
51+
"no-trailing-punctuation": {
52+
"punctuation": ".,;:。,;:"
53+
},
54+
55+
// No trailing spaces.
56+
// https://google.github.io/styleguide/docguide/style.html#trailing-whitespace
57+
"whitespace": {
58+
"br_spaces": 0
59+
},
60+
61+
// Google style is 80 characters.
62+
// Google style exempts some constructs from the line-length limit:
63+
// https://google.github.io/styleguide/docguide/style.html#exceptions
64+
"line-length": {
65+
"line_length": 80,
66+
"code_block_line_length": 80,
67+
"heading_line_length": 80,
68+
"code_blocks": false,
69+
"headings": false,
70+
"tables": false
71+
},
72+
73+
// Google Markdown style specifies 2 spaces after item numbers, 3 spaces
74+
// after bullets, so that the text itself is consistently indented 4 spaces.
75+
// https://google.github.io/styleguide/docguide/style.html#nested-list-spacing
76+
"list-marker-space": {
77+
"ol_multi": 2,
78+
"ol_single": 2,
79+
"ul_multi": 3,
80+
"ul_single": 3
81+
},
82+
83+
"ul-indent": {
84+
"indent": 4
85+
},
86+
87+
// Bare URLs are allowed in GitHub-flavored Markdown and in Google’s style.
88+
"no-bare-urls": false,
89+
90+
// Basic Markdown allows raw HTML. Both GitHub & PyPI support subsets of
91+
// HTML, though it's unclear what subset PyPI supports. Google's style guide
92+
// recommends against using raw HTML, but does allow it. (C.f. the bottom of
93+
// https://google.github.io/styleguide/docguide/style.html) Google's in-house
94+
// documentation system allows many inline and block-level tags, but strips
95+
// others that can pose security risks (e.g., <object> and standalone <svg>).
96+
// The list below tries to capture the intersection of what GitHub allows
97+
// (c.f. https://github.com/github/markup/issues/245#issuecomment-682231577),
98+
// what PyPI seems to allow, what Google allows, and what seems likely to be
99+
// most useful in situations where someone needs to reach for HTML.
100+
"html": {
101+
"allowed_elements": [
102+
"a",
103+
"abbr",
104+
"b",
105+
"blockquote",
106+
"br",
107+
"caption",
108+
"cite",
109+
"code",
110+
"dd",
111+
"del",
112+
"details",
113+
"dfn",
114+
"div",
115+
"dl",
116+
"dt",
117+
"em",
118+
"figcaption",
119+
"figure",
120+
"h1",
121+
"h2",
122+
"h3",
123+
"h4",
124+
"h5",
125+
"h6",
126+
"hr",
127+
"i",
128+
"img",
129+
"ins",
130+
"kbd",
131+
"li",
132+
"mark",
133+
"ol",
134+
"p",
135+
"picture",
136+
"pre",
137+
"q",
138+
"s",
139+
"samp",
140+
"small",
141+
"span",
142+
"strong",
143+
"sub",
144+
"summary",
145+
"sup",
146+
"table",
147+
"tbody",
148+
"td",
149+
"tfoot",
150+
"th",
151+
"thead",
152+
"time",
153+
"tr",
154+
"tt",
155+
"ul",
156+
"var",
157+
"wbr"
158+
]
159+
}
160+
}

.yamlfmt.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright 2025 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+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16+
# yamlfmt configuration for this project.
17+
# See https://github.com/google/yamlfmt for info about options.
18+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19+
20+
# Read .gitignore for paths to exclude.
21+
gitignore_excludes: true
22+
23+
formatter:
24+
type: basic
25+
eof_newline: true
26+
max_line_length: 80
27+
retain_line_breaks: true
28+
trim_trailing_whitespace: true

.yamllint.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright 2025 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+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16+
# Yamllint configuration to match project settings like line length.
17+
# See https://yamllint.readthedocs.io/ for info about configuration options.
18+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19+
20+
rules:
21+
line-length:
22+
max: 80
23+
# When the last item on a line can't be broken (e.g., a URL as a value),
24+
# it's rarely useful to flag it. The next 2 settings save developer time by
25+
# not requiring comment directives to disable warnings at every occurrence.
26+
allow-non-breakable-words: true
27+
allow-non-breakable-inline-mappings: true

0 commit comments

Comments
 (0)