From 5362561e758a062d5061e00e0b0283afb6cc231b Mon Sep 17 00:00:00 2001 From: BO41 Date: Tue, 3 Dec 2019 00:15:33 +0100 Subject: [PATCH 1/6] docs(eslint-plugin): typo in space-before-function-paren docs (#1297) --- .../eslint-plugin/docs/rules/space-before-function-paren.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/eslint-plugin/docs/rules/space-before-function-paren.md b/packages/eslint-plugin/docs/rules/space-before-function-paren.md index df8d848c7b42..99c9bcdd9dd0 100644 --- a/packages/eslint-plugin/docs/rules/space-before-function-paren.md +++ b/packages/eslint-plugin/docs/rules/space-before-function-paren.md @@ -4,7 +4,7 @@ When formatting a function, whitespace is allowed between the function name or ` ```ts -function withoutSpace (x) { +function withoutSpace(x) { // ... } @@ -12,7 +12,7 @@ function withSpace (x) { // ... } -var anonymousWithoutSpace = function () {}; +var anonymousWithoutSpace = function() {}; var anonymousWithSpace = function () {}; ``` From 39f654b3042d0b1d7059ac85dc2a45876dd2a8a5 Mon Sep 17 00:00:00 2001 From: komkanit Date: Tue, 3 Dec 2019 11:13:07 +0700 Subject: [PATCH 2/6] test(eslint-plugin): [unified-signatures] add tests for #740 (#1074) Co-authored-by: Brad Zacher --- .../tests/rules/unified-signatures.test.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/packages/eslint-plugin/tests/rules/unified-signatures.test.ts b/packages/eslint-plugin/tests/rules/unified-signatures.test.ts index 38a74429af7f..e3438ff78856 100644 --- a/packages/eslint-plugin/tests/rules/unified-signatures.test.ts +++ b/packages/eslint-plugin/tests/rules/unified-signatures.test.ts @@ -136,6 +136,27 @@ declare module "foo" { `, ` export default function(foo: number): string[]; +`, + // https://github.com/typescript-eslint/typescript-eslint/issues/740 + ` +function p(key: string): Promise +function p(key: string, defaultValue: string): Promise +function p(key: string, defaultValue?: string): Promise +{ + const obj: Record = { } + return obj[key] || defaultValue +} + `, + ` +interface I { + p(x: T): Promise; + p(x: number): Promise; +} + `, + ` +function rest(...xs: number[]): Promise; +function rest(xs: number[], y: string): Promise; +async function rest(...args: any[], y?: string): Promise { return y || args } `, ], invalid: [ From b5a52a3aae85fce3bc45b39a2107a00d2655f5f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Veyret?= Date: Tue, 3 Dec 2019 19:55:57 +0100 Subject: [PATCH 3/6] feat(eslint-plugin): [member-ordering] add index signature (#1190) Co-authored-by: Brad Zacher --- .../docs/rules/member-ordering.md | 70 ++++- .../src/rules/member-ordering.ts | 12 +- packages/eslint-plugin/src/util/misc.ts | 13 + .../tests/rules/member-ordering.test.ts | 292 +++++++++++++----- 4 files changed, 298 insertions(+), 89 deletions(-) diff --git a/packages/eslint-plugin/docs/rules/member-ordering.md b/packages/eslint-plugin/docs/rules/member-ordering.md index 517673f09d68..d803e9def7e8 100644 --- a/packages/eslint-plugin/docs/rules/member-ordering.md +++ b/packages/eslint-plugin/docs/rules/member-ordering.md @@ -17,8 +17,8 @@ It allows to group members by their type (e.g. `public-static-field`, `protected classes?: Array | never classExpressions?: Array | never - interfaces?: ['field' | 'method' | 'constructor'] | never - typeLiterals?: ['field' | 'method' | 'constructor'] | never + interfaces?: ['signature' | 'field' | 'method' | 'constructor'] | never + typeLiterals?: ['signature' | 'field' | 'method' | 'constructor'] | never } ``` @@ -30,6 +30,9 @@ There are multiple ways to specify the member types. The most explicit and granu ```json5 [ + // Index signature + 'signature', + // Fields 'public-static-field', 'protected-static-field', @@ -67,6 +70,9 @@ It is also possible to group member types by their accessibility (`static`, `ins ```json5 [ + // Index signature + // No accessibility for index signature. See above. + // Fields 'public-field', // = ['public-static-field', 'public-instance-field']) 'protected-field', // = ['protected-static-field', 'protected-instance-field']) @@ -88,6 +94,9 @@ Another option is to group the member types by their scope (`public`, `protected ```json5 [ + // Index signature + // No scope for index signature. See above. + // Fields 'static-field', // = ['public-static-field', 'protected-static-field', 'private-static-field']) 'instance-field', // = ['public-instance-field', 'protected-instance-field', 'private-instance-field']) @@ -109,6 +118,9 @@ The third grouping option is to ignore both scope and accessibility. ```json5 [ + // Index signature + // No grouping for index signature. See above. + // Fields 'field', // = ['public-static-field', 'protected-static-field', 'private-static-field', 'public-instance-field', 'protected-instance-field', 'private-instance-field', // 'public-abstract-field', 'protected-abstract-field', private-abstract-field']) @@ -129,6 +141,8 @@ The default configuration looks as follows: ```json { "default": [ + "signature", + "public-static-field", "protected-static-field", "private-static-field", @@ -186,7 +200,7 @@ Note: The default configuration contains member group types which contain other Note: The `default` options are overwritten in these examples. -#### Configuration: `{ "default": ["method", "constructor", "field"] }` +#### Configuration: `{ "default": ["signature", "method", "constructor", "field"] }` ##### Incorrect examples @@ -197,6 +211,8 @@ interface Foo { new (); // -> constructor A(): void; // -> method + + [Z: string]: any; // -> signature } ``` @@ -209,6 +225,8 @@ type Foo = { // no constructor A(): void; // -> method + + // no signature }; ``` @@ -224,10 +242,12 @@ class Foo { public static A(): void {} // -> method public B(): void {} // -> method + + [Z: string]: any; // -> signature } ``` -Note: Accessibility or scope are ignored with this ignored. +Note: Accessibility or scope are ignored with this configuration. ```ts const Foo = class { @@ -239,6 +259,8 @@ const Foo = class { public static A(): void {} // -> method public B(): void {} // -> method + [Z: string]: any; // -> signature + protected static E: string; // -> field }; ``` @@ -249,6 +271,8 @@ Note: Not all members have to be grouped to find rule violations. ```ts interface Foo { + [Z: string]: any; // -> signature + A(): void; // -> method new (); // -> constructor @@ -259,6 +283,8 @@ interface Foo { ```ts type Foo = { + // no signature + A(): void; // -> method // no constructor @@ -269,6 +295,8 @@ type Foo = { ```ts class Foo { + [Z: string]: any; // -> signature + public static A(): void {} // -> method public B(): void {} // -> method @@ -282,6 +310,8 @@ class Foo { ```ts const Foo = class { + [Z: string]: any; // -> signature + public static A(): void {} // -> method public B(): void {} // -> method @@ -311,6 +341,8 @@ class Foo { public static A(): void {} // (irrelevant) + [Z: string]: any; // (irrelevant) + public B(): void {} // -> public instance method } ``` @@ -321,6 +353,8 @@ Note: Public instance methods should come first before public static fields. Eve const Foo = class { private C: string; // (irrelevant) + [Z: string]: any; // (irrelevant) + public static E: string; // -> public static field public D: string; // (irrelevant) @@ -350,6 +384,8 @@ class Foo { constructor() {} // (irrelevant) public static A(): void {} // (irrelevant) + + [Z: string]: any; // (irrelevant) } ``` @@ -359,6 +395,8 @@ const Foo = class { private C: string; // (irrelevant) + [Z: string]: any; // (irrelevant) + public D: string; // (irrelevant) constructor() {} // (irrelevant) @@ -384,6 +422,8 @@ class Foo { private static D: string; // -> static field public static A: string; // -> public static field + + [Z: string]: any; // (irrelevant) } ``` @@ -402,6 +442,8 @@ const foo = class { protected static C: string; // -> static field private static D: string; // -> static field + [Z: string]: any; // (irrelevant) + public static A: string; // -> public static field }; ``` @@ -424,6 +466,8 @@ class Foo { ```ts const foo = class { + [Z: string]: any; // -> signature + public static A: string; // -> public static field constructor() {} // -> constructor @@ -596,11 +640,11 @@ const foo = class { Note: If this is not set, the `default` will automatically be applied to classes expressions as well. If a `interfaces` configuration is provided, only this configuration will be used for `interfaces` (i.e. nothing will be merged with `default`). -Note: The configuration for `interfaces` only allows a limited set of member types: `field`, `constructor` and `method`. +Note: The configuration for `interfaces` only allows a limited set of member types: `signature`, `field`, `constructor` and `method`. Note: The configuration for `interfaces` does not apply to type literals (use `typeLiterals` for them). -#### Configuration: `{ "interfaces": ["method", "constructor", "field"] }` +#### Configuration: `{ "interfaces": ["signature", "method", "constructor", "field"] }` ##### Incorrect example @@ -611,6 +655,8 @@ interface Foo { new (); // -> constructor A(): void; // -> method + + [Z: string]: any; // -> signature } ``` @@ -618,6 +664,8 @@ interface Foo { ```ts interface Foo { + [Z: string]: any; // -> signature + A(): void; // -> method new (); // -> constructor @@ -630,11 +678,11 @@ interface Foo { Note: If this is not set, the `default` will automatically be applied to classes expressions as well. If a `typeLiterals` configuration is provided, only this configuration will be used for `typeLiterals` (i.e. nothing will be merged with `default`). -Note: The configuration for `typeLiterals` only allows a limited set of member types: `field`, `constructor` and `method`. +Note: The configuration for `typeLiterals` only allows a limited set of member types: `signature`, `field`, `constructor` and `method`. -Note: The configuration for `typeLiterals` does not apply to type literals (use `interfaces` for them). +Note: The configuration for `typeLiterals` does not apply to interfaces (use `interfaces` for them). -#### Configuration: `{ "typeLiterals": ["method", "constructor", "field"] }` +#### Configuration: `{ "typeLiterals": ["signature", "method", "constructor", "field"] }` ##### Incorrect example @@ -645,6 +693,8 @@ type Foo = { A(): void; // -> method new (); // -> constructor + + [Z: string]: any; // -> signature }; ``` @@ -652,6 +702,8 @@ type Foo = { ```ts type Foo = { + [Z: string]: any; // -> signature + A(): void; // -> method new (); // -> constructor diff --git a/packages/eslint-plugin/src/rules/member-ordering.ts b/packages/eslint-plugin/src/rules/member-ordering.ts index c8911292836b..56e3fae240cb 100644 --- a/packages/eslint-plugin/src/rules/member-ordering.ts +++ b/packages/eslint-plugin/src/rules/member-ordering.ts @@ -39,6 +39,7 @@ const allMemberTypes = ['field', 'method', 'constructor'].reduce( }, [], ); +allMemberTypes.unshift('signature'); export default util.createRule({ name: 'member-ordering', @@ -104,7 +105,7 @@ export default util.createRule({ { type: 'array', items: { - enum: ['field', 'method', 'constructor'], + enum: ['signature', 'field', 'method', 'constructor'], }, }, ], @@ -117,7 +118,7 @@ export default util.createRule({ { type: 'array', items: { - enum: ['field', 'method', 'constructor'], + enum: ['signature', 'field', 'method', 'constructor'], }, }, ], @@ -130,6 +131,8 @@ export default util.createRule({ defaultOptions: [ { default: [ + 'signature', + 'public-static-field', 'protected-static-field', 'private-static-field', @@ -194,7 +197,6 @@ export default util.createRule({ node: TSESTree.ClassElement | TSESTree.TypeElement, ): string | null { // TODO: add missing TSCallSignatureDeclaration - // TODO: add missing TSIndexSignature switch (node.type) { case AST_NODE_TYPES.TSAbstractMethodDefinition: case AST_NODE_TYPES.MethodDefinition: @@ -210,6 +212,8 @@ export default util.createRule({ : 'field'; case AST_NODE_TYPES.TSPropertySignature: return 'field'; + case AST_NODE_TYPES.TSIndexSignature: + return 'signature'; default: return null; } @@ -235,6 +239,8 @@ export default util.createRule({ : util.getNameFromClassMember(node, sourceCode); case AST_NODE_TYPES.TSConstructSignatureDeclaration: return 'new'; + case AST_NODE_TYPES.TSIndexSignature: + return util.getNameFromIndexSignature(node); default: return null; } diff --git a/packages/eslint-plugin/src/util/misc.ts b/packages/eslint-plugin/src/util/misc.ts index f7c8c0194ba5..bf65b97b898a 100644 --- a/packages/eslint-plugin/src/util/misc.ts +++ b/packages/eslint-plugin/src/util/misc.ts @@ -48,6 +48,19 @@ type InferMessageIdsTypeFromRule = T extends TSESLint.RuleModule< ? TMessageIds : unknown; +/** + * Gets a string representation of the name of the index signature. + */ +export function getNameFromIndexSignature( + node: TSESTree.TSIndexSignature, +): string { + const propName: TSESTree.PropertyName | undefined = node.parameters.find( + (parameter: TSESTree.Parameter): parameter is TSESTree.Identifier => + parameter.type === AST_NODE_TYPES.Identifier, + ); + return propName ? getNameFromPropertyName(propName) : '(index signature)'; +} + /** * Gets a string name representation of the given PropertyName node */ diff --git a/packages/eslint-plugin/tests/rules/member-ordering.test.ts b/packages/eslint-plugin/tests/rules/member-ordering.test.ts index 936fe3a89004..5307793c3d7f 100644 --- a/packages/eslint-plugin/tests/rules/member-ordering.test.ts +++ b/packages/eslint-plugin/tests/rules/member-ordering.test.ts @@ -10,6 +10,7 @@ ruleTester.run('member-ordering', rule, { ` // no accessibility === public interface Foo { + [Z: string]: any; A: string; B: string; C: string; @@ -38,6 +39,7 @@ interface Foo { new(); G(); H(); + [Z: string]: any; B: string; C: string; I(); @@ -50,6 +52,7 @@ interface Foo { code: ` // no accessibility === public interface Foo { + [Z: string]: any; A: string; B: string; C: string; @@ -65,7 +68,7 @@ interface Foo { L(); } `, - options: [{ default: ['field', 'constructor', 'method'] }], + options: [{ default: ['signature', 'field', 'constructor', 'method'] }], }, { @@ -76,6 +79,7 @@ interface Foo { J(); K(); D: string; + [Z: string]: any; E: string; F: string; new(); @@ -93,6 +97,7 @@ interface Foo { code: ` // no accessibility === public interface Foo { + [Z: string]: any; G(); H(); I(); @@ -108,7 +113,9 @@ interface Foo { F: string; } `, - options: [{ interfaces: ['method', 'constructor', 'field'] }], + options: [ + { interfaces: ['signature', 'method', 'constructor', 'field'] }, + ], }, { code: ` @@ -127,12 +134,13 @@ interface Foo { D: string; E: string; F: string; + [Z: string]: any; } `, options: [ { - default: ['field', 'constructor', 'method'], - interfaces: ['method', 'constructor', 'field'], + default: ['signature', 'field', 'constructor', 'method'], + interfaces: ['method', 'constructor', 'field', 'signature'], }, ], }, @@ -144,6 +152,7 @@ interface Foo { H(); I(); new(); + [Z: string]: any; D: string; E: string; F: string; @@ -176,6 +185,7 @@ interface Foo { J(); K(); L(); + [Z: string]: any; D: string; E: string; F: string; @@ -194,6 +204,7 @@ interface Foo { ` // no accessibility === public type Foo = { + [Z: string]: any; A: string; B: string; C: string; @@ -219,6 +230,7 @@ type Foo = { D: string; E: string; F: string; + [Z: string]: any; G(); H(); I(); @@ -233,6 +245,7 @@ type Foo = { code: ` // no accessibility === public type Foo = { + [Z: string]: any; A: string; B: string; C: string; @@ -247,12 +260,13 @@ type Foo = { L(); } `, - options: [{ default: ['field', 'constructor', 'method'] }], + options: [{ default: ['signature', 'field', 'constructor', 'method'] }], }, { code: ` // no accessibility === public type Foo = { + [Z: string]: any; new(); A: string; B: string; @@ -276,6 +290,7 @@ type Foo = { type Foo = { G(); H(); + [Z: string]: any; K(); L(); A: string; @@ -306,9 +321,10 @@ type Foo = { D: string; E: string; F: string; + [Z: string]: any; } `, - options: [{ typeLiterals: ['method', 'field'] }], + options: [{ typeLiterals: ['method', 'field', 'signature'] }], }, { code: ` @@ -326,9 +342,12 @@ type Foo = { D: string; E: string; F: string; + [Z: string]: any; } `, - options: [{ typeLiterals: ['method', 'constructor', 'field'] }], + options: [ + { typeLiterals: ['method', 'constructor', 'field', 'signature'] }, + ], }, { code: ` @@ -346,12 +365,13 @@ type Foo = { D: string; E: string; F: string; + [Z: string]: any; } `, options: [ { - default: ['field', 'constructor', 'method'], - typeLiterals: ['method', 'constructor', 'field'], + default: ['signature', 'field', 'constructor', 'method'], + typeLiterals: ['method', 'constructor', 'field', 'signature'], }, ], }, @@ -359,6 +379,7 @@ type Foo = { code: ` // no accessibility === public type Foo = { + [Z: string]: any; D: string; E: string; F: string; @@ -380,12 +401,13 @@ type Foo = { 'public-constructor', 'protected-static-field', ], - typeLiterals: ['field', 'method'], + typeLiterals: ['signature', 'field', 'method'], }, ], }, ` class Foo { + [Z: string]: any; public static A: string; protected static B: string = ""; private static C: string = ""; @@ -404,6 +426,7 @@ class Foo { { code: ` class Foo { + [Z: string]: any; public static A: string; protected static B: string = ""; private static C: string = ""; @@ -424,6 +447,7 @@ class Foo { { code: ` class Foo { + [Z: string]: any; public static A: string; protected static B: string = ""; private static C: string = ""; @@ -439,11 +463,12 @@ class Foo { private L() {} } `, - options: [{ default: ['field', 'constructor', 'method'] }], + options: [{ default: ['signature', 'field', 'constructor', 'method'] }], }, { code: ` class Foo { + [Z: string]: any; constructor() {} public static A: string; protected static B: string = ""; @@ -470,6 +495,7 @@ class Foo { private static I() {} public J() {} public D: string = ""; + [Z: string]: any; protected static H() {} public static A: string; protected static B: string = ""; @@ -490,6 +516,7 @@ class Foo { public J() {} protected K() {} private L() {} + [Z: string]: any; public static A: string; protected static B: string = ""; private static C: string = ""; @@ -517,9 +544,10 @@ class Foo { public D: string = ""; protected E: string = ""; private F: string = ""; + [Z: string]: any; } `, - options: [{ classes: ['method', 'constructor', 'field'] }], + options: [{ classes: ['method', 'constructor', 'field', 'signature'] }], }, { code: ` @@ -552,12 +580,13 @@ class Foo { public D: string = ""; protected E: string = ""; private F: string = ""; + [Z: string]: any; } `, options: [ { - default: ['field', 'constructor', 'method'], - classes: ['method', 'constructor', 'field'], + default: ['signature', 'field', 'constructor', 'method'], + classes: ['method', 'constructor', 'field', 'signature'], }, ], }, @@ -570,6 +599,7 @@ class Foo { private static I() {} protected K() {} private L() {} + [Z: string]: any; constructor() {} public D: string = ""; public static A: string; @@ -583,6 +613,7 @@ class Foo { { classes: [ 'public-method', + 'signature', 'constructor', 'public-field', 'private-field', @@ -600,6 +631,7 @@ class Foo { public J() {} private L() {} protected K() {} + [Z: string]: any; constructor() {} public D: string = ""; public static A: string; @@ -616,6 +648,7 @@ class Foo { 'static-method', 'public-instance-method', 'instance-method', + 'signature', 'constructor', 'public-field', 'protected-field', @@ -640,6 +673,7 @@ class Foo { private static C: string = ""; protected E: string = ""; private F: string = ""; + [Z: string]: any; } `, options: [ @@ -650,6 +684,7 @@ class Foo { 'constructor', 'method', 'field', + 'signature', ], }, ], @@ -664,6 +699,7 @@ class Foo { protected K() {} private L() {} constructor() {} + [Z: string]: any; public static A: string; private F: string = ""; protected static B: string = ""; @@ -681,6 +717,7 @@ class Foo { 'protected-instance-method', 'private-instance-method', 'constructor', + 'signature', 'field', ], }, @@ -702,7 +739,7 @@ class Foo { public static A: string; public D: string = ""; constructor() {} - + [Z: string]: any; } `, options: [ @@ -727,7 +764,7 @@ class Foo { public static A: string; public D: string = ""; constructor() {} - + [Z: string]: any; } `, options: [ @@ -752,7 +789,7 @@ class Foo { public static A: string; public D: string = ""; constructor() {} - + [Z: string]: any; } `, options: [ @@ -764,6 +801,7 @@ class Foo { { code: ` class Foo { + [Z: string]: any; public D: string = ""; private L() {} private static I() {} @@ -804,6 +842,7 @@ class Foo { protected static H() {} public static G() {} public J() {} + [Z: string]: any; protected static B: string = ""; protected K() {} private static C: string = ""; @@ -829,6 +868,7 @@ class Foo { }, ` const foo = class Foo { + [Z: string]: any; public static A: string; protected static B: string = ""; private static C: string = ""; @@ -853,6 +893,7 @@ const foo = class Foo { private static I() {} public J() {} private F: string = ""; + [Z: string]: any; public static G() {} private static C: string = ""; public D: string = ""; @@ -867,6 +908,7 @@ const foo = class Foo { { code: ` const foo = class Foo { + [Z: string]: any; public static A: string; protected static B: string = ""; private static C: string = ""; @@ -882,7 +924,7 @@ const foo = class Foo { private L() {} } `, - options: [{ default: ['field', 'constructor', 'method'] }], + options: [{ default: ['signature', 'field', 'constructor', 'method'] }], }, { code: ` @@ -894,6 +936,7 @@ const foo = class Foo { public D: string = ""; protected E: string = ""; private F: string = ""; + [Z: string]: any; public static G() {} protected static H() {} private static I() {} @@ -913,6 +956,7 @@ const foo = class Foo { private static I() {} public J() {} private static C: string = ""; + [Z: string]: any; public D: string = ""; protected K() {} public static G() {} @@ -940,6 +984,7 @@ const foo = class Foo { protected E: string = ""; private F: string = ""; constructor() {} + [Z: string]: any; } `, options: [{ classExpressions: ['method', 'field'] }], @@ -953,6 +998,7 @@ const foo = class Foo { public J() {} protected K() {} private L() {} + [Z: string]: any; constructor() {} public static A: string; protected static B: string = ""; @@ -962,7 +1008,9 @@ const foo = class Foo { private F: string = ""; } `, - options: [{ classExpressions: ['method', 'constructor', 'field'] }], + options: [ + { classExpressions: ['method', 'signature', 'constructor', 'field'] }, + ], }, { code: ` @@ -973,6 +1021,7 @@ const foo = class Foo { public J() {} protected K() {} private L() {} + [Z: string]: any; constructor() {} public static A: string; protected static B: string = ""; @@ -985,13 +1034,14 @@ const foo = class Foo { options: [ { default: ['field', 'constructor', 'method'], - classExpressions: ['method', 'constructor', 'field'], + classExpressions: ['method', 'signature', 'constructor', 'field'], }, ], }, { code: ` const foo = class Foo { + [Z: string]: any; private L() {} private static I() {} protected static H() {} @@ -1025,6 +1075,7 @@ const foo = class Foo { protected static H() {} public static G() {} public J() {} + [Z: string]: any; protected static B: string = ""; protected K() {} private static C: string = ""; @@ -1050,6 +1101,7 @@ const foo = class Foo { protected static H() {} public static G() {} public J() {} + [Z: string]: any; protected static B: string = ""; protected K() {} private static C: string = ""; @@ -1079,6 +1131,7 @@ const foo = class Foo { protected static H() {} public static G() {} public J() {} + [Z: string]: any; private constructor() {} protected static B: string = ""; protected K() {} @@ -1120,6 +1173,7 @@ const foo = class Foo { public J() {} protected static B: string = ""; protected K() {} + [Z: string]: any; private static C: string = ""; private F: string = ""; protected E: string = ""; @@ -1148,6 +1202,7 @@ const foo = class Foo { }, ` class Foo { + [Z: string]: any; A: string; constructor () {} J() {} @@ -1161,9 +1216,10 @@ class Foo { K = () => {} constructor () {} A: string; + [Z: string]: any; } `, - options: [{ default: ['method', 'constructor', 'field'] }], + options: [{ default: ['method', 'constructor', 'field', 'signature'] }], }, { code: ` @@ -1171,14 +1227,16 @@ class Foo { J() {} K = () => {} constructor () {} + [Z: string]: any; A: string; L: () => {} } `, - options: [{ default: ['method', 'constructor', 'field'] }], + options: [{ default: ['method', 'constructor', 'signature', 'field'] }], }, ` interface Foo { + [Z: string]: any; A: string; K: () => {}; J(); @@ -1187,15 +1245,17 @@ interface Foo { { code: ` interface Foo { + [Z: string]: any; J(); K: () => {} A: string; } `, - options: [{ default: ['method', 'constructor', 'field'] }], + options: [{ default: ['signature', 'method', 'constructor', 'field'] }], }, ` type Foo = { + [Z: string]: any; A: string; K: () => {} J(); @@ -1205,11 +1265,12 @@ type Foo = { code: ` type Foo = { J(); + [Z: string]: any; K: () => {} A: string; } `, - options: [{ default: ['method', 'constructor', 'field'] }], + options: [{ default: ['method', 'constructor', 'signature', 'field'] }], }, { code: ` @@ -1222,14 +1283,15 @@ abstract class Foo { { code: ` interface Foo { - public B: string; [A:string]: number; + public B: string; } `, }, { code: ` abstract class Foo { + [Z: string]: any; private static C: string; B: string; private D: string; @@ -1248,7 +1310,7 @@ abstract class Foo { abstract verify(): void; } `, - options: [{ classes: ['field', 'constructor', 'method'] }], + options: [{ classes: ['signature', 'field', 'constructor', 'method'] }], }, ], invalid: [ @@ -1256,6 +1318,7 @@ abstract class Foo { code: ` // no accessibility === public interface Foo { + [Z: string]: any; A: string; B: string; C: string; @@ -1278,7 +1341,7 @@ interface Foo { name: 'new', rank: 'method', }, - line: 16, + line: 17, column: 5, }, ], @@ -1300,9 +1363,10 @@ interface Foo { K(); L(); new(); + [Z: string]: any; } `, - options: [{ default: ['method', 'constructor', 'field'] }], + options: [{ default: ['signature', 'method', 'constructor', 'field'] }], errors: [ { messageId: 'incorrectOrder', @@ -1367,6 +1431,15 @@ interface Foo { line: 16, column: 5, }, + { + messageId: 'incorrectOrder', + data: { + name: 'Z', + rank: 'field', + }, + line: 17, + column: 5, + }, ], }, { @@ -1386,9 +1459,12 @@ interface Foo { K(); L(); new(); + [Z: string]: any; } `, - options: [{ interfaces: ['method', 'constructor', 'field'] }], + options: [ + { interfaces: ['method', 'signature', 'constructor', 'field'] }, + ], errors: [ { messageId: 'incorrectOrder', @@ -1453,6 +1529,15 @@ interface Foo { line: 16, column: 5, }, + { + messageId: 'incorrectOrder', + data: { + name: 'Z', + rank: 'field', + }, + line: 17, + column: 5, + }, ], }, { @@ -1472,12 +1557,13 @@ interface Foo { K(); L(); new(); + [Z: string]: any; } `, options: [ { - default: ['field', 'method', 'constructor'], - interfaces: ['method', 'constructor', 'field'], + default: ['field', 'method', 'constructor', 'signature'], + interfaces: ['method', 'signature', 'constructor', 'field'], }, ], errors: [ @@ -1544,12 +1630,22 @@ interface Foo { line: 16, column: 5, }, + { + messageId: 'incorrectOrder', + data: { + name: 'Z', + rank: 'field', + }, + line: 17, + column: 5, + }, ], }, { code: ` // no accessibility === public interface Foo { + [Z: string]: any; new(); A: string; G(); @@ -1567,7 +1663,7 @@ interface Foo { `, options: [ { - interfaces: ['constructor', 'field', 'method'], + interfaces: ['signature', 'constructor', 'field', 'method'], }, ], errors: [ @@ -1577,7 +1673,7 @@ interface Foo { name: 'B', rank: 'method', }, - line: 7, + line: 8, column: 5, }, { @@ -1586,7 +1682,7 @@ interface Foo { name: 'C', rank: 'method', }, - line: 9, + line: 10, column: 5, }, { @@ -1595,7 +1691,7 @@ interface Foo { name: 'D', rank: 'method', }, - line: 11, + line: 12, column: 5, }, { @@ -1604,7 +1700,7 @@ interface Foo { name: 'E', rank: 'method', }, - line: 13, + line: 14, column: 5, }, { @@ -1613,7 +1709,7 @@ interface Foo { name: 'F', rank: 'method', }, - line: 15, + line: 16, column: 5, }, ], @@ -1622,6 +1718,7 @@ interface Foo { code: ` // no accessibility === public type Foo = { + [Z: string]: any; A: string; B: string; C: string; @@ -1644,7 +1741,7 @@ type Foo = { name: 'new', rank: 'method', }, - line: 16, + line: 17, column: 5, }, ], @@ -1665,10 +1762,11 @@ type Foo = { J(); K(); L(); + [Z: string]: any; new(); } `, - options: [{ default: ['method', 'constructor', 'field'] }], + options: [{ default: ['method', 'constructor', 'signature', 'field'] }], errors: [ { messageId: 'incorrectOrder', @@ -1727,18 +1825,28 @@ type Foo = { { messageId: 'incorrectOrder', data: { - name: 'new', + name: 'Z', rank: 'field', }, line: 16, column: 5, }, + { + messageId: 'incorrectOrder', + data: { + name: 'new', + rank: 'field', + }, + line: 17, + column: 5, + }, ], }, { code: ` // no accessibility === public type Foo = { + [Z: string]: any; A: string; B: string; C: string; @@ -1754,69 +1862,71 @@ type Foo = { new(); } `, - options: [{ typeLiterals: ['method', 'constructor', 'field'] }], + options: [ + { typeLiterals: ['method', 'constructor', 'signature', 'field'] }, + ], errors: [ { messageId: 'incorrectOrder', data: { name: 'G', - rank: 'field', + rank: 'signature', }, - line: 10, + line: 11, column: 5, }, { messageId: 'incorrectOrder', data: { name: 'H', - rank: 'field', + rank: 'signature', }, - line: 11, + line: 12, column: 5, }, { messageId: 'incorrectOrder', data: { name: 'I', - rank: 'field', + rank: 'signature', }, - line: 12, + line: 13, column: 5, }, { messageId: 'incorrectOrder', data: { name: 'J', - rank: 'field', + rank: 'signature', }, - line: 13, + line: 14, column: 5, }, { messageId: 'incorrectOrder', data: { name: 'K', - rank: 'field', + rank: 'signature', }, - line: 14, + line: 15, column: 5, }, { messageId: 'incorrectOrder', data: { name: 'L', - rank: 'field', + rank: 'signature', }, - line: 15, + line: 16, column: 5, }, { messageId: 'incorrectOrder', data: { name: 'new', - rank: 'field', + rank: 'signature', }, - line: 16, + line: 17, column: 5, }, ], @@ -1838,12 +1948,13 @@ type Foo = { K(); L(); new(); + [Z: string]: any; } `, options: [ { - default: ['field', 'method', 'constructor'], - typeLiterals: ['method', 'constructor', 'field'], + default: ['field', 'method', 'constructor', 'signature'], + typeLiterals: ['signature', 'method', 'constructor', 'field'], }, ], errors: [ @@ -1910,6 +2021,15 @@ type Foo = { line: 16, column: 5, }, + { + messageId: 'incorrectOrder', + data: { + name: 'Z', + rank: 'field', + }, + line: 17, + column: 5, + }, ], }, { @@ -1917,6 +2037,7 @@ type Foo = { // no accessibility === public type Foo = { new(); + [Z: string]: any; A: string; G(); B: string; @@ -1933,7 +2054,7 @@ type Foo = { `, options: [ { - typeLiterals: ['constructor', 'field', 'method'], + typeLiterals: ['constructor', 'signature', 'field', 'method'], }, ], errors: [ @@ -1943,7 +2064,7 @@ type Foo = { name: 'B', rank: 'method', }, - line: 7, + line: 8, column: 5, }, { @@ -1952,7 +2073,7 @@ type Foo = { name: 'C', rank: 'method', }, - line: 9, + line: 10, column: 5, }, { @@ -1961,7 +2082,7 @@ type Foo = { name: 'D', rank: 'method', }, - line: 11, + line: 12, column: 5, }, { @@ -1970,7 +2091,7 @@ type Foo = { name: 'E', rank: 'method', }, - line: 13, + line: 14, column: 5, }, { @@ -1979,7 +2100,7 @@ type Foo = { name: 'F', rank: 'method', }, - line: 15, + line: 16, column: 5, }, ], @@ -1987,6 +2108,7 @@ type Foo = { { code: ` class Foo { + [Z: string]: any; public static A: string = ""; protected static B: string = ""; private static C: string = ""; @@ -2009,7 +2131,7 @@ class Foo { name: 'G', rank: 'public instance method', }, - line: 13, + line: 14, column: 5, }, { @@ -2018,7 +2140,7 @@ class Foo { name: 'H', rank: 'public instance method', }, - line: 14, + line: 15, column: 5, }, { @@ -2027,7 +2149,7 @@ class Foo { name: 'I', rank: 'public instance method', }, - line: 15, + line: 16, column: 5, }, ], @@ -2048,9 +2170,10 @@ class Foo { public static G() {} protected static H() {} private static I() {} + [Z: string]: any; } `, - options: [{ default: ['field', 'constructor', 'method'] }], + options: [{ default: ['field', 'constructor', 'method', 'signature'] }], errors: [ { messageId: 'incorrectOrder', @@ -2647,6 +2770,7 @@ const foo = class Foo { { code: ` const foo = class { + [Z: string]: any; constructor() {} public static A: string = ""; protected static B: string = ""; @@ -2662,7 +2786,7 @@ const foo = class { private static I() {} } `, - options: [{ default: ['field', 'constructor', 'method'] }], + options: [{ default: ['signature', 'field', 'constructor', 'method'] }], errors: [ { messageId: 'incorrectOrder', @@ -2670,7 +2794,7 @@ const foo = class { name: 'A', rank: 'constructor', }, - line: 4, + line: 5, column: 5, }, { @@ -2679,7 +2803,7 @@ const foo = class { name: 'B', rank: 'constructor', }, - line: 5, + line: 6, column: 5, }, { @@ -2688,7 +2812,7 @@ const foo = class { name: 'C', rank: 'constructor', }, - line: 6, + line: 7, column: 5, }, { @@ -2697,7 +2821,7 @@ const foo = class { name: 'D', rank: 'constructor', }, - line: 7, + line: 8, column: 5, }, { @@ -2706,7 +2830,7 @@ const foo = class { name: 'E', rank: 'constructor', }, - line: 8, + line: 9, column: 5, }, { @@ -2715,7 +2839,7 @@ const foo = class { name: 'F', rank: 'constructor', }, - line: 9, + line: 10, column: 5, }, ], @@ -2729,6 +2853,7 @@ const foo = class { public D: string = ""; protected E: string = ""; private F: string = ""; + [Z: string]: any; public static G() {} public static A: string; protected static H() {} @@ -2746,7 +2871,7 @@ const foo = class { name: 'A', rank: 'method', }, - line: 10, + line: 11, column: 5, }, ], @@ -2794,6 +2919,7 @@ const foo = class { private L() {} public static A: string; constructor() {} + [Z: string]: any; private static C: string = ""; public D: string = ""; protected E: string = ""; @@ -3219,6 +3345,7 @@ class Foo { K = () => {} A: string; constructor () {} + [Z: string]: any; J() {} } `, @@ -3241,6 +3368,15 @@ class Foo { line: 5, column: 5, }, + { + messageId: 'incorrectOrder', + data: { + name: 'Z', + rank: 'public instance method', + }, + line: 6, + column: 5, + }, ], }, { @@ -3250,9 +3386,10 @@ class Foo { constructor () {} K = () => {} A: string; + [Z: string]: any; } `, - options: [{ default: ['method', 'constructor', 'field'] }], + options: [{ default: ['method', 'constructor', 'field', 'signature'] }], errors: [ { messageId: 'incorrectOrder', @@ -3427,6 +3564,7 @@ class Foo { 'method', 'public-static-method', 'private-static-method', + 'signature', ], }, ], @@ -3435,7 +3573,7 @@ class Foo { messageId: 'incorrectOrder', data: { name: 'D', - rank: 'private static method', + rank: 'signature', }, line: 5, column: 5, From 3ddf1a2a0fb0b7863dee048913053f2c59f8283e Mon Sep 17 00:00:00 2001 From: Alexander T Date: Wed, 4 Dec 2019 21:44:07 +0200 Subject: [PATCH 4/6] fix(eslint-plugin): [brace-style] handle enum declarations (#1281) --- .../eslint-plugin/src/rules/brace-style.ts | 138 +++++++++++++++--- packages/eslint-plugin/src/util/astUtils.ts | 11 ++ .../tests/rules/brace-style.test.ts | 71 ++++++++- 3 files changed, 195 insertions(+), 25 deletions(-) diff --git a/packages/eslint-plugin/src/rules/brace-style.ts b/packages/eslint-plugin/src/rules/brace-style.ts index 0f0f75afb301..5be461b8c23b 100644 --- a/packages/eslint-plugin/src/rules/brace-style.ts +++ b/packages/eslint-plugin/src/rules/brace-style.ts @@ -1,14 +1,16 @@ -import { - TSESTree, - AST_NODE_TYPES, -} from '@typescript-eslint/experimental-utils'; +import { TSESTree } from '@typescript-eslint/experimental-utils'; import baseRule from 'eslint/lib/rules/brace-style'; -import * as util from '../util'; +import { + InferOptionsTypeFromRule, + InferMessageIdsTypeFromRule, + createRule, + isTokenOnSameLine, +} from '../util'; -export type Options = util.InferOptionsTypeFromRule; -export type MessageIds = util.InferMessageIdsTypeFromRule; +export type Options = InferOptionsTypeFromRule; +export type MessageIds = InferMessageIdsTypeFromRule; -export default util.createRule({ +export default createRule({ name: 'brace-style', meta: { type: 'layout', @@ -23,23 +25,117 @@ export default util.createRule({ }, defaultOptions: ['1tbs'], create(context) { + const [ + style, + { allowSingleLine } = { allowSingleLine: false }, + ] = context.options; + + const isAllmanStyle = style === 'allman'; + const sourceCode = context.getSourceCode(); const rules = baseRule.create(context); - const checkBlockStatement = ( - node: TSESTree.TSModuleBlock | TSESTree.TSInterfaceBody, - ): void => { - rules.BlockStatement({ - type: AST_NODE_TYPES.BlockStatement, - parent: node.parent, - range: node.range, - body: node.body as any, // eslint-disable-line @typescript-eslint/no-explicit-any - loc: node.loc, - }); - }; + + /** + * Checks a pair of curly brackets based on the user's config + */ + function validateCurlyPair( + openingCurlyToken: TSESTree.Token, + closingCurlyToken: TSESTree.Token, + ): void { + if ( + allowSingleLine && + isTokenOnSameLine(openingCurlyToken, closingCurlyToken) + ) { + return; + } + + const tokenBeforeOpeningCurly = sourceCode.getTokenBefore( + openingCurlyToken, + )!; + const tokenBeforeClosingCurly = sourceCode.getTokenBefore( + closingCurlyToken, + )!; + const tokenAfterOpeningCurly = sourceCode.getTokenAfter( + openingCurlyToken, + )!; + + if ( + !isAllmanStyle && + !isTokenOnSameLine(tokenBeforeOpeningCurly, openingCurlyToken) + ) { + context.report({ + node: openingCurlyToken, + messageId: 'nextLineOpen', + fix: fixer => { + const textRange: TSESTree.Range = [ + tokenBeforeOpeningCurly.range[1], + openingCurlyToken.range[0], + ]; + const textBetween = sourceCode.text.slice( + textRange[0], + textRange[1], + ); + + if (textBetween.trim()) { + return null; + } + + return fixer.replaceTextRange(textRange, ' '); + }, + }); + } + + if ( + isAllmanStyle && + isTokenOnSameLine(tokenBeforeOpeningCurly, openingCurlyToken) + ) { + context.report({ + node: openingCurlyToken, + messageId: 'sameLineOpen', + fix: fixer => fixer.insertTextBefore(openingCurlyToken, '\n'), + }); + } + + if ( + isTokenOnSameLine(openingCurlyToken, tokenAfterOpeningCurly) && + tokenAfterOpeningCurly !== closingCurlyToken + ) { + context.report({ + node: openingCurlyToken, + messageId: 'blockSameLine', + fix: fixer => fixer.insertTextAfter(openingCurlyToken, '\n'), + }); + } + + if ( + isTokenOnSameLine(tokenBeforeClosingCurly, closingCurlyToken) && + tokenBeforeClosingCurly !== openingCurlyToken + ) { + context.report({ + node: closingCurlyToken, + messageId: 'singleLineClose', + fix: fixer => fixer.insertTextBefore(closingCurlyToken, '\n'), + }); + } + } return { ...rules, - TSInterfaceBody: checkBlockStatement, - TSModuleBlock: checkBlockStatement, + 'TSInterfaceBody, TSModuleBlock'( + node: TSESTree.TSModuleBlock | TSESTree.TSInterfaceBody, + ): void { + const openingCurly = sourceCode.getFirstToken(node)!; + const closingCurly = sourceCode.getLastToken(node)!; + + validateCurlyPair(openingCurly, closingCurly); + }, + TSEnumDeclaration(node): void { + const closingCurly = sourceCode.getLastToken(node)!; + const openingCurly = sourceCode.getTokenBefore( + node.members.length ? node.members[0] : closingCurly, + )!; + + validateCurlyPair(openingCurly, closingCurly); + }, }; }, }); diff --git a/packages/eslint-plugin/src/util/astUtils.ts b/packages/eslint-plugin/src/util/astUtils.ts index 30e8231f95e2..9398f4eb64b3 100644 --- a/packages/eslint-plugin/src/util/astUtils.ts +++ b/packages/eslint-plugin/src/util/astUtils.ts @@ -42,11 +42,22 @@ function isOptionalOptionalChain( ); } +/** + * Determines whether two adjacent tokens are on the same line + */ +function isTokenOnSameLine( + left: TSESTree.Token, + right: TSESTree.Token, +): boolean { + return left.loc.end.line === right.loc.start.line; +} + export { isNonNullAssertionPunctuator, isNotNonNullAssertionPunctuator, isNotOptionalChainPunctuator, isOptionalChainPunctuator, isOptionalOptionalChain, + isTokenOnSameLine, LINEBREAK_MATCHER, }; diff --git a/packages/eslint-plugin/tests/rules/brace-style.test.ts b/packages/eslint-plugin/tests/rules/brace-style.test.ts index d1f586afc2f8..21d10998eac1 100644 --- a/packages/eslint-plugin/tests/rules/brace-style.test.ts +++ b/packages/eslint-plugin/tests/rules/brace-style.test.ts @@ -539,6 +539,38 @@ namespace Foo `, options: ['allman'], }, + { + code: ` +enum Foo +{ + A, + B +} + `, + options: ['allman'], + }, + { + code: ` +enum Foo { + A, + B +} + `, + options: ['1tbs'], + }, + { + code: ` +enum Foo { + A, + B +} + `, + options: ['stroustrup'], + }, + { + code: `enum Foo { A, B }`, + options: ['1tbs', { allowSingleLine: true }], + }, ], invalid: [ @@ -760,7 +792,6 @@ if (f) { options: ['allman'], errors: [{ messageId: 'sameLineClose' }], }, - // allowSingleLine: true { code: `function foo() { return; \n}`, @@ -912,14 +943,12 @@ if (f) { { messageId: 'sameLineOpen' }, ], }, - // Comment interferes with fix { code: `if (foo) // comment \n{\nbar();\n}`, output: null, errors: [{ messageId: 'nextLineOpen' }], }, - // https://github.com/eslint/eslint/issues/7493 { code: `if (foo) {\n bar\n.baz }`, @@ -995,7 +1024,6 @@ if (f) { options: ['allman'], errors: [{ messageId: 'sameLineOpen' }], }, - // https://github.com/eslint/eslint/issues/7621 { code: ` @@ -1109,5 +1137,40 @@ namespace Foo { options: ['allman'], errors: [{ messageId: 'sameLineOpen' }], }, + { + code: ` +enum Foo +{ +} + `, + output: ` +enum Foo { +} + `, + errors: [{ messageId: 'nextLineOpen' }], + }, + { + code: ` +enum Foo +{ +} + `, + output: ` +enum Foo { +} + `, + options: ['stroustrup'], + errors: [{ messageId: 'nextLineOpen' }], + }, + { + code: `enum Foo { A }`, + output: `enum Foo \n{\n A \n}`, + options: ['allman'], + errors: [ + { messageId: 'sameLineOpen' }, + { messageId: 'blockSameLine' }, + { messageId: 'singleLineClose' }, + ], + }, ], }); From 324f155fc2c4618e5b844e9a481607a08ed821da Mon Sep 17 00:00:00 2001 From: Maciej Suchecki Date: Mon, 9 Dec 2019 12:58:27 +0100 Subject: [PATCH 5/6] docs(eslint-plugin): ROADMAP note some jsdoc rules (#1319) --- packages/eslint-plugin/ROADMAP.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/eslint-plugin/ROADMAP.md b/packages/eslint-plugin/ROADMAP.md index 2d4e37bded7e..c97e1a303148 100644 --- a/packages/eslint-plugin/ROADMAP.md +++ b/packages/eslint-plugin/ROADMAP.md @@ -142,7 +142,7 @@ | [`class-name`] | ✅ | [`@typescript-eslint/class-name-casing`] | | [`comment-format`] | 🌟 | [`capitalized-comments`][capitalized-comments] & [`spaced-comment`][spaced-comment] | | [`comment-type`] | 🛑 | N/A | -| [`completed-docs`] | 🔌 | [`eslint-plugin-jsdoc`][plugin:jsdoc] | +| [`completed-docs`] | 🔌 | [`jsdoc/require-jsdoc`] | | [`encoding`] | 🛑 | N/A | | [`file-header`] | 🔌 | [`eslint-plugin-header`][plugin:header] or [`-file-header`][plugin:file-header] | | [`file-name-casing`] | 🔌 | [`unicorn/filename-case`] | @@ -160,7 +160,7 @@ | [`no-consecutive-blank-lines`] | 🌟 | [`no-multiple-empty-lines`][no-multiple-empty-lines] | | [`no-irregular-whitespace`] | 🌟 | [`no-irregular-whitespace`][no-irregular-whitespace] with `skipStrings: false` | | [`no-parameter-properties`] | ✅ | [`@typescript-eslint/no-parameter-properties`] | -| [`no-redundant-jsdoc`] | 🛑 | N/A ([open issue](https://github.com/gajus/eslint-plugin-jsdoc/issues/134)) | +| [`no-redundant-jsdoc`] | 🔌 | [`jsdoc/no-types`] | | [`no-reference-import`] | 🛑 | N/A | | [`no-trailing-whitespace`] | 🌟 | [`no-trailing-spaces`][no-trailing-spaces] | | [`no-unnecessary-callback-wrapper`] | 🛑 | N/A and this might be unsafe (i.e. with `forEach`) | @@ -664,11 +664,16 @@ Relevant plugins: [`chai-expect-keywords`](https://github.com/gavinaiken/eslint- [`security/detect-non-literal-require`]: https://github.com/nodesecurity/eslint-plugin-security#detect-non-literal-require [`security/detect-possible-timing-attacks`]: https://github.com/nodesecurity/eslint-plugin-security#detect-possible-timing-attacks + + +[plugin:jsdoc]: https://github.com/gajus/eslint-plugin-jsdoc +[`jsdoc/require-jsdoc`]: https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-jsdoc +[`jsdoc/no-types`]: https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-no-types + [`prefer-arrow/prefer-arrow-functions`]: https://github.com/TristonJ/eslint-plugin-prefer-arrow [plugin:promise]: https://github.com/xjamundx/eslint-plugin-promise -[plugin:jsdoc]: https://github.com/gajus/eslint-plugin-jsdoc [plugin:header]: https://github.com/Stuk/eslint-plugin-header [plugin:file-header]: https://github.com/Sekhmet/eslint-plugin-file-header [plugin:compat]: https://github.com/amilajack/eslint-plugin-compat From 9f7609580eefa140ffb8f65046d4c1ada903b83f Mon Sep 17 00:00:00 2001 From: James Henry Date: Mon, 9 Dec 2019 18:01:41 +0000 Subject: [PATCH 6/6] chore: publish v2.11.0 --- CHANGELOG.md | 16 ++++++++++++++++ lerna.json | 2 +- packages/eslint-plugin-tslint/CHANGELOG.md | 8 ++++++++ packages/eslint-plugin-tslint/package.json | 6 +++--- packages/eslint-plugin/CHANGELOG.md | 16 ++++++++++++++++ packages/eslint-plugin/package.json | 4 ++-- packages/experimental-utils/CHANGELOG.md | 8 ++++++++ packages/experimental-utils/package.json | 4 ++-- packages/parser/CHANGELOG.md | 8 ++++++++ packages/parser/package.json | 8 ++++---- packages/shared-fixtures/CHANGELOG.md | 8 ++++++++ packages/shared-fixtures/package.json | 2 +- packages/typescript-estree/CHANGELOG.md | 8 ++++++++ packages/typescript-estree/package.json | 4 ++-- 14 files changed, 87 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19ec0dfaae03..6d7607ea06f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [2.11.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.10.0...v2.11.0) (2019-12-09) + + +### Bug Fixes + +* **eslint-plugin:** [brace-style] handle enum declarations ([#1281](https://github.com/typescript-eslint/typescript-eslint/issues/1281)) ([3ddf1a2](https://github.com/typescript-eslint/typescript-eslint/commit/3ddf1a2)) + + +### Features + +* **eslint-plugin:** [member-ordering] add index signature ([#1190](https://github.com/typescript-eslint/typescript-eslint/issues/1190)) ([b5a52a3](https://github.com/typescript-eslint/typescript-eslint/commit/b5a52a3)) + + + + + # [2.10.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.9.0...v2.10.0) (2019-12-02) diff --git a/lerna.json b/lerna.json index b81dc17b54b1..dc773f1cb452 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.10.0", + "version": "2.11.0", "npmClient": "yarn", "useWorkspaces": true, "stream": true diff --git a/packages/eslint-plugin-tslint/CHANGELOG.md b/packages/eslint-plugin-tslint/CHANGELOG.md index 77dd508e5f6a..8293ab343103 100644 --- a/packages/eslint-plugin-tslint/CHANGELOG.md +++ b/packages/eslint-plugin-tslint/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [2.11.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.10.0...v2.11.0) (2019-12-09) + +**Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint + + + + + # [2.10.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.9.0...v2.10.0) (2019-12-02) **Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint diff --git a/packages/eslint-plugin-tslint/package.json b/packages/eslint-plugin-tslint/package.json index 58cc56a13d50..559b761c1ae5 100644 --- a/packages/eslint-plugin-tslint/package.json +++ b/packages/eslint-plugin-tslint/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin-tslint", - "version": "2.10.0", + "version": "2.11.0", "main": "dist/index.js", "typings": "src/index.ts", "description": "TSLint wrapper plugin for ESLint", @@ -31,7 +31,7 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/experimental-utils": "2.10.0", + "@typescript-eslint/experimental-utils": "2.11.0", "lodash.memoize": "^4.1.2" }, "peerDependencies": { @@ -41,6 +41,6 @@ }, "devDependencies": { "@types/lodash.memoize": "^4.1.4", - "@typescript-eslint/parser": "2.10.0" + "@typescript-eslint/parser": "2.11.0" } } diff --git a/packages/eslint-plugin/CHANGELOG.md b/packages/eslint-plugin/CHANGELOG.md index dee39704de43..13d3eff3377d 100644 --- a/packages/eslint-plugin/CHANGELOG.md +++ b/packages/eslint-plugin/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [2.11.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.10.0...v2.11.0) (2019-12-09) + + +### Bug Fixes + +* **eslint-plugin:** [brace-style] handle enum declarations ([#1281](https://github.com/typescript-eslint/typescript-eslint/issues/1281)) ([3ddf1a2](https://github.com/typescript-eslint/typescript-eslint/commit/3ddf1a2)) + + +### Features + +* **eslint-plugin:** [member-ordering] add index signature ([#1190](https://github.com/typescript-eslint/typescript-eslint/issues/1190)) ([b5a52a3](https://github.com/typescript-eslint/typescript-eslint/commit/b5a52a3)) + + + + + # [2.10.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.9.0...v2.10.0) (2019-12-02) diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index 94ff71ea8ef7..b70e26301203 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin", - "version": "2.10.0", + "version": "2.11.0", "description": "TypeScript plugin for ESLint", "keywords": [ "eslint", @@ -40,7 +40,7 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/experimental-utils": "2.10.0", + "@typescript-eslint/experimental-utils": "2.11.0", "eslint-utils": "^1.4.3", "functional-red-black-tree": "^1.0.1", "regexpp": "^3.0.0", diff --git a/packages/experimental-utils/CHANGELOG.md b/packages/experimental-utils/CHANGELOG.md index 236368fb39cc..6a3f92667947 100644 --- a/packages/experimental-utils/CHANGELOG.md +++ b/packages/experimental-utils/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [2.11.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.10.0...v2.11.0) (2019-12-09) + +**Note:** Version bump only for package @typescript-eslint/experimental-utils + + + + + # [2.10.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.9.0...v2.10.0) (2019-12-02) diff --git a/packages/experimental-utils/package.json b/packages/experimental-utils/package.json index 310714e14f53..fe0b531ad244 100644 --- a/packages/experimental-utils/package.json +++ b/packages/experimental-utils/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/experimental-utils", - "version": "2.10.0", + "version": "2.11.0", "description": "(Experimental) Utilities for working with TypeScript + ESLint together", "keywords": [ "eslint", @@ -37,7 +37,7 @@ }, "dependencies": { "@types/json-schema": "^7.0.3", - "@typescript-eslint/typescript-estree": "2.10.0", + "@typescript-eslint/typescript-estree": "2.11.0", "eslint-scope": "^5.0.0" }, "peerDependencies": { diff --git a/packages/parser/CHANGELOG.md b/packages/parser/CHANGELOG.md index 7b665de26a05..4dce721a6b9a 100644 --- a/packages/parser/CHANGELOG.md +++ b/packages/parser/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [2.11.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.10.0...v2.11.0) (2019-12-09) + +**Note:** Version bump only for package @typescript-eslint/parser + + + + + # [2.10.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.9.0...v2.10.0) (2019-12-02) **Note:** Version bump only for package @typescript-eslint/parser diff --git a/packages/parser/package.json b/packages/parser/package.json index 8641c433f05f..ffe2ca6787bc 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/parser", - "version": "2.10.0", + "version": "2.11.0", "description": "An ESLint custom parser which leverages TypeScript ESTree", "main": "dist/parser.js", "types": "dist/parser.d.ts", @@ -43,13 +43,13 @@ }, "dependencies": { "@types/eslint-visitor-keys": "^1.0.0", - "@typescript-eslint/experimental-utils": "2.10.0", - "@typescript-eslint/typescript-estree": "2.10.0", + "@typescript-eslint/experimental-utils": "2.11.0", + "@typescript-eslint/typescript-estree": "2.11.0", "eslint-visitor-keys": "^1.1.0" }, "devDependencies": { "@types/glob": "^7.1.1", - "@typescript-eslint/shared-fixtures": "2.10.0", + "@typescript-eslint/shared-fixtures": "2.11.0", "glob": "*" } } diff --git a/packages/shared-fixtures/CHANGELOG.md b/packages/shared-fixtures/CHANGELOG.md index cc0c786f2eab..de6b5d8158e8 100644 --- a/packages/shared-fixtures/CHANGELOG.md +++ b/packages/shared-fixtures/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [2.11.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.10.0...v2.11.0) (2019-12-09) + +**Note:** Version bump only for package @typescript-eslint/shared-fixtures + + + + + # [2.10.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.9.0...v2.10.0) (2019-12-02) **Note:** Version bump only for package @typescript-eslint/shared-fixtures diff --git a/packages/shared-fixtures/package.json b/packages/shared-fixtures/package.json index 8c2d9ed8c1ed..8f549941a756 100644 --- a/packages/shared-fixtures/package.json +++ b/packages/shared-fixtures/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/shared-fixtures", - "version": "2.10.0", + "version": "2.11.0", "private": true, "scripts": { "build": "tsc -b tsconfig.build.json", diff --git a/packages/typescript-estree/CHANGELOG.md b/packages/typescript-estree/CHANGELOG.md index 6a4367f1718f..cba63aa7c51d 100644 --- a/packages/typescript-estree/CHANGELOG.md +++ b/packages/typescript-estree/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [2.11.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.10.0...v2.11.0) (2019-12-09) + +**Note:** Version bump only for package @typescript-eslint/typescript-estree + + + + + # [2.10.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.9.0...v2.10.0) (2019-12-02) diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json index ced5d06d426a..3426420f6f42 100644 --- a/packages/typescript-estree/package.json +++ b/packages/typescript-estree/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/typescript-estree", - "version": "2.10.0", + "version": "2.11.0", "description": "A parser that converts TypeScript source code into an ESTree compatible form", "main": "dist/parser.js", "types": "dist/parser.d.ts", @@ -59,7 +59,7 @@ "@types/lodash.unescape": "^4.0.4", "@types/semver": "^6.2.0", "@types/tmp": "^0.1.0", - "@typescript-eslint/shared-fixtures": "2.10.0", + "@typescript-eslint/shared-fixtures": "2.11.0", "babel-code-frame": "^6.26.0", "lodash.isplainobject": "4.0.6", "tmp": "^0.1.0",