Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: add JSDoc types for RuleTester test cases #12325

Merged
merged 9 commits into from Jan 3, 2020
40 changes: 39 additions & 1 deletion lib/rule-tester/rule-tester.js
Expand Up @@ -272,11 +272,49 @@ class RuleTester {
this.rules[name] = rule;
}

/**
golopot marked this conversation as resolved.
Show resolved Hide resolved
* @typedef {{
* code: string,
* options?: any,
golopot marked this conversation as resolved.
Show resolved Hide resolved
* filename?: string,
* parserOptions?: Linter.ParserOptions,
golopot marked this conversation as resolved.
Show resolved Hide resolved
* settings?: { [name: string]: any },
* parser?: string,
* globals?: { [name: string]: boolean }
mysticatea marked this conversation as resolved.
Show resolved Hide resolved
* }} ValidTestCase
*
* @typedef {{
* code: string,
* errors: number | Array<TestCaseError | string>,
* output?: string | null,
* options?: any,
golopot marked this conversation as resolved.
Show resolved Hide resolved
* filename?: string,
* parserOptions?: Linter.ParserOptions,
golopot marked this conversation as resolved.
Show resolved Hide resolved
* settings?: { [name: string]: any },
* parser?: string,
* globals?: { [name: string]: boolean }
mysticatea marked this conversation as resolved.
Show resolved Hide resolved
* }} InvalidTestCase
*
* @typedef {{
* message?: string | RegExp,
* messageId?: string,
* type?: string,
* data?: any,
golopot marked this conversation as resolved.
Show resolved Hide resolved
* line?: number,
* column?: number,
* endLine?: number,
* endColumn?: number,
* }} TestCaseError
*/

/**
* Adds a new rule test to execute.
* @param {string} ruleName The name of the rule to run.
* @param {Function} rule The rule to test.
* @param {Object} test The collection of tests to run.
* @param {{
* valid: (ValidTestCase | string)[],
* invalid: InvalidTestCase[]
* }} test The collection of tests to run.
* @returns {void}
*/
run(ruleName, rule, test) {
Expand Down