@clipboard-health/oxlint-plugin 1.6.0 → 1.7.1
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 +5 -0
- package/package.json +1 -1
- package/src/index.d.ts +1 -0
- package/src/index.js +2 -0
- package/src/index.js.map +1 -1
- package/src/lib/rules/no-tests-in-contract-packages/index.d.ts +2 -0
- package/src/lib/rules/no-tests-in-contract-packages/index.js +55 -0
- package/src/lib/rules/no-tests-in-contract-packages/index.js.map +1 -0
package/README.md
CHANGED
|
@@ -16,6 +16,7 @@ ESLint.
|
|
|
16
16
|
- `no-empty-boolean-call`
|
|
17
17
|
- `no-cross-contract-imports`
|
|
18
18
|
- `no-parallel-mongo-session-ops`
|
|
19
|
+
- `no-tests-in-contract-packages`
|
|
19
20
|
- `require-contract-fixture-construction`
|
|
20
21
|
- `require-contract-response-parse`
|
|
21
22
|
- `require-http-module-factory`
|
|
@@ -32,6 +33,10 @@ apply the shared controller, module, contract, and cross-contract-import scopes.
|
|
|
32
33
|
`require-run-validators-with-upsert` are opt-in because their safe adoption scope is
|
|
33
34
|
repository-specific.
|
|
34
35
|
|
|
36
|
+
`customRules` enables `no-tests-in-contract-packages` from `@clipboard-health/oxlint-config` 3.0.0.
|
|
37
|
+
It reports only test files inside `packages/contract-*` directories, excluding
|
|
38
|
+
`packages/contract-core`.
|
|
39
|
+
|
|
35
40
|
`no-parallel-mongo-session-ops` is also opt-in. Out of the box it covers `Promise.all`,
|
|
36
41
|
`Promise.allSettled`, `Promise.race`, and `Promise.any`. Repositories with their own
|
|
37
42
|
bounded-concurrency helpers must name them, or those call sites go unchecked:
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare const rules: {
|
|
|
5
5
|
"no-empty-boolean-call": import("@oxlint/plugins").Rule;
|
|
6
6
|
"no-cross-contract-imports": import("@oxlint/plugins").Rule;
|
|
7
7
|
"no-parallel-mongo-session-ops": import("@oxlint/plugins").Rule;
|
|
8
|
+
"no-tests-in-contract-packages": import("@oxlint/plugins").Rule;
|
|
8
9
|
"require-contract-fixture-construction": import("@oxlint/plugins").Rule;
|
|
9
10
|
"require-contract-response-parse": import("@oxlint/plugins").Rule;
|
|
10
11
|
"require-http-module-factory": import("@oxlint/plugins").Rule;
|
package/src/index.js
CHANGED
|
@@ -8,6 +8,7 @@ const no_ambiguous_positional_parameters_1 = tslib_1.__importDefault(require("./
|
|
|
8
8
|
const no_cross_contract_imports_1 = tslib_1.__importDefault(require("./lib/rules/no-cross-contract-imports"));
|
|
9
9
|
const no_empty_boolean_call_1 = tslib_1.__importDefault(require("./lib/rules/no-empty-boolean-call"));
|
|
10
10
|
const no_parallel_mongo_session_ops_1 = tslib_1.__importDefault(require("./lib/rules/no-parallel-mongo-session-ops"));
|
|
11
|
+
const no_tests_in_contract_packages_1 = tslib_1.__importDefault(require("./lib/rules/no-tests-in-contract-packages"));
|
|
11
12
|
const require_contract_fixture_construction_1 = tslib_1.__importDefault(require("./lib/rules/require-contract-fixture-construction"));
|
|
12
13
|
const require_contract_response_parse_1 = tslib_1.__importDefault(require("./lib/rules/require-contract-response-parse"));
|
|
13
14
|
const require_http_module_factory_1 = tslib_1.__importDefault(require("./lib/rules/require-http-module-factory"));
|
|
@@ -20,6 +21,7 @@ exports.rules = {
|
|
|
20
21
|
"no-empty-boolean-call": no_empty_boolean_call_1.default,
|
|
21
22
|
"no-cross-contract-imports": no_cross_contract_imports_1.default,
|
|
22
23
|
"no-parallel-mongo-session-ops": no_parallel_mongo_session_ops_1.default,
|
|
24
|
+
"no-tests-in-contract-packages": no_tests_in_contract_packages_1.default,
|
|
23
25
|
"require-contract-fixture-construction": require_contract_fixture_construction_1.default,
|
|
24
26
|
"require-contract-response-parse": require_contract_response_parse_1.default,
|
|
25
27
|
"require-http-module-factory": require_http_module_factory_1.default,
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/oxlint-plugin/src/index.ts"],"names":[],"mappings":";;;;AAAA,0HAAuF;AACvF,wHAAoF;AACpF,gIAA6F;AAC7F,8GAA2E;AAC3E,sGAAmE;AACnE,sHAAkF;AAClF,sIAAmG;AACnG,0HAAuF;AACvF,kHAA+E;AAC/E,gIAA4F;AAC5F,0HAAsF;AAEzE,QAAA,KAAK,GAAG;IACnB,iCAAiC,EAAE,yCAA4B;IAC/D,gCAAgC,EAAE,wCAA0B;IAC5D,oCAAoC,EAAE,4CAA+B;IACrE,uBAAuB,EAAE,+BAAkB;IAC3C,2BAA2B,EAAE,mCAAsB;IACnD,+BAA+B,EAAE,uCAAyB;IAC1D,uCAAuC,EAAE,+CAAkC;IAC3E,iCAAiC,EAAE,yCAA4B;IAC/D,6BAA6B,EAAE,qCAAwB;IACvD,oCAAoC,EAAE,4CAA8B;IACpE,iCAAiC,EAAE,yCAA2B;CAC/D,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/oxlint-plugin/src/index.ts"],"names":[],"mappings":";;;;AAAA,0HAAuF;AACvF,wHAAoF;AACpF,gIAA6F;AAC7F,8GAA2E;AAC3E,sGAAmE;AACnE,sHAAkF;AAClF,sHAAkF;AAClF,sIAAmG;AACnG,0HAAuF;AACvF,kHAA+E;AAC/E,gIAA4F;AAC5F,0HAAsF;AAEzE,QAAA,KAAK,GAAG;IACnB,iCAAiC,EAAE,yCAA4B;IAC/D,gCAAgC,EAAE,wCAA0B;IAC5D,oCAAoC,EAAE,4CAA+B;IACrE,uBAAuB,EAAE,+BAAkB;IAC3C,2BAA2B,EAAE,mCAAsB;IACnD,+BAA+B,EAAE,uCAAyB;IAC1D,+BAA+B,EAAE,uCAAyB;IAC1D,uCAAuC,EAAE,+CAAkC;IAC3E,iCAAiC,EAAE,yCAA4B;IAC/D,6BAA6B,EAAE,qCAAwB;IACvD,oCAAoC,EAAE,4CAA8B;IACpE,iCAAiC,EAAE,yCAA2B;CAC/D,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Forbid test files in contract packages. The owning service's service tests cover
|
|
5
|
+
* contract behavior by exercising the contract through real handlers.
|
|
6
|
+
*/
|
|
7
|
+
const plugins_1 = require("@oxlint/plugins");
|
|
8
|
+
const TEST_FILE_PATTERN = /\.(?:spec|test)\.[cm]?[jt]sx?$/;
|
|
9
|
+
const CONTRACT_PACKAGE_DIRECTORY_PREFIX = "contract-";
|
|
10
|
+
// A shared schema-helper library rather than a service contract, so it owns its unit tests.
|
|
11
|
+
const SHARED_CONTRACT_PACKAGE_DIRECTORY = "contract-core";
|
|
12
|
+
/**
|
|
13
|
+
* Returns the directory name under the innermost `packages/` segment of `filename`, so a
|
|
14
|
+
* repository checked out under a directory named `packages/contract-*` doesn't mark its own
|
|
15
|
+
* workspace packages as contract packages.
|
|
16
|
+
*/
|
|
17
|
+
function workspacePackageDirectory(filename) {
|
|
18
|
+
const segments = filename.split(/[/\\]/);
|
|
19
|
+
// The last segment is the file name, so a package directory needs at least one segment after it.
|
|
20
|
+
const index = segments.findLastIndex((segment, segmentIndex) => segment === "packages" && segmentIndex < segments.length - 2);
|
|
21
|
+
return index === -1 ? undefined : segments[index + 1];
|
|
22
|
+
}
|
|
23
|
+
function isInContractPackage(filename) {
|
|
24
|
+
const directory = workspacePackageDirectory(filename);
|
|
25
|
+
return (directory !== undefined &&
|
|
26
|
+
directory.startsWith(CONTRACT_PACKAGE_DIRECTORY_PREFIX) &&
|
|
27
|
+
directory !== SHARED_CONTRACT_PACKAGE_DIRECTORY);
|
|
28
|
+
}
|
|
29
|
+
const rule = (0, plugins_1.defineRule)({
|
|
30
|
+
meta: {
|
|
31
|
+
type: "problem",
|
|
32
|
+
docs: {
|
|
33
|
+
description: "Forbid test files in contract packages; the owning service's service tests cover contract behavior",
|
|
34
|
+
url: "https://github.com/ClipboardHealth/core-utils/tree/main/packages/eslint-plugin/src/lib/rules/no-tests-in-contract-packages",
|
|
35
|
+
},
|
|
36
|
+
schema: [],
|
|
37
|
+
messages: {
|
|
38
|
+
noTestsInContractPackage: "Contract packages must not contain test files. The owning service's service tests cover contract behavior through its real handlers; move these assertions into those service tests and delete this file.",
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
create(context) {
|
|
42
|
+
// `filename` requires ESLint >=8.40; keep the fallback for older ESLint 8 hosts.
|
|
43
|
+
const filename = context.filename || context.getFilename();
|
|
44
|
+
if (!TEST_FILE_PATTERN.test(filename) || !isInContractPackage(filename)) {
|
|
45
|
+
return {};
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
Program(node) {
|
|
49
|
+
context.report({ node, messageId: "noTestsInContractPackage" });
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
exports.default = rule;
|
|
55
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/oxlint-plugin/src/lib/rules/no-tests-in-contract-packages/index.ts"],"names":[],"mappings":";;AAAA;;;GAGG;AACH,6CAA6C;AAE7C,MAAM,iBAAiB,GAAG,gCAAgC,CAAC;AAC3D,MAAM,iCAAiC,GAAG,WAAW,CAAC;AACtD,4FAA4F;AAC5F,MAAM,iCAAiC,GAAG,eAAe,CAAC;AAE1D;;;;GAIG;AACH,SAAS,yBAAyB,CAAC,QAAgB;IACjD,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACzC,iGAAiG;IACjG,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAClC,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,CAAC,OAAO,KAAK,UAAU,IAAI,YAAY,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,CACxF,C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