From c1601580363c63e7628b17f94c4fde1b0dfb8260 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Thu, 20 Dec 2018 22:02:53 -0800 Subject: [PATCH] [BREAKING] [no-type-alias] simplify config --- docs/rules/no-type-alias.md | 24 +- lib/rules/no-type-alias.js | 109 +- lib/util.js | 10 + tests/lib/rules/no-type-alias.js | 1813 ++++++++++++++++-------------- 4 files changed, 1036 insertions(+), 920 deletions(-) diff --git a/docs/rules/no-type-alias.md b/docs/rules/no-type-alias.md index d1ae4d1..fb0f72d 100644 --- a/docs/rules/no-type-alias.md +++ b/docs/rules/no-type-alias.md @@ -82,10 +82,10 @@ and simplified types (primitives, tuples, unions, intersections, etc). This rule, in its default state, does not require any argument. If you would like to enable one or more of the following you may pass an object with the options set as follows: -- `allowAliases` set to `true` or `"always"` will allow you to do aliasing (Defaults to `false`/`"never"`). -- `allowCallbacks` set to `true` or `"always"` will allow you to use type aliases with callbacks (Defaults to `false`/`"never"`) -- `allowLiterals` set to `true` or `"always"` will allow you to use type aliases with literal objects (Defaults to `false`/`"never"`) -- `allowMappedTypes` set to `true` or `"always"` will allow you to use type aliases as mapping tools (Defaults to `false`/`"never"`) +- `allowAliases` set to `"always"` will allow you to do aliasing (Defaults to `"never"`). +- `allowCallbacks` set to `"always"` will allow you to use type aliases with callbacks (Defaults to `"never"`) +- `allowLiterals` set to `"always"` will allow you to use type aliases with literal objects (Defaults to `"never"`) +- `allowMappedTypes` set to `"always"` will allow you to use type aliases as mapping tools (Defaults to `"never"`) ### allowAliases @@ -93,12 +93,12 @@ This applies to primitive types and reference types. The setting accepts the following values: -- `true` or `false` (`"always"` or `"never"`) to active or deactivate the feature. +- `"always"` or `"never"` to active or deactivate the feature. - `"in-unions"`, allows aliasing in union statements, e.g. `type Foo = string | string[];` - `"in-intersections"`, allows aliasing in intersection statements, e.g. `type Foo = string & string[];` - `"in-unions-and-intersections"`, allows aliasing in union and/or intersection statements. -Examples of **correct** code for the `{ "allowAliases": true }` or `{ "allowAliases": "always" }` options: +Examples of **correct** code for the `{ "allowAliases": "always" }` options: ```ts // primitives @@ -231,9 +231,9 @@ This applies to function types. The setting accepts the following values: -- `true` or `false` (`"always"` or `"never"`) to active or deactivate the feature. +- `"always"` or `"never"` to active or deactivate the feature. -Examples of **correct** code for the `{ "allowCallbacks": true }` or `{ "allowCallbacks": "always" }` option: +Examples of **correct** code for the `{ "allowCallbacks": "always" }` option: ```ts type Foo = () => void; @@ -253,12 +253,12 @@ This applies to literal types (`type Foo = { ... }`). The setting accepts the following options: -- `true` or `false` (`"always"` or `"never"`) to active or deactivate the feature. +- `"always"` or `"never"` to active or deactivate the feature. - `"in-unions"`, allows literals in union statements, e.g. `type Foo = string | string[];` - `"in-intersections"`, allows literals in intersection statements, e.g. `type Foo = string & string[];` - `"in-unions-and-intersections"`, allows literals in union and/or intersection statements. -Examples of **correct** code for the `{ "allowLiterals": true }` or `{ "allowLiterals": "always" }` options: +Examples of **correct** code for the `{ "allowLiterals": "always" }` options: ```ts type Foo = {}; @@ -360,12 +360,12 @@ This applies to literal types. The setting accepts the following values: -- `true` or `false` (`"always"` or `"never"`) to active or deactivate the feature. +- `"always"` or `"never"` to active or deactivate the feature. - `"in-unions"`, allows aliasing in union statements, e.g. `type Foo = string | string[];` - `"in-intersections"`, allows aliasing in intersection statements, e.g. `type Foo = string & string[];` - `"in-unions-and-intersections"`, allows aliasing in union and/or intersection statements. -Examples of **correct** code for the `{ "allowMappedTypes": true }` or `{ "allowMappedTypes": "always" }` options: +Examples of **correct** code for the `{ "allowMappedTypes": "always" }` options: ```ts type Foo = { readonly [P in keyof T]: T[P] }; diff --git a/lib/rules/no-type-alias.js b/lib/rules/no-type-alias.js index 6311835..1778ad2 100644 --- a/lib/rules/no-type-alias.js +++ b/lib/rules/no-type-alias.js @@ -19,14 +19,17 @@ module.exports = { category: "TypeScript", url: util.metaDocsUrl("no-type-alias"), }, + messages: { + noTypeAlias: "Type {{alias}} are not allowed.", + noCompositionAlias: + "{{typeName}} in {{compositionType}} types are not allowed.", + }, schema: [ { type: "object", properties: { allowAliases: { enum: [ - true, - false, "always", "never", "in-unions", @@ -35,12 +38,10 @@ module.exports = { ], }, allowCallbacks: { - enum: [true, false, "always", "never"], + enum: ["always", "never"], }, allowLiterals: { enum: [ - true, - false, "always", "never", "in-unions", @@ -50,8 +51,6 @@ module.exports = { }, allowMappedTypes: { enum: [ - true, - false, "always", "never", "in-unions", @@ -66,22 +65,15 @@ module.exports = { }, create(context) { - const options = context.options[0]; + const options = context.options[0] || {}; - const allowAliases = (options && options.allowAliases) || "never"; - const allowCallbacks = (options && options.allowCallbacks) || "never"; - const allowLiterals = (options && options.allowLiterals) || "never"; - const allowMappedTypes = - (options && options.allowMappedTypes) || "never"; + const allowAliases = options.allowAliases || "never"; + const allowCallbacks = options.allowCallbacks || "never"; + const allowLiterals = options.allowLiterals || "never"; + const allowMappedTypes = options.allowMappedTypes || "never"; - const unions = [ - true, - "always", - "in-unions", - "in-unions-and-intersections", - ]; + const unions = ["always", "in-unions", "in-unions-and-intersections"]; const intersections = [ - true, "always", "in-intersections", "in-unions-and-intersections", @@ -181,6 +173,7 @@ module.exports = { /** * Gets the message to be displayed based on the node type and whether the node is a top level declaration. + * @param {Object} node the location * @param {string} compositionType the type of composition this alias is part of (undefined if not * part of a composition) * @param {boolean} isRoot a flag indicating we are dealing with the top level declaration. @@ -188,20 +181,28 @@ module.exports = { * @returns {string} the message to be displayed. * @private */ - function getMessage(compositionType, isRoot, type) { + function getMessage(node, compositionType, isRoot, type) { if (isRoot) { - return type - ? `Type ${type} are not allowed.` - : "Type aliases are not allowed."; + return { + node, + messageId: "noTypeAlias", + data: { + alias: type || "aliases", + }, + }; } - return compositionType === "TSUnionType" - ? `${type[0].toUpperCase()}${type.slice( - 1 - )} in union types are not allowed.` - : `${type[0].toUpperCase()}${type.slice( - 1 - )} in intersection types are not allowed.`; + return { + node, + messageId: "noCompositionAlias", + data: { + compositionType: + compositionType === "TSUnionType" + ? "union" + : "intersection", + typeName: util.upperCaseFirst(type), + }, + }; } /** @@ -223,25 +224,20 @@ module.exports = { allowAliases ) ) { - context.report({ - node, - message: getMessage( - compositionType, - isTopLevel, - "aliases" - ), - }); + context.report( + getMessage(node, compositionType, isTopLevel, "aliases") + ); } } else if (isCallback(node)) { if (allowCallbacks === "never") { - context.report({ - node, - message: getMessage( + context.report( + getMessage( + node, compositionType, isTopLevel, "callbacks" - ), - }); + ) + ); } } else if (isLiteral(node)) { if ( @@ -252,14 +248,14 @@ module.exports = { allowLiterals ) ) { - context.report({ - node, - message: getMessage( + context.report( + getMessage( + node, compositionType, isTopLevel, "literals" - ), - }); + ) + ); } } else if (isMappedType(node)) { if ( @@ -270,20 +266,17 @@ module.exports = { allowMappedTypes ) ) { - context.report({ - node, - message: getMessage( + context.report( + getMessage( + node, compositionType, isTopLevel, "mapped types" - ), - }); + ) + ); } } else { - context.report({ - node, - message: getMessage(compositionType, isTopLevel), - }); + context.report(getMessage(node, compositionType, isTopLevel)); } } diff --git a/lib/util.js b/lib/util.js index 67b5a3f..1dd2901 100644 --- a/lib/util.js +++ b/lib/util.js @@ -62,3 +62,13 @@ function deepMerge(first = {}, second = {}) { }, {}); } exports.deepMerge = deepMerge; + +/** + * Upper cases the first character or the string + * @param {string} str a string + * @returns {string} upper case first + */ +function upperCaseFirst(str) { + return str[0].toUpperCase() + str.slice(1); +} +exports.upperCaseFirst = upperCaseFirst; diff --git a/tests/lib/rules/no-type-alias.js b/tests/lib/rules/no-type-alias.js index 3a509ae..2a0536f 100644 --- a/tests/lib/rules/no-type-alias.js +++ b/tests/lib/rules/no-type-alias.js @@ -21,18 +21,10 @@ const ruleTester = new RuleTester({ ruleTester.run("no-type-alias", rule, { valid: [ - { - code: "type Foo = 'a';", - options: [{ allowAliases: true }], - }, { code: "type Foo = 'a';", options: [{ allowAliases: "always" }], }, - { - code: "type Foo = 'a' | 'b';", - options: [{ allowAliases: true }], - }, { code: "type Foo = 'a' | 'b';", options: [{ allowAliases: "always" }], @@ -45,10 +37,6 @@ ruleTester.run("no-type-alias", rule, { code: "type Foo = 'a' | 'b';", options: [{ allowAliases: "in-unions" }], }, - { - code: "type Foo = 'a' | 'b' | 'c';", - options: [{ allowAliases: true }], - }, { code: "type Foo = 'a' | 'b' | 'c';", options: [{ allowAliases: "always" }], @@ -61,10 +49,6 @@ ruleTester.run("no-type-alias", rule, { code: "type Foo = 'a' | 'b' | 'c';", options: [{ allowAliases: "in-unions" }], }, - { - code: "type Foo = 'a' & 'b';", - options: [{ allowAliases: true }], - }, { code: "type Foo = 'a' & 'b';", options: [{ allowAliases: "always" }], @@ -77,10 +61,6 @@ ruleTester.run("no-type-alias", rule, { code: "type Foo = 'a' & 'b';", options: [{ allowAliases: "in-intersections" }], }, - { - code: "type Foo = 'a' & 'b' & 'c';", - options: [{ allowAliases: true }], - }, { code: "type Foo = 'a' & 'b' & 'c';", options: [{ allowAliases: "always" }], @@ -93,10 +73,6 @@ ruleTester.run("no-type-alias", rule, { code: "type Foo = 'a' & 'b' & 'c';", options: [{ allowAliases: "in-intersections" }], }, - { - code: "type Foo = 'a' | 'b' & 'c';", - options: [{ allowAliases: true }], - }, { code: "type Foo = 'a' | 'b' & 'c';", options: [{ allowAliases: "always" }], @@ -105,18 +81,10 @@ ruleTester.run("no-type-alias", rule, { code: "type Foo = 'a' | 'b' & 'c';", options: [{ allowAliases: "in-unions-and-intersections" }], }, - { - code: "type Foo = 1;", - options: [{ allowAliases: true }], - }, { code: "type Foo = 1;", options: [{ allowAliases: "always" }], }, - { - code: "type Foo = 1 | 2;", - options: [{ allowAliases: true }], - }, { code: "type Foo = 1 | 2;", options: [{ allowAliases: "always" }], @@ -129,10 +97,6 @@ ruleTester.run("no-type-alias", rule, { code: "type Foo = 1 | 2;", options: [{ allowAliases: "in-unions" }], }, - { - code: "type Foo = 1 | 2 | 3;", - options: [{ allowAliases: true }], - }, { code: "type Foo = 1 | 2 | 3;", options: [{ allowAliases: "always" }], @@ -145,10 +109,6 @@ ruleTester.run("no-type-alias", rule, { code: "type Foo = 1 | 2 | 3;", options: [{ allowAliases: "in-unions" }], }, - { - code: "type Foo = 1 & 2;", - options: [{ allowAliases: true }], - }, { code: "type Foo = 1 & 2;", options: [{ allowAliases: "always" }], @@ -161,10 +121,6 @@ ruleTester.run("no-type-alias", rule, { code: "type Foo = 1 & 2;", options: [{ allowAliases: "in-intersections" }], }, - { - code: "type Foo = 1 & 2 & 3;", - options: [{ allowAliases: true }], - }, { code: "type Foo = 1 & 2 & 3;", options: [{ allowAliases: "always" }], @@ -177,10 +133,6 @@ ruleTester.run("no-type-alias", rule, { code: "type Foo = 1 & 2 & 3;", options: [{ allowAliases: "in-intersections" }], }, - { - code: "type Foo = 1 | 2 & 3;", - options: [{ allowAliases: true }], - }, { code: "type Foo = 1 | 2 & 3;", options: [{ allowAliases: "always" }], @@ -189,10 +141,6 @@ ruleTester.run("no-type-alias", rule, { code: "type Foo = 1 | 2 & 3;", options: [{ allowAliases: "in-unions-and-intersections" }], }, - { - code: "type Foo = true;", - options: [{ allowAliases: true }], - }, { code: "type Foo = true;", options: [{ allowAliases: "always" }], @@ -209,10 +157,6 @@ ruleTester.run("no-type-alias", rule, { code: "type Foo = true | false;", options: [{ allowAliases: "in-unions" }], }, - { - code: "type Foo = true & false;", - options: [{ allowAliases: true }], - }, { code: "type Foo = true & false;", options: [{ allowAliases: "always" }], @@ -228,13 +172,6 @@ ruleTester.run("no-type-alias", rule, { { code: ` interface Bar {} -type Foo = Bar | string; - `, - options: [{ allowAliases: true }], - }, - { - code: ` -interface Bar {} type Foo = Bar | string; `, options: [{ allowAliases: "always" }], @@ -256,13 +193,6 @@ type Foo = Bar | string; { code: ` interface Bar {} -type Foo = Bar & string; - `, - options: [{ allowAliases: true }], - }, - { - code: ` -interface Bar {} type Foo = Bar & string; `, options: [{ allowAliases: "always" }], @@ -281,10 +211,6 @@ type Foo = Bar & string; `, options: [{ allowAliases: "in-intersections" }], }, - { - code: "type Foo = string;", - options: [{ allowAliases: true }], - }, { code: "type Foo = string;", options: [{ allowAliases: "always" }], @@ -301,10 +227,6 @@ type Foo = Bar & string; code: "type Foo = string | string[];", options: [{ allowAliases: "in-unions" }], }, - { - code: "type Foo = string | string[] | number;", - options: [{ allowAliases: true }], - }, { code: "type Foo = string | string[] | number;", options: [{ allowAliases: "always" }], @@ -317,10 +239,6 @@ type Foo = Bar & string; code: "type Foo = string | string[] | number;", options: [{ allowAliases: "in-unions" }], }, - { - code: "type Foo = string & string[];", - options: [{ allowAliases: true }], - }, { code: "type Foo = string & string[];", options: [{ allowAliases: "always" }], @@ -333,10 +251,6 @@ type Foo = Bar & string; code: "type Foo = string & string[];", options: [{ allowAliases: "in-intersections" }], }, - { - code: "type Foo = string & string[] & number;", - options: [{ allowAliases: true }], - }, { code: "type Foo = string & string[] & number;", options: [{ allowAliases: "always" }], @@ -349,10 +263,6 @@ type Foo = Bar & string; code: "type Foo = string & string[] & number;", options: [{ allowAliases: "in-intersections" }], }, - { - code: "type Foo = () => void;", - options: [{ allowCallbacks: true }], - }, { code: "type Foo = () => void;", options: [{ allowCallbacks: "always" }], @@ -361,18 +271,10 @@ type Foo = Bar & string; code: "type Foo = () => void | string;", options: [{ allowCallbacks: "always" }], }, - { - code: "type Foo = {};", - options: [{ allowLiterals: true }], - }, { code: "type Foo = {};", options: [{ allowLiterals: "always" }], }, - { - code: "type Foo = {} | {};", - options: [{ allowLiterals: true }], - }, { code: "type Foo = {} | {};", options: [{ allowLiterals: "always" }], @@ -385,10 +287,6 @@ type Foo = Bar & string; code: "type Foo = {} | {};", options: [{ allowLiterals: "in-unions" }], }, - { - code: "type Foo = {} & {};", - options: [{ allowLiterals: true }], - }, { code: "type Foo = {} & {};", options: [{ allowLiterals: "always" }], @@ -405,14 +303,6 @@ type Foo = Bar & string; code: ` type Foo = { readonly [P in keyof T] : T[P] -}; - `, - options: [{ allowMappedTypes: true }], - }, - { - code: ` -type Foo = { - readonly [P in keyof T] : T[P] }; `, options: [{ allowMappedTypes: "always" }], @@ -423,16 +313,6 @@ type Foo = { readonly [P in keyof T] : T[P] } | { readonly [P in keyof T] : T[P] -}; - `, - options: [{ allowMappedTypes: true }], - }, - { - code: ` -type Foo = { - readonly [P in keyof T] : T[P] -} | { - readonly [P in keyof T] : T[P] }; `, options: [{ allowMappedTypes: "always" }], @@ -463,16 +343,6 @@ type Foo = { readonly [P in keyof T] : T[P] } & { readonly [P in keyof T] : T[P] -}; - `, - options: [{ allowMappedTypes: true }], - }, - { - code: ` -type Foo = { - readonly [P in keyof T] : T[P] -} & { - readonly [P in keyof T] : T[P] }; `, options: [{ allowMappedTypes: "always" }], @@ -502,7 +372,7 @@ type Foo = { options: [ { allowAliases: "in-unions-and-intersections", - allowCallbacks: true, + allowCallbacks: "always", allowLiterals: "in-unions-and-intersections", allowMappedTypes: "in-unions-and-intersections", }, @@ -514,18 +384,10 @@ type Foo = { code: "type Foo = 'a'", errors: [ { - message: "Type aliases are not allowed.", - row: 1, - column: 12, - }, - ], - }, - { - code: "type Foo = 'a'", - options: [{ allowAliases: false }], - errors: [ - { - message: "Type aliases are not allowed.", + messageId: "noTypeAlias", + data: { + alias: "aliases", + }, row: 1, column: 12, }, @@ -536,7 +398,10 @@ type Foo = { options: [{ allowAliases: "never" }], errors: [ { - message: "Type aliases are not allowed.", + messageId: "noTypeAlias", + data: { + alias: "aliases", + }, row: 1, column: 12, }, @@ -546,12 +411,20 @@ type Foo = { code: "type Foo = 'a' | 'b';", errors: [ { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 18, }, @@ -562,44 +435,20 @@ type Foo = { options: [{ allowLiterals: "in-unions" }], errors: [ { - message: "Aliases in union types are not allowed.", - row: 1, - column: 12, - }, - { - message: "Aliases in union types are not allowed.", - row: 1, - column: 18, - }, - ], - }, - { - code: "type Foo = 'a' | 'b';", - options: [{ allowAliases: false }], - errors: [ - { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Aliases in union types are not allowed.", - row: 1, - column: 18, - }, - ], - }, - { - code: "type Foo = 'a' | 'b';", - options: [{ allowAliases: false, allowLiterals: "in-unions" }], - errors: [ - { - message: "Aliases in union types are not allowed.", - row: 1, - column: 12, - }, - { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 18, }, @@ -610,12 +459,20 @@ type Foo = { options: [{ allowAliases: "never" }], errors: [ { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 18, }, @@ -626,12 +483,20 @@ type Foo = { options: [{ allowAliases: "never", allowLiterals: "in-unions" }], errors: [ { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 18, }, @@ -647,12 +512,20 @@ type Foo = { ], errors: [ { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 18, }, @@ -662,17 +535,29 @@ type Foo = { code: "type Foo = 'a' | 'b' | 'c';", errors: [ { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 18, }, { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 24, }, @@ -683,59 +568,29 @@ type Foo = { options: [{ allowLiterals: "in-unions" }], errors: [ { - message: "Aliases in union types are not allowed.", - row: 1, - column: 12, - }, - { - message: "Aliases in union types are not allowed.", - row: 1, - column: 18, - }, - { - message: "Aliases in union types are not allowed.", - row: 1, - column: 24, - }, - ], - }, - { - code: "type Foo = 'a' | 'b' | 'c';", - options: [{ allowAliases: false }], - errors: [ - { - message: "Aliases in union types are not allowed.", - row: 1, - column: 12, - }, - { - message: "Aliases in union types are not allowed.", - row: 1, - column: 18, - }, - { - message: "Aliases in union types are not allowed.", - row: 1, - column: 24, - }, - ], - }, - { - code: "type Foo = 'a' | 'b' | 'c';", - options: [{ allowAliases: false, allowLiterals: "in-unions" }], - errors: [ - { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 18, }, { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 24, }, @@ -746,17 +601,29 @@ type Foo = { options: [{ allowAliases: "never" }], errors: [ { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 18, }, { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 24, }, @@ -767,17 +634,29 @@ type Foo = { options: [{ allowAliases: "never", allowLiterals: "in-unions" }], errors: [ { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 18, }, { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 24, }, @@ -788,17 +667,29 @@ type Foo = { options: [{ allowAliases: "in-intersections" }], errors: [ { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 18, }, { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 24, }, @@ -814,17 +705,29 @@ type Foo = { ], errors: [ { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 18, }, { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 24, }, @@ -834,12 +737,20 @@ type Foo = { code: "type Foo = 'a' & 'b';", errors: [ { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 12, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 18, }, @@ -850,46 +761,20 @@ type Foo = { options: [{ allowLiterals: "in-intersections" }], errors: [ { - message: "Aliases in intersection types are not allowed.", - row: 1, - column: 12, - }, - { - message: "Aliases in intersection types are not allowed.", - row: 1, - column: 18, - }, - ], - }, - { - code: "type Foo = 'a' & 'b';", - options: [{ allowAliases: false }], - errors: [ - { - message: "Aliases in intersection types are not allowed.", - row: 1, - column: 12, - }, - { - message: "Aliases in intersection types are not allowed.", - row: 1, - column: 18, - }, - ], - }, - { - code: "type Foo = 'a' & 'b';", - options: [ - { allowAliases: false, allowLiterals: "in-intersections" }, - ], - errors: [ - { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 12, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 18, }, @@ -900,12 +785,20 @@ type Foo = { options: [{ allowAliases: "never" }], errors: [ { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 12, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 18, }, @@ -918,12 +811,20 @@ type Foo = { ], errors: [ { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 12, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 18, }, @@ -934,12 +835,20 @@ type Foo = { options: [{ allowAliases: "in-unions" }], errors: [ { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 12, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 18, }, @@ -955,12 +864,20 @@ type Foo = { ], errors: [ { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 12, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 18, }, @@ -970,17 +887,29 @@ type Foo = { code: "type Foo = 'a' & 'b' & 'c';", errors: [ { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 12, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 18, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 24, }, @@ -991,61 +920,29 @@ type Foo = { options: [{ allowLiterals: "in-intersections" }], errors: [ { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 12, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 18, }, { - message: "Aliases in intersection types are not allowed.", - row: 1, - column: 24, - }, - ], - }, - { - code: "type Foo = 'a' & 'b' & 'c';", - options: [{ allowAliases: false }], - errors: [ - { - message: "Aliases in intersection types are not allowed.", - row: 1, - column: 12, - }, - { - message: "Aliases in intersection types are not allowed.", - row: 1, - column: 18, - }, - { - message: "Aliases in intersection types are not allowed.", - row: 1, - column: 24, - }, - ], - }, - { - code: "type Foo = 'a' & 'b' & 'c';", - options: [ - { allowAliases: false, allowLiterals: "in-intersections" }, - ], - errors: [ - { - message: "Aliases in intersection types are not allowed.", - row: 1, - column: 12, - }, - { - message: "Aliases in intersection types are not allowed.", - row: 1, - column: 18, - }, - { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 24, }, @@ -1056,17 +953,29 @@ type Foo = { options: [{ allowAliases: "never" }], errors: [ { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 12, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 18, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 24, }, @@ -1079,17 +988,29 @@ type Foo = { ], errors: [ { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 12, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 18, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 24, }, @@ -1100,17 +1021,29 @@ type Foo = { options: [{ allowAliases: "in-unions" }], errors: [ { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 12, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 18, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 24, }, @@ -1126,58 +1059,29 @@ type Foo = { ], errors: [ { - message: "Aliases in intersection types are not allowed.", - row: 1, - column: 12, - }, - { - message: "Aliases in intersection types are not allowed.", - row: 1, - column: 18, - }, - { - message: "Aliases in intersection types are not allowed.", - row: 1, - column: 24, - }, - ], - }, - { - code: "type Foo = 'a' | 'b' & 'c';", - errors: [ - { - message: "Aliases in union types are not allowed.", - row: 1, - column: 12, - }, - { - message: "Aliases in intersection types are not allowed.", - row: 1, - column: 18, - }, - { - message: "Aliases in intersection types are not allowed.", - row: 1, - column: 24, - }, - ], - }, - { - code: "type Foo = 'a' | 'b' & 'c';", - options: [{ allowLiterals: "in-intersections" }], - errors: [ - { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 12, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 18, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 24, }, @@ -1185,20 +1089,31 @@ type Foo = { }, { code: "type Foo = 'a' | 'b' & 'c';", - options: [{ allowAliases: false }], errors: [ { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 18, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 24, }, @@ -1206,22 +1121,32 @@ type Foo = { }, { code: "type Foo = 'a' | 'b' & 'c';", - options: [ - { allowAliases: false, allowLiterals: "in-intersections" }, - ], + options: [{ allowLiterals: "in-intersections" }], errors: [ { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 18, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 24, }, @@ -1232,17 +1157,29 @@ type Foo = { options: [{ allowAliases: "never" }], errors: [ { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 18, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 24, }, @@ -1255,17 +1192,29 @@ type Foo = { ], errors: [ { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 18, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 24, }, @@ -1276,12 +1225,20 @@ type Foo = { options: [{ allowAliases: "in-unions" }], errors: [ { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 18, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 24, }, @@ -1297,12 +1254,20 @@ type Foo = { ], errors: [ { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 18, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 24, }, @@ -1313,7 +1278,11 @@ type Foo = { options: [{ allowAliases: "in-intersections" }], errors: [ { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, @@ -1329,17 +1298,11 @@ type Foo = { ], errors: [ { - message: "Aliases in union types are not allowed.", - row: 1, - column: 12, - }, - ], - }, - { - code: "type Foo = string;", - errors: [ - { - message: "Type aliases are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, @@ -1347,10 +1310,12 @@ type Foo = { }, { code: "type Foo = string;", - options: [{ allowAliases: false }], errors: [ { - message: "Type aliases are not allowed.", + messageId: "noTypeAlias", + data: { + alias: "aliases", + }, row: 1, column: 12, }, @@ -1361,7 +1326,10 @@ type Foo = { options: [{ allowAliases: "never" }], errors: [ { - message: "Type aliases are not allowed.", + messageId: "noTypeAlias", + data: { + alias: "aliases", + }, row: 1, column: 12, }, @@ -1372,7 +1340,10 @@ type Foo = { options: [{ allowAliases: "in-unions" }], errors: [ { - message: "Type aliases are not allowed.", + messageId: "noTypeAlias", + data: { + alias: "aliases", + }, row: 1, column: 12, }, @@ -1383,7 +1354,10 @@ type Foo = { options: [{ allowAliases: "in-intersections" }], errors: [ { - message: "Type aliases are not allowed.", + messageId: "noTypeAlias", + data: { + alias: "aliases", + }, row: 1, column: 12, }, @@ -1394,7 +1368,10 @@ type Foo = { options: [{ allowAliases: "in-unions-and-intersections" }], errors: [ { - message: "Type aliases are not allowed.", + messageId: "noTypeAlias", + data: { + alias: "aliases", + }, row: 1, column: 12, }, @@ -1404,12 +1381,20 @@ type Foo = { code: "type Foo = string | string[];", errors: [ { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 21, }, @@ -1420,44 +1405,20 @@ type Foo = { options: [{ allowLiterals: "in-unions" }], errors: [ { - message: "Aliases in union types are not allowed.", - row: 1, - column: 12, - }, - { - message: "Aliases in union types are not allowed.", - row: 1, - column: 21, - }, - ], - }, - { - code: "type Foo = string | string[];", - options: [{ allowAliases: false }], - errors: [ - { - message: "Aliases in union types are not allowed.", - row: 1, - column: 12, - }, - { - message: "Aliases in union types are not allowed.", - row: 1, - column: 21, - }, - ], - }, - { - code: "type Foo = string | string[];", - options: [{ allowAliases: false, allowLiterals: "in-unions" }], - errors: [ - { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 21, }, @@ -1468,12 +1429,20 @@ type Foo = { options: [{ allowAliases: "never" }], errors: [ { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 21, }, @@ -1484,12 +1453,20 @@ type Foo = { options: [{ allowAliases: "never", allowLiterals: "in-unions" }], errors: [ { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 21, }, @@ -1500,12 +1477,20 @@ type Foo = { options: [{ allowAliases: "in-intersections" }], errors: [ { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 21, }, @@ -1521,12 +1506,20 @@ type Foo = { ], errors: [ { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 21, }, @@ -1536,17 +1529,29 @@ type Foo = { code: "type Foo = string | string[] | number;", errors: [ { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 21, }, { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 32, }, @@ -1557,59 +1562,29 @@ type Foo = { options: [{ allowLiterals: "in-unions" }], errors: [ { - message: "Aliases in union types are not allowed.", - row: 1, - column: 12, - }, - { - message: "Aliases in union types are not allowed.", - row: 1, - column: 21, - }, - { - message: "Aliases in union types are not allowed.", - row: 1, - column: 32, - }, - ], - }, - { - code: "type Foo = string | string[] | number;", - options: [{ allowAliases: false }], - errors: [ - { - message: "Aliases in union types are not allowed.", - row: 1, - column: 12, - }, - { - message: "Aliases in union types are not allowed.", - row: 1, - column: 21, - }, - { - message: "Aliases in union types are not allowed.", - row: 1, - column: 32, - }, - ], - }, - { - code: "type Foo = string | string[] | number;", - options: [{ allowAliases: false, allowLiterals: "in-unions" }], - errors: [ - { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 21, }, { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 32, }, @@ -1620,17 +1595,29 @@ type Foo = { options: [{ allowAliases: "never" }], errors: [ { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 21, }, { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 32, }, @@ -1641,17 +1628,29 @@ type Foo = { options: [{ allowAliases: "never", allowLiterals: "in-unions" }], errors: [ { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 21, }, { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 32, }, @@ -1662,17 +1661,29 @@ type Foo = { options: [{ allowAliases: "in-intersections" }], errors: [ { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 21, }, { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 32, }, @@ -1688,17 +1699,29 @@ type Foo = { ], errors: [ { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 21, }, { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 32, }, @@ -1708,17 +1731,29 @@ type Foo = { code: "type Foo = string | string[] & number;", errors: [ { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 21, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 32, }, @@ -1729,59 +1764,29 @@ type Foo = { options: [{ allowLiterals: "in-unions" }], errors: [ { - message: "Aliases in union types are not allowed.", - row: 1, - column: 12, - }, - { - message: "Aliases in intersection types are not allowed.", - row: 1, - column: 21, - }, - { - message: "Aliases in intersection types are not allowed.", - row: 1, - column: 32, - }, - ], - }, - { - code: "type Foo = string | string[] & number;", - options: [{ allowAliases: false }], - errors: [ - { - message: "Aliases in union types are not allowed.", - row: 1, - column: 12, - }, - { - message: "Aliases in intersection types are not allowed.", - row: 1, - column: 21, - }, - { - message: "Aliases in intersection types are not allowed.", - row: 1, - column: 32, - }, - ], - }, - { - code: "type Foo = string | string[] & number;", - options: [{ allowAliases: false, allowLiterals: "in-unions" }], - errors: [ - { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 21, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 32, }, @@ -1792,17 +1797,29 @@ type Foo = { options: [{ allowAliases: "never" }], errors: [ { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 21, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 32, }, @@ -1813,17 +1830,29 @@ type Foo = { options: [{ allowAliases: "never", allowLiterals: "in-unions" }], errors: [ { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 21, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 32, }, @@ -1834,12 +1863,20 @@ type Foo = { options: [{ allowAliases: "in-unions" }], errors: [ { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 21, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 32, }, @@ -1852,12 +1889,20 @@ type Foo = { ], errors: [ { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 21, }, { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 32, }, @@ -1868,7 +1913,11 @@ type Foo = { options: [{ allowAliases: "in-intersections" }], errors: [ { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, @@ -1884,20 +1933,11 @@ type Foo = { ], errors: [ { - message: "Aliases in union types are not allowed.", - row: 1, - column: 12, - }, - ], - }, - { - code: ` -interface Bar {} -type Foo = Bar; - `, - errors: [ - { - message: "Type aliases are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, @@ -1908,10 +1948,12 @@ type Foo = Bar; interface Bar {} type Foo = Bar; `, - options: [{ allowAliases: false }], errors: [ { - message: "Type aliases are not allowed.", + messageId: "noTypeAlias", + data: { + alias: "aliases", + }, row: 1, column: 12, }, @@ -1925,7 +1967,10 @@ type Foo = Bar; options: [{ allowAliases: "never" }], errors: [ { - message: "Type aliases are not allowed.", + messageId: "noTypeAlias", + data: { + alias: "aliases", + }, row: 1, column: 12, }, @@ -1939,7 +1984,10 @@ type Foo = Bar; options: [{ allowAliases: "in-unions" }], errors: [ { - message: "Type aliases are not allowed.", + messageId: "noTypeAlias", + data: { + alias: "aliases", + }, row: 1, column: 12, }, @@ -1953,7 +2001,10 @@ type Foo = Bar; options: [{ allowAliases: "in-intersections" }], errors: [ { - message: "Type aliases are not allowed.", + messageId: "noTypeAlias", + data: { + alias: "aliases", + }, row: 1, column: 12, }, @@ -1967,28 +2018,13 @@ type Foo = Bar; options: [{ allowAliases: "in-unions-and-intersections" }], errors: [ { - message: "Type aliases are not allowed.", - row: 1, - column: 12, - }, - ], - }, - { - code: ` -interface Bar {} -type Foo = Bar | {}; - `, - errors: [ - { - message: "Aliases in union types are not allowed.", + messageId: "noTypeAlias", + data: { + alias: "aliases", + }, row: 1, column: 12, }, - { - message: "Literals in union types are not allowed.", - row: 1, - column: 18, - }, ], }, { @@ -1996,15 +2032,22 @@ type Foo = Bar | {}; interface Bar {} type Foo = Bar | {}; `, - options: [{ allowAliases: false }], errors: [ { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Literals in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Literals", + compositionType: "union", + }, row: 1, column: 18, }, @@ -2018,12 +2061,20 @@ type Foo = Bar | {}; options: [{ allowAliases: "never" }], errors: [ { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Literals in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Literals", + compositionType: "union", + }, row: 1, column: 18, }, @@ -2037,7 +2088,11 @@ type Foo = Bar | {}; options: [{ allowAliases: "in-unions" }], errors: [ { - message: "Literals in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Literals", + compositionType: "union", + }, row: 1, column: 18, }, @@ -2051,12 +2106,20 @@ type Foo = Bar | {}; options: [{ allowAliases: "in-intersections" }], errors: [ { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Literals in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Literals", + compositionType: "union", + }, row: 1, column: 18, }, @@ -2070,25 +2133,11 @@ type Foo = Bar | {}; options: [{ allowAliases: "in-unions-and-intersections" }], errors: [ { - message: "Literals in union types are not allowed.", - row: 1, - column: 18, - }, - ], - }, - { - code: ` -interface Bar {} -type Foo = Bar & {}; - `, - errors: [ - { - message: "Aliases in intersection types are not allowed.", - row: 1, - column: 12, - }, - { - message: "Literals in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Literals", + compositionType: "union", + }, row: 1, column: 18, }, @@ -2099,15 +2148,22 @@ type Foo = Bar & {}; interface Bar {} type Foo = Bar & {}; `, - options: [{ allowAliases: false }], errors: [ { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 12, }, { - message: "Literals in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Literals", + compositionType: "intersection", + }, row: 1, column: 18, }, @@ -2121,12 +2177,20 @@ type Foo = Bar & {}; options: [{ allowAliases: "never" }], errors: [ { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 12, }, { - message: "Literals in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Literals", + compositionType: "intersection", + }, row: 1, column: 18, }, @@ -2140,12 +2204,20 @@ type Foo = Bar & {}; options: [{ allowAliases: "in-unions" }], errors: [ { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 12, }, { - message: "Literals in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Literals", + compositionType: "intersection", + }, row: 1, column: 18, }, @@ -2159,7 +2231,11 @@ type Foo = Bar & {}; options: [{ allowAliases: "in-intersections" }], errors: [ { - message: "Literals in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Literals", + compositionType: "intersection", + }, row: 1, column: 18, }, @@ -2173,7 +2249,11 @@ type Foo = Bar & {}; options: [{ allowAliases: "in-unions-and-intersections" }], errors: [ { - message: "Literals in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Literals", + compositionType: "intersection", + }, row: 1, column: 18, }, @@ -2183,18 +2263,10 @@ type Foo = Bar & {}; code: "type Foo = () => void;", errors: [ { - message: "Type callbacks are not allowed.", - row: 1, - column: 12, - }, - ], - }, - { - code: "type Foo = () => void;", - options: [{ allowCallbacks: false }], - errors: [ - { - message: "Type callbacks are not allowed.", + messageId: "noTypeAlias", + data: { + alias: "callbacks", + }, row: 1, column: 12, }, @@ -2205,17 +2277,10 @@ type Foo = Bar & {}; options: [{ allowCallbacks: "never" }], errors: [ { - message: "Type callbacks are not allowed.", - row: 1, - column: 12, - }, - ], - }, - { - code: "type Foo = {};", - errors: [ - { - message: "Type literals are not allowed.", + messageId: "noTypeAlias", + data: { + alias: "callbacks", + }, row: 1, column: 12, }, @@ -2223,10 +2288,12 @@ type Foo = Bar & {}; }, { code: "type Foo = {};", - options: [{ allowLiterals: false }], errors: [ { - message: "Type literals are not allowed.", + messageId: "noTypeAlias", + data: { + alias: "literals", + }, row: 1, column: 12, }, @@ -2237,7 +2304,10 @@ type Foo = Bar & {}; options: [{ allowLiterals: "never" }], errors: [ { - message: "Type literals are not allowed.", + messageId: "noTypeAlias", + data: { + alias: "literals", + }, row: 1, column: 12, }, @@ -2248,7 +2318,10 @@ type Foo = Bar & {}; options: [{ allowLiterals: "in-unions" }], errors: [ { - message: "Type literals are not allowed.", + messageId: "noTypeAlias", + data: { + alias: "literals", + }, row: 1, column: 12, }, @@ -2259,7 +2332,10 @@ type Foo = Bar & {}; options: [{ allowLiterals: "in-intersections" }], errors: [ { - message: "Type literals are not allowed.", + messageId: "noTypeAlias", + data: { + alias: "literals", + }, row: 1, column: 12, }, @@ -2270,7 +2346,10 @@ type Foo = Bar & {}; options: [{ allowLiterals: "in-unions-and-intersections" }], errors: [ { - message: "Type literals are not allowed.", + messageId: "noTypeAlias", + data: { + alias: "literals", + }, row: 1, column: 12, }, @@ -2281,20 +2360,10 @@ type Foo = Bar & {}; options: [{ allowAliases: "in-intersections" }], errors: [ { - message: "Type literals are not allowed.", - row: 1, - column: 12, - }, - ], - }, - { - code: "type Foo = {};", - options: [ - { allowLiterals: false, allowAliases: "in-intersections" }, - ], - errors: [ - { - message: "Type literals are not allowed.", + messageId: "noTypeAlias", + data: { + alias: "literals", + }, row: 1, column: 12, }, @@ -2307,7 +2376,10 @@ type Foo = Bar & {}; ], errors: [ { - message: "Type literals are not allowed.", + messageId: "noTypeAlias", + data: { + alias: "literals", + }, row: 1, column: 12, }, @@ -2323,7 +2395,10 @@ type Foo = Bar & {}; ], errors: [ { - message: "Type literals are not allowed.", + messageId: "noTypeAlias", + data: { + alias: "literals", + }, row: 1, column: 12, }, @@ -2339,7 +2414,10 @@ type Foo = Bar & {}; ], errors: [ { - message: "Type literals are not allowed.", + messageId: "noTypeAlias", + data: { + alias: "literals", + }, row: 1, column: 12, }, @@ -2355,38 +2433,33 @@ type Foo = Bar & {}; ], errors: [ { - message: "Type literals are not allowed.", - row: 1, - column: 12, - }, - ], - }, - { - code: "type Foo = {} | {};", - errors: [ - { - message: "Literals in union types are not allowed.", + messageId: "noTypeAlias", + data: { + alias: "literals", + }, row: 1, column: 12, }, - { - message: "Literals in union types are not allowed.", - row: 1, - column: 17, - }, ], }, { code: "type Foo = {} | {};", - options: [{ allowLiterals: false }], errors: [ { - message: "Literals in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Literals", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Literals in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Literals", + compositionType: "union", + }, row: 1, column: 17, }, @@ -2397,12 +2470,20 @@ type Foo = Bar & {}; options: [{ allowLiterals: "never" }], errors: [ { - message: "Literals in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Literals", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Literals in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Literals", + compositionType: "union", + }, row: 1, column: 17, }, @@ -2413,12 +2494,20 @@ type Foo = Bar & {}; options: [{ allowLiterals: "in-intersections" }], errors: [ { - message: "Literals in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Literals", + compositionType: "union", + }, row: 1, column: 12, }, { - message: "Literals in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Literals", + compositionType: "union", + }, row: 1, column: 17, }, @@ -2428,28 +2517,20 @@ type Foo = Bar & {}; code: "type Foo = {} & {};", errors: [ { - message: "Literals in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Literals", + compositionType: "intersection", + }, row: 1, column: 12, }, { - message: "Literals in intersection types are not allowed.", - row: 1, - column: 17, - }, - ], - }, - { - code: "type Foo = {} & {};", - options: [{ allowLiterals: false }], - errors: [ - { - message: "Literals in intersection types are not allowed.", - row: 1, - column: 12, - }, - { - message: "Literals in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Literals", + compositionType: "intersection", + }, row: 1, column: 17, }, @@ -2460,12 +2541,20 @@ type Foo = Bar & {}; options: [{ allowLiterals: "never" }], errors: [ { - message: "Literals in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Literals", + compositionType: "intersection", + }, row: 1, column: 12, }, { - message: "Literals in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Literals", + compositionType: "intersection", + }, row: 1, column: 17, }, @@ -2476,12 +2565,20 @@ type Foo = Bar & {}; options: [{ allowLiterals: "in-unions" }], errors: [ { - message: "Literals in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Literals", + compositionType: "intersection", + }, row: 1, column: 12, }, { - message: "Literals in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Literals", + compositionType: "intersection", + }, row: 1, column: 17, }, @@ -2494,12 +2591,20 @@ type Foo = Bar & {}; ], errors: [ { - message: "Aliases in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "intersection", + }, row: 1, column: 12, }, { - message: "Literals in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Literals", + compositionType: "intersection", + }, row: 1, column: 21, }, @@ -2515,17 +2620,29 @@ type Foo = Bar & {}; ], errors: [ { - message: "Literals in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Literals", + compositionType: "intersection", + }, row: 1, column: 21, }, { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 26, }, { - message: "Aliases in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Aliases", + compositionType: "union", + }, row: 1, column: 32, }, @@ -2539,22 +2656,10 @@ type Foo = { `, errors: [ { - message: "Type mapped types are not allowed.", - row: 1, - column: 15, - }, - ], - }, - { - code: ` -type Foo = { - readonly [P in keyof T] : T[P] -}; - `, - options: [{ allowMappedTypes: false }], - errors: [ - { - message: "Type mapped types are not allowed.", + messageId: "noTypeAlias", + data: { + alias: "mapped types", + }, row: 1, column: 15, }, @@ -2569,7 +2674,10 @@ type Foo = { options: [{ allowMappedTypes: "never" }], errors: [ { - message: "Type mapped types are not allowed.", + messageId: "noTypeAlias", + data: { + alias: "mapped types", + }, row: 1, column: 15, }, @@ -2584,7 +2692,10 @@ type Foo = { options: [{ allowMappedTypes: "in-unions" }], errors: [ { - message: "Type mapped types are not allowed.", + messageId: "noTypeAlias", + data: { + alias: "mapped types", + }, row: 1, column: 15, }, @@ -2599,7 +2710,10 @@ type Foo = { options: [{ allowMappedTypes: "in-intersections" }], errors: [ { - message: "Type mapped types are not allowed.", + messageId: "noTypeAlias", + data: { + alias: "mapped types", + }, row: 1, column: 15, }, @@ -2614,31 +2728,13 @@ type Foo = { options: [{ allowMappedTypes: "in-unions-and-intersections" }], errors: [ { - message: "Type mapped types are not allowed.", - row: 1, - column: 15, - }, - ], - }, - { - code: ` -type Foo = { - readonly [P in keyof T] : T[P] -} | { - readonly [P in keyof T] : T[P] -}; - `, - errors: [ - { - message: "Mapped types in union types are not allowed.", + messageId: "noTypeAlias", + data: { + alias: "mapped types", + }, row: 1, column: 15, }, - { - message: "Mapped types in union types are not allowed.", - row: 4, - column: 5, - }, ], }, { @@ -2649,15 +2745,22 @@ type Foo = { readonly [P in keyof T] : T[P] }; `, - options: [{ allowMappedTypes: false }], errors: [ { - message: "Mapped types in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Mapped types", + compositionType: "union", + }, row: 1, column: 15, }, { - message: "Mapped types in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Mapped types", + compositionType: "union", + }, row: 4, column: 5, }, @@ -2674,12 +2777,20 @@ type Foo = { options: [{ allowMappedTypes: "never" }], errors: [ { - message: "Mapped types in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Mapped types", + compositionType: "union", + }, row: 1, column: 15, }, { - message: "Mapped types in union types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Mapped types", + compositionType: "union", + }, row: 4, column: 5, }, @@ -2696,35 +2807,20 @@ type Foo = { options: [{ allowMappedTypes: "in-intersections" }], errors: [ { - message: "Mapped types in union types are not allowed.", - row: 1, - column: 15, - }, - { - message: "Mapped types in union types are not allowed.", - row: 4, - column: 5, - }, - ], - }, - { - code: ` -type Foo = { - readonly [P in keyof T] : T[P] -} & { - readonly [P in keyof T] : T[P] -}; - `, - errors: [ - { - message: - "Mapped types in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Mapped types", + compositionType: "union", + }, row: 1, column: 15, }, { - message: - "Mapped types in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Mapped types", + compositionType: "union", + }, row: 4, column: 5, }, @@ -2738,17 +2834,22 @@ type Foo = { readonly [P in keyof T] : T[P] }; `, - options: [{ allowMappedTypes: false }], errors: [ { - message: - "Mapped types in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Mapped types", + compositionType: "intersection", + }, row: 1, column: 15, }, { - message: - "Mapped types in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Mapped types", + compositionType: "intersection", + }, row: 4, column: 5, }, @@ -2765,14 +2866,20 @@ type Foo = { options: [{ allowMappedTypes: "never" }], errors: [ { - message: - "Mapped types in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Mapped types", + compositionType: "intersection", + }, row: 1, column: 15, }, { - message: - "Mapped types in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Mapped types", + compositionType: "intersection", + }, row: 4, column: 5, }, @@ -2789,14 +2896,20 @@ type Foo = { options: [{ allowMappedTypes: "in-unions" }], errors: [ { - message: - "Mapped types in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Mapped types", + compositionType: "intersection", + }, row: 1, column: 15, }, { - message: - "Mapped types in intersection types are not allowed.", + messageId: "noCompositionAlias", + data: { + typeName: "Mapped types", + compositionType: "intersection", + }, row: 4, column: 5, },