From 356a307104270f1bddd209a6d288f658197eb187 Mon Sep 17 00:00:00 2001 From: koooge Date: Thu, 28 Oct 2021 23:57:31 +0200 Subject: [PATCH 1/2] feat(eslint-plugin): distinguish whether readonly or not Signed-off-by: koooge --- .../eslint-plugin/src/rules/array-type.ts | 32 +++++++++--- .../tests/rules/array-type.test.ts | 50 +++++++++---------- 2 files changed, 51 insertions(+), 31 deletions(-) diff --git a/packages/eslint-plugin/src/rules/array-type.ts b/packages/eslint-plugin/src/rules/array-type.ts index da2bfdef518..dfa0f2161ad 100644 --- a/packages/eslint-plugin/src/rules/array-type.ts +++ b/packages/eslint-plugin/src/rules/array-type.ts @@ -80,9 +80,13 @@ type Options = [ ]; type MessageIds = | 'errorStringGeneric' - | 'errorStringGenericSimple' + | 'errorStringReadonlyGeneric' | 'errorStringArray' - | 'errorStringArraySimple'; + | 'errorStringReadonlyArray' + | 'errorStringArraySimple' + | 'errorStringGenericSimple' + | 'errorStringReadonlyArraySimple' + | 'errorStringReadonlyGenericSimple'; const arrayOption = { enum: ['array', 'generic', 'array-simple'] }; @@ -99,12 +103,20 @@ export default util.createRule({ messages: { errorStringGeneric: "Array type using '{{type}}[]' is forbidden. Use 'Array<{{type}}>' instead.", - errorStringGenericSimple: - "Array type using '{{type}}[]' is forbidden for non-simple types. Use 'Array<{{type}}>' instead.", + errorStringReadonlyGeneric: + "Array type using 'readonly {{type}}[]' is forbidden. Use 'ReadonlyArray<{{type}}>' instead.", errorStringArray: "Array type using 'Array<{{type}}>' is forbidden. Use '{{type}}[]' instead.", + errorStringReadonlyArray: + "Array type using 'ReadonlyArray<{{type}}>' is forbidden. Use 'readonly {{type}}[]' instead.", errorStringArraySimple: "Array type using 'Array<{{type}}>' is forbidden for simple types. Use '{{type}}[]' instead.", + errorStringReadonlyArraySimple: + "Array type using 'ReadonlyArray<{{type}}>' is forbidden for simple types. Use 'readonly {{type}}[]' instead.", + errorStringGenericSimple: + "Array type using '{{type}}[]' is forbidden for non-simple types. Use 'Array<{{type}}>' instead.", + errorStringReadonlyGenericSimple: + "Array type using 'readonly {{type}}[]' is forbidden for non-simple types. Use 'ReadonlyArray<{{type}}>' instead.", }, schema: [ { @@ -155,7 +167,11 @@ export default util.createRule({ const messageId = currentOption === 'generic' - ? 'errorStringGeneric' + ? isReadonly + ? 'errorStringReadonlyGeneric' + : 'errorStringGeneric' + : isReadonly + ? 'errorStringReadonlyGenericSimple' : 'errorStringGenericSimple'; const errorNode = isReadonly ? node.parent! : node; @@ -207,7 +223,11 @@ export default util.createRule({ const typeParams = node.typeParameters?.params; const messageId = currentOption === 'array' - ? 'errorStringArray' + ? isReadonlyArrayType + ? 'errorStringReadonlyArray' + : 'errorStringArray' + : isReadonlyArrayType + ? 'errorStringReadonlyArraySimple' : 'errorStringArraySimple'; if (!typeParams || typeParams.length === 0) { diff --git a/packages/eslint-plugin/tests/rules/array-type.test.ts b/packages/eslint-plugin/tests/rules/array-type.test.ts index 3c2c1893a3f..27db3546f0a 100644 --- a/packages/eslint-plugin/tests/rules/array-type.test.ts +++ b/packages/eslint-plugin/tests/rules/array-type.test.ts @@ -400,7 +400,7 @@ function bazFunction(baz: Arr>) { options: [{ default: 'array' }], errors: [ { - messageId: 'errorStringArray', + messageId: 'errorStringReadonlyArray', data: { type: 'number' }, line: 1, column: 8, @@ -413,7 +413,7 @@ function bazFunction(baz: Arr>) { options: [{ default: 'array' }], errors: [ { - messageId: 'errorStringArray', + messageId: 'errorStringReadonlyArray', data: { type: 'T' }, line: 1, column: 8, @@ -452,7 +452,7 @@ function bazFunction(baz: Arr>) { options: [{ default: 'array', readonly: 'array' }], errors: [ { - messageId: 'errorStringArray', + messageId: 'errorStringReadonlyArray', data: { type: 'number' }, line: 1, column: 8, @@ -465,7 +465,7 @@ function bazFunction(baz: Arr>) { options: [{ default: 'array', readonly: 'array' }], errors: [ { - messageId: 'errorStringArray', + messageId: 'errorStringReadonlyArray', data: { type: 'T' }, line: 1, column: 8, @@ -504,7 +504,7 @@ function bazFunction(baz: Arr>) { options: [{ default: 'array', readonly: 'array-simple' }], errors: [ { - messageId: 'errorStringArraySimple', + messageId: 'errorStringReadonlyArraySimple', data: { type: 'number' }, line: 1, column: 8, @@ -517,7 +517,7 @@ function bazFunction(baz: Arr>) { options: [{ default: 'array', readonly: 'array-simple' }], errors: [ { - messageId: 'errorStringGenericSimple', + messageId: 'errorStringReadonlyGenericSimple', data: { type: 'T' }, line: 1, column: 8, @@ -556,7 +556,7 @@ function bazFunction(baz: Arr>) { options: [{ default: 'array', readonly: 'generic' }], errors: [ { - messageId: 'errorStringGeneric', + messageId: 'errorStringReadonlyGeneric', data: { type: 'number' }, line: 1, column: 8, @@ -569,7 +569,7 @@ function bazFunction(baz: Arr>) { options: [{ default: 'array', readonly: 'generic' }], errors: [ { - messageId: 'errorStringGeneric', + messageId: 'errorStringReadonlyGeneric', data: { type: 'T' }, line: 1, column: 8, @@ -608,7 +608,7 @@ function bazFunction(baz: Arr>) { options: [{ default: 'array-simple' }], errors: [ { - messageId: 'errorStringArraySimple', + messageId: 'errorStringReadonlyArraySimple', data: { type: 'number' }, line: 1, column: 8, @@ -621,7 +621,7 @@ function bazFunction(baz: Arr>) { options: [{ default: 'array-simple' }], errors: [ { - messageId: 'errorStringGenericSimple', + messageId: 'errorStringReadonlyGenericSimple', data: { type: 'T' }, line: 1, column: 8, @@ -660,7 +660,7 @@ function bazFunction(baz: Arr>) { options: [{ default: 'array-simple', readonly: 'array' }], errors: [ { - messageId: 'errorStringArray', + messageId: 'errorStringReadonlyArray', data: { type: 'number' }, line: 1, column: 8, @@ -673,7 +673,7 @@ function bazFunction(baz: Arr>) { options: [{ default: 'array-simple', readonly: 'array' }], errors: [ { - messageId: 'errorStringArray', + messageId: 'errorStringReadonlyArray', data: { type: 'T' }, line: 1, column: 8, @@ -712,7 +712,7 @@ function bazFunction(baz: Arr>) { options: [{ default: 'array-simple', readonly: 'array-simple' }], errors: [ { - messageId: 'errorStringArraySimple', + messageId: 'errorStringReadonlyArraySimple', data: { type: 'number' }, line: 1, column: 8, @@ -725,7 +725,7 @@ function bazFunction(baz: Arr>) { options: [{ default: 'array-simple', readonly: 'array-simple' }], errors: [ { - messageId: 'errorStringGenericSimple', + messageId: 'errorStringReadonlyGenericSimple', data: { type: 'T' }, line: 1, column: 8, @@ -764,7 +764,7 @@ function bazFunction(baz: Arr>) { options: [{ default: 'array-simple', readonly: 'generic' }], errors: [ { - messageId: 'errorStringGeneric', + messageId: 'errorStringReadonlyGeneric', data: { type: 'number' }, line: 1, column: 8, @@ -777,7 +777,7 @@ function bazFunction(baz: Arr>) { options: [{ default: 'array-simple', readonly: 'generic' }], errors: [ { - messageId: 'errorStringGeneric', + messageId: 'errorStringReadonlyGeneric', data: { type: 'T' }, line: 1, column: 8, @@ -816,7 +816,7 @@ function bazFunction(baz: Arr>) { options: [{ default: 'generic' }], errors: [ { - messageId: 'errorStringGeneric', + messageId: 'errorStringReadonlyGeneric', data: { type: 'number' }, line: 1, column: 8, @@ -829,7 +829,7 @@ function bazFunction(baz: Arr>) { options: [{ default: 'generic' }], errors: [ { - messageId: 'errorStringGeneric', + messageId: 'errorStringReadonlyGeneric', data: { type: 'T' }, line: 1, column: 8, @@ -868,7 +868,7 @@ function bazFunction(baz: Arr>) { options: [{ default: 'generic', readonly: 'array' }], errors: [ { - messageId: 'errorStringArray', + messageId: 'errorStringReadonlyArray', data: { type: 'number' }, line: 1, column: 8, @@ -881,7 +881,7 @@ function bazFunction(baz: Arr>) { options: [{ default: 'generic', readonly: 'array' }], errors: [ { - messageId: 'errorStringArray', + messageId: 'errorStringReadonlyArray', data: { type: 'T' }, line: 1, column: 8, @@ -920,7 +920,7 @@ function bazFunction(baz: Arr>) { options: [{ default: 'generic', readonly: 'array-simple' }], errors: [ { - messageId: 'errorStringArraySimple', + messageId: 'errorStringReadonlyArraySimple', data: { type: 'number' }, line: 1, column: 8, @@ -933,7 +933,7 @@ function bazFunction(baz: Arr>) { options: [{ default: 'generic', readonly: 'array-simple' }], errors: [ { - messageId: 'errorStringGenericSimple', + messageId: 'errorStringReadonlyGenericSimple', data: { type: 'T' }, line: 1, column: 8, @@ -972,7 +972,7 @@ function bazFunction(baz: Arr>) { options: [{ default: 'generic', readonly: 'generic' }], errors: [ { - messageId: 'errorStringGeneric', + messageId: 'errorStringReadonlyGeneric', data: { type: 'number' }, line: 1, column: 8, @@ -985,7 +985,7 @@ function bazFunction(baz: Arr>) { options: [{ default: 'generic', readonly: 'generic' }], errors: [ { - messageId: 'errorStringGeneric', + messageId: 'errorStringReadonlyGeneric', data: { type: 'T' }, line: 1, column: 8, @@ -1654,7 +1654,7 @@ interface FooInterface { options: [{ default: 'array' }], errors: [ { - messageId: 'errorStringArray', + messageId: 'errorStringReadonlyArray', data: { type: 'object' }, line: 1, column: 12, From 4c7aaf9d7b8cbf336822c263f52d5e3f4909ed83 Mon Sep 17 00:00:00 2001 From: koooge Date: Mon, 1 Nov 2021 13:02:04 +0100 Subject: [PATCH 2/2] refactor: template messages Signed-off-by: koooge --- .../eslint-plugin/src/rules/array-type.ts | 40 +-- .../tests/rules/array-type.test.ts | 338 ++++++++++++------ 2 files changed, 234 insertions(+), 144 deletions(-) diff --git a/packages/eslint-plugin/src/rules/array-type.ts b/packages/eslint-plugin/src/rules/array-type.ts index dfa0f2161ad..35045fdd985 100644 --- a/packages/eslint-plugin/src/rules/array-type.ts +++ b/packages/eslint-plugin/src/rules/array-type.ts @@ -80,13 +80,9 @@ type Options = [ ]; type MessageIds = | 'errorStringGeneric' - | 'errorStringReadonlyGeneric' | 'errorStringArray' - | 'errorStringReadonlyArray' | 'errorStringArraySimple' - | 'errorStringGenericSimple' - | 'errorStringReadonlyArraySimple' - | 'errorStringReadonlyGenericSimple'; + | 'errorStringGenericSimple'; const arrayOption = { enum: ['array', 'generic', 'array-simple'] }; @@ -102,21 +98,13 @@ export default util.createRule({ fixable: 'code', messages: { errorStringGeneric: - "Array type using '{{type}}[]' is forbidden. Use 'Array<{{type}}>' instead.", - errorStringReadonlyGeneric: - "Array type using 'readonly {{type}}[]' is forbidden. Use 'ReadonlyArray<{{type}}>' instead.", + "Array type using '{{readonlyPrefix}}{{type}}[]' is forbidden. Use '{{className}}<{{type}}>' instead.", errorStringArray: - "Array type using 'Array<{{type}}>' is forbidden. Use '{{type}}[]' instead.", - errorStringReadonlyArray: - "Array type using 'ReadonlyArray<{{type}}>' is forbidden. Use 'readonly {{type}}[]' instead.", + "Array type using '{{className}}<{{type}}>' is forbidden. Use '{{readonlyPrefix}}{{type}}[]' instead.", errorStringArraySimple: - "Array type using 'Array<{{type}}>' is forbidden for simple types. Use '{{type}}[]' instead.", - errorStringReadonlyArraySimple: - "Array type using 'ReadonlyArray<{{type}}>' is forbidden for simple types. Use 'readonly {{type}}[]' instead.", + "Array type using '{{className}}<{{type}}>' is forbidden for simple types. Use '{{readonlyPrefix}}{{type}}[]' instead.", errorStringGenericSimple: - "Array type using '{{type}}[]' is forbidden for non-simple types. Use 'Array<{{type}}>' instead.", - errorStringReadonlyGenericSimple: - "Array type using 'readonly {{type}}[]' is forbidden for non-simple types. Use 'ReadonlyArray<{{type}}>' instead.", + "Array type using '{{readonlyPrefix}}{{type}}[]' is forbidden for non-simple types. Use '{{className}}<{{type}}>' instead.", }, schema: [ { @@ -167,11 +155,7 @@ export default util.createRule({ const messageId = currentOption === 'generic' - ? isReadonly - ? 'errorStringReadonlyGeneric' - : 'errorStringGeneric' - : isReadonly - ? 'errorStringReadonlyGenericSimple' + ? 'errorStringGeneric' : 'errorStringGenericSimple'; const errorNode = isReadonly ? node.parent! : node; @@ -179,6 +163,8 @@ export default util.createRule({ node: errorNode, messageId, data: { + className: isReadonly ? 'ReadonlyArray' : 'Array', + readonlyPrefix: isReadonly ? 'readonly ' : '', type: getMessageType(node.elementType), }, fix(fixer) { @@ -223,11 +209,7 @@ export default util.createRule({ const typeParams = node.typeParameters?.params; const messageId = currentOption === 'array' - ? isReadonlyArrayType - ? 'errorStringReadonlyArray' - : 'errorStringArray' - : isReadonlyArrayType - ? 'errorStringReadonlyArraySimple' + ? 'errorStringArray' : 'errorStringArraySimple'; if (!typeParams || typeParams.length === 0) { @@ -236,6 +218,8 @@ export default util.createRule({ node, messageId, data: { + className: isReadonlyArrayType ? 'ReadonlyArray' : 'Array', + readonlyPrefix, type: 'any', }, fix(fixer) { @@ -270,6 +254,8 @@ export default util.createRule({ node, messageId, data: { + className: isReadonlyArrayType ? 'ReadonlyArray' : 'Array', + readonlyPrefix, type: getMessageType(type), }, fix(fixer) { diff --git a/packages/eslint-plugin/tests/rules/array-type.test.ts b/packages/eslint-plugin/tests/rules/array-type.test.ts index 27db3546f0a..eafd9a912cf 100644 --- a/packages/eslint-plugin/tests/rules/array-type.test.ts +++ b/packages/eslint-plugin/tests/rules/array-type.test.ts @@ -375,7 +375,7 @@ function bazFunction(baz: Arr>) { errors: [ { messageId: 'errorStringArray', - data: { type: 'number' }, + data: { className: 'Array', readonlyPrefix: '', type: 'number' }, line: 1, column: 8, }, @@ -388,7 +388,7 @@ function bazFunction(baz: Arr>) { errors: [ { messageId: 'errorStringArray', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 1, column: 8, }, @@ -400,8 +400,12 @@ function bazFunction(baz: Arr>) { options: [{ default: 'array' }], errors: [ { - messageId: 'errorStringReadonlyArray', - data: { type: 'number' }, + messageId: 'errorStringArray', + data: { + className: 'ReadonlyArray', + readonlyPrefix: 'readonly ', + type: 'number', + }, line: 1, column: 8, }, @@ -413,8 +417,12 @@ function bazFunction(baz: Arr>) { options: [{ default: 'array' }], errors: [ { - messageId: 'errorStringReadonlyArray', - data: { type: 'T' }, + messageId: 'errorStringArray', + data: { + className: 'ReadonlyArray', + readonlyPrefix: 'readonly ', + type: 'T', + }, line: 1, column: 8, }, @@ -427,7 +435,7 @@ function bazFunction(baz: Arr>) { errors: [ { messageId: 'errorStringArray', - data: { type: 'number' }, + data: { className: 'Array', readonlyPrefix: '', type: 'number' }, line: 1, column: 8, }, @@ -440,7 +448,7 @@ function bazFunction(baz: Arr>) { errors: [ { messageId: 'errorStringArray', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 1, column: 8, }, @@ -452,8 +460,12 @@ function bazFunction(baz: Arr>) { options: [{ default: 'array', readonly: 'array' }], errors: [ { - messageId: 'errorStringReadonlyArray', - data: { type: 'number' }, + messageId: 'errorStringArray', + data: { + className: 'ReadonlyArray', + readonlyPrefix: 'readonly ', + type: 'number', + }, line: 1, column: 8, }, @@ -465,8 +477,12 @@ function bazFunction(baz: Arr>) { options: [{ default: 'array', readonly: 'array' }], errors: [ { - messageId: 'errorStringReadonlyArray', - data: { type: 'T' }, + messageId: 'errorStringArray', + data: { + className: 'ReadonlyArray', + readonlyPrefix: 'readonly ', + type: 'T', + }, line: 1, column: 8, }, @@ -479,7 +495,7 @@ function bazFunction(baz: Arr>) { errors: [ { messageId: 'errorStringArray', - data: { type: 'number' }, + data: { className: 'Array', readonlyPrefix: '', type: 'number' }, line: 1, column: 8, }, @@ -492,7 +508,7 @@ function bazFunction(baz: Arr>) { errors: [ { messageId: 'errorStringArray', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 1, column: 8, }, @@ -504,8 +520,12 @@ function bazFunction(baz: Arr>) { options: [{ default: 'array', readonly: 'array-simple' }], errors: [ { - messageId: 'errorStringReadonlyArraySimple', - data: { type: 'number' }, + messageId: 'errorStringArraySimple', + data: { + className: 'ReadonlyArray', + readonlyPrefix: 'readonly ', + type: 'number', + }, line: 1, column: 8, }, @@ -517,8 +537,12 @@ function bazFunction(baz: Arr>) { options: [{ default: 'array', readonly: 'array-simple' }], errors: [ { - messageId: 'errorStringReadonlyGenericSimple', - data: { type: 'T' }, + messageId: 'errorStringGenericSimple', + data: { + className: 'ReadonlyArray', + readonlyPrefix: 'readonly ', + type: 'T', + }, line: 1, column: 8, }, @@ -531,7 +555,7 @@ function bazFunction(baz: Arr>) { errors: [ { messageId: 'errorStringArray', - data: { type: 'number' }, + data: { className: 'Array', readonlyPrefix: '', type: 'number' }, line: 1, column: 8, }, @@ -544,7 +568,7 @@ function bazFunction(baz: Arr>) { errors: [ { messageId: 'errorStringArray', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 1, column: 8, }, @@ -556,8 +580,12 @@ function bazFunction(baz: Arr>) { options: [{ default: 'array', readonly: 'generic' }], errors: [ { - messageId: 'errorStringReadonlyGeneric', - data: { type: 'number' }, + messageId: 'errorStringGeneric', + data: { + className: 'ReadonlyArray', + readonlyPrefix: 'readonly ', + type: 'number', + }, line: 1, column: 8, }, @@ -569,8 +597,12 @@ function bazFunction(baz: Arr>) { options: [{ default: 'array', readonly: 'generic' }], errors: [ { - messageId: 'errorStringReadonlyGeneric', - data: { type: 'T' }, + messageId: 'errorStringGeneric', + data: { + className: 'ReadonlyArray', + readonlyPrefix: 'readonly ', + type: 'T', + }, line: 1, column: 8, }, @@ -583,7 +615,7 @@ function bazFunction(baz: Arr>) { errors: [ { messageId: 'errorStringArraySimple', - data: { type: 'number' }, + data: { className: 'Array', readonlyPrefix: '', type: 'number' }, line: 1, column: 8, }, @@ -596,7 +628,7 @@ function bazFunction(baz: Arr>) { errors: [ { messageId: 'errorStringGenericSimple', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 1, column: 8, }, @@ -608,8 +640,12 @@ function bazFunction(baz: Arr>) { options: [{ default: 'array-simple' }], errors: [ { - messageId: 'errorStringReadonlyArraySimple', - data: { type: 'number' }, + messageId: 'errorStringArraySimple', + data: { + className: 'ReadonlyArray', + readonlyPrefix: 'readonly ', + type: 'number', + }, line: 1, column: 8, }, @@ -621,8 +657,12 @@ function bazFunction(baz: Arr>) { options: [{ default: 'array-simple' }], errors: [ { - messageId: 'errorStringReadonlyGenericSimple', - data: { type: 'T' }, + messageId: 'errorStringGenericSimple', + data: { + className: 'ReadonlyArray', + readonlyPrefix: 'readonly ', + type: 'T', + }, line: 1, column: 8, }, @@ -635,7 +675,7 @@ function bazFunction(baz: Arr>) { errors: [ { messageId: 'errorStringArraySimple', - data: { type: 'number' }, + data: { className: 'Array', readonlyPrefix: '', type: 'number' }, line: 1, column: 8, }, @@ -648,7 +688,7 @@ function bazFunction(baz: Arr>) { errors: [ { messageId: 'errorStringGenericSimple', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 1, column: 8, }, @@ -660,8 +700,12 @@ function bazFunction(baz: Arr>) { options: [{ default: 'array-simple', readonly: 'array' }], errors: [ { - messageId: 'errorStringReadonlyArray', - data: { type: 'number' }, + messageId: 'errorStringArray', + data: { + className: 'ReadonlyArray', + readonlyPrefix: 'readonly ', + type: 'number', + }, line: 1, column: 8, }, @@ -673,8 +717,12 @@ function bazFunction(baz: Arr>) { options: [{ default: 'array-simple', readonly: 'array' }], errors: [ { - messageId: 'errorStringReadonlyArray', - data: { type: 'T' }, + messageId: 'errorStringArray', + data: { + className: 'ReadonlyArray', + readonlyPrefix: 'readonly ', + type: 'T', + }, line: 1, column: 8, }, @@ -687,7 +735,7 @@ function bazFunction(baz: Arr>) { errors: [ { messageId: 'errorStringArraySimple', - data: { type: 'number' }, + data: { className: 'Array', readonlyPrefix: '', type: 'number' }, line: 1, column: 8, }, @@ -700,7 +748,7 @@ function bazFunction(baz: Arr>) { errors: [ { messageId: 'errorStringGenericSimple', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 1, column: 8, }, @@ -712,8 +760,12 @@ function bazFunction(baz: Arr>) { options: [{ default: 'array-simple', readonly: 'array-simple' }], errors: [ { - messageId: 'errorStringReadonlyArraySimple', - data: { type: 'number' }, + messageId: 'errorStringArraySimple', + data: { + className: 'ReadonlyArray', + readonlyPrefix: 'readonly ', + type: 'number', + }, line: 1, column: 8, }, @@ -725,8 +777,12 @@ function bazFunction(baz: Arr>) { options: [{ default: 'array-simple', readonly: 'array-simple' }], errors: [ { - messageId: 'errorStringReadonlyGenericSimple', - data: { type: 'T' }, + messageId: 'errorStringGenericSimple', + data: { + className: 'ReadonlyArray', + readonlyPrefix: 'readonly ', + type: 'T', + }, line: 1, column: 8, }, @@ -739,7 +795,7 @@ function bazFunction(baz: Arr>) { errors: [ { messageId: 'errorStringArraySimple', - data: { type: 'number' }, + data: { className: 'Array', readonlyPrefix: '', type: 'number' }, line: 1, column: 8, }, @@ -752,7 +808,7 @@ function bazFunction(baz: Arr>) { errors: [ { messageId: 'errorStringGenericSimple', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 1, column: 8, }, @@ -764,8 +820,12 @@ function bazFunction(baz: Arr>) { options: [{ default: 'array-simple', readonly: 'generic' }], errors: [ { - messageId: 'errorStringReadonlyGeneric', - data: { type: 'number' }, + messageId: 'errorStringGeneric', + data: { + className: 'ReadonlyArray', + readonlyPrefix: 'readonly ', + type: 'number', + }, line: 1, column: 8, }, @@ -777,8 +837,12 @@ function bazFunction(baz: Arr>) { options: [{ default: 'array-simple', readonly: 'generic' }], errors: [ { - messageId: 'errorStringReadonlyGeneric', - data: { type: 'T' }, + messageId: 'errorStringGeneric', + data: { + className: 'ReadonlyArray', + readonlyPrefix: 'readonly ', + type: 'T', + }, line: 1, column: 8, }, @@ -791,7 +855,7 @@ function bazFunction(baz: Arr>) { errors: [ { messageId: 'errorStringGeneric', - data: { type: 'number' }, + data: { className: 'Array', readonlyPrefix: '', type: 'number' }, line: 1, column: 8, }, @@ -804,7 +868,7 @@ function bazFunction(baz: Arr>) { errors: [ { messageId: 'errorStringGeneric', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 1, column: 8, }, @@ -816,8 +880,12 @@ function bazFunction(baz: Arr>) { options: [{ default: 'generic' }], errors: [ { - messageId: 'errorStringReadonlyGeneric', - data: { type: 'number' }, + messageId: 'errorStringGeneric', + data: { + className: 'ReadonlyArray', + readonlyPrefix: 'readonly ', + type: 'number', + }, line: 1, column: 8, }, @@ -829,8 +897,12 @@ function bazFunction(baz: Arr>) { options: [{ default: 'generic' }], errors: [ { - messageId: 'errorStringReadonlyGeneric', - data: { type: 'T' }, + messageId: 'errorStringGeneric', + data: { + className: 'ReadonlyArray', + readonlyPrefix: 'readonly ', + type: 'T', + }, line: 1, column: 8, }, @@ -843,7 +915,7 @@ function bazFunction(baz: Arr>) { errors: [ { messageId: 'errorStringGeneric', - data: { type: 'number' }, + data: { className: 'Array', readonlyPrefix: '', type: 'number' }, line: 1, column: 8, }, @@ -856,7 +928,7 @@ function bazFunction(baz: Arr>) { errors: [ { messageId: 'errorStringGeneric', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 1, column: 8, }, @@ -868,8 +940,12 @@ function bazFunction(baz: Arr>) { options: [{ default: 'generic', readonly: 'array' }], errors: [ { - messageId: 'errorStringReadonlyArray', - data: { type: 'number' }, + messageId: 'errorStringArray', + data: { + className: 'ReadonlyArray', + readonlyPrefix: 'readonly ', + type: 'number', + }, line: 1, column: 8, }, @@ -881,8 +957,12 @@ function bazFunction(baz: Arr>) { options: [{ default: 'generic', readonly: 'array' }], errors: [ { - messageId: 'errorStringReadonlyArray', - data: { type: 'T' }, + messageId: 'errorStringArray', + data: { + className: 'ReadonlyArray', + readonlyPrefix: 'readonly ', + type: 'T', + }, line: 1, column: 8, }, @@ -895,7 +975,7 @@ function bazFunction(baz: Arr>) { errors: [ { messageId: 'errorStringGeneric', - data: { type: 'number' }, + data: { className: 'Array', readonlyPrefix: '', type: 'number' }, line: 1, column: 8, }, @@ -908,7 +988,7 @@ function bazFunction(baz: Arr>) { errors: [ { messageId: 'errorStringGeneric', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 1, column: 8, }, @@ -920,8 +1000,12 @@ function bazFunction(baz: Arr>) { options: [{ default: 'generic', readonly: 'array-simple' }], errors: [ { - messageId: 'errorStringReadonlyArraySimple', - data: { type: 'number' }, + messageId: 'errorStringArraySimple', + data: { + className: 'ReadonlyArray', + readonlyPrefix: 'readonly ', + type: 'number', + }, line: 1, column: 8, }, @@ -933,8 +1017,12 @@ function bazFunction(baz: Arr>) { options: [{ default: 'generic', readonly: 'array-simple' }], errors: [ { - messageId: 'errorStringReadonlyGenericSimple', - data: { type: 'T' }, + messageId: 'errorStringGenericSimple', + data: { + className: 'ReadonlyArray', + readonlyPrefix: 'readonly ', + type: 'T', + }, line: 1, column: 8, }, @@ -947,7 +1035,7 @@ function bazFunction(baz: Arr>) { errors: [ { messageId: 'errorStringGeneric', - data: { type: 'number' }, + data: { className: 'Array', readonlyPrefix: '', type: 'number' }, line: 1, column: 8, }, @@ -960,7 +1048,7 @@ function bazFunction(baz: Arr>) { errors: [ { messageId: 'errorStringGeneric', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 1, column: 8, }, @@ -972,8 +1060,12 @@ function bazFunction(baz: Arr>) { options: [{ default: 'generic', readonly: 'generic' }], errors: [ { - messageId: 'errorStringReadonlyGeneric', - data: { type: 'number' }, + messageId: 'errorStringGeneric', + data: { + className: 'ReadonlyArray', + readonlyPrefix: 'readonly ', + type: 'number', + }, line: 1, column: 8, }, @@ -985,8 +1077,12 @@ function bazFunction(baz: Arr>) { options: [{ default: 'generic', readonly: 'generic' }], errors: [ { - messageId: 'errorStringReadonlyGeneric', - data: { type: 'T' }, + messageId: 'errorStringGeneric', + data: { + className: 'ReadonlyArray', + readonlyPrefix: 'readonly ', + type: 'T', + }, line: 1, column: 8, }, @@ -1001,7 +1097,7 @@ function bazFunction(baz: Arr>) { errors: [ { messageId: 'errorStringArray', - data: { type: 'Bar' }, + data: { className: 'Array', readonlyPrefix: '', type: 'Bar' }, line: 1, column: 15, }, @@ -1014,7 +1110,7 @@ function bazFunction(baz: Arr>) { errors: [ { messageId: 'errorStringGeneric', - data: { type: 'Bar' }, + data: { className: 'Array', readonlyPrefix: '', type: 'Bar' }, line: 1, column: 21, }, @@ -1027,7 +1123,7 @@ function bazFunction(baz: Arr>) { errors: [ { messageId: 'errorStringGeneric', - data: { type: 'Bar' }, + data: { className: 'Array', readonlyPrefix: '', type: 'Bar' }, line: 1, column: 27, }, @@ -1040,13 +1136,13 @@ function bazFunction(baz: Arr>) { errors: [ { messageId: 'errorStringArray', - data: { type: 'Bar' }, + data: { className: 'Array', readonlyPrefix: '', type: 'Bar' }, line: 1, column: 17, }, { messageId: 'errorStringArray', - data: { type: 'Bar' }, + data: { className: 'Array', readonlyPrefix: '', type: 'Bar' }, line: 1, column: 30, }, @@ -1059,7 +1155,7 @@ function bazFunction(baz: Arr>) { errors: [ { messageId: 'errorStringArraySimple', - data: { type: 'undefined' }, + data: { className: 'Array', readonlyPrefix: '', type: 'undefined' }, line: 1, column: 8, }, @@ -1072,7 +1168,7 @@ function bazFunction(baz: Arr>) { errors: [ { messageId: 'errorStringArraySimple', - data: { type: 'string' }, + data: { className: 'Array', readonlyPrefix: '', type: 'string' }, line: 1, column: 20, }, @@ -1085,7 +1181,7 @@ function bazFunction(baz: Arr>) { errors: [ { messageId: 'errorStringArraySimple', - data: { type: 'any' }, + data: { className: 'Array', readonlyPrefix: '', type: 'any' }, line: 1, column: 8, }, @@ -1098,7 +1194,7 @@ function bazFunction(baz: Arr>) { errors: [ { messageId: 'errorStringGenericSimple', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 1, column: 24, }, @@ -1111,7 +1207,7 @@ function bazFunction(baz: Arr>) { errors: [ { messageId: 'errorStringArraySimple', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 1, column: 15, }, @@ -1130,7 +1226,7 @@ let yyyy: Arr>>> = [[[['2']]]]; errors: [ { messageId: 'errorStringGenericSimple', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 3, column: 15, }, @@ -1157,7 +1253,7 @@ interface ArrayClass { errors: [ { messageId: 'errorStringArraySimple', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 3, column: 8, }, @@ -1178,7 +1274,7 @@ function barFunction(bar: Array>) { errors: [ { messageId: 'errorStringGenericSimple', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 2, column: 27, }, @@ -1191,7 +1287,7 @@ function barFunction(bar: Array>) { errors: [ { messageId: 'errorStringGenericSimple', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 1, column: 13, }, @@ -1204,7 +1300,7 @@ function barFunction(bar: Array>) { errors: [ { messageId: 'errorStringGenericSimple', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 1, column: 17, }, @@ -1217,7 +1313,7 @@ function barFunction(bar: Array>) { errors: [ { messageId: 'errorStringGenericSimple', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 1, column: 24, }, @@ -1230,7 +1326,11 @@ function barFunction(bar: Array>) { errors: [ { messageId: 'errorStringArraySimple', - data: { type: 'fooName.BarType' }, + data: { + className: 'Array', + readonlyPrefix: '', + type: 'fooName.BarType', + }, line: 1, column: 8, }, @@ -1243,7 +1343,7 @@ function barFunction(bar: Array>) { errors: [ { messageId: 'errorStringGenericSimple', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 1, column: 8, }, @@ -1256,7 +1356,7 @@ function barFunction(bar: Array>) { errors: [ { messageId: 'errorStringArray', - data: { type: 'undefined' }, + data: { className: 'Array', readonlyPrefix: '', type: 'undefined' }, line: 1, column: 8, }, @@ -1269,7 +1369,7 @@ function barFunction(bar: Array>) { errors: [ { messageId: 'errorStringArray', - data: { type: 'string' }, + data: { className: 'Array', readonlyPrefix: '', type: 'string' }, line: 1, column: 20, }, @@ -1282,7 +1382,7 @@ function barFunction(bar: Array>) { errors: [ { messageId: 'errorStringArray', - data: { type: 'any' }, + data: { className: 'Array', readonlyPrefix: '', type: 'any' }, line: 1, column: 8, }, @@ -1295,7 +1395,7 @@ function barFunction(bar: Array>) { errors: [ { messageId: 'errorStringArray', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 1, column: 15, }, @@ -1314,7 +1414,7 @@ let yyyy: Arr[][]> = [[[['2']]]]; errors: [ { messageId: 'errorStringArray', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 3, column: 15, }, @@ -1339,7 +1439,7 @@ interface ArrayClass { errors: [ { messageId: 'errorStringArray', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 3, column: 8, }, @@ -1360,7 +1460,7 @@ function fooFunction(foo: ArrayClass[]) { errors: [ { messageId: 'errorStringArray', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 2, column: 27, }, @@ -1373,7 +1473,7 @@ function fooFunction(foo: ArrayClass[]) { errors: [ { messageId: 'errorStringArray', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 1, column: 13, }, @@ -1386,7 +1486,7 @@ function fooFunction(foo: ArrayClass[]) { errors: [ { messageId: 'errorStringArray', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 1, column: 17, }, @@ -1399,7 +1499,7 @@ function fooFunction(foo: ArrayClass[]) { errors: [ { messageId: 'errorStringArray', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 1, column: 24, }, @@ -1412,7 +1512,7 @@ function fooFunction(foo: ArrayClass[]) { errors: [ { messageId: 'errorStringArray', - data: { type: 'any' }, + data: { className: 'Array', readonlyPrefix: '', type: 'any' }, line: 1, column: 8, }, @@ -1425,7 +1525,7 @@ function fooFunction(foo: ArrayClass[]) { errors: [ { messageId: 'errorStringArray', - data: { type: 'any' }, + data: { className: 'Array', readonlyPrefix: '', type: 'any' }, line: 1, column: 8, }, @@ -1438,7 +1538,7 @@ function fooFunction(foo: ArrayClass[]) { errors: [ { messageId: 'errorStringArraySimple', - data: { type: 'any' }, + data: { className: 'Array', readonlyPrefix: '', type: 'any' }, line: 1, column: 8, }, @@ -1463,7 +1563,7 @@ function fooFunction(foo: ArrayClass[]) { errors: [ { messageId: 'errorStringGeneric', - data: { type: 'number' }, + data: { className: 'Array', readonlyPrefix: '', type: 'number' }, line: 1, column: 31, }, @@ -1476,7 +1576,7 @@ function fooFunction(foo: ArrayClass[]) { errors: [ { messageId: 'errorStringGeneric', - data: { type: 'string' }, + data: { className: 'Array', readonlyPrefix: '', type: 'string' }, line: 1, column: 8, }, @@ -1489,7 +1589,7 @@ function fooFunction(foo: ArrayClass[]) { errors: [ { messageId: 'errorStringGeneric', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 1, column: 24, }, @@ -1508,7 +1608,7 @@ let yyyy: Arr>>> = [[[['2']]]]; errors: [ { messageId: 'errorStringGeneric', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 3, column: 15, }, @@ -1533,7 +1633,7 @@ interface ArrayClass { errors: [ { messageId: 'errorStringGeneric', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 4, column: 8, }, @@ -1554,7 +1654,7 @@ function barFunction(bar: Array>) { errors: [ { messageId: 'errorStringGeneric', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 2, column: 27, }, @@ -1567,7 +1667,7 @@ function barFunction(bar: Array>) { errors: [ { messageId: 'errorStringGeneric', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 1, column: 13, }, @@ -1580,7 +1680,7 @@ function barFunction(bar: Array>) { errors: [ { messageId: 'errorStringGeneric', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 1, column: 17, }, @@ -1593,7 +1693,7 @@ function barFunction(bar: Array>) { errors: [ { messageId: 'errorStringGeneric', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 1, column: 24, }, @@ -1614,7 +1714,7 @@ interface FooInterface { errors: [ { messageId: 'errorStringGeneric', - data: { type: 'string' }, + data: { className: 'Array', readonlyPrefix: '', type: 'string' }, line: 3, column: 18, }, @@ -1628,7 +1728,7 @@ interface FooInterface { errors: [ { messageId: 'errorStringArray', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 1, column: 28, }, @@ -1642,7 +1742,7 @@ interface FooInterface { errors: [ { messageId: 'errorStringGeneric', - data: { type: 'T' }, + data: { className: 'Array', readonlyPrefix: '', type: 'T' }, line: 1, column: 28, }, @@ -1654,8 +1754,12 @@ interface FooInterface { options: [{ default: 'array' }], errors: [ { - messageId: 'errorStringReadonlyArray', - data: { type: 'object' }, + messageId: 'errorStringArray', + data: { + className: 'ReadonlyArray', + readonlyPrefix: 'readonly ', + type: 'object', + }, line: 1, column: 12, },