diff --git a/base.js b/base.js index ca0477f..91e9891 100644 --- a/base.js +++ b/base.js @@ -19,6 +19,13 @@ module.exports = { rules: { // https://typescript-eslint.io/rules/ + '@typescript-eslint/array-type': [ + 'error', + { + default: 'array-simple', + readonly: 'array-simple', + }, + ], // Too noisy for now. '@typescript-eslint/no-confusing-void-expression': 'off', // Empty interfaces are common (React component props that extend others, AdonisJS default configs). diff --git a/test/notOk.ts b/test/notOk.ts index ebafda3..5c610ff 100644 --- a/test/notOk.ts +++ b/test/notOk.ts @@ -5,3 +5,9 @@ function testX(x: number) { } testX(x!); + +function testY(y: (number | string)[]) { + return y; +} + +testY([1, 2, 3, '4']); diff --git a/test/ok.ts b/test/ok.ts index 3abcd3f..007cff6 100644 --- a/test/ok.ts +++ b/test/ok.ts @@ -7,11 +7,11 @@ export interface X { * @param x - This is a x. * @returns The best number in the world. */ -function test(x: number) { - return x + 42; +function test(x: readonly number[]) { + return x[0] + 42; } -test(1); +test([1]); /** * Logs 42. diff --git a/test/test.mjs b/test/test.mjs index 7e553e7..3fab194 100644 --- a/test/test.mjs +++ b/test/test.mjs @@ -26,6 +26,7 @@ const errors = notOkResult.messages .map((error) => error.ruleId) .sort(); assert.deepStrictEqual(errors, [ + '@typescript-eslint/array-type', '@typescript-eslint/no-non-null-assertion', '@typescript-eslint/no-unnecessary-type-assertion', ]);