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.
- package/CHANGELOG.md +5 -0
- package/README.md +5 -1
- package/dist/constants/preset.constants.d.ts +5 -1
- package/dist/index.js +5 -0
- package/dist/presets/index.d.ts +1 -1
- package/dist/presets/index.js +40 -2
- package/dist/presets/next-react-modules-preset.js +40 -2
- package/dist/presets/react-modules-preset.js +40 -2
- package/dist/presets/tanstack-start-react-modules-preset.js +40 -2
- package/dist/rules/dillon-anti-slop/index.js +1155 -24
- package/dist/rules/dillon-anti-slop/rules/no-module-mocking.d.ts +7 -0
- package/dist/rules/module-policy/index.js +5 -0
- package/dist/types/preset.types.d.ts +19 -0
- package/dist/utils/helpers/index.d.ts +1 -0
- package/dist/utils/helpers/mocking.d.ts +2 -0
- package/package.json +1 -1
- package/src/rules/dillon-anti-slop/UPSTREAM.md +6 -0
|
@@ -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[];
|
package/package.json
CHANGED
|
@@ -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.
|