Skip to content

Commit 6647f54

Browse files
authored
style: use pre-commit to enforce line endings/etc (#2005)
This sets up [`pre-commit`](https://pre-commit.com/) to enforce line endings, trailing whitespace, bad symlinks, and other surface-level details. It also fixes all existing violations.
2 parents 5e56d9d + 4c6ccb0 commit 6647f54

24 files changed

+63
-34
lines changed

.github/linters/phpcs.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
<rule ref="PSR12">
66
<exclude name="PSR12.Properties.ConstantVisibility" />
77
</rule>
8-
</ruleset>
8+
</ruleset>

.github/linters/sun_checks.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154

155155
<!-- Checks for class design -->
156156
<!-- See https://checkstyle.org/config_design.html -->
157-
<!-- TODO re-enable once we Javadoc <module name="DesignForExtension"/> -->
157+
<!-- TODO re-enable once we Javadoc <module name="DesignForExtension"/> -->
158158
<module name="FinalClass"/>
159159
<module name="HideUtilityClassConstructor"/>
160160
<module name="InterfaceIsType"/>
@@ -175,4 +175,4 @@
175175

176176
</module>
177177

178-
</module>
178+
</module>

.github/workflows/mega-releaser.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ jobs:
88
name: Kick-off Releases
99
runs-on: ubuntu-latest
1010
steps:
11-
- run: /bin/true
11+
- run: /bin/true

.github/workflows/pre-commit.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: pre-commit
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
typos:
11+
name: Validate pre-commit
12+
runs-on: ubuntu-24.04
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-python@v5
16+
- uses: pre-commit/action@v3.0.1

.pre-commit-config.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: 582b9c66e0791980685c8b80bb11e6a3df1a06ef
4+
hooks:
5+
- id: end-of-file-fixer
6+
exclude: "(^.yarn/)|(.svg$)|(-openapi.json)|(java/lib/src/test/resources/__files/)|(kotlin/lib/src/test/resources/__files/)|(server/svix-server/migrations/202[234])"
7+
- id: trailing-whitespace
8+
exclude: "(^.yarn/)|(.svg$)|(-openapi.json)|(java/lib/src/test/resources/__files/)|(kotlin/lib/src/test/resources/__files/)|(svix-cli/wix/main.wxs)|(server/svix-server/migrations/202[234])"
9+
- id: check-case-conflict
10+
- id: check-illegal-windows-names
11+
- id: check-merge-conflict
12+
- id: check-symlinks
13+
- id: check-toml
14+
- id: check-yaml
15+
- id: check-json
16+
exclude: "(kotlin/lib/src/test/resources/__files/ExpectedMsgCreateBodyWithHeaders.json)|(tsconfig.json)"

ChangeLog.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ This version contains a big overhaul of the client libraries, with improved typi
270270
* Libs: Upgrade `openapi-generator` to 7.9.0, with dependency upgrades and internal changes in the SDKs.
271271
* Server: Add Redis sentinel support
272272
* Server: Add OTEL metrics for Redis queues
273-
* Server: Add Redis DLQ support
273+
* Server: Add Redis DLQ support
274274
* Server: Several dependency upgrades and CI improvements
275275

276276
## Version 1.38.0
@@ -343,7 +343,7 @@ This version contains a big overhaul of the client libraries, with improved typi
343343
* Libs/Rust: Add `Svix::with_token` to allow changing API token
344344
* Libs/PHP: Replace ctype_digit for PHP 8.1 deprecation of non-string arguments
345345

346-
## Version 1.24.0
346+
## Version 1.24.0
347347
* Server: Update redis health check
348348
* Server: Clean up tracing spans for HTTP requests
349349
* Libs: Update OpenAPI
@@ -377,17 +377,17 @@ This version contains a big overhaul of the client libraries, with improved typi
377377
* Libs/Rust: Make request timeout configurable
378378

379379
## Version 1.18.0
380-
* Server: upgrade dependencies
380+
* Server: upgrade dependencies
381381
* Server: adopt omniqueue as a queue backend
382382
* Libs/C#: **[Breaking]** Return iterator information in list endpoints. Changes the return type of list endpoints.
383383
* Libs/Java: don't serialize nulls in PATCH endpoint methods
384-
* Libs/Rust: upgrade and clean up dependencies
384+
* Libs/Rust: upgrade and clean up dependencies
385385
* Libs/Rust: switch from reqwest to hyper 1.0
386386

387387
## Version 1.17.0
388388
* Server: Upgrade hyper to 0.14.28
389389
* Libs/Rust: **[Important]** Fix a bug in the webhook signature verification method where certain signatures could bypass the verification.
390-
* Libs/Java: **[Breaking]** Use Java time instead of threetenbp. This removes the need to import threetenbp to use the library. Depending on how the lib is used, it might require migrating uses of threetenbp to Java 8 Date-Time APIs.
390+
* Libs/Java: **[Breaking]** Use Java time instead of threetenbp. This removes the need to import threetenbp to use the library. Depending on how the lib is used, it might require migrating uses of threetenbp to Java 8 Date-Time APIs.
391391

392392
## Version 1.16.0
393393
* Server: Add `tag` parameter to list-message for Go, JavaScript, and Python.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ Contributions are what makes the open source world go round! All contributions a
420420
Please refer to the [contribution guide](./CONTRIBUTING.md) for information on how to contribute.
421421

422422
A quick how to for contribution:
423-
423+
424424
1. Fork the project
425425
2. Create your feature branch (`git checkout -b feature/some-feature`)
426426
3. Make your changes

codegen/generated_files.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1507,4 +1507,4 @@
15071507
"svix-cli/src/cmds/api/operational_webhook.rs",
15081508
"svix-cli/src/cmds/api/operational_webhook_endpoint.rs"
15091509
]
1510-
]
1510+
]

codegen/templates/go/types/struct_enum.go.jinja

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ import (
2525
// - {% for v in vars %}"{{ v.name }}"{% if not loop.last %},{% endif %}{% endfor %}: {{ use_type }}
2626
{%- endfor -%}
2727
type {{ ty_name }} struct {
28-
{% include "types/struct_fields.go.jinja" -%}
28+
{% include "types/struct_fields.go.jinja" -%}
2929
{{ discriminator_field }} {{ ty_name }}{{ discriminator_field }} `json:"{{ type.discriminator_field }}"`
3030
{{ content_field }} {{ ty_name }}{{ content_field }} `json:"{{ type.content_field }}"`
3131
}
3232

3333
type {{ ty_name }}{{ discriminator_field }} string
3434

3535
const (
36-
{% for v in type.variants -%}
36+
{% for v in type.variants -%}
3737
{{ ty_name }}{{ discriminator_field }}{{ v.name | to_upper_camel_case }} {{ ty_name }}{{ discriminator_field }} = "{{ v.name }}"
38-
{% endfor -%}
38+
{% endfor -%}
3939
)
4040

4141

@@ -83,7 +83,7 @@ func (i *{{ ty_name }}) UnmarshalJSON(data []byte) error {
8383
var {{ ty_name }}{{ discriminator_field }}WithNo{{ content_field }} = map[string]bool{
8484
{% for v in type.variants -%}
8585
{% if v.schema_ref is not defined -%}
86-
"{{ v.name }}": true,
86+
"{{ v.name }}": true,
8787
{% endif -%}
8888
{% endfor -%}
8989
}
@@ -93,7 +93,7 @@ func (i {{ ty_name }}) MarshalJSON() ([]byte, error) {
9393
type Alias {{ ty_name }}
9494
{% if has_variant_with_no_schema_ref -%}
9595
if _, found := {{ ty_name }}{{ discriminator_field }}WithNo{{ content_field }}[string(i.{{ discriminator_field }})]; found {
96-
i.{{ content_field }} = emptyMap{}
96+
i.{{ content_field }} = emptyMap{}
9797
}
9898
{% endif -%}
9999
return json.Marshal(&struct {Alias}{Alias: (Alias)(i)})

codegen/templates/kotlin/types/struct_enum.kt.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ sealed class {{ enum_type_name }} {
2929
val variantName: String get() = this::class.annotations.filterIsInstance<VariantName>().first().name
3030
abstract fun toJsonElement(): JsonElement
3131

32-
{% for variant in type.variants %}
32+
{% for variant in type.variants %}
3333
{% set val_name %}{{ variant.name | to_lower_camel_case }}{% endset -%}
3434
@VariantName("{{ variant.name }}")
3535
{% if variant.schema_ref is defined -%}

0 commit comments

Comments
 (0)