@kamaal111/kamaal-quality-config 0.8.0 → 0.9.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 (48) hide show
  1. package/README.md +107 -4
  2. package/dist/index.d.ts +2 -2
  3. package/dist/oxlint.d.ts +2 -2
  4. package/dist/oxlint.d.ts.map +1 -1
  5. package/dist/oxlint.js +22 -8
  6. package/dist/oxlint.js.map +1 -1
  7. package/dist/oxlintrc.json +18 -4
  8. package/dist/plugins/anti-slop.d.ts +3 -0
  9. package/dist/plugins/anti-slop.d.ts.map +1 -0
  10. package/dist/plugins/anti-slop.js +3 -0
  11. package/dist/plugins/anti-slop.js.map +1 -0
  12. package/dist/plugins/consistent-inline-type-imports.js +5 -3
  13. package/dist/plugins/consistent-inline-type-imports.js.map +1 -1
  14. package/dist/plugins/import.d.ts +3 -0
  15. package/dist/plugins/import.d.ts.map +1 -0
  16. package/dist/plugins/import.js +3 -0
  17. package/dist/plugins/import.js.map +1 -0
  18. package/dist/plugins/prefer-nonempty.d.ts +4 -0
  19. package/dist/plugins/prefer-nonempty.d.ts.map +1 -0
  20. package/dist/plugins/prefer-nonempty.js +135 -0
  21. package/dist/plugins/prefer-nonempty.js.map +1 -0
  22. package/dist/plugins/prefer-nullish.d.ts +3 -32
  23. package/dist/plugins/prefer-nullish.d.ts.map +1 -1
  24. package/dist/plugins/prefer-nullish.js +24 -28
  25. package/dist/plugins/prefer-nullish.js.map +1 -1
  26. package/dist/plugins/prefer-while-true.d.ts +26 -0
  27. package/dist/plugins/prefer-while-true.d.ts.map +1 -0
  28. package/dist/plugins/prefer-while-true.js +26 -0
  29. package/dist/plugins/prefer-while-true.js.map +1 -0
  30. package/dist/plugins/require-multiline-arrow-braces.d.ts +30 -0
  31. package/dist/plugins/require-multiline-arrow-braces.d.ts.map +1 -0
  32. package/dist/plugins/require-multiline-arrow-braces.js +51 -0
  33. package/dist/plugins/require-multiline-arrow-braces.js.map +1 -0
  34. package/dist/plugins/rule-context.d.ts +11 -0
  35. package/dist/plugins/rule-context.d.ts.map +1 -1
  36. package/dist/plugins/stylistic.d.ts +3 -0
  37. package/dist/plugins/stylistic.d.ts.map +1 -0
  38. package/dist/plugins/stylistic.js +3 -0
  39. package/dist/plugins/stylistic.js.map +1 -0
  40. package/dist/plugins/zod.d.ts +11 -0
  41. package/dist/plugins/zod.d.ts.map +1 -0
  42. package/dist/plugins/zod.js +10 -0
  43. package/dist/plugins/zod.js.map +1 -0
  44. package/package.json +8 -3
  45. package/swift/SwiftLintChecks/Sources/SwiftLintChecks/LintViolation.swift +9 -0
  46. package/swift/SwiftLintChecks/Sources/SwiftLintChecks/SingleTryPerDoCatchVisitor.swift +34 -0
  47. package/swift/SwiftLintChecks/Sources/SwiftLintChecks/SwiftLint.swift +4 -1
  48. package/swift/SwiftLintChecks/Tests/SwiftLintChecksTests/SingleTryPerDoCatchTests.swift +290 -0
package/README.md CHANGED
@@ -5,21 +5,47 @@ Kamaal Farah's shared quality configs for [oxlint and oxfmt](https://oxc.rs), Sw
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
7
7
  rules from oxlint's built-in `typescript`, `unicorn`, `oxc`, and `vitest` plugins and from
8
- `eslint-plugin-import` (via oxlint's `jsPlugins`), plus selected rules from `@stylistic/eslint-plugin` and three hand-written local rules:
8
+ `eslint-plugin-import` (via oxlint's `jsPlugins`), plus selected rules from `@stylistic/eslint-plugin` and six hand-written local rules:
9
9
 
10
10
  - `kamaal-imports/no-all-inline-type-imports` — forbids `import { type A, type B } from 'x'` in favor
11
11
  of a top-level `import type { A, B } from 'x'`.
12
12
  - `kamaal-ternary/no-nullish-check-first-ternary` — forbids ternaries that check for a nullish value
13
13
  first (e.g. `x == null ? undefined : x.trim()`), requiring the value-producing branch first instead
14
14
  (`x != null ? x.trim() : undefined`).
15
+ - `kamaal-arrows/require-multiline-arrow-braces` — requires braces for multiline expression bodies,
16
+ except direct object-literal returns.
17
+ - `kamaal-zod/prefer-nonempty` — requires `.nonempty()` instead of `.min(1)` on verified
18
+ inline Zod 4 string, array, and set schemas, with autofix preserving custom errors and comments.
19
+ Supports imports and aliases from `zod` and `zod/v4`; the root import is assumed to be Zod 4.
20
+ Numeric schemas, schema variables, unsupported intermediate methods, and explicit Zod 3/Mini/Core
21
+ imports are left unchanged. Known chains such as `z.string().trim().min(1)` are supported.
15
22
  - `kamaal-zod/prefer-nullish` — requires `.nullish()` instead of consecutive `.nullable()` and
16
23
  `.optional()` calls in either order. This syntax-based rule applies to any receiver and has no autofix.
24
+ - `kamaal-loops/prefer-while-true` — requires `while (true)` instead of `for (;;)` when all three
25
+ header parts are empty. Autofix replaces comment-free headers; headers containing comments are
26
+ reported without a fix. Other `for` loops are unchanged.
27
+
28
+ The Zod plugin is exported at `@kamaal111/kamaal-quality-config/plugins/zod`.
17
29
 
18
30
  The shared defaults also require blank lines around class methods and constructors (with autofix),
19
31
  allow consecutive fields to stay grouped, require default imports for `node:` modules, and prohibit
20
32
  `Object.assign` in favor of explicit typed assignments or object spread. Vitest globals and
21
33
  project-specific server restrictions remain consumer choices.
22
34
 
35
+ Multiline arrow bodies require braces and an explicit return, with autofix through
36
+ `kamaal-arrows/require-multiline-arrow-braces`. Single-line expression bodies, wrapped parameters,
37
+ and direct object-literal returns (including multiline objects) remain allowed:
38
+
39
+ ```ts
40
+ const double = x => x * 2;
41
+ const makeUser = () => ({
42
+ name: 'Kamaal',
43
+ });
44
+ const readAnswer = () => {
45
+ return fetchAnswer('Kamaal');
46
+ };
47
+ ```
48
+
23
49
  More rule sources will be folded in over time.
24
50
 
25
51
  ## Table of contents
@@ -53,6 +79,21 @@ Extend it from your `.oxlintrc.json`:
53
79
  }
54
80
  ```
55
81
 
82
+ The shared config owns its external JavaScript plugins, including
83
+ `@stylistic/eslint-plugin`, `eslint-plugin-import`, and
84
+ `@kamaal111/oxlint-plugin-anti-slop`. Consumers do not need to declare those plugins
85
+ directly or repeat their rule settings. Install `oxlint` and `oxlint-tsgolint`
86
+ as development tools if your project does not already provide them:
87
+
88
+ ```sh
89
+ pnpm add -D oxlint oxlint-tsgolint
90
+ ```
91
+
92
+ Plugin entry points are exported by this package so both JSON and TypeScript
93
+ configs resolve plugins through the shared package's own dependencies. This
94
+ resolution fix requires a release after v0.8.0; v0.8.0 and earlier can require
95
+ plugins to be exposed at the consumer root under isolated dependency layouts.
96
+
56
97
  The package ships a plain, statically-generated `dist/oxlintrc.json` — no `oxlint.config.ts` or
57
98
  package-import support is needed, since `.oxlintrc.json`'s `extends` field accepts plain file paths.
58
99
 
@@ -158,12 +199,73 @@ Without paths, the command checks the current directory recursively. Explicit fi
158
199
  paths are relative to your working directory. Recursive scanning skips hidden paths (including
159
200
  `.build`), `node_modules`, symlinks, and non-Swift files. Use `--` before paths starting with a dash.
160
201
 
161
- All three checks are enabled:
202
+ All four checks are enabled:
162
203
 
163
204
  - `member_spacing`: separate methods and initializers from adjacent members with a blank line.
164
205
  - `multiline_chain_spacing`: put each chained call on its own line in multiline expressions.
165
206
  - `view_body_declarations`: move local `let` and `var` declarations out of SwiftUI
166
207
  `var body: some View`, including nested builder closures. Conditional bindings remain allowed.
208
+ - `single_try_per_do_catch`: allow at most one plain `try` expression per `do/catch` body.
209
+ Count across branches and loops; `try?` and `try!` do not count. Nested `do/catch` bodies
210
+ are checked independently, while catchless `do` blocks contribute to the enclosing count.
211
+ Closures, local functions, and nested types have separate scopes; their own `do/catch` blocks
212
+ are still checked. A `try` in a nested catch contributes to an enclosing handler, if present.
213
+ All conditional-compilation branches count, including inactive branches.
214
+
215
+ For example, this shares error handling between two throwing operations and is rejected at the second `try`:
216
+
217
+ ```swift
218
+ do {
219
+ try load()
220
+ try save()
221
+ } catch {
222
+ reportError(error)
223
+ }
224
+ ```
225
+
226
+ Give each operation its own error handling, or extract a helper that handles its error. Decide whether
227
+ each failure should recover, propagate, or gain more context. For operations without a returned value:
228
+
229
+ ```swift
230
+ do {
231
+ try load()
232
+ } catch {
233
+ reportLoad(error)
234
+ return
235
+ }
236
+
237
+ do {
238
+ try save()
239
+ } catch {
240
+ reportSave(error)
241
+ }
242
+ ```
243
+
244
+ Here the early return prevents saving after loading fails. Choose continuation based on the operation.
245
+
246
+ For an operation that returns a value, declare a typed `let` before the `do` and assign it inside:
247
+
248
+ ```swift
249
+ let result: SaveResult
250
+ do {
251
+ result = try save()
252
+ } catch {
253
+ reportError(error)
254
+ return
255
+ }
256
+
257
+ display(result)
258
+ ```
259
+
260
+ If the value is used afterward, the catch must exit, rethrow the error, or assign a meaningful fallback
261
+ so the value is initialized on every continuing path. Reporting the error alone is sufficient only
262
+ when no subsequent path reads the uninitialized value. `SaveResult` is the operation's return type;
263
+ it is not Swift's generic `Result<Success, Failure>`.
264
+
265
+ Diagnostics explain these alternatives. The rule has no autofix because choosing error handling
266
+ requires judgment. It counts explicit plain `try` expressions rather than throwing calls: one
267
+ `try` covering multiple calls counts as one, but combining calls merely to silence the rule
268
+ defeats its purpose.
167
269
 
168
270
  The CLI runs `swift run --package-path` against the bundled `SwiftLintChecks` package and does not
169
271
  modify source files. Diagnostics include file, line, column, and rule identifier. Exit codes are
@@ -188,8 +290,9 @@ pnpm test
188
290
  Vitest also checks the packed package. To select a consumer runtime, run
189
291
  `CONSUMER_NODE=/absolute/path/to/node pnpm test src/packed-consumer.test.ts` inside the devcontainer.
190
292
  CI selects the latest Node.js 22 release while building and running Vitest on Node.js 26.
191
- The test fixture installs the JS plugins at the consumer project root, where oxlint resolves
192
- the plugin specifiers in the shared configuration.
293
+ The fixture installs only the packed shared package and Oxlint tooling. It checks
294
+ both JSON and TypeScript configs without declaring external plugin dependencies
295
+ at the consumer root, so package-owned plugin resolution stays covered.
193
296
 
194
297
  The dependency-free example package in `fixtures/swift-format` verifies the installed Swift config.
195
298
  CI's Swift consumer job supplies Swift 6.4.1 and runs `pnpm test:swift-format`: it builds the package,
package/dist/index.d.ts CHANGED
@@ -10,10 +10,10 @@ declare const _default: {
10
10
  };
11
11
  oxlint: {
12
12
  plugins: ("oxc" | "typescript" | "unicorn" | "vitest")[];
13
- jsPlugins: (string | {
13
+ jsPlugins: {
14
14
  name: string;
15
15
  specifier: string;
16
- })[];
16
+ }[];
17
17
  options: {
18
18
  typeAware: true;
19
19
  };
package/dist/oxlint.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  declare const _default: {
2
2
  plugins: ("oxc" | "typescript" | "unicorn" | "vitest")[];
3
- jsPlugins: (string | {
3
+ jsPlugins: {
4
4
  name: string;
5
5
  specifier: string;
6
- })[];
6
+ }[];
7
7
  options: {
8
8
  typeAware: true;
9
9
  };
@@ -1 +1 @@
1
- {"version":3,"file":"oxlint.d.ts","sourceRoot":"","sources":["../src/oxlint.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAkIuB,KAAK;gBAAS,eAAe"}
1
+ {"version":3,"file":"oxlint.d.ts","sourceRoot":"","sources":["../src/oxlint.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAqJuB,KAAK;gBAAS,eAAe"}
package/dist/oxlint.js CHANGED
@@ -2,24 +2,36 @@ import antiSlopPlugin from '@kamaal111/oxlint-plugin-anti-slop';
2
2
  import { defineConfig } from 'oxlint';
3
3
  import consistentInlineTypeImportsPlugin from './plugins/consistent-inline-type-imports.js';
4
4
  import noNullishCheckFirstTernaryPlugin from './plugins/no-nullish-check-first-ternary.js';
5
- import preferNullishPlugin from './plugins/prefer-nullish.js';
5
+ import preferWhileTruePlugin from './plugins/prefer-while-true.js';
6
+ import requireMultilineArrowBracesPlugin from './plugins/require-multiline-arrow-braces.js';
7
+ import zodPlugin from './plugins/zod.js';
6
8
  function pluginRules(namespace, ruleNames) {
7
9
  return Object.fromEntries(ruleNames.map(ruleName => [`${namespace}/${ruleName}`, 'error']));
8
10
  }
9
11
  const antiSlopRules = pluginRules('anti-slop', Object.keys(antiSlopPlugin.rules));
10
12
  const consistentInlineTypeImportsRules = pluginRules(consistentInlineTypeImportsPlugin.meta.name, Object.keys(consistentInlineTypeImportsPlugin.rules));
11
13
  const noNullishCheckFirstTernaryRules = pluginRules(noNullishCheckFirstTernaryPlugin.meta.name, Object.keys(noNullishCheckFirstTernaryPlugin.rules));
12
- const preferNullishRules = pluginRules(preferNullishPlugin.meta.name, Object.keys(preferNullishPlugin.rules));
14
+ const zodRules = pluginRules(zodPlugin.meta.name, Object.keys(zodPlugin.rules));
15
+ const preferWhileTrueRules = pluginRules(preferWhileTruePlugin.meta.name, Object.keys(preferWhileTruePlugin.rules));
16
+ const requireMultilineArrowBracesRules = pluginRules(requireMultilineArrowBracesPlugin.meta.name, Object.keys(requireMultilineArrowBracesPlugin.rules));
13
17
  export default defineConfig({
14
18
  plugins: ['typescript', 'unicorn', 'oxc', 'vitest'],
15
19
  jsPlugins: [
16
- '@stylistic/eslint-plugin',
20
+ { name: '@stylistic', specifier: '@kamaal111/kamaal-quality-config/plugins/stylistic' },
17
21
  {
18
- name: preferNullishPlugin.meta.name,
19
- specifier: '@kamaal111/kamaal-quality-config/plugins/prefer-nullish',
22
+ name: requireMultilineArrowBracesPlugin.meta.name,
23
+ specifier: '@kamaal111/kamaal-quality-config/plugins/require-multiline-arrow-braces',
20
24
  },
21
- { name: 'anti-slop', specifier: '@kamaal111/oxlint-plugin-anti-slop' },
22
- { name: 'import-js', specifier: 'eslint-plugin-import' },
25
+ {
26
+ name: preferWhileTruePlugin.meta.name,
27
+ specifier: '@kamaal111/kamaal-quality-config/plugins/prefer-while-true',
28
+ },
29
+ {
30
+ name: zodPlugin.meta.name,
31
+ specifier: '@kamaal111/kamaal-quality-config/plugins/zod',
32
+ },
33
+ { name: 'anti-slop', specifier: '@kamaal111/kamaal-quality-config/plugins/anti-slop' },
34
+ { name: 'import-js', specifier: '@kamaal111/kamaal-quality-config/plugins/import' },
23
35
  {
24
36
  name: consistentInlineTypeImportsPlugin.meta.name,
25
37
  specifier: '@kamaal111/kamaal-quality-config/plugins/consistent-inline-type-imports',
@@ -33,7 +45,9 @@ export default defineConfig({
33
45
  categories: { correctness: 'error' },
34
46
  rules: {
35
47
  ...antiSlopRules,
36
- ...preferNullishRules,
48
+ ...zodRules,
49
+ ...preferWhileTrueRules,
50
+ ...requireMultilineArrowBracesRules,
37
51
  '@stylistic/lines-between-class-members': [
38
52
  'error',
39
53
  {
@@ -1 +1 @@
1
- {"version":3,"file":"oxlint.js","sourceRoot":"","sources":["../src/oxlint.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,iCAAiC,MAAM,6CAA6C,CAAC;AAC5F,OAAO,gCAAgC,MAAM,6CAA6C,CAAC;AAC3F,OAAO,mBAAmB,MAAM,6BAA6B,CAAC;AAE9D,SAAS,WAAW,CAAC,SAAiB,EAAE,SAAmB;IACzD,OAAO,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,IAAI,QAAQ,EAAE,EAAE,OAAO,CAAU,CAAC,CAAC,CAAC;AACvG,CAAC;AAED,MAAM,aAAa,GAAG,WAAW,CAAC,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;AAElF,MAAM,gCAAgC,GAAG,WAAW,CAClD,iCAAiC,CAAC,IAAI,CAAC,IAAI,EAC3C,MAAM,CAAC,IAAI,CAAC,iCAAiC,CAAC,KAAK,CAAC,CACrD,CAAC;AAEF,MAAM,+BAA+B,GAAG,WAAW,CACjD,gCAA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E,CAAC;QACrE,mCAAmC,EAAE,OAAO;QAC5C,mBAAmB,EAAE,OAAO;QAC5B,iBAAiB,EAAE;YACjB,OAAO;YACP;gBACE,MAAM,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,CAAC,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;gBAC3E,kBAAkB,EAAE,QAAQ;gBAC5B,WAAW,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE;aACrD;SACF;KACF;IACD,GAAG,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;CACvB,CAAC,CAAC"}
@@ -6,18 +6,29 @@
6
6
  "vitest"
7
7
  ],
8
8
  "jsPlugins": [
9
- "@stylistic/eslint-plugin",
9
+ {
10
+ "name": "@stylistic",
11
+ "specifier": "@kamaal111/kamaal-quality-config/plugins/stylistic"
12
+ },
13
+ {
14
+ "name": "kamaal-arrows",
15
+ "specifier": "@kamaal111/kamaal-quality-config/plugins/require-multiline-arrow-braces"
16
+ },
17
+ {
18
+ "name": "kamaal-loops",
19
+ "specifier": "@kamaal111/kamaal-quality-config/plugins/prefer-while-true"
20
+ },
10
21
  {
11
22
  "name": "kamaal-zod",
12
- "specifier": "@kamaal111/kamaal-quality-config/plugins/prefer-nullish"
23
+ "specifier": "@kamaal111/kamaal-quality-config/plugins/zod"
13
24
  },
14
25
  {
15
26
  "name": "anti-slop",
16
- "specifier": "@kamaal111/oxlint-plugin-anti-slop"
27
+ "specifier": "@kamaal111/kamaal-quality-config/plugins/anti-slop"
17
28
  },
18
29
  {
19
30
  "name": "import-js",
20
- "specifier": "eslint-plugin-import"
31
+ "specifier": "@kamaal111/kamaal-quality-config/plugins/import"
21
32
  },
22
33
  {
23
34
  "name": "kamaal-imports",
@@ -58,7 +69,10 @@
58
69
  "anti-slop/no-widen-then-assert": "error",
59
70
  "anti-slop/require-readable-spacing": "error",
60
71
  "anti-slop/require-safety-comment-for-type-assertion": "error",
72
+ "kamaal-zod/prefer-nonempty": "error",
61
73
  "kamaal-zod/prefer-nullish": "error",
74
+ "kamaal-loops/prefer-while-true": "error",
75
+ "kamaal-arrows/require-multiline-arrow-braces": "error",
62
76
  "@stylistic/lines-between-class-members": [
63
77
  "error",
64
78
  {
@@ -0,0 +1,3 @@
1
+ import plugin from '@kamaal111/oxlint-plugin-anti-slop';
2
+ export default plugin;
3
+ //# sourceMappingURL=anti-slop.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anti-slop.d.ts","sourceRoot":"","sources":["../../src/plugins/anti-slop.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oCAAoC,CAAC;eAEzC,MAAM"}
@@ -0,0 +1,3 @@
1
+ import plugin from '@kamaal111/oxlint-plugin-anti-slop';
2
+ export default plugin;
3
+ //# sourceMappingURL=anti-slop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anti-slop.js","sourceRoot":"","sources":["../../src/plugins/anti-slop.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oCAAoC,CAAC;AAExD,eAAe,MAAM,CAAC"}
@@ -31,9 +31,11 @@ export default {
31
31
  node,
32
32
  message: 'Use a top-level `import type` instead of marking every named specifier with an inline `type` modifier.',
33
33
  fix(fixer) {
34
- const names = namedSpecifiers.map(specifier => specifier.imported.name === specifier.local.name
35
- ? specifier.imported.name
36
- : `${specifier.imported.name} as ${specifier.local.name}`);
34
+ const names = namedSpecifiers.map(specifier => {
35
+ return specifier.imported.name === specifier.local.name
36
+ ? specifier.imported.name
37
+ : `${specifier.imported.name} as ${specifier.local.name}`;
38
+ });
37
39
  const sourceText = context.sourceCode.getText(node.source);
38
40
  return fixer.replaceText(node, `import type { ${names.join(', ')} } from ${sourceText};`);
39
41
  },
@@ -1 +1 @@
1
- {"version":3,"file":"consistent-inline-type-imports.js","sourceRoot":"","sources":["../../src/plugins/consistent-inline-type-imports.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2FAA2F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,CAAC,IAAI,OAAO,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,CAC5D,CAAC;gCAEF,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gCAE3D,OAAO,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,iBAAiB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,UAAU,GAAG,CAAC,CAAC;4BAC5F,CAAC;yBACF,CAAC,CAAC;oBACL,CAAC;iBACF,CAAC;YACJ,CAAC;SACF;KACF;CACF,CAAC"}
1
+ {"version":3,"file":"consistent-inline-type-imports.js","sourceRoot":"","sources":["../../src/plugins/consistent-inline-type-imports.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2FAA2F;AAC3F,iEAAiE;AAkBjE,SAAS,iBAAiB,CAAC,SAAsD;IAC/E,OAAO,SAAS,CAAC,IAAI,KAAK,iBAAiB,CAAC;AAC9C,CAAC;AAED,eAAe;IACb,IAAI,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE;IAChC,KAAK,EAAE;QACL,4BAA4B,EAAE;YAC5B,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;YACzB,MAAM,CAAC,OAAoB;gBACzB,OAAO;oBACL,iBAAiB,CAAC,IAA2B;wBAC3C,IAAI,IAAI,CAAC,UAAU,KAAK,MAAM,EAAE,CAAC;4BAC/B,OAAO;wBACT,CAAC;wBAED,MAAM,eAAe,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;wBAElE,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;4BACjC,OAAO;wBACT,CAAC;wBAED,MAAM,qBAAqB,GAAG,eAAe,CAAC,MAAM,KAAK,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;wBAEhF,IAAI,qBAAqB,EAAE,CAAC;4BAC1B,OAAO;wBACT,CAAC;wBAED,MAAM,aAAa,GAAG,eAAe,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,UAAU,KAAK,MAAM,CAAC,CAAC;wBAE1F,IAAI,CAAC,aAAa,EAAE,CAAC;4BACnB,OAAO;wBACT,CAAC;wBAED,OAAO,CAAC,MAAM,CAAC;4BACb,IAAI;4BACJ,OAAO,EACL,wGAAwG;4BAC1G,GAAG,CAAC,KAAK;gCACP,MAAM,KAAK,GAAG,eAAe,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;oCAC5C,OAAO,SAAS,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS,CAAC,KAAK,CAAC,IAAI;wCACrD,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI;wCACzB,CAAC,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,IAAI,OAAO,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;gCAC9D,CAAC,CAAC,CAAC;gCAEH,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gCAE3D,OAAO,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,iBAAiB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,UAAU,GAAG,CAAC,CAAC;4BAC5F,CAAC;yBACF,CAAC,CAAC;oBACL,CAAC;iBACF,CAAC;YACJ,CAAC;SACF;KACF;CACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import plugin from 'eslint-plugin-import';
2
+ export default plugin;
3
+ //# sourceMappingURL=import.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import.d.ts","sourceRoot":"","sources":["../../src/plugins/import.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,sBAAsB,CAAC;eAE3B,MAAM"}
@@ -0,0 +1,3 @@
1
+ import plugin from 'eslint-plugin-import';
2
+ export default plugin;
3
+ //# sourceMappingURL=import.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import.js","sourceRoot":"","sources":["../../src/plugins/import.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,sBAAsB,CAAC;AAE1C,eAAe,MAAM,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Rule } from '@oxlint/plugins';
2
+ declare const preferNonempty: Rule;
3
+ export default preferNonempty;
4
+ //# sourceMappingURL=prefer-nonempty.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prefer-nonempty.d.ts","sourceRoot":"","sources":["../../src/plugins/prefer-nonempty.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,IAAI,EAAS,MAAM,iBAAiB,CAAC;AA+HpE,QAAA,MAAM,cAAc,EAAE,IAoDrB,CAAC;eAEa,cAAc"}
@@ -0,0 +1,135 @@
1
+ const CHAIN_METHODS = {
2
+ string: new Set([
3
+ 'trim',
4
+ 'toLowerCase',
5
+ 'toUpperCase',
6
+ 'normalize',
7
+ 'min',
8
+ 'max',
9
+ 'length',
10
+ 'regex',
11
+ 'includes',
12
+ 'startsWith',
13
+ 'endsWith',
14
+ 'nonempty',
15
+ ]),
16
+ array: new Set(['min', 'max', 'length', 'nonempty']),
17
+ set: new Set(['min', 'max', 'size', 'nonempty']),
18
+ };
19
+ function schemaKind(name) {
20
+ if (name === 'string' || name === 'array' || name === 'set') {
21
+ return name;
22
+ }
23
+ return undefined;
24
+ }
25
+ function importedName(node, context) {
26
+ let scope = context.sourceCode.getScope(node);
27
+ while (scope) {
28
+ const variable = scope.set.get(node.name);
29
+ if (variable) {
30
+ const definition = variable.defs[0];
31
+ if (!definition || definition.type !== 'ImportBinding') {
32
+ return undefined;
33
+ }
34
+ const declaration = definition.parent;
35
+ const specifier = definition.node;
36
+ if (declaration?.type !== 'ImportDeclaration' ||
37
+ declaration.importKind === 'type' ||
38
+ (declaration.source.value !== 'zod' && declaration.source.value !== 'zod/v4')) {
39
+ return undefined;
40
+ }
41
+ if (specifier.type === 'ImportDefaultSpecifier' || specifier.type === 'ImportNamespaceSpecifier') {
42
+ return 'z';
43
+ }
44
+ if (specifier.type === 'ImportSpecifier' && specifier.importKind !== 'type') {
45
+ return specifier.imported.type === 'Identifier' ? specifier.imported.name : specifier.imported.value;
46
+ }
47
+ return undefined;
48
+ }
49
+ scope = scope.upper;
50
+ }
51
+ return undefined;
52
+ }
53
+ function isNamedMember(node) {
54
+ return node.type === 'MemberExpression' && !node.computed && !node.optional && node.property.type === 'Identifier';
55
+ }
56
+ function isZodNamespace(node, context) {
57
+ return node.type === 'Identifier' && importedName(node, context) === 'z';
58
+ }
59
+ function inlineSchemaKind(node, context) {
60
+ if (node.type !== 'CallExpression' || node.optional) {
61
+ return undefined;
62
+ }
63
+ const callee = node.callee;
64
+ if (callee.type === 'Identifier') {
65
+ const name = importedName(callee, context);
66
+ return name !== undefined ? schemaKind(name) : undefined;
67
+ }
68
+ if (!isNamedMember(callee)) {
69
+ return undefined;
70
+ }
71
+ const name = callee.property.name;
72
+ if (isZodNamespace(callee.object, context)) {
73
+ return schemaKind(name);
74
+ }
75
+ if (name === 'string' &&
76
+ isNamedMember(callee.object) &&
77
+ callee.object.property.name === 'coerce' &&
78
+ isZodNamespace(callee.object.object, context)) {
79
+ return 'string';
80
+ }
81
+ const receiverKind = inlineSchemaKind(callee.object, context);
82
+ if (receiverKind === undefined) {
83
+ return undefined;
84
+ }
85
+ if (name === 'array') {
86
+ return 'array';
87
+ }
88
+ return CHAIN_METHODS[receiverKind].has(name) ? receiverKind : undefined;
89
+ }
90
+ const preferNonempty = {
91
+ meta: { type: 'suggestion', fixable: 'code', schema: [] },
92
+ create(context) {
93
+ return {
94
+ CallExpression(node) {
95
+ const member = node.callee;
96
+ const [bound, error] = node.arguments;
97
+ if (node.optional ||
98
+ !isNamedMember(member) ||
99
+ member.property.name !== 'min' ||
100
+ bound?.type !== 'Literal' ||
101
+ bound.value !== 1 ||
102
+ node.arguments.length > 2 ||
103
+ error?.type === 'SpreadElement' ||
104
+ inlineSchemaKind(member.object, context) === undefined) {
105
+ return;
106
+ }
107
+ context.report({
108
+ node: member.property,
109
+ message: 'Use .nonempty() instead of .min(1).',
110
+ fix(fixer) {
111
+ const opening = context.sourceCode.getTokenAfter(member.property);
112
+ const closing = context.sourceCode.getLastToken(node);
113
+ if (!opening || !closing) {
114
+ return null;
115
+ }
116
+ const tokens = context.sourceCode.getTokensBetween(opening, error ?? closing);
117
+ const commaIndex = tokens.findIndex(token => token.value === ',');
118
+ const removedTokens = error ? tokens.slice(0, commaIndex + 1) : tokens;
119
+ const lastRemoved = removedTokens.at(-1);
120
+ const next = lastRemoved ? context.sourceCode.getTokenAfter(lastRemoved) : closing;
121
+ if (!next) {
122
+ return null;
123
+ }
124
+ const removals = context.sourceCode.commentsExistBetween(opening, next)
125
+ ? removedTokens.map(token => fixer.remove(token))
126
+ : [fixer.removeRange([opening.range[1], next.range[0]])];
127
+ return [fixer.replaceText(member.property, 'nonempty'), ...removals];
128
+ },
129
+ });
130
+ },
131
+ };
132
+ },
133
+ };
134
+ export default preferNonempty;
135
+ //# sourceMappingURL=prefer-nonempty.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prefer-nonempty.js","sourceRoot":"","sources":["../../src/plugins/prefer-nonempty.ts"],"names":[],"mappings":"AAMA,MAAM,aAAa,GAA4C;IAC7D,MAAM,EAAE,IAAI,GAAG,CAAC;QACd,MAAM;QACN,aAAa;QACb,aAAa;QACb,WAAW;QACX,KAAK;QACL,KAAK;QACL,QAAQ;QACR,OAAO;QACP,UAAU;QACV,YAAY;QACZ,UAAU;QACV,UAAU;KACX,CAAC;IACF,KAAK,EAAE,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;IACpD,GAAG,EAAE,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;CACjD,CAAC;AAEF,SAAS,UAAU,CAAC,IAAY;IAC9B,IA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UAAU,CAAC,oBAAoB,CAAC,OAAO,EAAE,IAAI,CAAC;4BACrE,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;4BACjD,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;wBAE3D,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE,GAAG,QAAQ,CAAC,CAAC;oBACvE,CAAC;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -1,33 +1,4 @@
1
- import type { AstNode, RuleContext } from './rule-context.ts';
2
- interface IdentifierNode extends AstNode {
3
- type: 'Identifier';
4
- name: string;
5
- }
6
- interface MemberExpressionNode extends AstNode {
7
- type: 'MemberExpression';
8
- computed: boolean;
9
- object: ExpressionNode;
10
- property: ExpressionNode;
11
- }
12
- interface CallExpressionNode extends AstNode {
13
- type: 'CallExpression';
14
- callee: ExpressionNode;
15
- }
16
- type ExpressionNode = IdentifierNode | MemberExpressionNode | CallExpressionNode | AstNode;
17
- declare const _default: {
18
- meta: {
19
- name: string;
20
- };
21
- rules: {
22
- 'prefer-nullish': {
23
- meta: {
24
- type: string;
25
- };
26
- create(context: RuleContext): {
27
- CallExpression(node: CallExpressionNode): void;
28
- };
29
- };
30
- };
31
- };
32
- export default _default;
1
+ import type { Rule } from '@oxlint/plugins';
2
+ declare const preferNullish: Rule;
3
+ export default preferNullish;
33
4
  //# sourceMappingURL=prefer-nullish.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prefer-nullish.d.ts","sourceRoot":"","sources":["../../src/plugins/prefer-nullish.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE9D,UAAU,cAAe,SAAQ,OAAO;IACtC,IAAI,EAAE,YAAY,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,oBAAqB,SAAQ,OAAO;IAC5C,IAAI,EAAE,kBAAkB,CAAC;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,cAAc,CAAC;IACvB,QAAQ,EAAE,cAAc,CAAC;CAC1B;AAED,UAAU,kBAAmB,SAAQ,OAAO;IAC1C,IAAI,EAAE,gBAAgB,CAAC;IACvB,MAAM,EAAE,cAAc,CAAC;CACxB;AAED,KAAK,cAAc,GAAG,cAAc,GAAG,oBAAoB,GAAG,kBAAkB,GAAG,OAAO,CAAC;;IAazF,IAAI;QAAI,IAAI;;IACZ,KAAK;QACH,gBAAgB;YACd,IAAI;gBAAI,IAAI;;YACZ,MAAM,UAAU,WAAW;gBAEvB,cAAc,OAAO,kBAAkB"}
1
+ {"version":3,"file":"prefer-nullish.d.ts","sourceRoot":"","sources":["../../src/plugins/prefer-nullish.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAYpD,QAAA,MAAM,aAAa,EAAE,IA6BpB,CAAC;eAEa,aAAa"}
@@ -1,36 +1,32 @@
1
1
  function isNamedMember(node) {
2
- return (node.type === 'MemberExpression' && 'computed' in node && !node.computed && node.property.type === 'Identifier');
2
+ return node.type === 'MemberExpression' && !node.computed && node.property.type === 'Identifier';
3
3
  }
4
4
  function isCall(node) {
5
- return node.type === 'CallExpression' && 'callee' in node;
5
+ return node.type === 'CallExpression';
6
6
  }
7
- export default {
8
- meta: { name: 'kamaal-zod' },
9
- rules: {
10
- 'prefer-nullish': {
11
- meta: { type: 'suggestion' },
12
- create(context) {
13
- return {
14
- CallExpression(node) {
15
- const outer = node.callee;
16
- if (!isNamedMember(outer) || !isCall(outer.object)) {
17
- return;
18
- }
19
- const inner = outer.object.callee;
20
- if (!isNamedMember(inner)) {
21
- return;
22
- }
23
- if ((outer.property.name === 'optional' && inner.property.name === 'nullable') ||
24
- (outer.property.name === 'nullable' && inner.property.name === 'optional')) {
25
- context.report({
26
- node,
27
- message: 'Use .nullish() instead of chaining .nullable() and .optional().',
28
- });
29
- }
30
- },
31
- };
7
+ const preferNullish = {
8
+ meta: { type: 'suggestion' },
9
+ create(context) {
10
+ return {
11
+ CallExpression(node) {
12
+ const outer = node.callee;
13
+ if (!isNamedMember(outer) || !isCall(outer.object)) {
14
+ return;
15
+ }
16
+ const inner = outer.object.callee;
17
+ if (!isNamedMember(inner)) {
18
+ return;
19
+ }
20
+ if ((outer.property.name === 'optional' && inner.property.name === 'nullable') ||
21
+ (outer.property.name === 'nullable' && inner.property.name === 'optional')) {
22
+ context.report({
23
+ node,
24
+ message: 'Use .nullish() instead of chaining .nullable() and .optional().',
25
+ });
26
+ }
32
27
  },
33
- },
28
+ };
34
29
  },
35
30
  };
31
+ export default preferNullish;
36
32
  //# sourceMappingURL=prefer-nullish.js.map