@typescript-eslint/rule-tester 6.4.1-alpha.5 → 6.4.1-alpha.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typescript-eslint/rule-tester",
3
- "version": "6.4.1-alpha.5+da77e69aa",
3
+ "version": "6.4.1-alpha.7+951a3bb9e",
4
4
  "description": "Tooling to test ESLint rules",
5
5
  "files": [
6
6
  "dist",
@@ -47,8 +47,8 @@
47
47
  },
48
48
  "//": "NOTE - AJV is out-of-date, but it's intentionally synced with ESLint - https://github.com/eslint/eslint/blob/ad9dd6a933fd098a0d99c6a9aa059850535c23ee/package.json#L70",
49
49
  "dependencies": {
50
- "@typescript-eslint/typescript-estree": "6.4.1-alpha.5+da77e69aa",
51
- "@typescript-eslint/utils": "6.4.1-alpha.5+da77e69aa",
50
+ "@typescript-eslint/typescript-estree": "6.4.1-alpha.7+951a3bb9e",
51
+ "@typescript-eslint/utils": "6.4.1-alpha.7+951a3bb9e",
52
52
  "ajv": "^6.10.0",
53
53
  "lodash.merge": "4.6.2",
54
54
  "semver": "^7.5.4"
@@ -59,10 +59,10 @@
59
59
  },
60
60
  "devDependencies": {
61
61
  "@types/lodash.merge": "4.6.7",
62
- "@typescript-eslint/parser": "6.4.1-alpha.5+da77e69aa",
62
+ "@typescript-eslint/parser": "6.4.1-alpha.7+951a3bb9e",
63
63
  "chai": "^4.3.7",
64
64
  "mocha": "^10.0.0",
65
- "sinon": "^11.0.0",
65
+ "sinon": "^15.0.0",
66
66
  "source-map-support": "^0.5.21"
67
67
  },
68
68
  "funding": {
@@ -79,5 +79,5 @@
79
79
  ]
80
80
  }
81
81
  },
82
- "gitHead": "da77e69aaf36102a87a2a322fd276bb80b77233a"
82
+ "gitHead": "951a3bb9e9a3eef00729b22d981b8a779380faf7"
83
83
  }
@@ -1,46 +0,0 @@
1
- import type { AnyRuleCreateFunction, AnyRuleModule, RuleModule } from '@typescript-eslint/utils/ts-eslint';
2
- import { TestFramework } from './TestFramework';
3
- import type { InvalidTestCase, RuleTesterConfig, RunTests, ValidTestCase } from './types';
4
- export declare class RuleTester extends TestFramework {
5
- #private;
6
- /**
7
- * Creates a new instance of RuleTester.
8
- */
9
- constructor(testerConfig?: RuleTesterConfig);
10
- /**
11
- * Set the configuration to use for all future tests
12
- */
13
- static setDefaultConfig(config: RuleTesterConfig): void;
14
- /**
15
- * Get the current configuration used for all tests
16
- */
17
- static getDefaultConfig(): Readonly<RuleTesterConfig>;
18
- /**
19
- * Reset the configuration to the initial configuration of the tester removing
20
- * any changes made until now.
21
- */
22
- static resetDefaultConfig(): void;
23
- /**
24
- * Adds the `only` property to a test to run it in isolation.
25
- */
26
- static only<TOptions extends Readonly<unknown[]>>(item: ValidTestCase<TOptions> | string): ValidTestCase<TOptions>;
27
- /**
28
- * Adds the `only` property to a test to run it in isolation.
29
- */
30
- static only<TMessageIds extends string, TOptions extends Readonly<unknown[]>>(item: InvalidTestCase<TMessageIds, TOptions>): InvalidTestCase<TMessageIds, TOptions>;
31
- /**
32
- * Define a rule for one particular run of tests.
33
- */
34
- defineRule(name: string, rule: AnyRuleCreateFunction | AnyRuleModule): void;
35
- /**
36
- * Adds a new rule test to execute.
37
- */
38
- run<TMessageIds extends string, TOptions extends readonly unknown[]>(ruleName: string, rule: RuleModule<TMessageIds, TOptions>, test: RunTests<TMessageIds, TOptions>): void;
39
- /**
40
- * Run the rule for the given item
41
- * @throws {Error} If an invalid schema.
42
- * Use @private instead of #private to expose it for testing purposes
43
- */
44
- private runRuleForItem;
45
- }
46
- //# sourceMappingURL=RuleTester.d.ts.map
@@ -1,66 +0,0 @@
1
- /**
2
- * @param text a string describing the rule
3
- * @param callback the test callback
4
- */
5
- export type RuleTesterTestFrameworkFunctionBase = (text: string, callback: () => void) => void;
6
- export type RuleTesterTestFrameworkFunction = RuleTesterTestFrameworkFunctionBase & {
7
- /**
8
- * Skips running the tests inside this `describe` for the current file
9
- */
10
- skip?: RuleTesterTestFrameworkFunctionBase;
11
- };
12
- export type RuleTesterTestFrameworkItFunction = RuleTesterTestFrameworkFunctionBase & {
13
- /**
14
- * Only runs this test in the current file.
15
- */
16
- only?: RuleTesterTestFrameworkFunctionBase;
17
- /**
18
- * Skips running this test in the current file.
19
- */
20
- skip?: RuleTesterTestFrameworkFunctionBase;
21
- };
22
- type Maybe<T> = T | null | undefined;
23
- /**
24
- * @param fn a callback called after all the tests are done
25
- */
26
- type AfterAll = (fn: () => void) => void;
27
- /**
28
- * Defines a test framework used by the rule tester
29
- * This class defaults to using functions defined on the global scope, but also
30
- * allows the user to manually supply functions in case they want to roll their
31
- * own tooling
32
- */
33
- export declare abstract class TestFramework {
34
- /**
35
- * Runs a function after all the tests in this file have completed.
36
- */
37
- static get afterAll(): AfterAll;
38
- static set afterAll(value: Maybe<AfterAll>);
39
- /**
40
- * Creates a test grouping
41
- */
42
- static get describe(): RuleTesterTestFrameworkFunction;
43
- static set describe(value: Maybe<RuleTesterTestFrameworkFunction>);
44
- /**
45
- * Skips running the tests inside this `describe` for the current file
46
- */
47
- static get describeSkip(): RuleTesterTestFrameworkFunctionBase;
48
- static set describeSkip(value: Maybe<RuleTesterTestFrameworkFunctionBase>);
49
- /**
50
- * Creates a test closure
51
- */
52
- static get it(): RuleTesterTestFrameworkItFunction;
53
- static set it(value: Maybe<RuleTesterTestFrameworkItFunction>);
54
- /**
55
- * Only runs this test in the current file.
56
- */
57
- static get itOnly(): RuleTesterTestFrameworkFunctionBase;
58
- static set itOnly(value: Maybe<RuleTesterTestFrameworkFunctionBase>);
59
- /**
60
- * Skips running this test in the current file.
61
- */
62
- static get itSkip(): RuleTesterTestFrameworkFunctionBase;
63
- static set itSkip(value: Maybe<RuleTesterTestFrameworkFunctionBase>);
64
- }
65
- export {};
66
- //# sourceMappingURL=TestFramework.d.ts.map
@@ -1,5 +0,0 @@
1
- export { RuleTester } from './RuleTester';
2
- export { noFormat } from './noFormat';
3
- export type { InvalidTestCase, RuleTesterConfig, RunTests, SuggestionOutput, TestCaseError, ValidTestCase, } from './types';
4
- export type { AtLeastVersionConstraint, DependencyConstraint, SemverVersionConstraint, VersionConstraint, } from './types/DependencyConstraint';
5
- //# sourceMappingURL=index.d.ts.map
@@ -1,6 +0,0 @@
1
- /**
2
- * Simple no-op tag to mark code samples as "should not format with prettier"
3
- * for the plugin-test-formatting lint rule
4
- */
5
- export declare function noFormat(raw: TemplateStringsArray, ...keys: string[]): string;
6
- //# sourceMappingURL=noFormat.d.ts.map
@@ -1,12 +0,0 @@
1
- import type { RangeOptions } from 'semver';
2
- export interface SemverVersionConstraint {
3
- readonly range: string;
4
- readonly options?: RangeOptions | boolean;
5
- }
6
- export type AtLeastVersionConstraint = `${number}.${number}.${number}-${string}` | `${number}.${number}.${number}` | `${number}.${number}` | `${number}`;
7
- export type VersionConstraint = AtLeastVersionConstraint | SemverVersionConstraint;
8
- /**
9
- * Passing a string for the value is shorthand for a '>=' constraint
10
- */
11
- export type DependencyConstraint = Readonly<Record<string, VersionConstraint>>;
12
- //# sourceMappingURL=DependencyConstraint.d.ts.map
@@ -1,68 +0,0 @@
1
- import type { AST_NODE_TYPES, AST_TOKEN_TYPES } from '@typescript-eslint/utils';
2
- import type { ReportDescriptorMessageData } from '@typescript-eslint/utils/ts-eslint';
3
- import type { DependencyConstraint } from './DependencyConstraint';
4
- import type { ValidTestCase } from './ValidTestCase';
5
- export interface SuggestionOutput<TMessageIds extends string> {
6
- /**
7
- * Reported message ID.
8
- */
9
- readonly messageId: TMessageIds;
10
- /**
11
- * The data used to fill the message template.
12
- */
13
- readonly data?: ReportDescriptorMessageData;
14
- /**
15
- * NOTE: Suggestions will be applied as a stand-alone change, without triggering multi-pass fixes.
16
- * Each individual error has its own suggestion, so you have to show the correct, _isolated_ output for each suggestion.
17
- */
18
- readonly output: string;
19
- }
20
- export interface TestCaseError<TMessageIds extends string> {
21
- /**
22
- * The 1-based column number of the reported start location.
23
- */
24
- readonly column?: number;
25
- /**
26
- * The data used to fill the message template.
27
- */
28
- readonly data?: ReportDescriptorMessageData;
29
- /**
30
- * The 1-based column number of the reported end location.
31
- */
32
- readonly endColumn?: number;
33
- /**
34
- * The 1-based line number of the reported end location.
35
- */
36
- readonly endLine?: number;
37
- /**
38
- * The 1-based line number of the reported start location.
39
- */
40
- readonly line?: number;
41
- /**
42
- * Reported message ID.
43
- */
44
- readonly messageId: TMessageIds;
45
- /**
46
- * Reported suggestions.
47
- */
48
- readonly suggestions?: readonly SuggestionOutput<TMessageIds>[] | null;
49
- /**
50
- * The type of the reported AST node.
51
- */
52
- readonly type?: AST_NODE_TYPES | AST_TOKEN_TYPES;
53
- }
54
- export interface InvalidTestCase<TMessageIds extends string, TOptions extends Readonly<unknown[]>> extends ValidTestCase<TOptions> {
55
- /**
56
- * Expected errors.
57
- */
58
- readonly errors: readonly TestCaseError<TMessageIds>[];
59
- /**
60
- * The expected code after autofixes are applied. If set to `null`, the test runner will assert that no autofix is suggested.
61
- */
62
- readonly output?: string | null;
63
- /**
64
- * Constraints that must pass in the current environment for the test to run
65
- */
66
- readonly dependencyConstraints?: DependencyConstraint;
67
- }
68
- //# sourceMappingURL=InvalidTestCase.d.ts.map
@@ -1,26 +0,0 @@
1
- import type { Linter, ParserOptions } from '@typescript-eslint/utils/ts-eslint';
2
- import type { DependencyConstraint } from './DependencyConstraint';
3
- export interface RuleTesterConfig extends Linter.Config {
4
- /**
5
- * The default parser to use for tests.
6
- * @default '@typescript-eslint/parser'
7
- */
8
- readonly parser: string;
9
- /**
10
- * The default parser options to use for tests.
11
- */
12
- readonly parserOptions?: Readonly<ParserOptions>;
13
- /**
14
- * Constraints that must pass in the current environment for any tests to run.
15
- */
16
- readonly dependencyConstraints?: DependencyConstraint;
17
- /**
18
- * The default filenames to use for type-aware tests.
19
- * @default { ts: 'file.ts', tsx: 'react.tsx' }
20
- */
21
- readonly defaultFilenames?: Readonly<{
22
- ts: string;
23
- tsx: string;
24
- }>;
25
- }
26
- //# sourceMappingURL=RuleTesterConfig.d.ts.map
@@ -1,53 +0,0 @@
1
- import type { ParserOptions, SharedConfigurationSettings } from '@typescript-eslint/utils/ts-eslint';
2
- import type { DependencyConstraint } from './DependencyConstraint';
3
- export interface ValidTestCase<TOptions extends Readonly<unknown[]>> {
4
- /**
5
- * Name for the test case.
6
- */
7
- readonly name?: string;
8
- /**
9
- * Code for the test case.
10
- */
11
- readonly code: string;
12
- /**
13
- * Environments for the test case.
14
- */
15
- readonly env?: Readonly<Record<string, boolean>>;
16
- /**
17
- * The fake filename for the test case. Useful for rules that make assertion about filenames.
18
- */
19
- readonly filename?: string;
20
- /**
21
- * The additional global variables.
22
- */
23
- readonly globals?: Record<string, 'off' | 'readonly' | 'writable' | true>;
24
- /**
25
- * Options for the test case.
26
- */
27
- readonly options?: Readonly<TOptions>;
28
- /**
29
- * The absolute path for the parser.
30
- */
31
- readonly parser?: string;
32
- /**
33
- * Options for the parser.
34
- */
35
- readonly parserOptions?: Readonly<ParserOptions>;
36
- /**
37
- * Settings for the test case.
38
- */
39
- readonly settings?: Readonly<SharedConfigurationSettings>;
40
- /**
41
- * Run this case exclusively for debugging in supported test frameworks.
42
- */
43
- readonly only?: boolean;
44
- /**
45
- * Skip this case in supported test frameworks.
46
- */
47
- readonly skip?: boolean;
48
- /**
49
- * Constraints that must pass in the current environment for the test to run
50
- */
51
- readonly dependencyConstraints?: DependencyConstraint;
52
- }
53
- //# sourceMappingURL=ValidTestCase.d.ts.map
@@ -1,19 +0,0 @@
1
- import type { InvalidTestCase } from './InvalidTestCase';
2
- import type { RuleTesterConfig } from './RuleTesterConfig';
3
- import type { ValidTestCase } from './ValidTestCase';
4
- type Mutable<T> = {
5
- -readonly [P in keyof T]: T[P];
6
- };
7
- export type TesterConfigWithDefaults = Mutable<Required<Pick<RuleTesterConfig, 'defaultFilenames' | 'parser' | 'rules'>> & RuleTesterConfig>;
8
- export interface RunTests<TMessageIds extends string, TOptions extends Readonly<unknown[]>> {
9
- readonly valid: readonly (ValidTestCase<TOptions> | string)[];
10
- readonly invalid: readonly InvalidTestCase<TMessageIds, TOptions>[];
11
- }
12
- export interface NormalizedRunTests<TMessageIds extends string, TOptions extends Readonly<unknown[]>> {
13
- readonly valid: readonly ValidTestCase<TOptions>[];
14
- readonly invalid: readonly InvalidTestCase<TMessageIds, TOptions>[];
15
- }
16
- export type { ValidTestCase } from './ValidTestCase';
17
- export type { InvalidTestCase, SuggestionOutput, TestCaseError, } from './InvalidTestCase';
18
- export type { RuleTesterConfig } from './RuleTesterConfig';
19
- //# sourceMappingURL=index.d.ts.map
@@ -1,16 +0,0 @@
1
- import type { Linter } from '@typescript-eslint/utils/ts-eslint';
2
- type LintMessage = Linter.LintMessage | Linter.LintSuggestion;
3
- /**
4
- * Applies the fixes specified by the messages to the given text. Tries to be
5
- * smart about the fixes and won't apply fixes over the same area in the text.
6
- * @param sourceText The text to apply the changes to.
7
- * @param messages The array of messages reported by ESLint.
8
- * @returns {Object} An object containing the fixed text and any unfixed messages.
9
- */
10
- export declare function applyFixes(sourceText: string, messages: readonly LintMessage[]): {
11
- fixed: boolean;
12
- messages: readonly LintMessage[];
13
- output: string;
14
- };
15
- export {};
16
- //# sourceMappingURL=SourceCodeFixer.d.ts.map
@@ -1,3 +0,0 @@
1
- import Ajv from 'ajv';
2
- export declare function ajvBuilder(additionalOptions?: {}): Ajv.Ajv;
3
- //# sourceMappingURL=ajv.d.ts.map
@@ -1,6 +0,0 @@
1
- /**
2
- * Clones a given value deeply.
3
- * Note: This ignores `parent` property.
4
- */
5
- export declare function cloneDeeplyExcludesParent<T>(x: T): T;
6
- //# sourceMappingURL=cloneDeeplyExcludesParent.d.ts.map
@@ -1,3 +0,0 @@
1
- import type { JSONSchema4 } from '@typescript-eslint/utils/json-schema';
2
- export declare const configSchema: JSONSchema4;
3
- //# sourceMappingURL=config-schema.d.ts.map
@@ -1,12 +0,0 @@
1
- import type { AnyRuleModule } from '@typescript-eslint/utils/ts-eslint';
2
- import type { TesterConfigWithDefaults } from '../types';
3
- type GetAdditionalRule = (ruleId: string) => AnyRuleModule | null;
4
- /**
5
- * Validates an entire config object.
6
- * @param config The config object to validate.
7
- * @param source The name of the configuration source to report in any errors.
8
- * @param getAdditionalRule A map from strings to loaded rules.
9
- */
10
- export declare function validate(config: TesterConfigWithDefaults, source: string, getAdditionalRule: GetAdditionalRule): void;
11
- export {};
12
- //# sourceMappingURL=config-validator.d.ts.map
@@ -1,3 +0,0 @@
1
- import type { DependencyConstraint } from '../types/DependencyConstraint';
2
- export declare function satisfiesAllDependencyConstraints(dependencyConstraints: DependencyConstraint | undefined): boolean;
3
- //# sourceMappingURL=dependencyConstraints.d.ts.map
@@ -1,13 +0,0 @@
1
- declare const deprecationWarningMessages: {
2
- readonly ESLINT_LEGACY_ECMAFEATURES: "The 'ecmaFeatures' config file property is deprecated and has no effect.";
3
- };
4
- /**
5
- * Emits a deprecation warning containing a given filepath. A new deprecation warning is emitted
6
- * for each unique file path, but repeated invocations with the same file path have no effect.
7
- * No warnings are emitted if the `--no-deprecation` or `--no-warnings` Node runtime flags are active.
8
- * @param source The name of the configuration source to report the warning for.
9
- * @param errorCode The warning message to show.
10
- */
11
- export declare function emitDeprecationWarning(source: string, errorCode: keyof typeof deprecationWarningMessages): void;
12
- export {};
13
- //# sourceMappingURL=deprecation-warnings.d.ts.map
@@ -1,5 +0,0 @@
1
- /**
2
- * Freezes a given value deeply.
3
- */
4
- export declare function freezeDeeply(x: unknown): void;
5
- //# sourceMappingURL=freezeDeeply.d.ts.map
@@ -1,9 +0,0 @@
1
- import type { JSONSchema4 } from '@typescript-eslint/utils/json-schema';
2
- import type { AnyRuleModule } from '@typescript-eslint/utils/ts-eslint';
3
- /**
4
- * Gets a complete options schema for a rule.
5
- * @param rule A new-style rule object
6
- * @returns JSON Schema for the rule's options.
7
- */
8
- export declare function getRuleOptionsSchema(rule: AnyRuleModule): JSONSchema4 | null;
9
- //# sourceMappingURL=getRuleOptionsSchema.d.ts.map
@@ -1,4 +0,0 @@
1
- export declare const hasOwnProperty: <TObj extends object, TK extends keyof TObj>(obj: TObj, key: TK) => obj is TObj & {
2
- [key in TK]-?: TObj[key];
3
- };
4
- //# sourceMappingURL=hasOwnProperty.d.ts.map
@@ -1,3 +0,0 @@
1
- import type { ReportDescriptorMessageData } from '@typescript-eslint/utils/ts-eslint';
2
- export declare function interpolate(text: string, data: ReportDescriptorMessageData): string;
3
- //# sourceMappingURL=interpolate.d.ts.map
@@ -1,2 +0,0 @@
1
- export declare function isReadonlyArray(arg: unknown): arg is readonly unknown[];
2
- //# sourceMappingURL=isReadonlyArray.d.ts.map
@@ -1,43 +0,0 @@
1
- import type { Linter } from '@typescript-eslint/utils/ts-eslint';
2
- export declare const RULE_TESTER_PARAMETERS: readonly [
3
- "code",
4
- "defaultFilenames",
5
- "dependencyConstraints",
6
- "errors",
7
- "filename",
8
- "name",
9
- "only",
10
- "options",
11
- "output",
12
- "skip"
13
- ];
14
- export declare const ERROR_OBJECT_PARAMETERS: ReadonlySet<string>;
15
- export declare const FRIENDLY_ERROR_OBJECT_PARAMETER_LIST: string;
16
- export declare const SUGGESTION_OBJECT_PARAMETERS: ReadonlySet<string>;
17
- export declare const FRIENDLY_SUGGESTION_OBJECT_PARAMETER_LIST: string;
18
- /**
19
- * Replace control characters by `\u00xx` form.
20
- */
21
- export declare function sanitize(text: string): string;
22
- /**
23
- * Wraps the given parser in order to intercept and modify return values from the `parse` and `parseForESLint` methods, for test purposes.
24
- * In particular, to modify ast nodes, tokens and comments to throw on access to their `start` and `end` properties.
25
- */
26
- export declare function wrapParser(parser: Linter.ParserModule): Linter.ParserModule;
27
- /**
28
- * Function to replace `SourceCode.prototype.getComments`.
29
- */
30
- export declare function getCommentsDeprecation(): never;
31
- /**
32
- * Emit a deprecation warning if function-style format is being used.
33
- */
34
- export declare function emitLegacyRuleAPIWarning(ruleName: string): void;
35
- /**
36
- * Emit a deprecation warning if rule has options but is missing the "meta.schema" property
37
- */
38
- export declare function emitMissingSchemaWarning(ruleName: string): void;
39
- export declare const REQUIRED_SCENARIOS: readonly [
40
- "valid",
41
- "invalid"
42
- ];
43
- //# sourceMappingURL=validationHelpers.d.ts.map