@noctcore/eslint-plugin-code-quality 0.1.0 → 0.2.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/dist/index.d.cts CHANGED
@@ -1,5 +1,57 @@
1
1
  import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
2
2
 
3
+ interface NoRealNetworkInUnitTestsOptions {
4
+ /** A file is a unit test when its path ends with one of these. */
5
+ readonly testFileSuffixes?: readonly string[];
6
+ /** A test file whose project-relative path contains one of these is an integration test and is skipped. */
7
+ readonly integrationMarkers?: readonly string[];
8
+ /** Global functions that perform network I/O when called (`fetch`, `globalThis.fetch`). */
9
+ readonly networkCallees?: readonly string[];
10
+ /** Default-imported or global HTTP clients whose request methods, and direct calls, perform network I/O. */
11
+ readonly httpClients?: readonly string[];
12
+ }
13
+
14
+ interface FakeTimersMustBeRestoredOptions {
15
+ /** Method names that install fake timers (`jest.useFakeTimers`, `vi.useFakeTimers`). */
16
+ readonly fakeTimerMethods?: readonly string[];
17
+ /** Method names that restore real timers. Any one call anywhere in the file satisfies the rule. */
18
+ readonly restoreTimerMethods?: readonly string[];
19
+ /**
20
+ * Follow relative imports whose binding this file calls (the shared-suite
21
+ * shape: `runProviderContract(subject)`) and accept a restore call found in
22
+ * that module's source.
23
+ */
24
+ readonly followImportedSuites?: boolean;
25
+ /**
26
+ * Globs matched against import specifiers. A file that imports and calls a
27
+ * binding from a matching module is trusted to have its timers restored by
28
+ * that module. Use for suites the rule cannot resolve on disk (path aliases,
29
+ * workspace packages).
30
+ */
31
+ readonly sharedSuiteModules?: readonly string[];
32
+ }
33
+
34
+ interface NoConditionalExpectOptions {
35
+ /** Treat an `expect` inside a loop body as conditional (the loop may run zero times). */
36
+ readonly checkLoops?: boolean;
37
+ }
38
+
39
+ interface NoVacuousExpectOptions {
40
+ /**
41
+ * Matchers that cannot carry a test on their own. A `not.` prefix names the
42
+ * negated form, so `not.toBeUndefined` is the same check as `toBeDefined`.
43
+ */
44
+ readonly weakMatchers?: readonly string[];
45
+ /**
46
+ * Regex sources (compiled with the `u` flag) for callees that also count as
47
+ * an assertion, so a test that pairs a weak `expect` with `assert.equal(...)`
48
+ * or a custom `expectValidUser(...)` helper is not reported. Matched against
49
+ * `name` for a bare call, `obj.name` for a member call on an identifier and
50
+ * `.name` for any other member call.
51
+ */
52
+ readonly assertionCallees?: readonly string[];
53
+ }
54
+
3
55
  interface SkippedTestsNeedTrackingOptions {
4
56
  /** Regex sources (compiled with the `u` flag) any of which satisfies the
5
57
  * tracking requirement. The default accepts a URL or `TODO(@owner)`. */
@@ -42,6 +94,18 @@ declare const rules: {
42
94
  'skipped-tests-need-tracking': _typescript_eslint_utils_ts_eslint.RuleModule<"needsTracking", [SkippedTestsNeedTrackingOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
43
95
  name: string;
44
96
  };
97
+ 'no-vacuous-expect': _typescript_eslint_utils_ts_eslint.RuleModule<"typeofExpect" | "tautologyExpect" | "soleWeakExpect", [NoVacuousExpectOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
98
+ name: string;
99
+ };
100
+ 'no-conditional-expect': _typescript_eslint_utils_ts_eslint.RuleModule<"conditionalExpect", [NoConditionalExpectOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
101
+ name: string;
102
+ };
103
+ 'fake-timers-must-be-restored': _typescript_eslint_utils_ts_eslint.RuleModule<"timersNotRestored", [FakeTimersMustBeRestoredOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
104
+ name: string;
105
+ };
106
+ 'no-real-network-in-unit-tests': _typescript_eslint_utils_ts_eslint.RuleModule<"realNetworkInUnitTest", [NoRealNetworkInUnitTestsOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
107
+ name: string;
108
+ };
45
109
  'interface-prefix-i': _typescript_eslint_utils_ts_eslint.RuleModule<"missingPrefix", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
46
110
  name: string;
47
111
  };
@@ -80,6 +144,18 @@ declare const plugin: {
80
144
  'skipped-tests-need-tracking': _typescript_eslint_utils_ts_eslint.RuleModule<"needsTracking", [SkippedTestsNeedTrackingOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
81
145
  name: string;
82
146
  };
147
+ 'no-vacuous-expect': _typescript_eslint_utils_ts_eslint.RuleModule<"typeofExpect" | "tautologyExpect" | "soleWeakExpect", [NoVacuousExpectOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
148
+ name: string;
149
+ };
150
+ 'no-conditional-expect': _typescript_eslint_utils_ts_eslint.RuleModule<"conditionalExpect", [NoConditionalExpectOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
151
+ name: string;
152
+ };
153
+ 'fake-timers-must-be-restored': _typescript_eslint_utils_ts_eslint.RuleModule<"timersNotRestored", [FakeTimersMustBeRestoredOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
154
+ name: string;
155
+ };
156
+ 'no-real-network-in-unit-tests': _typescript_eslint_utils_ts_eslint.RuleModule<"realNetworkInUnitTest", [NoRealNetworkInUnitTestsOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
157
+ name: string;
158
+ };
83
159
  'interface-prefix-i': _typescript_eslint_utils_ts_eslint.RuleModule<"missingPrefix", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
84
160
  name: string;
85
161
  };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,57 @@
1
1
  import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
2
2
 
3
+ interface NoRealNetworkInUnitTestsOptions {
4
+ /** A file is a unit test when its path ends with one of these. */
5
+ readonly testFileSuffixes?: readonly string[];
6
+ /** A test file whose project-relative path contains one of these is an integration test and is skipped. */
7
+ readonly integrationMarkers?: readonly string[];
8
+ /** Global functions that perform network I/O when called (`fetch`, `globalThis.fetch`). */
9
+ readonly networkCallees?: readonly string[];
10
+ /** Default-imported or global HTTP clients whose request methods, and direct calls, perform network I/O. */
11
+ readonly httpClients?: readonly string[];
12
+ }
13
+
14
+ interface FakeTimersMustBeRestoredOptions {
15
+ /** Method names that install fake timers (`jest.useFakeTimers`, `vi.useFakeTimers`). */
16
+ readonly fakeTimerMethods?: readonly string[];
17
+ /** Method names that restore real timers. Any one call anywhere in the file satisfies the rule. */
18
+ readonly restoreTimerMethods?: readonly string[];
19
+ /**
20
+ * Follow relative imports whose binding this file calls (the shared-suite
21
+ * shape: `runProviderContract(subject)`) and accept a restore call found in
22
+ * that module's source.
23
+ */
24
+ readonly followImportedSuites?: boolean;
25
+ /**
26
+ * Globs matched against import specifiers. A file that imports and calls a
27
+ * binding from a matching module is trusted to have its timers restored by
28
+ * that module. Use for suites the rule cannot resolve on disk (path aliases,
29
+ * workspace packages).
30
+ */
31
+ readonly sharedSuiteModules?: readonly string[];
32
+ }
33
+
34
+ interface NoConditionalExpectOptions {
35
+ /** Treat an `expect` inside a loop body as conditional (the loop may run zero times). */
36
+ readonly checkLoops?: boolean;
37
+ }
38
+
39
+ interface NoVacuousExpectOptions {
40
+ /**
41
+ * Matchers that cannot carry a test on their own. A `not.` prefix names the
42
+ * negated form, so `not.toBeUndefined` is the same check as `toBeDefined`.
43
+ */
44
+ readonly weakMatchers?: readonly string[];
45
+ /**
46
+ * Regex sources (compiled with the `u` flag) for callees that also count as
47
+ * an assertion, so a test that pairs a weak `expect` with `assert.equal(...)`
48
+ * or a custom `expectValidUser(...)` helper is not reported. Matched against
49
+ * `name` for a bare call, `obj.name` for a member call on an identifier and
50
+ * `.name` for any other member call.
51
+ */
52
+ readonly assertionCallees?: readonly string[];
53
+ }
54
+
3
55
  interface SkippedTestsNeedTrackingOptions {
4
56
  /** Regex sources (compiled with the `u` flag) any of which satisfies the
5
57
  * tracking requirement. The default accepts a URL or `TODO(@owner)`. */
@@ -42,6 +94,18 @@ declare const rules: {
42
94
  'skipped-tests-need-tracking': _typescript_eslint_utils_ts_eslint.RuleModule<"needsTracking", [SkippedTestsNeedTrackingOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
43
95
  name: string;
44
96
  };
97
+ 'no-vacuous-expect': _typescript_eslint_utils_ts_eslint.RuleModule<"typeofExpect" | "tautologyExpect" | "soleWeakExpect", [NoVacuousExpectOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
98
+ name: string;
99
+ };
100
+ 'no-conditional-expect': _typescript_eslint_utils_ts_eslint.RuleModule<"conditionalExpect", [NoConditionalExpectOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
101
+ name: string;
102
+ };
103
+ 'fake-timers-must-be-restored': _typescript_eslint_utils_ts_eslint.RuleModule<"timersNotRestored", [FakeTimersMustBeRestoredOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
104
+ name: string;
105
+ };
106
+ 'no-real-network-in-unit-tests': _typescript_eslint_utils_ts_eslint.RuleModule<"realNetworkInUnitTest", [NoRealNetworkInUnitTestsOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
107
+ name: string;
108
+ };
45
109
  'interface-prefix-i': _typescript_eslint_utils_ts_eslint.RuleModule<"missingPrefix", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
46
110
  name: string;
47
111
  };
@@ -80,6 +144,18 @@ declare const plugin: {
80
144
  'skipped-tests-need-tracking': _typescript_eslint_utils_ts_eslint.RuleModule<"needsTracking", [SkippedTestsNeedTrackingOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
81
145
  name: string;
82
146
  };
147
+ 'no-vacuous-expect': _typescript_eslint_utils_ts_eslint.RuleModule<"typeofExpect" | "tautologyExpect" | "soleWeakExpect", [NoVacuousExpectOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
148
+ name: string;
149
+ };
150
+ 'no-conditional-expect': _typescript_eslint_utils_ts_eslint.RuleModule<"conditionalExpect", [NoConditionalExpectOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
151
+ name: string;
152
+ };
153
+ 'fake-timers-must-be-restored': _typescript_eslint_utils_ts_eslint.RuleModule<"timersNotRestored", [FakeTimersMustBeRestoredOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
154
+ name: string;
155
+ };
156
+ 'no-real-network-in-unit-tests': _typescript_eslint_utils_ts_eslint.RuleModule<"realNetworkInUnitTest", [NoRealNetworkInUnitTestsOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
157
+ name: string;
158
+ };
83
159
  'interface-prefix-i': _typescript_eslint_utils_ts_eslint.RuleModule<"missingPrefix", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
84
160
  name: string;
85
161
  };