@kamaal111/kamaal-quality-config 0.6.0 → 0.8.0

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.
Files changed (27) hide show
  1. package/README.md +74 -1
  2. package/dist/cli.d.ts +3 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +72 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/index.d.ts +75 -1
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +3 -2
  9. package/dist/index.js.map +1 -1
  10. package/dist/swift-format.d.ts +75 -0
  11. package/dist/swift-format.d.ts.map +1 -0
  12. package/dist/swift-format.js +75 -0
  13. package/dist/swift-format.js.map +1 -0
  14. package/package.json +20 -5
  15. package/swift/SwiftLintChecks/Package.resolved +15 -0
  16. package/swift/SwiftLintChecks/Package.swift +22 -0
  17. package/swift/SwiftLintChecks/Sources/SwiftLintChecks/LintViolation.swift +23 -0
  18. package/swift/SwiftLintChecks/Sources/SwiftLintChecks/MultilineChainSpacingVisitor.swift +35 -0
  19. package/swift/SwiftLintChecks/Sources/SwiftLintChecks/SwiftLint.swift +64 -0
  20. package/swift/SwiftLintChecks/Sources/SwiftLintChecks/SwiftLintChecks.swift +12 -0
  21. package/swift/SwiftLintChecks/Sources/SwiftLintChecks/SwiftLintCommand.swift +47 -0
  22. package/swift/SwiftLintChecks/Sources/SwiftLintChecks/ViewBodyDeclarationVisitor.swift +36 -0
  23. package/swift/SwiftLintChecks/Tests/SwiftLintChecksTests/MemberSpacingTests.swift +171 -0
  24. package/swift/SwiftLintChecks/Tests/SwiftLintChecksTests/MultilineChainSpacingTests.swift +68 -0
  25. package/swift/SwiftLintChecks/Tests/SwiftLintChecksTests/SwiftLintCommandTests.swift +143 -0
  26. package/swift/SwiftLintChecks/Tests/SwiftLintChecksTests/ViewBodyDeclarationTests.swift +129 -0
  27. package/swift-format.json +75 -0
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @kamaal111/kamaal-quality-config
2
2
 
3
- Kamaal Farah's shared [oxlint](https://oxc.rs) quality configs.
3
+ Kamaal Farah's shared quality configs for [oxlint and oxfmt](https://oxc.rs), Swift format, and custom Swift lint checks.
4
4
 
5
5
  Currently enables every rule from [`@kamaal111/oxlint-plugin-anti-slop`](https://github.com/kamaal111/anti-slop),
6
6
  Kamaal's fork of [`dmmulroy/anti-slop`](https://github.com/dmmulroy/anti-slop), plus a curated set of
@@ -28,6 +28,8 @@ More rule sources will be folded in over time.
28
28
  - [Usage](#usage)
29
29
  - [oxlint](#oxlint)
30
30
  - [oxfmt](#oxfmt)
31
+ - [Swift format](#swift-format)
32
+ - [Swift lint](#swift-lint)
31
33
  - [Development](#development)
32
34
 
33
35
  ## Install
@@ -113,6 +115,65 @@ const { default: options } = await import(pathToFileURL(path.join(repoRoot, 'oxf
113
115
  const result = await format(filepath, sourceText, options);
114
116
  ```
115
117
 
118
+ ### Swift format
119
+
120
+ The package ships a shared configuration for Swift's built-in formatter. Install the package using
121
+ pnpm as above, and install a Swift toolchain separately. From your project's root, run:
122
+
123
+ ```sh
124
+ swift format lint --strict -r . \
125
+ --configuration node_modules/@kamaal111/kamaal-quality-config/swift-format.json
126
+ ```
127
+
128
+ To format files in place:
129
+
130
+ ```sh
131
+ swift format format --in-place -r . \
132
+ --configuration node_modules/@kamaal111/kamaal-quality-config/swift-format.json
133
+ ```
134
+
135
+ Paths are relative to your working directory. Swift format does not support `extends`:
136
+ `--configuration` selects this complete configuration and does not merge your project's
137
+ `.swift-format` file. The shared style uses four-space indentation and a 120-character line limit.
138
+
139
+ For programmatic consumption, import the same plain object from
140
+ `@kamaal111/kamaal-quality-config/swift-format` or use `kamaalQuality.swiftFormat` from the root
141
+ namespace. The generated JSON is also exported at the `./swift-format.json` package subpath.
142
+
143
+ ### Swift lint
144
+
145
+ The package provides `kqc swift-lint` for syntax-based Swift checks. Install a Swift 6.4 or newer
146
+ toolchain separately, then run from your project root:
147
+
148
+ ```sh
149
+ pnpm exec kqc swift-lint
150
+ pnpm exec kqc swift-lint Sources Tests
151
+ pnpm exec kqc swift-lint "Source Files/Example.swift"
152
+ ```
153
+
154
+ In package scripts, use `"lint:swift": "kqc swift-lint Sources Tests"`. With the package installed
155
+ globally, invoke `kqc swift-lint` directly.
156
+
157
+ Without paths, the command checks the current directory recursively. Explicit file and directory
158
+ paths are relative to your working directory. Recursive scanning skips hidden paths (including
159
+ `.build`), `node_modules`, symlinks, and non-Swift files. Use `--` before paths starting with a dash.
160
+
161
+ All three checks are enabled:
162
+
163
+ - `member_spacing`: separate methods and initializers from adjacent members with a blank line.
164
+ - `multiline_chain_spacing`: put each chained call on its own line in multiline expressions.
165
+ - `view_body_declarations`: move local `let` and `var` declarations out of SwiftUI
166
+ `var body: some View`, including nested builder closures. Conditional bindings remain allowed.
167
+
168
+ The CLI runs `swift run --package-path` against the bundled `SwiftLintChecks` package and does not
169
+ modify source files. Diagnostics include file, line, column, and rule identifier. Exit codes are
170
+ `0` for clean sources, `1` for violations or unreadable/invalid sources, `2` for usage errors,
171
+ and `127` when Swift is missing. Swift build failures retain their exit status.
172
+
173
+ The first invocation may download SwiftSyntax and compile the checker. SwiftPM caches build
174
+ artifacts in the installed Swift package's `.build` directory, so that directory must be writable.
175
+ Subsequent invocations reuse the build. Run `kqc swift-lint --help` for usage.
176
+
116
177
  ## Development
117
178
 
118
179
  Use the devcontainer with Node.js 26 (as specified in `.nvmrc`) and pnpm 12.14.0.
@@ -129,3 +190,15 @@ Vitest also checks the packed package. To select a consumer runtime, run
129
190
  CI selects the latest Node.js 22 release while building and running Vitest on Node.js 26.
130
191
  The test fixture installs the JS plugins at the consumer project root, where oxlint resolves
131
192
  the plugin specifiers in the shared configuration.
193
+
194
+ The dependency-free example package in `fixtures/swift-format` verifies the installed Swift config.
195
+ CI's Swift consumer job supplies Swift 6.4.1 and runs `pnpm test:swift-format`: it builds the package,
196
+ lints it using the packed npm artifact, rejects two-space indentation, and verifies formatter repair
197
+ and idempotence. To run that command locally, Swift must be available inside the devcontainer.
198
+ The dedicated command fails if Swift is missing; ordinary `pnpm test` skips only the Swift toolchain
199
+ cases while still checking the packed configuration and exports, including on Node.js 22.
200
+
201
+ Run `pnpm test:swift-lint` with Swift 6.4 or newer available inside the devcontainer to run the
202
+ bundled checker regression suites and packed CLI integration tests. CI supplies Swift 6.4.1.
203
+ The dedicated command fails if Swift is missing; ordinary tests still verify CLI dispatch,
204
+ packaging, and consumer compatibility without requiring Swift.
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
package/dist/cli.js ADDED
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env node
2
+ import childProcess from 'node:child_process';
3
+ import os from 'node:os';
4
+ import path from 'node:path';
5
+ import url from 'node:url';
6
+ import util from 'node:util';
7
+ const usage = `Usage: kqc swift-lint [paths...]
8
+
9
+ Check Swift sources recursively (default: current directory).
10
+ Requires Swift 6.4 or newer. Use -- before paths beginning with a dash.
11
+ `;
12
+ function runSwift(paths) {
13
+ const packageDirectory = url.fileURLToPath(new URL('../swift/SwiftLintChecks', import.meta.url));
14
+ const child = childProcess.spawn('swift', ['run', '--package-path', packageDirectory, 'kqc-swift-lint', ...paths.map(target => path.resolve(target))], { stdio: 'inherit' });
15
+ const interrupt = () => {
16
+ child.kill('SIGINT');
17
+ };
18
+ const terminate = () => {
19
+ child.kill('SIGTERM');
20
+ };
21
+ process.on('SIGINT', interrupt);
22
+ process.on('SIGTERM', terminate);
23
+ child.once('error', error => {
24
+ if ('code' in error && error.code === 'ENOENT') {
25
+ console.error('kqc: Swift 6.4 or newer is required; install it and ensure swift is on PATH.');
26
+ process.exitCode = 127;
27
+ }
28
+ else {
29
+ console.error(`kqc: Cannot launch Swift: ${error.message}`);
30
+ process.exitCode = 1;
31
+ }
32
+ });
33
+ child.once('close', (code, signal) => {
34
+ process.off('SIGINT', interrupt);
35
+ process.off('SIGTERM', terminate);
36
+ if (signal) {
37
+ process.kill(process.pid, signal);
38
+ process.exitCode = 128 + os.constants.signals[signal];
39
+ }
40
+ else if (code !== null && code >= 0) {
41
+ process.exitCode = code;
42
+ }
43
+ });
44
+ }
45
+ function parseArguments() {
46
+ try {
47
+ return util.parseArgs({
48
+ options: { help: { type: 'boolean' } },
49
+ allowPositionals: true,
50
+ });
51
+ }
52
+ catch {
53
+ console.error(usage);
54
+ process.exitCode = 2;
55
+ return undefined;
56
+ }
57
+ }
58
+ const parsed = parseArguments();
59
+ if (parsed !== undefined) {
60
+ const [command, ...paths] = parsed.positionals;
61
+ if (parsed.values.help && paths.length === 0 && (command === undefined || command === 'swift-lint')) {
62
+ console.log(usage);
63
+ }
64
+ else if (command !== 'swift-lint' || parsed.values.help) {
65
+ console.error(usage);
66
+ process.exitCode = 2;
67
+ }
68
+ else {
69
+ runSwift(paths.length === 0 ? ['.'] : paths);
70
+ }
71
+ }
72
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,KAAK,GAAG;;;;CAIb,CAAC;AAEF,SAAS,QAAQ,CAAC,KAAwB;IACxC,MAAM,gBAAgB,GAAG,GAAG,CAAC,aAAa,CAAC,IAAI,GAAG,CAAC,0BAA0B,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAEjG,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAC9B,OAAO,EACP,CAAC,KAAK,EAAE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AK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;AACH,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import oxfmt from './oxfmt.ts';
2
2
  import oxlint from './oxlint.ts';
3
- export { oxfmt, oxlint };
3
+ import swiftFormat from './swift-format.ts';
4
+ export { oxfmt, oxlint, swiftFormat };
4
5
  declare const _default: {
5
6
  oxfmt: {
6
7
  readonly printWidth: 120;
@@ -103,6 +104,79 @@ declare const _default: {
103
104
  builtin: true;
104
105
  };
105
106
  };
107
+ swiftFormat: {
108
+ readonly fileScopedDeclarationPrivacy: {
109
+ readonly accessLevel: 'private';
110
+ };
111
+ readonly indentConditionalCompilationBlocks: true;
112
+ readonly indentSwitchCaseLabels: false;
113
+ readonly indentation: {
114
+ readonly spaces: 4;
115
+ };
116
+ readonly lineBreakAroundMultilineExpressionChainComponents: false;
117
+ readonly lineBreakBeforeControlFlowKeywords: false;
118
+ readonly lineBreakBeforeEachArgument: true;
119
+ readonly lineBreakBeforeEachGenericRequirement: false;
120
+ readonly lineBreakBetweenDeclarationAttributes: false;
121
+ readonly lineLength: 120;
122
+ readonly maximumBlankLines: 1;
123
+ readonly multiElementCollectionTrailingCommas: true;
124
+ readonly noAssignmentInExpressions: {
125
+ readonly allowedFunctions: readonly ['XCTAssertNoThrow'];
126
+ };
127
+ readonly prioritizeKeepingFunctionOutputTogether: false;
128
+ readonly reflowMultilineStringLiterals: 'never';
129
+ readonly respectsExistingLineBreaks: true;
130
+ readonly rules: {
131
+ readonly AllPublicDeclarationsHaveDocumentation: false;
132
+ readonly AlwaysUseLiteralForEmptyCollectionInit: false;
133
+ readonly AlwaysUseLowerCamelCase: true;
134
+ readonly AmbiguousTrailingClosureOverload: true;
135
+ readonly AvoidRetroactiveConformances: true;
136
+ readonly BeginDocumentationCommentWithOneLineSummary: false;
137
+ readonly DoNotUseSemicolons: true;
138
+ readonly DontRepeatTypeInStaticProperties: true;
139
+ readonly FileScopedDeclarationPrivacy: true;
140
+ readonly FullyIndirectEnum: true;
141
+ readonly GroupNumericLiterals: true;
142
+ readonly IdentifiersMustBeASCII: true;
143
+ readonly NeverForceUnwrap: true;
144
+ readonly NeverUseForceTry: true;
145
+ readonly NeverUseImplicitlyUnwrappedOptionals: true;
146
+ readonly NoAccessLevelOnExtensionDeclaration: true;
147
+ readonly NoAssignmentInExpressions: true;
148
+ readonly NoBlockComments: true;
149
+ readonly NoCasesWithOnlyFallthrough: true;
150
+ readonly NoEmptyLinesOpeningClosingBraces: false;
151
+ readonly NoEmptyTrailingClosureParentheses: true;
152
+ readonly NoLabelsInCasePatterns: true;
153
+ readonly NoLeadingUnderscores: false;
154
+ readonly NoParensAroundConditions: true;
155
+ readonly NoPlaygroundLiterals: true;
156
+ readonly NoVoidReturnOnFunctionSignature: true;
157
+ readonly OmitExplicitReturns: false;
158
+ readonly OneCasePerLine: true;
159
+ readonly OneVariableDeclarationPerLine: true;
160
+ readonly OnlyOneTrailingClosureArgument: true;
161
+ readonly OrderedImports: true;
162
+ readonly ReplaceForEachWithForLoop: true;
163
+ readonly ReturnVoidInsteadOfEmptyTuple: true;
164
+ readonly TypeNamesShouldBeCapitalized: true;
165
+ readonly UseEarlyExits: false;
166
+ readonly UseExplicitNilCheckInConditions: true;
167
+ readonly UseLetInEveryBoundCaseVariable: true;
168
+ readonly UseShorthandTypeNames: true;
169
+ readonly UseSingleLinePropertyGetter: true;
170
+ readonly UseSynthesizedInitializer: true;
171
+ readonly UseTripleSlashForDocumentationComments: true;
172
+ readonly UseWhereClausesInForLoops: false;
173
+ readonly ValidateDocumentationComments: false;
174
+ };
175
+ readonly spacesAroundRangeFormationOperators: false;
176
+ readonly spacesBeforeEndOfLineComments: 2;
177
+ readonly tabWidth: 8;
178
+ readonly version: 1;
179
+ };
106
180
  };
107
181
  export default _default;
108
182
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import oxfmt from './oxfmt.js';
2
2
  import oxlint from './oxlint.js';
3
- export { oxfmt, oxlint };
4
- export default { oxfmt, oxlint };
3
+ import swiftFormat from './swift-format.js';
4
+ export { oxfmt, oxlint, swiftFormat };
5
+ export default { oxfmt, oxlint, swiftFormat };
5
6
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAEzB,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;AAEtC,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC"}
@@ -0,0 +1,75 @@
1
+ declare const kamaalSwiftFormatConfig: {
2
+ readonly fileScopedDeclarationPrivacy: {
3
+ readonly accessLevel: 'private';
4
+ };
5
+ readonly indentConditionalCompilationBlocks: true;
6
+ readonly indentSwitchCaseLabels: false;
7
+ readonly indentation: {
8
+ readonly spaces: 4;
9
+ };
10
+ readonly lineBreakAroundMultilineExpressionChainComponents: false;
11
+ readonly lineBreakBeforeControlFlowKeywords: false;
12
+ readonly lineBreakBeforeEachArgument: true;
13
+ readonly lineBreakBeforeEachGenericRequirement: false;
14
+ readonly lineBreakBetweenDeclarationAttributes: false;
15
+ readonly lineLength: 120;
16
+ readonly maximumBlankLines: 1;
17
+ readonly multiElementCollectionTrailingCommas: true;
18
+ readonly noAssignmentInExpressions: {
19
+ readonly allowedFunctions: readonly ['XCTAssertNoThrow'];
20
+ };
21
+ readonly prioritizeKeepingFunctionOutputTogether: false;
22
+ readonly reflowMultilineStringLiterals: 'never';
23
+ readonly respectsExistingLineBreaks: true;
24
+ readonly rules: {
25
+ readonly AllPublicDeclarationsHaveDocumentation: false;
26
+ readonly AlwaysUseLiteralForEmptyCollectionInit: false;
27
+ readonly AlwaysUseLowerCamelCase: true;
28
+ readonly AmbiguousTrailingClosureOverload: true;
29
+ readonly AvoidRetroactiveConformances: true;
30
+ readonly BeginDocumentationCommentWithOneLineSummary: false;
31
+ readonly DoNotUseSemicolons: true;
32
+ readonly DontRepeatTypeInStaticProperties: true;
33
+ readonly FileScopedDeclarationPrivacy: true;
34
+ readonly FullyIndirectEnum: true;
35
+ readonly GroupNumericLiterals: true;
36
+ readonly IdentifiersMustBeASCII: true;
37
+ readonly NeverForceUnwrap: true;
38
+ readonly NeverUseForceTry: true;
39
+ readonly NeverUseImplicitlyUnwrappedOptionals: true;
40
+ readonly NoAccessLevelOnExtensionDeclaration: true;
41
+ readonly NoAssignmentInExpressions: true;
42
+ readonly NoBlockComments: true;
43
+ readonly NoCasesWithOnlyFallthrough: true;
44
+ readonly NoEmptyLinesOpeningClosingBraces: false;
45
+ readonly NoEmptyTrailingClosureParentheses: true;
46
+ readonly NoLabelsInCasePatterns: true;
47
+ readonly NoLeadingUnderscores: false;
48
+ readonly NoParensAroundConditions: true;
49
+ readonly NoPlaygroundLiterals: true;
50
+ readonly NoVoidReturnOnFunctionSignature: true;
51
+ readonly OmitExplicitReturns: false;
52
+ readonly OneCasePerLine: true;
53
+ readonly OneVariableDeclarationPerLine: true;
54
+ readonly OnlyOneTrailingClosureArgument: true;
55
+ readonly OrderedImports: true;
56
+ readonly ReplaceForEachWithForLoop: true;
57
+ readonly ReturnVoidInsteadOfEmptyTuple: true;
58
+ readonly TypeNamesShouldBeCapitalized: true;
59
+ readonly UseEarlyExits: false;
60
+ readonly UseExplicitNilCheckInConditions: true;
61
+ readonly UseLetInEveryBoundCaseVariable: true;
62
+ readonly UseShorthandTypeNames: true;
63
+ readonly UseSingleLinePropertyGetter: true;
64
+ readonly UseSynthesizedInitializer: true;
65
+ readonly UseTripleSlashForDocumentationComments: true;
66
+ readonly UseWhereClausesInForLoops: false;
67
+ readonly ValidateDocumentationComments: false;
68
+ };
69
+ readonly spacesAroundRangeFormationOperators: false;
70
+ readonly spacesBeforeEndOfLineComments: 2;
71
+ readonly tabWidth: 8;
72
+ readonly version: 1;
73
+ };
74
+ export default kamaalSwiftFormatConfig;
75
+ //# sourceMappingURL=swift-format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swift-format.d.ts","sourceRoot":"","sources":["../src/swift-format.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,uBAAuB;aAC3B,4BAA4B;iBAC1B,WAAW,EAAE,SAAS;;aAExB,kCAAkC;aAClC,sBAAsB;aACtB,WAAW;iBACT,MAAM,EAAE,CAAC;;aAEX,iDAAiD;aACjD,kCAAkC;aAClC,2BAA2B;aAC3B,qCAAqC;aACrC,qCAAqC;aACrC,UAAU,EAAE,GAAG;aACf,iBAAiB,EAAE,CAAC;aACpB,oCAAoC;aACpC,yBAAyB;iBACvB,gBAAgB,YAAG,kBAAkB;;aAEvC,uCAAuC;aACvC,6BAA6B,EAAE,OAAO;aACtC,0BAA0B;aAC1B,KAAK;iBACH,sCAAsC;iBACtC,sCAAsC;iBACtC,uBAAuB;iBACvB,gCAAgC;iBAChC,4BAA4B;iBAC5B,2CAA2C;iBAC3C,kBAAkB;iBAClB,gCAAgC;iBAChC,4BAA4B;iBAC5B,iBAAiB;iBACjB,oBAAoB;iBACpB,sBAAsB;iBACtB,gBAAgB;iBAChB,gBAAgB;iBAChB,oCAAoC;iBACpC,mCAAmC;iBACnC,yBAAyB;iBACzB,eAAe;iBACf,0BAA0B;iBAC1B,gCAAgC;iBAChC,iCAAiC;iBACjC,sBAAsB;iBACtB,oBAAoB;iBACpB,wBAAwB;iBACxB,oBAAoB;iBACpB,+BAA+B;iBAC/B,mBAAmB;iBACnB,cAAc;iBACd,6BAA6B;iBAC7B,8BAA8B;iBAC9B,cAAc;iBACd,yBAAyB;iBACzB,6BAA6B;iBAC7B,4BAA4B;iBAC5B,aAAa;iBACb,+BAA+B;iBAC/B,8BAA8B;iBAC9B,qBAAqB;iBACrB,2BAA2B;iBAC3B,yBAAyB;iBACzB,sCAAsC;iBACtC,yBAAyB;iBACzB,6BAA6B;;aAE/B,mCAAmC;aACnC,6BAA6B,EAAE,CAAC;aAChC,QAAQ,EAAE,CAAC;aACX,OAAO,EAAE,CAAC;CACF,CAAC;eAEI,uBAAuB"}
@@ -0,0 +1,75 @@
1
+ const kamaalSwiftFormatConfig = {
2
+ fileScopedDeclarationPrivacy: {
3
+ accessLevel: 'private',
4
+ },
5
+ indentConditionalCompilationBlocks: true,
6
+ indentSwitchCaseLabels: false,
7
+ indentation: {
8
+ spaces: 4,
9
+ },
10
+ lineBreakAroundMultilineExpressionChainComponents: false,
11
+ lineBreakBeforeControlFlowKeywords: false,
12
+ lineBreakBeforeEachArgument: true,
13
+ lineBreakBeforeEachGenericRequirement: false,
14
+ lineBreakBetweenDeclarationAttributes: false,
15
+ lineLength: 120,
16
+ maximumBlankLines: 1,
17
+ multiElementCollectionTrailingCommas: true,
18
+ noAssignmentInExpressions: {
19
+ allowedFunctions: ['XCTAssertNoThrow'],
20
+ },
21
+ prioritizeKeepingFunctionOutputTogether: false,
22
+ reflowMultilineStringLiterals: 'never',
23
+ respectsExistingLineBreaks: true,
24
+ rules: {
25
+ AllPublicDeclarationsHaveDocumentation: false,
26
+ AlwaysUseLiteralForEmptyCollectionInit: false,
27
+ AlwaysUseLowerCamelCase: true,
28
+ AmbiguousTrailingClosureOverload: true,
29
+ AvoidRetroactiveConformances: true,
30
+ BeginDocumentationCommentWithOneLineSummary: false,
31
+ DoNotUseSemicolons: true,
32
+ DontRepeatTypeInStaticProperties: true,
33
+ FileScopedDeclarationPrivacy: true,
34
+ FullyIndirectEnum: true,
35
+ GroupNumericLiterals: true,
36
+ IdentifiersMustBeASCII: true,
37
+ NeverForceUnwrap: true,
38
+ NeverUseForceTry: true,
39
+ NeverUseImplicitlyUnwrappedOptionals: true,
40
+ NoAccessLevelOnExtensionDeclaration: true,
41
+ NoAssignmentInExpressions: true,
42
+ NoBlockComments: true,
43
+ NoCasesWithOnlyFallthrough: true,
44
+ NoEmptyLinesOpeningClosingBraces: false,
45
+ NoEmptyTrailingClosureParentheses: true,
46
+ NoLabelsInCasePatterns: true,
47
+ NoLeadingUnderscores: false,
48
+ NoParensAroundConditions: true,
49
+ NoPlaygroundLiterals: true,
50
+ NoVoidReturnOnFunctionSignature: true,
51
+ OmitExplicitReturns: false,
52
+ OneCasePerLine: true,
53
+ OneVariableDeclarationPerLine: true,
54
+ OnlyOneTrailingClosureArgument: true,
55
+ OrderedImports: true,
56
+ ReplaceForEachWithForLoop: true,
57
+ ReturnVoidInsteadOfEmptyTuple: true,
58
+ TypeNamesShouldBeCapitalized: true,
59
+ UseEarlyExits: false,
60
+ UseExplicitNilCheckInConditions: true,
61
+ UseLetInEveryBoundCaseVariable: true,
62
+ UseShorthandTypeNames: true,
63
+ UseSingleLinePropertyGetter: true,
64
+ UseSynthesizedInitializer: true,
65
+ UseTripleSlashForDocumentationComments: true,
66
+ UseWhereClausesInForLoops: false,
67
+ ValidateDocumentationComments: false,
68
+ },
69
+ spacesAroundRangeFormationOperators: false,
70
+ spacesBeforeEndOfLineComments: 2,
71
+ tabWidth: 8,
72
+ version: 1,
73
+ };
74
+ export default kamaalSwiftFormatConfig;
75
+ //# sourceMappingURL=swift-format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swift-format.js","sourceRoot":"","sources":["../src/swift-format.ts"],"names":[],"mappings":"AAAA,MAAM,uBAAuB,GAAG;IAC9B,4BAA4B,EAAE;QAC5B,WAAW,EAAE,SAAS;KACvB;IACD,kCAAkC,EAAE,IAAI;IACxC,sBAAsB,EAAE,KAAK;IAC7B,WAAW,EAAE;QACX,MAAM,EAAE,CAAC;KACV;IACD,iDAAiD,EAAE,KAAK;IACxD,kCAAkC,EAAE,KAAK;IACzC,2BAA2B,EAAE,IAAI;IACjC,qCAAqC,EAAE,KAAK;IAC5C,qCAAqC,EAAE,KAAK;IAC5C,UAAU,EAAE,GAAG;IACf,iBAAiB,EAAE,CAAC;IACpB,oCAAoC,EAAE,IAAI;IAC1C,yBAAyB,EAAE;QACzB,gBAAgB,EAAE,CAAC,kBAAkB,CAAC;KACvC;IACD,uCAAuC,EAAE,KAAK;IAC9C,6BAA6B,EAAE,OAAO;IACtC,0BAA0B,EAAE,IAAI;IAChC,KAAK,EAAE;QACL,sCAAsC,EAAE,KAAK;QAC7C,sCAAsC,EAAE,KAAK;QAC7C,uBAAuB,EAAE,IAAI;QAC7B,gCAAgC,EAAE,IAAI;QACtC,4BAA4B,EAAE,IAAI;QAClC,2CAA2C,EAAE,KAAK;QAClD,kBAAkB,EAAE,IAAI;QACxB,gCAAgC,EAAE,IAAI;QACtC,4BAA4B,EAAE,IAAI;QAClC,iBAAiB,EAAE,IAAI;QACvB,oBAAoB,EAAE,IAAI;QAC1B,sBAAsB,EAAE,IAAI;QAC5B,gBAAgB,EAAE,IAAI;QACtB,gBAAgB,EAAE,IAAI;QACtB,oCAAoC,EAAE,IAAI;QAC1C,mCAAmC,EAAE,IAAI;QACzC,yBAAyB,EAAE,IAAI;QAC/B,eAAe,EAAE,IAAI;QACrB,0BAA0B,EAAE,IAAI;QAChC,gCAAgC,EAAE,KAAK;QACvC,iCAAiC,EAAE,IAAI;QACvC,sBAAsB,EAAE,IAAI;QAC5B,oBAAoB,EAAE,KAAK;QAC3B,wBAAwB,EAAE,IAAI;QAC9B,oBAAoB,EAAE,IAAI;QAC1B,+BAA+B,EAAE,IAAI;QACrC,mBAAmB,EAAE,KAAK;QAC1B,cAAc,EAAE,IAAI;QACpB,6BAA6B,EAAE,IAAI;QACnC,8BAA8B,EAAE,IAAI;QACpC,cAAc,EAAE,IAAI;QACpB,yBAAyB,EAAE,IAAI;QAC/B,6BAA6B,EAAE,IAAI;QACnC,4BAA4B,EAAE,IAAI;QAClC,aAAa,EAAE,KAAK;QACpB,+BAA+B,EAAE,IAAI;QACrC,8BAA8B,EAAE,IAAI;QACpC,qBAAqB,EAAE,IAAI;QAC3B,2BAA2B,EAAE,IAAI;QACjC,yBAAyB,EAAE,IAAI;QAC/B,sCAAsC,EAAE,IAAI;QAC5C,yBAAyB,EAAE,KAAK;QAChC,6BAA6B,EAAE,KAAK;KACrC;IACD,mCAAmC,EAAE,KAAK;IAC1C,6BAA6B,EAAE,CAAC;IAChC,QAAQ,EAAE,CAAC;IACX,OAAO,EAAE,CAAC;CACF,CAAC;AAEX,eAAe,uBAAuB,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kamaal111/kamaal-quality-config",
3
- "version": "0.6.0",
4
- "description": "Kamaal Farah's shared oxlint quality config.",
3
+ "version": "0.8.0",
4
+ "description": "Kamaal Farah's shared quality configurations.",
5
5
  "keywords": [
6
6
  "lint",
7
7
  "oxlint",
@@ -14,8 +14,16 @@
14
14
  "type": "git",
15
15
  "url": "git+https://github.com/kamaal111/kamaal-quality-config.git"
16
16
  },
17
+ "bin": {
18
+ "kqc": "./dist/cli.js"
19
+ },
17
20
  "files": [
18
- "dist"
21
+ "dist",
22
+ "swift-format.json",
23
+ "swift/SwiftLintChecks/Package.swift",
24
+ "swift/SwiftLintChecks/Package.resolved",
25
+ "swift/SwiftLintChecks/Sources",
26
+ "swift/SwiftLintChecks/Tests"
19
27
  ],
20
28
  "type": "module",
21
29
  "main": "./dist/index.js",
@@ -35,7 +43,12 @@
35
43
  },
36
44
  "./plugins/consistent-inline-type-imports": "./dist/plugins/consistent-inline-type-imports.js",
37
45
  "./plugins/no-nullish-check-first-ternary": "./dist/plugins/no-nullish-check-first-ternary.js",
38
- "./plugins/prefer-nullish": "./dist/plugins/prefer-nullish.js"
46
+ "./plugins/prefer-nullish": "./dist/plugins/prefer-nullish.js",
47
+ "./swift-format": {
48
+ "types": "./dist/swift-format.d.ts",
49
+ "default": "./dist/swift-format.js"
50
+ },
51
+ "./swift-format.json": "./swift-format.json"
39
52
  },
40
53
  "publishConfig": {
41
54
  "access": "public"
@@ -79,6 +92,8 @@
79
92
  "type-check": "tsc --noEmit",
80
93
  "quality": "pnpm run lint && pnpm run format:check && pnpm run type-check",
81
94
  "test": "pnpm run build && tsc -p tsconfig.tests.json && vitest run",
82
- "release": "node ./scripts/publish.ts"
95
+ "release": "node ./scripts/publish.ts",
96
+ "test:swift-format": "SWIFT_FORMAT_TEST=1 pnpm test src/packed-consumer.test.ts",
97
+ "test:swift-lint": "swift test --package-path swift/SwiftLintChecks && SWIFT_LINT_TEST=1 pnpm test src/packed-consumer.test.ts"
83
98
  }
84
99
  }
@@ -0,0 +1,15 @@
1
+ {
2
+ "originHash" : "a875d193e1e9527c2ef2d74f177469872114cdfa86907e7b82b1d2290d4fb61d",
3
+ "pins" : [
4
+ {
5
+ "identity" : "swift-syntax",
6
+ "kind" : "remoteSourceControl",
7
+ "location" : "https://github.com/swiftlang/swift-syntax",
8
+ "state" : {
9
+ "revision" : "050f1a346fbbac0ca2cfb15a95274f7bd1cf0ccf",
10
+ "version" : "604.0.0"
11
+ }
12
+ }
13
+ ],
14
+ "version" : 3
15
+ }
@@ -0,0 +1,22 @@
1
+ // swift-tools-version: 6.4
2
+
3
+ import PackageDescription
4
+
5
+ let package = Package(
6
+ name: "SwiftLintChecks",
7
+ platforms: [.macOS(.v15)],
8
+ products: [.executable(name: "kqc-swift-lint", targets: ["SwiftLintChecks"])],
9
+ dependencies: [
10
+ .package(url: "https://github.com/swiftlang/swift-syntax", exact: "604.0.0")
11
+ ],
12
+ targets: [
13
+ .executableTarget(
14
+ name: "SwiftLintChecks",
15
+ dependencies: [
16
+ .product(name: "SwiftSyntax", package: "swift-syntax"),
17
+ .product(name: "SwiftParser", package: "swift-syntax"),
18
+ ]
19
+ ),
20
+ .testTarget(name: "SwiftLintChecksTests", dependencies: ["SwiftLintChecks"]),
21
+ ]
22
+ )
@@ -0,0 +1,23 @@
1
+ import SwiftSyntax
2
+
3
+ struct LintViolation {
4
+ let position: AbsolutePosition
5
+ let rule: LintRule
6
+ }
7
+
8
+ enum LintRule: String {
9
+ case memberSpacing = "member_spacing"
10
+ case multilineChainSpacing = "multiline_chain_spacing"
11
+ case viewBodyDeclarations = "view_body_declarations"
12
+
13
+ var message: String {
14
+ switch self {
15
+ case .memberSpacing:
16
+ "Separate initializers and methods from adjacent members with a blank line."
17
+ case .multilineChainSpacing:
18
+ "Place each chained call on its own line in a multiline expression."
19
+ case .viewBodyDeclarations:
20
+ "Move local declarations out of SwiftUI body into computed properties or helper functions."
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,35 @@
1
+ import SwiftSyntax
2
+
3
+ final class MultilineChainSpacingVisitor: SyntaxVisitor {
4
+ private(set) var violations: [LintViolation] = []
5
+ private let converter: SourceLocationConverter
6
+
7
+ init(converter: SourceLocationConverter) {
8
+ self.converter = converter
9
+ super.init(viewMode: .sourceAccurate)
10
+ }
11
+
12
+ override func visit(_ node: FunctionCallExprSyntax) -> SyntaxVisitorContinueKind {
13
+ if let member = node.parent?.as(MemberAccessExprSyntax.self),
14
+ member.parent?.is(FunctionCallExprSyntax.self) == true
15
+ {
16
+ return .visitChildren
17
+ }
18
+ let startLine = converter.location(for: node.positionAfterSkippingLeadingTrivia).line
19
+ let endLine = converter.location(for: node.endPositionBeforeTrailingTrivia).line
20
+ guard startLine != endLine else { return .visitChildren }
21
+ var call = node
22
+ while let member = call.calledExpression.as(MemberAccessExprSyntax.self),
23
+ let previous = member.base?.as(FunctionCallExprSyntax.self)
24
+ {
25
+ let previousLine = converter.location(for: previous.endPositionBeforeTrailingTrivia).line
26
+ let dotPosition = member.period.positionAfterSkippingLeadingTrivia
27
+ let dotLine = converter.location(for: dotPosition).line
28
+ if previousLine == dotLine {
29
+ violations.append(LintViolation(position: dotPosition, rule: .multilineChainSpacing))
30
+ }
31
+ call = previous
32
+ }
33
+ return .visitChildren
34
+ }
35
+ }