diff --git a/.claude/skills/breaking-changes/SKILL.md b/.claude/skills/breaking-changes/SKILL.md new file mode 100644 index 0000000..47dd3b9 --- /dev/null +++ b/.claude/skills/breaking-changes/SKILL.md @@ -0,0 +1,49 @@ +--- +name: breaking-changes +description: Decide whether a change is breaking and label it. Use when labelling a PR, when a change touches public API or observable behaviour, or when the user mentions breaking changes, semver, or 1.0. +--- + +# Breaking changes + +Every PR carries exactly one release label (the `pr-labels` check enforces it). release-drafter turns the labels into +the next version. + +## Is it breaking? + +Label it `breaking` when a consumer who upgrades must change something or gets different behaviour: + +- a public type, member, parameter or overload is removed, renamed or changes signature; +- a default, an output format, an exit code or a thrown exception changes; +- a target framework is dropped, or a minimum dependency version rises enough to force consumers to upgrade. + +These are not breaking: adding API, internal changes, fixing behaviour that contradicted the documentation (label +that `bug` and say so in the PR body). + +If package validation (`EnablePackageValidation`) fails on `mise run pack`, the change is breaking at the binary +level, whatever it looks like. + +## What the label does + +| Repo version | `breaking` | `feature` / `enhancement` | everything else | +|---|---|---|---| +| 0.x | minor | minor | patch | +| 1.x and later | major | minor | patch | + +0.x never gets a major bump from a label. **Going to 1.0 is always the maintainer's manual decision**: they set the +draft's tag to `1.0.0` when publishing. Do not propose it, and do not edit the resolver on your own. + +When the maintainer has released 1.0.0, add a major resolver to `.github/release-drafter.yml` (and nothing else) in +its own PR: + +```yaml +version-resolver: + major: + labels: [breaking] + minor: + labels: [feature, enhancement] + default: patch +``` + +## In the PR body + +A `breaking` PR states what a consumer must change, in a **Breaking** line (see the pr skill). diff --git a/.claude/skills/format/SKILL.md b/.claude/skills/format/SKILL.md new file mode 100644 index 0000000..efb5916 --- /dev/null +++ b/.claude/skills/format/SKILL.md @@ -0,0 +1,19 @@ +--- +name: format +description: Format code with curb, or fix formatting failures in CI. Use when the user asks to format, when `mise run check` fails, or before committing C# changes. +--- + +# Format + +[curb](https://curb.nullean.net) formats C# from `.editorconfig`. Its defaults match the IDE's, so formatting in an +editor and with curb agree. + +```bash +mise run format # rewrite files in place +mise run check # exit 1 if anything would change (CI runs this) +``` + +- `.editorconfig` comes from `nullean/.github` and is identical in every repo. Change it there, not here. +- Re-formatting a whole repo goes in its own PR, labelled `chore`, so behaviour PRs stay readable. +- If curb produces output that looks wrong, do not hand-format around it: report it at + https://github.com/nullean/curb/issues with the input and the `.editorconfig` section. diff --git a/.claude/skills/pr/SKILL.md b/.claude/skills/pr/SKILL.md index 69c031b..df89cc6 100644 --- a/.claude/skills/pr/SKILL.md +++ b/.claude/skills/pr/SKILL.md @@ -157,6 +157,18 @@ EOF )" ``` -### 9. Return the PR URL +### 9. Turn on auto-merge + +Every nullean repository squash-merges and requires the release label, zizmor and CI. Once the PR exists, let it merge +itself when those pass, unless the user asked to hold it: + +```bash +gh pr merge --auto --squash +``` + +Say so in your reply: "auto-merge is on; it squash-merges once the required checks pass". Don't merge it with `--admin` +to skip checks. + +### 10. Return the PR URL Always print the URL so the user can open it directly. diff --git a/.claude/skills/upgrade-deps/SKILL.md b/.claude/skills/upgrade-deps/SKILL.md new file mode 100644 index 0000000..84a014b --- /dev/null +++ b/.claude/skills/upgrade-deps/SKILL.md @@ -0,0 +1,33 @@ +--- +name: upgrade-deps +description: Update NuGet packages, .NET tools, the SDK or GitHub Actions. Use when the user asks to bump, upgrade or update dependencies, or to triage dependabot PRs. +--- + +# Upgrade dependencies + +Versions live in one place each: + +| What | Where | +|---|---| +| NuGet packages | `Directory.Packages.props` (Central Package Management); never put `Version=` on a `PackageReference` | +| .NET tools | `.config/dotnet-tools.json` (or `dotnet-tools.json` at the root) | +| .NET SDK | `global.json` only; mise reads it from there | +| other CLI tools | `mise.toml` `[tools]` | +| GitHub Actions | pinned by commit SHA with a `# vX.Y.Z` comment; reusable workflows from `nullean/.github` likewise | + +## Steps + +1. Branch first. One concern per PR: SDK bumps, package bumps and action bumps go separately when any of them changes + behaviour. +2. Find what is outdated: `dotnet list package --outdated`, plus `dotnet tool list` against nuget.org. +3. Bump, then `mise run ci`. A new SDK also needs `mise install`. +4. Read the release notes of every major bump and say in the PR body what changed for this repo. +5. Label the PR `dependencies` unless the bump forces consumers to change something; then it is `breaking` (see + [breaking-changes](../breaking-changes/SKILL.md)). + +For dependabot PRs: patch and minor updates merge themselves once CI passes (`dependabot-automerge.yml`). Majors +wait for you: read the changelog, then `gh pr merge --auto --squash`. Do not rebase a dependabot PR by +hand; comment `@dependabot rebase`. + +Pin an action to the commit its release tag points at: +`gh api repos///commits/ --jq .sha`. diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..ac65815 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,163 @@ +root = true + +[*] +charset = utf-8 +indent_style = tab +indent_size = 4 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.{fs,fsx,cs}] +max_line_length = 160 + +[*.{fs,fsx}] +indent_style = space +indent_size = 4 + +[*.{md,markdown,json,js,yml,yaml,csproj,fsproj,targets,props,slnx,config}] +indent_style = space +indent_size = 2 + +# Golden-file fixtures are byte-exact: never let an editor touch them. +[*.test] +trim_trailing_whitespace = false +insert_final_newline = false + +[*.{cs,vb}] +end_of_line = lf + +# --- Naming --------------------------------------------------------------- + +# Constants are PascalCase +dotnet_naming_rule.constants_should_be_pascal_case.symbols = consts +dotnet_naming_rule.constants_should_be_pascal_case.style = pascal_case +dotnet_naming_rule.constants_should_be_pascal_case.severity = suggestion +dotnet_naming_symbols.consts.applicable_kinds = field +dotnet_naming_symbols.consts.applicable_accessibilities = * +dotnet_naming_symbols.consts.required_modifiers = const + +# Non-public STATIC fields are PascalCase. +# Must precede the private-instance-field rule below: naming rules are evaluated in file order +# and the first match wins, so the more specific (static) rule has to come first. +dotnet_naming_rule.non_public_static_fields_should_be_pascal_case.symbols = non_public_static_fields +dotnet_naming_rule.non_public_static_fields_should_be_pascal_case.style = pascal_case +dotnet_naming_rule.non_public_static_fields_should_be_pascal_case.severity = suggestion +dotnet_naming_symbols.non_public_static_fields.applicable_kinds = field +dotnet_naming_symbols.non_public_static_fields.applicable_accessibilities = private, protected, internal, protected_internal, private_protected +dotnet_naming_symbols.non_public_static_fields.required_modifiers = static + +# Private instance fields are _camelCase +dotnet_naming_rule.private_fields_should_be_underscored.symbols = private_fields +dotnet_naming_rule.private_fields_should_be_underscored.style = underscore_camel_case +dotnet_naming_rule.private_fields_should_be_underscored.severity = suggestion +dotnet_naming_symbols.private_fields.applicable_kinds = field +dotnet_naming_symbols.private_fields.applicable_accessibilities = private + +dotnet_naming_style.pascal_case.capitalization = pascal_case +dotnet_naming_style.underscore_camel_case.capitalization = camel_case +dotnet_naming_style.underscore_camel_case.required_prefix = _ + +# --- Language conventions ------------------------------------------------- + +dotnet_sort_system_directives_first = true +dotnet_separate_import_directive_groups = false + +dotnet_style_qualification_for_field = false:error +dotnet_style_qualification_for_property = false:error +dotnet_style_qualification_for_method = false:error +dotnet_style_qualification_for_event = false:error + +dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion +dotnet_style_predefined_type_for_member_access = true:suggestion +dotnet_style_object_initializer = true:suggestion +dotnet_style_collection_initializer = true:suggestion +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_null_propagation = true:suggestion +dotnet_style_readonly_field = true:suggestion +# Guard clauses stay guard clauses; collapsing them into ternaries hurts readability. +dotnet_style_prefer_conditional_expression_over_return = false:silent +dotnet_style_prefer_conditional_expression_over_assignment = false:silent + +csharp_style_var_for_built_in_types = true:suggestion +csharp_style_var_when_type_is_apparent = true:suggestion +csharp_style_var_elsewhere = true:suggestion + +csharp_style_namespace_declarations = file_scoped:error +csharp_style_expression_bodied_methods = when_on_single_line:suggestion +csharp_style_expression_bodied_constructors = when_on_single_line:suggestion +csharp_style_expression_bodied_local_functions = when_on_single_line:suggestion +csharp_style_expression_bodied_lambdas = true:suggestion +csharp_style_expression_bodied_operators = when_on_single_line:suggestion +csharp_style_expression_bodied_indexers = true:suggestion +csharp_style_expression_bodied_properties = true:suggestion +csharp_style_expression_bodied_accessors = true:suggestion +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion +csharp_prefer_braces = false:suggestion +csharp_using_directive_placement = outside_namespace:error + +# --- Formatting (IDE0055) ------------------------------------------------- +# Curb's own source is formatted to these. Once Curb can format itself, this +# section is also the dogfooding fixture: `curb check .` must be clean. + +csharp_new_line_before_open_brace = all +csharp_new_line_before_else = true +csharp_new_line_before_catch = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_object_initializers = false +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_between_query_expression_clauses = true + +csharp_indent_case_contents = true +csharp_indent_switch_labels = true +csharp_indent_labels = one_less_than_current +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents_when_block = true + +csharp_space_after_cast = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_between_parentheses = false +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_around_binary_operators = before_and_after +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +csharp_space_between_method_declaration_name_and_open_parenthesis = false +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +csharp_space_after_comma = true +csharp_space_before_comma = false +csharp_space_after_dot = false +csharp_space_before_dot = false +csharp_space_after_semicolon_in_for_statement = true +csharp_space_before_semicolon_in_for_statement = false +csharp_space_around_declaration_statements = false +csharp_space_before_open_square_brackets = false +csharp_space_between_empty_square_brackets = false +csharp_space_between_square_brackets = false + +csharp_preserve_single_line_statements = false +csharp_preserve_single_line_blocks = true + +# --- Analyzers ------------------------------------------------------------ + +dotnet_analyzer_diagnostic.severity = warning +dotnet_diagnostic.IDE0058.severity = none +dotnet_diagnostic.CA1848.severity = none +dotnet_diagnostic.CA1707.severity = none + +# The document IR switches over DocKind exhaustively via `default:`; listing every member at every +# site is noise, and a new kind should fall through to the default rather than break the build. +dotnet_diagnostic.IDE0010.severity = none +# Same reasoning for switch expressions: wildcard arms handle future enum values without breaking. +dotnet_diagnostic.IDE0072.severity = none +# Several types rent pooled buffers in their constructor, which a primary constructor cannot express. +dotnet_diagnostic.IDE0290.severity = suggestion +# Hot-path counters stay as fields; `Count => _count` reads better than an auto property here. +dotnet_diagnostic.IDE0032.severity = none + +[tests/**/*.cs] +dotnet_diagnostic.IDE0058.severity = none +dotnet_diagnostic.IDE0022.severity = none diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..3240e54 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,10 @@ +# The shared .editorconfig sets end_of_line = lf, and IDE0055 is an error: without this, a Windows checkout gets CRLF +# and every C# line fails the build. Binary files a repository adds need their own `binary` line below. +* text=auto eol=lf +*.png binary +*.jpg binary +*.gif binary +*.ico binary +*.snk binary +*.nupkg binary +*.zip binary diff --git a/.github/workflows/dependabot-automerge.yml b/.github/workflows/dependabot-automerge.yml new file mode 100644 index 0000000..17cef14 --- /dev/null +++ b/.github/workflows/dependabot-automerge.yml @@ -0,0 +1,13 @@ +name: dependabot-automerge + +on: + pull_request: + +permissions: {} + +jobs: + automerge: + uses: nullean/.github/.github/workflows/dependabot-automerge.yml@d850ce6eee9efa9f81b410d15fcd480409518d19 # v1.5.0 + permissions: + contents: write + pull-requests: write