Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
fix(experimental-utils): treat RuleTester arrays as readonly (#2601)
- Loading branch information
|
@@ -621,6 +621,9 @@ type Foo = string | { |
|
|
(acc, testCase) => { |
|
|
const indent = ' '; |
|
|
|
|
|
const validCases = [...acc.valid]; |
|
|
const invalidCases = [...acc.invalid]; |
|
|
|
|
|
const codeCases = testCase.code.map(code => |
|
|
[ |
|
|
'', // newline to make test error messages nicer |
|
@@ -631,7 +634,7 @@ type Foo = string | { |
|
|
|
|
|
codeCases.forEach(code => { |
|
|
// valid test case is just the code |
|
|
acc.valid.push(code); |
|
|
validCases.push(code); |
|
|
|
|
|
const invalid = { |
|
|
// test the fixer by removing all the spaces |
|
@@ -663,11 +666,11 @@ type Foo = string | { |
|
|
), |
|
|
}; |
|
|
if (invalid.errors.length > 0) { |
|
|
acc.invalid.push(invalid); |
|
|
invalidCases.push(invalid); |
|
|
} |
|
|
}); |
|
|
|
|
|
return acc; |
|
|
return { ...acc, valid: validCases, invalid: invalidCases }; |
|
|
}, |
|
|
{ valid: [], invalid: [] }, |
|
|
); |
|
|
|
@@ -64,7 +64,7 @@ interface InvalidTestCase< |
|
|
/** |
|
|
* Expected errors. |
|
|
*/ |
|
|
readonly errors: TestCaseError<TMessageIds>[]; |
|
|
readonly errors: readonly TestCaseError<TMessageIds>[]; |
|
|
/** |
|
|
* The expected code after autofixes are applied. If set to `null`, the test runner will assert that no autofix is suggested. |
|
|
*/ |
|
@@ -114,8 +114,8 @@ interface RunTests< |
|
|
TOptions extends Readonly<unknown[]> |
|
|
> { |
|
|
// RuleTester.run also accepts strings for valid cases |
|
|
readonly valid: (ValidTestCase<TOptions> | string)[]; |
|
|
readonly invalid: InvalidTestCase<TMessageIds, TOptions>[]; |
|
|
readonly valid: readonly (ValidTestCase<TOptions> | string)[]; |
|
|
readonly invalid: readonly InvalidTestCase<TMessageIds, TOptions>[]; |
|
|
} |
|
|
interface RuleTesterConfig { |
|
|
// should be require.resolve(parserPackageName) |
|
|