@mrciphersmith/keryx 0.4.29 → 0.4.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +2446 -1391
- package/dist/core.js +90 -27
- package/dist/keryx-general-worker-entry.js +82 -25
- package/package.json +1 -1
- package/src/gdskills/bundled/install-manifest.json +2 -0
- package/src/gdskills/bundled/rules/core/api-contracts.mdc +21 -136
- package/src/gdskills/bundled/rules/core/async-patterns.mdc +18 -171
- package/src/gdskills/bundled/rules/core/clean-architecture.mdc +21 -3
- package/src/gdskills/bundled/rules/core/cli-interface-design.mdc +63 -194
- package/src/gdskills/bundled/rules/core/code-style-patterns.mdc +36 -49
- package/src/gdskills/bundled/rules/core/concurrency-patterns.mdc +32 -0
- package/src/gdskills/bundled/rules/core/database-patterns.mdc +26 -148
- package/src/gdskills/bundled/rules/core/error-handling.mdc +7 -8
- package/src/gdskills/bundled/rules/core/frontend-assistant.mdc +14 -29
- package/src/gdskills/bundled/rules/core/layout-rendering.mdc +51 -0
- package/src/gdskills/bundled/rules/core/mobx-store-template.mdc +69 -511
- package/src/gdskills/bundled/rules/core/nestjs-dto.mdc +18 -36
- package/src/gdskills/bundled/rules/core/playwright-testing.mdc +35 -308
- package/src/gdskills/bundled/rules/core/security-baseline.mdc +18 -140
- package/src/gdskills/bundled/rules/core/solid-principles.mdc +31 -7
- package/src/gdskills/bundled/rules/core/storybook-guidelines.mdc +20 -22
- package/src/gdskills/bundled/rules/core/tdd-workflow.mdc +37 -74
- package/src/gdskills/bundled/rules/core/ui-anti-slop.mdc +48 -37
- package/src/gdskills/bundled/skills/quality/deprecation-path/SKILL.md +1 -1
- package/src/gdskills/bundled/skills/review/review-architecture/SKILL.md +24 -60
- package/src/gdskills/bundled/skills/review/review-backend/SKILL.md +13 -65
- package/src/gdskills/bundled/skills/review/review-clean-code/SKILL.md +22 -35
- package/src/gdskills/bundled/skills/review/review-frontend/SKILL.md +16 -309
- package/src/gdskills/bundled/skills/review/review-frontend-conventions/SKILL.md +7 -21
- package/src/gdskills/bundled/skills/review/review-highload/SKILL.md +83 -227
- package/src/gdskills/bundled/skills/review/review-layout/SKILL.md +22 -28
- package/src/gdskills/bundled/skills/review/review-logic/SKILL.md +8 -8
- package/src/gdskills/bundled/skills/review/review-performance/SKILL.md +15 -37
- package/src/gdskills/bundled/skills/review/review-security-code/SKILL.md +7 -7
- package/src/gdskills/bundled/skills/review/review-style/SKILL.md +31 -66
- package/src/gdskills/bundled/skills/review/review-testing-practices/SKILL.md +21 -39
- package/src/gdskills/bundled/skills/review/review-ui-ux/SKILL.md +42 -82
- package/src/gdskills/bundled/stacks/angular/rules/coding-style.mdc +15 -57
- package/src/gdskills/bundled/stacks/angular/rules/patterns.mdc +16 -60
- package/src/gdskills/bundled/stacks/angular/rules/security.mdc +11 -49
- package/src/gdskills/bundled/stacks/angular/rules/testing.mdc +13 -52
- package/src/gdskills/bundled/stacks/c-cpp/rules/coding-style.mdc +33 -57
- package/src/gdskills/bundled/stacks/c-cpp/rules/patterns.mdc +35 -62
- package/src/gdskills/bundled/stacks/c-cpp/rules/security.mdc +35 -62
- package/src/gdskills/bundled/stacks/c-cpp/rules/testing.mdc +34 -54
- package/src/gdskills/bundled/stacks/ci-github-gitlab/rules/patterns.mdc +27 -56
- package/src/gdskills/bundled/stacks/ci-github-gitlab/rules/security.mdc +51 -119
- package/src/gdskills/bundled/stacks/csharp-dotnet/rules/coding-style.mdc +42 -74
- package/src/gdskills/bundled/stacks/csharp-dotnet/rules/patterns.mdc +45 -84
- package/src/gdskills/bundled/stacks/csharp-dotnet/rules/security.mdc +34 -59
- package/src/gdskills/bundled/stacks/csharp-dotnet/rules/testing.mdc +33 -62
- package/src/gdskills/bundled/stacks/django/rules/coding-style.mdc +15 -56
- package/src/gdskills/bundled/stacks/django/rules/patterns.mdc +16 -68
- package/src/gdskills/bundled/stacks/django/rules/security.mdc +13 -71
- package/src/gdskills/bundled/stacks/django/rules/testing.mdc +16 -62
- package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/coding-style.mdc +30 -53
- package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/patterns.mdc +20 -56
- package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/security.mdc +52 -122
- package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/testing.mdc +23 -42
- package/src/gdskills/bundled/stacks/fastapi/rules/coding-style.mdc +13 -47
- package/src/gdskills/bundled/stacks/fastapi/rules/patterns.mdc +18 -81
- package/src/gdskills/bundled/stacks/fastapi/rules/security.mdc +13 -75
- package/src/gdskills/bundled/stacks/fastapi/rules/testing.mdc +14 -58
- package/src/gdskills/bundled/stacks/flutter-dart/rules/coding-style.mdc +36 -74
- package/src/gdskills/bundled/stacks/flutter-dart/rules/patterns.mdc +30 -66
- package/src/gdskills/bundled/stacks/flutter-dart/rules/security.mdc +33 -67
- package/src/gdskills/bundled/stacks/flutter-dart/rules/testing.mdc +41 -73
- package/src/gdskills/bundled/stacks/go/rules/coding-style.mdc +36 -57
- package/src/gdskills/bundled/stacks/go/rules/patterns.mdc +27 -42
- package/src/gdskills/bundled/stacks/go/rules/security.mdc +26 -43
- package/src/gdskills/bundled/stacks/go/rules/testing.mdc +23 -41
- package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/coding-style.mdc +18 -37
- package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/patterns.mdc +26 -43
- package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/security.mdc +25 -37
- package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/testing.mdc +34 -50
- package/src/gdskills/bundled/stacks/kotlin-android/rules/coding-style.mdc +28 -65
- package/src/gdskills/bundled/stacks/kotlin-android/rules/patterns.mdc +34 -78
- package/src/gdskills/bundled/stacks/kotlin-android/rules/security.mdc +35 -68
- package/src/gdskills/bundled/stacks/kotlin-android/rules/testing.mdc +34 -68
- package/src/gdskills/bundled/stacks/mobx/rules/coding-style.mdc +18 -64
- package/src/gdskills/bundled/stacks/mobx/rules/patterns.mdc +13 -66
- package/src/gdskills/bundled/stacks/mobx/rules/security.mdc +8 -35
- package/src/gdskills/bundled/stacks/mobx/rules/testing.mdc +10 -39
- package/src/gdskills/bundled/stacks/nestjs/rules/coding-style.mdc +32 -45
- package/src/gdskills/bundled/stacks/nestjs/rules/patterns.mdc +40 -60
- package/src/gdskills/bundled/stacks/nestjs/rules/security.mdc +30 -50
- package/src/gdskills/bundled/stacks/nestjs/rules/testing.mdc +27 -47
- package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/coding-style.mdc +14 -48
- package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/patterns.mdc +15 -67
- package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/security.mdc +12 -50
- package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/testing.mdc +11 -43
- package/src/gdskills/bundled/stacks/php-laravel/rules/coding-style.mdc +17 -58
- package/src/gdskills/bundled/stacks/php-laravel/rules/patterns.mdc +15 -56
- package/src/gdskills/bundled/stacks/php-laravel/rules/security.mdc +13 -50
- package/src/gdskills/bundled/stacks/php-laravel/rules/testing.mdc +14 -55
- package/src/gdskills/bundled/stacks/python/rules/coding-style.mdc +13 -41
- package/src/gdskills/bundled/stacks/python/rules/patterns.mdc +20 -61
- package/src/gdskills/bundled/stacks/python/rules/security.mdc +15 -57
- package/src/gdskills/bundled/stacks/python/rules/testing.mdc +16 -50
- package/src/gdskills/bundled/stacks/react/rules/coding-style.mdc +14 -40
- package/src/gdskills/bundled/stacks/react/rules/patterns.mdc +15 -55
- package/src/gdskills/bundled/stacks/react/rules/security.mdc +13 -49
- package/src/gdskills/bundled/stacks/react/rules/testing.mdc +10 -37
- package/src/gdskills/bundled/stacks/ruby-rails/rules/coding-style.mdc +12 -45
- package/src/gdskills/bundled/stacks/ruby-rails/rules/patterns.mdc +18 -67
- package/src/gdskills/bundled/stacks/ruby-rails/rules/security.mdc +11 -60
- package/src/gdskills/bundled/stacks/ruby-rails/rules/testing.mdc +14 -65
- package/src/gdskills/bundled/stacks/rust/rules/coding-style.mdc +39 -65
- package/src/gdskills/bundled/stacks/rust/rules/patterns.mdc +33 -60
- package/src/gdskills/bundled/stacks/rust/rules/security.mdc +35 -57
- package/src/gdskills/bundled/stacks/rust/rules/testing.mdc +29 -52
- package/src/gdskills/bundled/stacks/sql-db/rules/coding-style.mdc +12 -48
- package/src/gdskills/bundled/stacks/sql-db/rules/patterns.mdc +22 -113
- package/src/gdskills/bundled/stacks/sql-db/rules/security.mdc +11 -56
- package/src/gdskills/bundled/stacks/sql-db/rules/testing.mdc +14 -59
- package/src/gdskills/bundled/stacks/swift-ios/rules/coding-style.mdc +29 -65
- package/src/gdskills/bundled/stacks/swift-ios/rules/patterns.mdc +41 -88
- package/src/gdskills/bundled/stacks/swift-ios/rules/security.mdc +28 -53
- package/src/gdskills/bundled/stacks/swift-ios/rules/testing.mdc +32 -65
- package/src/gdskills/bundled/stacks/vue/rules/coding-style.mdc +17 -52
- package/src/gdskills/bundled/stacks/vue/rules/patterns.mdc +17 -63
- package/src/gdskills/bundled/stacks/vue/rules/security.mdc +11 -41
- package/src/gdskills/bundled/stacks/vue/rules/testing.mdc +16 -48
|
@@ -7,86 +7,50 @@ metadata:
|
|
|
7
7
|
|
|
8
8
|
# Swift/iOS coding style
|
|
9
9
|
|
|
10
|
-
Narrows `core-common-rules`'
|
|
11
|
-
(6.x) and SwiftUI idiom. Applies only to `*.swift` files — everything not
|
|
12
|
-
Swift-specific still comes from the common rules this file `extends`.
|
|
10
|
+
Narrows `core-common-rules`' style rules to the Swift API Design Guidelines (Swift 6.x) and SwiftUI idiom.
|
|
13
11
|
|
|
14
12
|
## Naming and structure
|
|
15
13
|
|
|
16
|
-
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
role noun (`DataSource`, `Delegate`); do not suffix a protocol with
|
|
21
|
-
`Protocol`.
|
|
22
|
-
- An identifier's name shrinks with its scope: a tight closure parameter
|
|
23
|
-
can be `$0`/a one-letter name, a public API member gets a full
|
|
24
|
-
descriptive name.
|
|
25
|
-
- File name matches the primary type it declares (`OrderService.swift`
|
|
26
|
-
declares `OrderService`); one primary type per file for anything
|
|
27
|
-
public.
|
|
14
|
+
- No `Protocol` suffix on a protocol name; name it as a capability (`Fetchable`)
|
|
15
|
+
or role noun (`DataSource`).
|
|
16
|
+
- File name matches the primary type it declares; one primary type per file for
|
|
17
|
+
anything public.
|
|
28
18
|
|
|
29
19
|
## Value types vs reference types
|
|
30
20
|
|
|
31
|
-
- Default to `struct` (and `enum` for closed sets
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
-
|
|
35
|
-
|
|
36
|
-
(`===`), or Objective-C interop. Justify a `class` model type in review
|
|
37
|
-
rather than defaulting to it out of habit from other languages.
|
|
38
|
-
- A `class` used as SwiftUI-observed state is marked `@Observable` (see
|
|
39
|
-
`patterns.mdc`) and, when its mutable state is touched from view code,
|
|
40
|
-
isolated to `@MainActor`.
|
|
21
|
+
- Default to `struct` (and `enum` for closed sets) for model and state types.
|
|
22
|
+
- `class` only for deliberate reference semantics: shared mutable state across
|
|
23
|
+
owners, identity (`===`), or Objective-C interop; justify a `class` model type in review.
|
|
24
|
+
- A `class` used as SwiftUI-observed state is `@Observable` (see `patterns.mdc`)
|
|
25
|
+
and `@MainActor` when view code touches its mutable state.
|
|
41
26
|
|
|
42
27
|
## Guard for early exit
|
|
43
28
|
|
|
44
|
-
- Use `guard
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
- Prefer a single `guard` with multiple comma-separated conditions over a
|
|
48
|
-
pyramid of nested `if let`s when several optionals must all be present
|
|
49
|
-
before the function can proceed.
|
|
29
|
+
- Use `guard` with an early `return`/`continue`/`throw` to keep the happy path
|
|
30
|
+
unindented, not an `if let` wrapping the function body.
|
|
31
|
+
- One `guard` with comma-separated conditions over a pyramid of nested `if let`.
|
|
50
32
|
|
|
51
33
|
## Optionals
|
|
52
34
|
|
|
53
|
-
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
- Prefer `guard let`/`if let`, nil-coalescing (`??`) with a real default,
|
|
60
|
-
or `try`/`try?` with explicit handling. Use `#require(...)` (Swift
|
|
61
|
-
Testing) or `XCTUnwrap` in tests instead of `!` when a test needs to
|
|
62
|
-
unwrap and fail with a clear message if the value is missing.
|
|
63
|
-
- Chain optional access with `?.`/optional chaining rather than
|
|
64
|
-
force-unwrapping an intermediate step in a chain.
|
|
35
|
+
- `!` and `try!` only for a value whose absence is a programmer error that
|
|
36
|
+
should crash in development (a storyboard `IBOutlet`, a compile-time-guaranteed
|
|
37
|
+
literal); never for network responses, decoded JSON or user input.
|
|
38
|
+
- Prefer `guard let`/`if let`, `??` with a real default, or `try`/`try?` with
|
|
39
|
+
explicit handling; in tests use `#require(...)` or `XCTUnwrap` instead of `!`.
|
|
40
|
+
- Use `?.` chaining, not a force-unwrapped intermediate step.
|
|
65
41
|
|
|
66
42
|
## @Observable vs legacy ObservableObject
|
|
67
43
|
|
|
68
|
-
- For
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
- Mark an `@Observable` class `@MainActor` unless the project has set a
|
|
75
|
-
module-wide default actor isolation to `MainActor` — this keeps its
|
|
76
|
-
mutable state confined to the main actor by construction (see
|
|
77
|
-
`patterns.mdc` for the concurrency implications).
|
|
78
|
-
- Only reach for `ObservableObject`/`@Published`/`@StateObject`/
|
|
79
|
-
`@ObservedObject` when the project's minimum deployment target
|
|
80
|
-
predates iOS 17, or an existing codebase has not yet migrated; do not
|
|
81
|
-
introduce the legacy pattern in new code on a project that already
|
|
82
|
-
targets iOS 17+.
|
|
44
|
+
- For iOS 17+ targets, use `@Observable`, not `ObservableObject`/`@Published`.
|
|
45
|
+
- Mark an `@Observable` class `@MainActor` unless the project sets a module-wide
|
|
46
|
+
default actor isolation of `MainActor`.
|
|
47
|
+
- Use `ObservableObject`/`@Published`/`@StateObject`/`@ObservedObject` only when
|
|
48
|
+
the minimum deployment target predates iOS 17 or the codebase has not migrated;
|
|
49
|
+
never introduce it in new code on an iOS 17+ project.
|
|
83
50
|
|
|
84
51
|
## Formatting and linting
|
|
85
52
|
|
|
86
|
-
- Format with the project's configured formatter (`swift-format` or
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
blanket `// swiftlint:disable` covering more than the one line it
|
|
91
|
-
actually applies to, and never disable a rule repository-wide to clear
|
|
92
|
-
one finding.
|
|
53
|
+
- Format with the project's configured formatter (`swift-format` or `swiftformat`);
|
|
54
|
+
do not hand-format around it.
|
|
55
|
+
- Fix a SwiftLint finding at its root cause; no `// swiftlint:disable` covering
|
|
56
|
+
more than the one line, and no repository-wide rule disable to clear one finding.
|
|
@@ -7,106 +7,59 @@ metadata:
|
|
|
7
7
|
|
|
8
8
|
# Swift/iOS patterns
|
|
9
9
|
|
|
10
|
-
Narrows `core-common-rules`'
|
|
11
|
-
Swift concurrency and SwiftUI state ownership. Applies only to `*.swift`
|
|
12
|
-
files.
|
|
10
|
+
Narrows `core-common-rules`' design guidance to Swift concurrency (Swift 6 data-race safety) and SwiftUI state ownership.
|
|
13
11
|
|
|
14
12
|
## Swift concurrency: async/await and structured concurrency
|
|
15
13
|
|
|
16
|
-
- Prefer `async`/`await` over completion
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
- SwiftUI's `.task { }` modifier closure is already async — it is the
|
|
29
|
-
boundary, not a place to wrap another `Task {}` inside it. Reach for a
|
|
30
|
-
bare `Task {}` only at a genuine synchronous-to-async boundary with no
|
|
31
|
-
async closure already available (a button action's `Void`-returning
|
|
32
|
-
handler, a delegate callback); give it an explicit reason it does not
|
|
33
|
-
need to be joined. Prefer `.task { }` directly on a SwiftUI view over a
|
|
34
|
-
manually created `Task` when the work should be tied to the view's
|
|
35
|
-
lifetime (it is cancelled automatically when the view disappears).
|
|
36
|
-
- Respect cancellation in long-running async work: check
|
|
37
|
-
`Task.isCancelled`/call `try Task.checkCancellation()` in a loop, so a
|
|
38
|
-
cancelled parent actually stops the child's work instead of running to
|
|
39
|
-
completion regardless.
|
|
14
|
+
- Prefer `async`/`await` over completion handlers for new asynchronous code.
|
|
15
|
+
- Use `async let` (small fixed number of tasks) or `TaskGroup`/`withThrowingTaskGroup`
|
|
16
|
+
(dynamic set) for concurrent child work, not a bare unstructured `Task {}`.
|
|
17
|
+
`Task.detached {}` is a distinct, rarely needed form; do not use the two names
|
|
18
|
+
interchangeably.
|
|
19
|
+
- SwiftUI's `.task { }` closure is already async: do not wrap another `Task {}`
|
|
20
|
+
in it. A bare `Task {}` only at a synchronous-to-async boundary with no async
|
|
21
|
+
closure available (a `Void` button action, a delegate callback), with an
|
|
22
|
+
explicit reason it need not be joined. Prefer `.task { }` when the work is
|
|
23
|
+
tied to the view's lifetime.
|
|
24
|
+
- Long-running async work checks `Task.isCancelled` or calls
|
|
25
|
+
`try Task.checkCancellation()` in a loop.
|
|
40
26
|
|
|
41
27
|
## Actors and @MainActor
|
|
42
28
|
|
|
43
|
-
- Use `actor` to protect mutable state
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
SEPARATE type: mark any standalone type whose state SwiftUI reads or
|
|
52
|
-
mutates `@MainActor` explicitly — view models, `@Observable` stores, or
|
|
53
|
-
any other type outside the `View` struct itself that a `body` touches.
|
|
54
|
-
Isolate at the type level (`@MainActor final class ...`) rather than
|
|
55
|
-
sprinkling `@MainActor` on individual methods, unless only some of the
|
|
56
|
-
type's methods genuinely need main-actor isolation.
|
|
57
|
-
- Cross an actor boundary explicitly with `await`; do not reach for
|
|
58
|
-
`@unchecked Sendable` or `nonisolated(unsafe)` to make a boundary
|
|
59
|
-
error disappear — either the type's state genuinely needs no
|
|
60
|
-
isolation (make that case explicitly, with a comment), or it needs a
|
|
61
|
-
real actor/lock, not a suppression.
|
|
29
|
+
- Use `actor` to protect mutable state touched by multiple tasks.
|
|
30
|
+
- Since the iOS 18 SDK, `View` is `@MainActor`-isolated, which does not extend to
|
|
31
|
+
a separate type: mark any standalone type whose state SwiftUI reads or mutates
|
|
32
|
+
(view models, `@Observable` stores) `@MainActor` explicitly, at the type level
|
|
33
|
+
(`@MainActor final class ...`), not per method, unless only some methods need it.
|
|
34
|
+
- Cross an actor boundary with `await`; no `@unchecked Sendable` or
|
|
35
|
+
`nonisolated(unsafe)` to make a boundary error disappear. Either the state needs
|
|
36
|
+
no isolation (say so in a comment) or it needs a real actor/lock.
|
|
62
37
|
|
|
63
38
|
## Sendable conformance
|
|
64
39
|
|
|
65
|
-
- A value crossing a concurrency boundary (
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
-
|
|
71
|
-
|
|
72
|
-
documenting why its mutable state cannot race — that trades a
|
|
73
|
-
compile-time guarantee for an unchecked promise, which is exactly the
|
|
74
|
-
class of bug Swift 6's data-race safety exists to catch.
|
|
75
|
-
- Under the Swift 6 language mode, treat a "Sendable" or "actor
|
|
76
|
-
isolation" compiler error as a real potential data race to fix at the
|
|
77
|
-
root (add an actor, make the type immutable, or copy the value before
|
|
78
|
-
crossing), not friction to suppress.
|
|
40
|
+
- A value crossing a concurrency boundary (into a `Task`, an actor method, a
|
|
41
|
+
`TaskGroup` child) must be `Sendable`; a `final class` with only immutable
|
|
42
|
+
(`let`) stored properties declares conformance explicitly.
|
|
43
|
+
- No `@unchecked Sendable` on a class to silence a diagnostic without auditing
|
|
44
|
+
and documenting why its mutable state cannot race.
|
|
45
|
+
- Under Swift 6 language mode, fix a "Sendable" or "actor isolation" error at
|
|
46
|
+
the root (add an actor, make the type immutable, copy before crossing).
|
|
79
47
|
|
|
80
48
|
## SwiftUI state ownership
|
|
81
49
|
|
|
82
|
-
- `@State` owns a value the view itself creates
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
propagate changes from.
|
|
90
|
-
- `@Environment` is for values that are ambient to a whole subtree
|
|
91
|
-
(theme, a shared service, a feature flag) rather than threaded
|
|
92
|
-
explicitly through every initializer; do not reach for it as a
|
|
93
|
-
shortcut to avoid passing an explicit dependency that only one or two
|
|
94
|
-
views actually need.
|
|
95
|
-
- A view that receives an `@Observable` model from a parent and needs to
|
|
96
|
-
pass a binding to one of its properties down further uses `@Bindable`,
|
|
97
|
-
not a manually reconstructed `Binding(get:set:)`.
|
|
50
|
+
- `@State` owns a value the view itself creates: a value type, or (iOS 17+) an
|
|
51
|
+
`@Observable` reference type (`@State private var model = Model()`, not `@StateObject`).
|
|
52
|
+
- `@Binding` for a child that reads and mutates a value it does not own.
|
|
53
|
+
- `@Environment` for values ambient to a subtree (theme, shared service, feature
|
|
54
|
+
flag); not a shortcut around passing a dependency only one or two views need.
|
|
55
|
+
- A view that receives an `@Observable` model and passes a binding to one of its
|
|
56
|
+
properties uses `@Bindable`, not a hand-built `Binding(get:set:)`.
|
|
98
57
|
|
|
99
58
|
## Anti-patterns to flag
|
|
100
59
|
|
|
101
|
-
- A
|
|
102
|
-
stored callback)
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
-
|
|
107
|
-
displays it, when a parent further up actually owns and mutates it —
|
|
108
|
-
that duplicates state instead of using `@Binding`/`@Observable`
|
|
109
|
-
references, and the two copies drift.
|
|
110
|
-
- A massive view or view-model type that owns navigation, networking,
|
|
111
|
-
and persistence together — split by responsibility the same way a
|
|
112
|
-
"god package"/"god object" is flagged in any other stack.
|
|
60
|
+
- A closure that outlives its creating call (completion handler, Combine `sink`,
|
|
61
|
+
stored callback) capturing `self` strongly: use `[weak self]`, or
|
|
62
|
+
`[unowned self]` only when `self`'s lifetime provably exceeds the closure's.
|
|
63
|
+
- Lifting a value into `@State`/`@StateObject` at a view that only displays it
|
|
64
|
+
when a parent owns and mutates it; use `@Binding`/`@Observable` references.
|
|
65
|
+
- A view or view-model type that owns navigation, networking and persistence together.
|
|
@@ -7,72 +7,47 @@ metadata:
|
|
|
7
7
|
|
|
8
8
|
# Swift/iOS security
|
|
9
9
|
|
|
10
|
-
Narrows `core-common-rules`'
|
|
11
|
-
iOS/Apple-platform-specific risks and the safe framework API to use
|
|
12
|
-
instead. Applies only to `*.swift` files.
|
|
10
|
+
Narrows `core-common-rules`' security rules to iOS/Apple-platform risks (OWASP Mobile Top 10) and the safe framework API for each.
|
|
13
11
|
|
|
14
12
|
## Secrets and credential storage
|
|
15
13
|
|
|
16
|
-
- Store credentials, tokens
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
fetched at runtime) that is excluded from source control, and treat a
|
|
25
|
-
literal key found in a diff as a finding, not a style nit.
|
|
26
|
-
- Set an appropriate Keychain accessibility level
|
|
27
|
-
(`kSecAttrAccessibleWhenUnlockedThisDeviceOnly` or stricter) for
|
|
28
|
-
anything sensitive — the default accessibility can survive a device
|
|
29
|
-
backup/restore onto different hardware, which is usually not the
|
|
30
|
-
intended threat model for a session token.
|
|
14
|
+
- Store credentials, tokens and refresh tokens in the Keychain (`Security`
|
|
15
|
+
framework or a thin wrapper), never in `UserDefaults` or a plain file.
|
|
16
|
+
- Never hardcode an API key, client secret or signing credential as a string
|
|
17
|
+
literal. Load it from build-time configuration (an `.xcconfig` value injected
|
|
18
|
+
into `Info.plist`, or a secrets manager fetched at runtime) excluded from
|
|
19
|
+
source control; a literal key in a diff is a finding, not a style nit.
|
|
20
|
+
- Set Keychain accessibility to `kSecAttrAccessibleWhenUnlockedThisDeviceOnly` or
|
|
21
|
+
stricter for anything sensitive.
|
|
31
22
|
|
|
32
23
|
## Network security (ATS and transport)
|
|
33
24
|
|
|
34
|
-
- Leave App Transport Security
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
- Validate TLS the platform's normal way (`URLSession`'s default trust
|
|
41
|
-
evaluation); do not implement a `URLSessionDelegate` that accepts any
|
|
42
|
-
server certificate (`.performDefaultHandling` bypassed with
|
|
43
|
-
unconditional trust) outside of a short-lived local/test
|
|
44
|
-
configuration, and never ship that in production.
|
|
25
|
+
- Leave App Transport Security at its default (HTTPS-only, TLS 1.2+); no
|
|
26
|
+
`NSAllowsArbitraryLoads` or blanket `NSExceptionDomains` bypass in `Info.plist`.
|
|
27
|
+
Scope any exception to the exact domain and minimum relaxation, with a comment.
|
|
28
|
+
- Use `URLSession`'s default trust evaluation; no `URLSessionDelegate` that
|
|
29
|
+
accepts any server certificate outside a short-lived local/test configuration,
|
|
30
|
+
and never shipped.
|
|
45
31
|
|
|
46
32
|
## Biometric authentication
|
|
47
33
|
|
|
48
|
-
-
|
|
49
|
-
|
|
50
|
-
a successful `evaluatePolicy` unlocks a locally-held secret (a
|
|
51
|
-
Keychain item, a locally cached credential); it does not substitute
|
|
52
|
-
for a real authentication token when talking to a backend.
|
|
34
|
+
- A `LAContext` biometric result is a local presence gate that unlocks a
|
|
35
|
+
locally-held secret, not proof of identity to a backend.
|
|
53
36
|
- Check the specific `LAError` case on failure (`.userCancel`,
|
|
54
|
-
`.biometryNotAvailable`, `.biometryLockout`, ...) and present a
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
later by unrelated code paths — re-evaluate at the point access is
|
|
59
|
-
actually needed, scoped to what that specific action requires.
|
|
37
|
+
`.biometryNotAvailable`, `.biometryLockout`, ...) and present a fallback
|
|
38
|
+
(passcode, credential re-entry); do not treat all failures alike or retry silently.
|
|
39
|
+
- Do not cache "biometric succeeded" as a long-lived boolean; re-evaluate where
|
|
40
|
+
access is needed.
|
|
60
41
|
|
|
61
42
|
## Input handling and injection-adjacent risks
|
|
62
43
|
|
|
63
|
-
- Parameterize any `NSPredicate`/Core Data query built from
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
- Validate/sanitize any URL or deep link the app opens
|
|
68
|
-
(`UIApplication.open`, a Universal Link handler) before acting on it —
|
|
69
|
-
a deep link is untrusted input from outside the process, not a value
|
|
70
|
-
to trust and route on directly.
|
|
44
|
+
- Parameterize any `NSPredicate`/Core Data query built from user-influenced input
|
|
45
|
+
rather than interpolating into the predicate format string.
|
|
46
|
+
- Validate any URL or deep link the app opens (`UIApplication.open`, a Universal
|
|
47
|
+
Link handler) before acting on it.
|
|
71
48
|
|
|
72
49
|
## Logging
|
|
73
50
|
|
|
74
|
-
- Never log a token, password
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
privacy: .private)`) for anything sensitive, or omit it from the log
|
|
78
|
-
entirely.
|
|
51
|
+
- Never log a token, password or full PII payload to persistent device logs
|
|
52
|
+
(`print`, unredacted `os_log`/`Logger` interpolation); use
|
|
53
|
+
`privacy: .private` or omit it.
|
|
@@ -7,84 +7,51 @@ metadata:
|
|
|
7
7
|
|
|
8
8
|
# Swift/iOS testing
|
|
9
9
|
|
|
10
|
-
Narrows `core-common-rules`'
|
|
11
|
-
Testing (the current default for new test code) and legacy XCTest, where
|
|
12
|
-
the project has not yet migrated. Applies only to `*.swift` files.
|
|
10
|
+
Narrows `core-common-rules`' testing rules to Swift Testing (default for new test code) and legacy XCTest where the project has not migrated.
|
|
13
11
|
|
|
14
12
|
## Swift Testing vs XCTest
|
|
15
13
|
|
|
16
|
-
- For new
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
the same target. Match whichever the project's existing test target
|
|
26
|
-
already uses for a given kind of test; introduce Swift Testing for new
|
|
27
|
-
unit-test coverage rather than mixing conventions within one file.
|
|
28
|
-
- A Swift Testing function is `@Test func name() async throws { ... }`
|
|
29
|
-
(not `test`-prefixed, no `XCTestCase` subclass needed); assert with
|
|
30
|
-
`#expect(condition)` for a check that should record a failure and
|
|
31
|
-
continue, or `try #require(optional)` for one that must stop the test
|
|
32
|
-
immediately if it fails (the Swift Testing equivalent of
|
|
33
|
-
`XCTUnwrap`/`XCTAssert...` followed by an early return).
|
|
14
|
+
- For new tests on a toolchain that supports it, prefer Swift Testing
|
|
15
|
+
(`import Testing`, `@Test`, `#expect`/`#require`) over XCTest.
|
|
16
|
+
- `XCUITest` and performance tests (`XCTMetric`/`measure`) stay on XCTest; an
|
|
17
|
+
existing XCTest suite is not rewritten wholesale, and the two coexist in one
|
|
18
|
+
target. Match the target's existing framework per kind of test; add Swift
|
|
19
|
+
Testing for new unit tests, without mixing conventions within one file.
|
|
20
|
+
- A Swift Testing function is `@Test func name() async throws { ... }`: no
|
|
21
|
+
`test` prefix, no `XCTestCase` subclass. `#expect(condition)` records a failure
|
|
22
|
+
and continues; `try #require(optional)` stops the test.
|
|
34
23
|
|
|
35
24
|
## Structure and naming
|
|
36
25
|
|
|
37
|
-
- One `@Test` (or
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
differ only by input.
|
|
44
|
-
- Group related tests with a `struct`/`enum` namespace and Swift
|
|
45
|
-
Testing's `@Suite`, or an `XCTestCase` subclass for legacy code,
|
|
46
|
-
matching whatever the target already does.
|
|
26
|
+
- One `@Test` (or XCTest method) per behavior, with a descriptive name
|
|
27
|
+
(`@Test("returns nil for an empty cart")` or `test_returnsNil_whenCartIsEmpty`).
|
|
28
|
+
- Use `arguments:` parameterization for the same assertion over several inputs,
|
|
29
|
+
not a hand-rolled loop or copy-pasted tests.
|
|
30
|
+
- Group with a `struct`/`enum` namespace and `@Suite`, or an `XCTestCase`
|
|
31
|
+
subclass for legacy code, matching the target.
|
|
47
32
|
|
|
48
33
|
## Mocking at the protocol boundary
|
|
49
34
|
|
|
50
|
-
- Mock external dependencies
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
-
|
|
56
|
-
|
|
57
|
-
inject a real conforming type in production and a test double
|
|
58
|
-
conforming to the same protocol in tests — the type under test never
|
|
59
|
-
needs to know it is under test.
|
|
60
|
-
- Do not mock one layer too deep (stubbing a private helper method, or
|
|
61
|
-
a concrete `URLSession` call inside a class instead of the protocol
|
|
62
|
-
that wraps it) — that couples the test to an implementation detail and
|
|
63
|
-
breaks on a harmless refactor instead of only on an actual behavior
|
|
64
|
-
change.
|
|
35
|
+
- Mock external dependencies (network clients, persistence, platform services) at
|
|
36
|
+
a protocol boundary production code already depends on, never the type under
|
|
37
|
+
test's internal collaborators or private state.
|
|
38
|
+
- Define or reuse a narrow protocol (`protocol OrderClient { func fetchOrder(id: String) async throws -> Order }`),
|
|
39
|
+
inject the real type in production and a test double in tests.
|
|
40
|
+
- Do not mock one layer too deep (a private helper, or a concrete `URLSession`
|
|
41
|
+
call instead of the protocol that wraps it).
|
|
65
42
|
|
|
66
43
|
## Async and concurrency in tests
|
|
67
44
|
|
|
68
|
-
- Mark
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
- Never synchronize with a fixed delay (`Thread.sleep`/`Task.sleep` used
|
|
74
|
-
as a guess at "enough time") to wait for concurrent work to finish —
|
|
75
|
-
`await` the async call, join a `TaskGroup`, or await an
|
|
76
|
-
`XCTestExpectation` with a real fulfillment signal instead of a timed
|
|
77
|
-
guess.
|
|
45
|
+
- Mark the test `async` and `await` the call directly; no `XCTestExpectation` or
|
|
46
|
+
semaphore to bridge an `async` API unless the minimum toolchain predates async tests.
|
|
47
|
+
- Never synchronize with a fixed delay (`Thread.sleep`/`Task.sleep` as a guess);
|
|
48
|
+
`await` the call, join a `TaskGroup`, or await an `XCTestExpectation` with a
|
|
49
|
+
real fulfillment signal.
|
|
78
50
|
- Annotate a test `@MainActor` when it exercises `@MainActor`-isolated
|
|
79
|
-
view-model/state code
|
|
80
|
-
subject requires.
|
|
51
|
+
view-model/state code.
|
|
81
52
|
|
|
82
53
|
## Determinism
|
|
83
54
|
|
|
84
|
-
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
provider instead of calling `Date()` directly inside the code under
|
|
88
|
-
test.
|
|
89
|
-
- A bug fix gets a regression test that fails before the fix and passes
|
|
90
|
-
after; new behavior gets new test coverage in the same change.
|
|
55
|
+
- No dependence on real network access, the real Keychain or wall-clock time;
|
|
56
|
+
inject a fake at the protocol boundary and a clock/date provider instead of
|
|
57
|
+
calling `Date()` in the code under test.
|
|
@@ -7,67 +7,32 @@ metadata:
|
|
|
7
7
|
|
|
8
8
|
# Vue coding style
|
|
9
9
|
|
|
10
|
-
Narrows `core-common-rules`'
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
rule, which this file `extends` transitively through the pack's `extends`.
|
|
10
|
+
Narrows `core-common-rules`' style rules to Vue Single File Component
|
|
11
|
+
conventions. Applies only to `*.vue`; the `<script>` block's TypeScript style
|
|
12
|
+
comes from `ts-js-node`'s coding-style rule.
|
|
14
13
|
|
|
15
14
|
## Script setup and typing
|
|
16
15
|
|
|
17
|
-
- Use `<script setup lang="ts">` for new components;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
-
|
|
21
|
-
|
|
22
|
-
checked against actual usage instead of a separate runtime shape. Use
|
|
23
|
-
`withDefaults(defineProps<Props>(), { ... })` for default values rather
|
|
24
|
-
than mutating the returned props object.
|
|
25
|
-
- Declare emits with the type-only form: `defineEmits<{ change: [id: number]
|
|
26
|
-
}>()` (named-tuple syntax) rather than the untyped string-array form
|
|
27
|
-
(`defineEmits(['change'])`).
|
|
28
|
-
- On Vue 3.5+ projects, destructuring `defineProps()` directly
|
|
29
|
-
(`const { title } = defineProps<Props>()`) is reactive and preferred over
|
|
30
|
-
a separate `props.title` reference; on pre-3.5 projects, keep the props
|
|
31
|
-
object intact (`props.title`, or `toRefs(props)`) since a destructured
|
|
32
|
-
prop is a frozen snapshot, not a live binding.
|
|
33
|
-
- Type `ref<T>()` explicitly when the initial value's inferred type is
|
|
34
|
-
narrower than the eventual type (`ref<string | null>(null)`, not a bare
|
|
35
|
-
`ref(null)` that infers `Ref<null>`).
|
|
16
|
+
- Use `<script setup lang="ts">` for new components; no Options API or bare `<script>` in new files unless the project has no `<script setup>` components yet.
|
|
17
|
+
- Declare props type-only, `defineProps<{ ... }>()`, not the runtime-object form; use `withDefaults(defineProps<Props>(), { ... })` for defaults, not mutation of the props object.
|
|
18
|
+
- Declare emits type-only with named-tuple syntax, `defineEmits<{ change: [id: number] }>()`, not the string-array form.
|
|
19
|
+
- Vue 3.5+: destructure `defineProps()` directly (`const { title } = defineProps<Props>()`). Pre-3.5: keep the props object intact (`props.title`, or `toRefs(props)`).
|
|
20
|
+
- Type `ref<T>()` explicitly when the initial value infers narrower than the eventual type (`ref<string | null>(null)`).
|
|
36
21
|
|
|
37
22
|
## Naming and structure
|
|
38
23
|
|
|
39
|
-
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
-
|
|
43
|
-
sub-markup repeated more than once becomes its own child component, not a
|
|
44
|
-
`v-for` over inline duplicated markup.
|
|
45
|
-
- Order SFC blocks `<script setup>`, `<template>`, `<style>` (or the
|
|
46
|
-
project's existing established order) consistently across the codebase;
|
|
47
|
-
do not invent a third ordering in new files.
|
|
48
|
-
- Multi-word component names (`UserCard`, not `Card`) to avoid clashing
|
|
49
|
-
with current and future HTML elements, matching `eslint-plugin-vue`'s
|
|
50
|
-
`multi-word-component-names` rule.
|
|
24
|
+
- `PascalCase` component file and `name` (`OrderSummary.vue`); composables `camelCase` prefixed `use` (`useOrderTotals.ts`).
|
|
25
|
+
- One component per `.vue` file; markup repeated within a template becomes a child component, not a `v-for` over inline duplicates.
|
|
26
|
+
- Order SFC blocks `<script setup>`, `<template>`, `<style>` (or the project's established order); no third ordering.
|
|
27
|
+
- Multi-word component names (`UserCard`, not `Card`), per `eslint-plugin-vue`'s `multi-word-component-names`.
|
|
51
28
|
|
|
52
29
|
## Formatting and imports
|
|
53
30
|
|
|
54
|
-
- Format with the project's configured formatter
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
- Run the project's configured `eslint` (with `eslint-plugin-vue`) instead
|
|
58
|
-
of hand-checking template directive order, unused template refs, or
|
|
59
|
-
v-for/v-if precedence; fix what it flags rather than adding a blanket
|
|
60
|
-
disable comment.
|
|
61
|
-
- Prefer auto-imported composables/components only when the project has
|
|
62
|
-
`unplugin-auto-import`/`unplugin-vue-components` (or Nuxt) configured;
|
|
63
|
-
otherwise import explicitly -- do not assume auto-import is active.
|
|
31
|
+
- Format with the project's configured formatter; do not hand-format around it.
|
|
32
|
+
- Run the project's `eslint` with `eslint-plugin-vue`; fix what it flags, no blanket disable comment.
|
|
33
|
+
- Use auto-imported composables/components only when `unplugin-auto-import`/`unplugin-vue-components` (or Nuxt) is configured; otherwise import explicitly.
|
|
64
34
|
|
|
65
35
|
## Errors
|
|
66
36
|
|
|
67
|
-
- Surface a composable or store action's failure to the caller (thrown
|
|
68
|
-
|
|
69
|
-
swallowing it in a bare `catch` with no rethrow and no user-visible
|
|
70
|
-
state change.
|
|
71
|
-
- Use Vue's `onErrorCaptured` (component-tree scope) or a top-level
|
|
72
|
-
`app.config.errorHandler` (app-wide scope) for error boundaries, not an
|
|
73
|
-
ad hoc `try/catch` wrapped around every template-triggered call site.
|
|
37
|
+
- Surface a composable or store action's failure to the caller (thrown error or a returned error/result shape), not a bare `catch` with no rethrow and no user-visible state change.
|
|
38
|
+
- Use `onErrorCaptured` (component-tree scope) or `app.config.errorHandler` (app-wide) for error boundaries, not ad hoc `try/catch` around every template-triggered call.
|