oxlint-plugin-arch 0.7.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.
@@ -1 +1,8 @@
1
+ /**
2
+ * Disallow Vitest and Jest module mocking, plus any other configured test-double APIs.
3
+ *
4
+ * Example: `vi.mock('./mailer')` fails; with `deny: ['*.spyOn']`,
5
+ * `vi.spyOn(mailer, 'send')` fails too. `checkDestructured` also catches
6
+ * `const { spyOn } = vi; spyOn(mailer, 'send')`.
7
+ */
1
8
  export declare const noModuleMockingRule: import("@oxlint/plugins").Rule;
@@ -790,6 +790,11 @@ function layoutNewline(text) {
790
790
  ` : `
791
791
  `;
792
792
  }
793
+ // src/utils/helpers/mocking.ts
794
+ function mockingApiPatternsAssert(patterns) {
795
+ if (patterns.some((pattern) => !/^(?:\*|(?:vi|jest|\*)\.(?:[A-Za-z_$][\w$]*|\*))$/.test(pattern)))
796
+ throw new Error("Test mocking APIs must be `*` or `<vi|jest|*>.<method|*>`.");
797
+ }
793
798
  // src/utils/helpers/options.ts
794
799
  function optionsFirst(context, fallback) {
795
800
  return context.options[0] ?? fallback;
@@ -70,6 +70,25 @@ export interface PresetTestsOptions {
70
70
  profile?: 'standard' | 'fixtures';
71
71
  additionalTestFunctions?: string[];
72
72
  additionalAssertionFunctions?: string[];
73
+ /** Test-double APIs banned in test files; `modules` (module mocking only) when omitted. */
74
+ mocking?: PresetTestMockingPreset | PresetTestMockingOptions;
75
+ }
76
+ export type PresetTestMockingPreset = 'modules' | 'strict';
77
+ export interface PresetTestMockingApi {
78
+ api: string;
79
+ message?: string;
80
+ }
81
+ export interface PresetTestMockingException {
82
+ files: string[];
83
+ /** API patterns allowed in these files; `*` allows every API. */
84
+ apis: string[];
85
+ }
86
+ export interface PresetTestMockingOptions {
87
+ preset?: PresetTestMockingPreset;
88
+ /** API patterns added to the preset list, such as `vi.*` or `jest.spyOn`. */
89
+ deny?: Array<string | PresetTestMockingApi>;
90
+ /** Per-file exceptions, added after the preset's own. */
91
+ allow?: PresetTestMockingException[];
73
92
  }
74
93
  export interface PresetImportsOptions {
75
94
  backendEntryPoints?: string[];
@@ -5,6 +5,7 @@ export * from './exports.ts';
5
5
  export * from './factories.ts';
6
6
  export * from './guards.ts';
7
7
  export * from './layout.ts';
8
+ export * from './mocking.ts';
8
9
  export * from './naming.ts';
9
10
  export * from './options.ts';
10
11
  export * from './orpc.ts';
@@ -0,0 +1,2 @@
1
+ /** Throws unless every pattern is `*` or `<vi|jest|*>.<method|*>`. */
2
+ export declare function mockingApiPatternsAssert(patterns: string[]): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oxlint-plugin-arch",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Configurable architecture rules for Oxlint JavaScript plugins.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -17,3 +17,9 @@ vendoring and does not publish an official npm package.
17
17
  Local behavior fixes recognize `SAFETY:` comments on exported declarations and
18
18
  export-default assertions, while retaining statement boundaries for other
19
19
  assertions. Covered by `src/tests/safety-comment.test.ts` and preset fixtures.
20
+
21
+ Local option changes let `no-module-mocking` take `deny` and `allow` API
22
+ patterns and `checkDestructured`, so the preset can also ban stubs such as
23
+ `vi.spyOn`. With no options
24
+ it reports the same calls as before. Covered by
25
+ `src/tests/no-module-mocking.test.ts` and preset tests.