@zgeoff/oxlint-config 0.6.1 → 0.6.3

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/README.md CHANGED
@@ -173,8 +173,17 @@ first statement, so put the comment above it:
173
173
  // oxlint-disable zgeoff/test-beside-module -- tests base.json and react.json together
174
174
  ```
175
175
 
176
- A second test file for a module (`<name>.host.test.ts`) needs its own `<name>.host.<ext>`, so the
177
- rule reports it beside only `<name>.ts`.
176
+ A lane suite, such as `<name>.browser.test.ts`, tests the same module as `<name>.test.ts` and needs
177
+ only `<name>.<ext>`; the suffix lets the repo's test script run the suite in its own lane. The rule
178
+ treats `browser` as a lane with no configuration. A repo adds its own lanes with the `lanes` option,
179
+ and `browser` stays a lane beside them:
180
+
181
+ ```json
182
+ { "rules": { "zgeoff/test-beside-module": ["error", { "lanes": ["sdk"] }] } }
183
+ ```
184
+
185
+ Any other suffix is part of the name. A second test file for a module (`<name>.host.test.ts`) needs
186
+ its own `<name>.host.<ext>`, so the rule reports it beside only `<name>.ts`.
178
187
 
179
188
  ## `zgeoff/setup-test-only`
180
189
 
@@ -182,10 +191,10 @@ A `<name>.test.ts` or `<name>.test.tsx` file declares one function, `setupTest()
182
191
  as the testing skill requires. At module level the rule allows imports, `type` and `interface`
183
192
  declarations, one `setupTest` function declaration, and statements that call `test`, `test.each`,
184
193
  `test.skipIf` or `test.if`, or a chain of them, with `test` under its local alias when the
185
- `bun:test` import renames it. It reports every other statement: a `let`, a `var`, a class, an enum,
186
- a second function, an export, and a call such as `beforeEach(...)`. The message holds the three ways
187
- out of a helper: inline it, swap it for a registered matcher, or move it to the shared test utils
188
- with tests of its own.
194
+ `bun:test` or `claude-code/testing` import renames it. It reports every other statement: a `let`, a
195
+ `var`, a class, an enum, a second function, an export, and a call such as `beforeEach(...)`. The
196
+ message holds the three ways out of a helper: inline it, swap it for a registered matcher, or move
197
+ it to the shared test utils with tests of its own.
189
198
 
190
199
  A module-level `const` passes only as a skip gate: a declarator that binds at least one name, each
191
200
  binding read, and read only at collection time, inside an argument of the test runner's `skipIf` or
@@ -334,7 +343,7 @@ that refuses an import of `to` from `from`, both paths relative to the repo root
334
343
  resolution, so `to` is the path that the rule would resolve the specifier to. The rule judges each
335
344
  edge through the same function.
336
345
 
337
- ## Notes
346
+ ## Plugins and type-aware rules
338
347
 
339
348
  - The config enables the `typescript`, `unicorn`, `oxc`, `import`, and `promise` plugins and loads
340
349
  `@stylistic/eslint-plugin` through `jsPlugins`. oxlint resolves `jsPlugins` specifiers from the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zgeoff/oxlint-config",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "description": "Shareable oxlint config: strict categories, house-style rules, and a custom JS plugin",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -60,13 +60,14 @@
60
60
  "access": "public"
61
61
  },
62
62
  "scripts": {
63
- "typecheck": "tsc"
63
+ "typecheck": "tsrs"
64
64
  },
65
65
  "dependencies": {
66
66
  "@stylistic/eslint-plugin": "5.10.0"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@types/bun": "1.4.2",
70
+ "tsrs": "0.18.0-ts7.1.0-dev.20260929",
70
71
  "typescript": "7.0.2"
71
72
  },
72
73
  "peerDependencies": {
@@ -71,7 +71,9 @@ const setupTestOnly = {
71
71
  },
72
72
  };
73
73
 
74
- // the local names that `test` from `bun:test` goes by, so an aliased import
74
+ const testModules = new Set(['bun:test', 'claude-code/testing']);
75
+
76
+ // the local names that `test` from a test module goes by, so an aliased import
75
77
  // such as `import { test as check }` counts; a file that imports no `test`
76
78
  // reads the global one, unless a module binding of its own takes the name
77
79
  function collectTestNames(context, program) {
@@ -79,7 +81,7 @@ function collectTestNames(context, program) {
79
81
  .filter(
80
82
  (statement) =>
81
83
  statement.type === 'ImportDeclaration' &&
82
- statement.source.value === 'bun:test' &&
84
+ testModules.has(statement.source.value) &&
83
85
  statement.importKind !== 'type',
84
86
  )
85
87
  .flatMap((statement) => statement.specifiers)
@@ -2,9 +2,7 @@ import { readdirSync, statSync } from 'node:fs';
2
2
  import { basename, dirname, join, relative, sep } from 'node:path';
3
3
  import resolveRepoRoot from './resolve-repo-root.js';
4
4
 
5
- // a browser suite (`<name>.browser.test.ts`) tests the same module as
6
- // `<name>.test.ts`, and the suffix lets a runner put it in its own lane
7
- const testFilePattern = /^(?<base>.+?)(?:\.browser)?\.test\.tsx?$/u;
5
+ const testFilePattern = /^(?<base>.+)\.test\.tsx?$/u;
8
6
 
9
7
  const testBesideModule = {
10
8
  meta: {
@@ -13,9 +11,19 @@ const testBesideModule = {
13
11
  missing:
14
12
  'Move this test beside the module it tests: no `{{name}}.<ext>` sits in this directory. Whole-program suites belong in a root `e2e/` or `evals/` directory.',
15
13
  },
16
- schema: [],
14
+ schema: [
15
+ {
16
+ type: 'object',
17
+ properties: {
18
+ lanes: { type: 'array', items: { type: 'string' } },
19
+ },
20
+ additionalProperties: false,
21
+ },
22
+ ],
17
23
  },
18
24
  create(context) {
25
+ const lanes = new Set(['browser', ...(context.options[0]?.lanes ?? [])]);
26
+
19
27
  return {
20
28
  Program() {
21
29
  const filename = context.physicalFilename;
@@ -25,7 +33,7 @@ const testBesideModule = {
25
33
  return;
26
34
  }
27
35
 
28
- const name = match.groups.base;
36
+ const name = toModuleName(match.groups.base, lanes);
29
37
 
30
38
  if (probeModuleSibling(dirname(filename), name)) {
31
39
  return;
@@ -58,6 +66,14 @@ function isUnderExemptRoot(cwd, filename) {
58
66
  return exemptRootDirs.has(first);
59
67
  }
60
68
 
69
+ // a lane suite (`<name>.browser.test.ts`) tests the same module as
70
+ // `<name>.test.ts`, and the suffix lets a runner put it in its own lane
71
+ function toModuleName(base, lanes) {
72
+ const dot = base.lastIndexOf('.');
73
+
74
+ return dot > 0 && lanes.has(base.slice(dot + 1)) ? base.slice(0, dot) : base;
75
+ }
76
+
61
77
  // a module is `<name>.<ext>` with a single-segment extension, so a
62
78
  // declaration file never stands in for one, and neither does another test
63
79
  // (`foo.test.ts` beside `foo.test.test.ts`)