diff --git a/.lintstagedrc.cjs b/.lintstagedrc.cjs new file mode 100644 index 0000000..1e941bd --- /dev/null +++ b/.lintstagedrc.cjs @@ -0,0 +1,15 @@ +// Format staged sources only. Framework/SwiftyUpdateKit.xcframework/ is a +// generated distribution artifact: running uncrustify over its generated +// headers reorders their #include lines and invalidates the bundle signature, +// so the formatters must never see it. +const GENERATED = 'Framework/SwiftyUpdateKit.xcframework/' + +const format = (command) => (files) => { + const targets = files.filter((file) => !file.includes(GENERATED)) + return targets.length ? [`${command} ${targets.map((f) => `'${f}'`).join(' ')}`] : [] +} + +module.exports = { + '**/*.swift': format('./.codeformat/swiftformat'), + '**/*.{m,h}': format('./.codeformat/uncrustify -c uncrustify-objc.cfg --no-backup -l OC'), +} diff --git a/AGENTS.md b/AGENTS.md index a27ced0..d984cf2 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -33,6 +33,9 @@ prompts, release notes, and review requests. - Format Swift code according to `.swiftformat`. The expected SwiftFormat version is defined in `codeformat.sh`. +- Formatters run on staged files through `.lintstagedrc.cjs`, which excludes + `Framework/SwiftyUpdateKit.xcframework/`. Do not widen those globs to cover it: uncrustify + reorders the `#include` lines in its generated headers and invalidates the bundle signature. - Follow the existing naming, access control, documentation comment, and closure styles. - Keep code comments self-contained. When referring to an issue or external resource, summarize the reason and include the complete URL. diff --git a/package.json b/package.json index 5aa1673..c14b392 100644 --- a/package.json +++ b/package.json @@ -14,13 +14,5 @@ "devDependencies": { "husky": "^8.0.3", "lint-staged": "^13.1.2" - }, - "lint-staged": { - "./**/*.swift": [ - "./.codeformat/swiftformat" - ], - "./**/*.{m,h}": [ - "./.codeformat/uncrustify -c uncrustify-objc.cfg --no-backup -l OC" - ] } }