Skip to content

Commit aeb267f

Browse files
renovate[bot]renovate-botG-Rath
authored
chore(deps): lock file maintenance (#805)
* chore(deps): lock file maintenance * test(unbound-method): apply upstream changes Co-authored-by: Renovate Bot <bot@renovateapp.com> Co-authored-by: Gareth Jones <jones258@gmail.com>
1 parent 7a1ab7a commit aeb267f

File tree

3 files changed

+343
-246
lines changed

3 files changed

+343
-246
lines changed

src/rules/__tests__/unbound-method.test.ts

Lines changed: 80 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const invalidTestCases: Array<TSESLint.InvalidTestCase<MessageIds, Options>> = [
6363
errors: [
6464
{
6565
line: 9,
66-
messageId: 'unbound',
66+
messageId: 'unboundWithoutThisAnnotation',
6767
},
6868
],
6969
},
@@ -72,7 +72,7 @@ const invalidTestCases: Array<TSESLint.InvalidTestCase<MessageIds, Options>> = [
7272
errors: [
7373
{
7474
line: 1,
75-
messageId: 'unbound',
75+
messageId: 'unboundWithoutThisAnnotation',
7676
},
7777
],
7878
},
@@ -87,7 +87,7 @@ const invalidTestCases: Array<TSESLint.InvalidTestCase<MessageIds, Options>> = [
8787
errors: [
8888
{
8989
line: 10,
90-
messageId: 'unbound',
90+
messageId: 'unboundWithoutThisAnnotation',
9191
},
9292
],
9393
},
@@ -101,7 +101,7 @@ const invalidTestCases: Array<TSESLint.InvalidTestCase<MessageIds, Options>> = [
101101
errors: [
102102
{
103103
line: 9,
104-
messageId: 'unbound' as const,
104+
messageId: 'unboundWithoutThisAnnotation' as const,
105105
},
106106
],
107107
})),
@@ -115,7 +115,7 @@ const invalidTestCases: Array<TSESLint.InvalidTestCase<MessageIds, Options>> = [
115115
errors: [
116116
{
117117
line: 9,
118-
messageId: 'unbound' as const,
118+
messageId: 'unboundWithoutThisAnnotation' as const,
119119
},
120120
],
121121
})),
@@ -237,7 +237,7 @@ function addContainsMethodsClassInvalid(
237237
errors: [
238238
{
239239
line: 18,
240-
messageId: 'unbound',
240+
messageId: 'unboundWithoutThisAnnotation',
241241
},
242242
],
243243
}));
@@ -460,6 +460,22 @@ class Foo {
460460
}
461461
const { bound } = new Foo();
462462
`,
463+
// https://github.com/typescript-eslint/typescript-eslint/issues/1866
464+
`
465+
class BaseClass {
466+
x: number = 42;
467+
logThis() {}
468+
}
469+
class OtherClass extends BaseClass {
470+
superLogThis: any;
471+
constructor() {
472+
super();
473+
this.superLogThis = super.logThis;
474+
}
475+
}
476+
const oc = new OtherClass();
477+
oc.superLogThis();
478+
`,
463479
],
464480
invalid: [
465481
{
@@ -477,7 +493,7 @@ Promise.resolve().then(console.log);
477493
errors: [
478494
{
479495
line: 10,
480-
messageId: 'unbound',
496+
messageId: 'unboundWithoutThisAnnotation',
481497
},
482498
],
483499
},
@@ -489,7 +505,7 @@ const x = console.log;
489505
errors: [
490506
{
491507
line: 3,
492-
messageId: 'unbound',
508+
messageId: 'unboundWithoutThisAnnotation',
493509
},
494510
],
495511
},
@@ -504,15 +520,15 @@ function foo(arg: ContainsMethods | null) {
504520
errors: [
505521
{
506522
line: 20,
507-
messageId: 'unbound',
523+
messageId: 'unboundWithoutThisAnnotation',
508524
},
509525
{
510526
line: 21,
511-
messageId: 'unbound',
527+
messageId: 'unboundWithoutThisAnnotation',
512528
},
513529
{
514530
line: 22,
515-
messageId: 'unbound',
531+
messageId: 'unboundWithoutThisAnnotation',
516532
},
517533
],
518534
},
@@ -554,7 +570,7 @@ ContainsMethods.unboundStatic;
554570
errors: [
555571
{
556572
line: 8,
557-
messageId: 'unbound',
573+
messageId: 'unboundWithoutThisAnnotation',
558574
},
559575
],
560576
},
@@ -569,7 +585,7 @@ const x = CommunicationError.prototype.foo;
569585
errors: [
570586
{
571587
line: 5,
572-
messageId: 'unbound',
588+
messageId: 'unboundWithoutThisAnnotation',
573589
},
574590
],
575591
},
@@ -579,7 +595,7 @@ const x = CommunicationError.prototype.foo;
579595
errors: [
580596
{
581597
line: 1,
582-
messageId: 'unbound',
598+
messageId: 'unboundWithoutThisAnnotation',
583599
},
584600
],
585601
},
@@ -598,7 +614,7 @@ instance.unbound = x; // THIS SHOULD NOT
598614
errors: [
599615
{
600616
line: 9,
601-
messageId: 'unbound',
617+
messageId: 'unboundWithoutThisAnnotation',
602618
},
603619
],
604620
},
@@ -626,7 +642,7 @@ const { unbound } = new Foo();
626642
errors: [
627643
{
628644
line: 5,
629-
messageId: 'unbound',
645+
messageId: 'unboundWithoutThisAnnotation',
630646
},
631647
],
632648
},
@@ -655,7 +671,7 @@ let unbound;
655671
errors: [
656672
{
657673
line: 6,
658-
messageId: 'unbound',
674+
messageId: 'unboundWithoutThisAnnotation',
659675
},
660676
],
661677
},
@@ -684,7 +700,7 @@ const { foo } = CommunicationError.prototype;
684700
errors: [
685701
{
686702
line: 5,
687-
messageId: 'unbound',
703+
messageId: 'unboundWithoutThisAnnotation',
688704
},
689705
],
690706
},
@@ -699,7 +715,7 @@ let foo;
699715
errors: [
700716
{
701717
line: 6,
702-
messageId: 'unbound',
718+
messageId: 'unboundWithoutThisAnnotation',
703719
},
704720
],
705721
},
@@ -711,7 +727,7 @@ const { log } = console;
711727
errors: [
712728
{
713729
line: 3,
714-
messageId: 'unbound',
730+
messageId: 'unboundWithoutThisAnnotation',
715731
},
716732
],
717733
},
@@ -720,7 +736,50 @@ const { log } = console;
720736
errors: [
721737
{
722738
line: 1,
723-
messageId: 'unbound',
739+
messageId: 'unboundWithoutThisAnnotation',
740+
},
741+
],
742+
},
743+
// https://github.com/typescript-eslint/typescript-eslint/issues/1866
744+
{
745+
code: `
746+
class BaseClass {
747+
logThis() {}
748+
}
749+
class OtherClass extends BaseClass {
750+
constructor() {
751+
super();
752+
const x = super.logThis;
753+
}
754+
}
755+
`,
756+
errors: [
757+
{
758+
line: 8,
759+
column: 15,
760+
messageId: 'unboundWithoutThisAnnotation',
761+
},
762+
],
763+
},
764+
// https://github.com/typescript-eslint/typescript-eslint/issues/1866
765+
{
766+
code: `
767+
class BaseClass {
768+
logThis() {}
769+
}
770+
class OtherClass extends BaseClass {
771+
constructor() {
772+
super();
773+
let x;
774+
x = super.logThis;
775+
}
776+
}
777+
`,
778+
errors: [
779+
{
780+
line: 9,
781+
column: 9,
782+
messageId: 'unboundWithoutThisAnnotation',
724783
},
725784
],
726785
},

src/rules/unbound-method.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,18 @@ interface Config {
5858

5959
export type Options = [Config];
6060

61-
export type MessageIds = 'unbound';
61+
export type MessageIds = 'unbound' | 'unboundWithoutThisAnnotation';
62+
63+
const DEFAULT_MESSAGE = 'This rule requires `@typescript-eslint/eslint-plugin`';
6264

6365
export default createRule<Options, MessageIds>({
6466
defaultOptions: [{ ignoreStatic: false }],
6567
...baseRule,
6668
name: __filename,
6769
meta: {
6870
messages: {
69-
unbound: 'This rule requires `@typescript-eslint/eslint-plugin`',
71+
unbound: DEFAULT_MESSAGE,
72+
unboundWithoutThisAnnotation: DEFAULT_MESSAGE,
7073
},
7174
schema: [],
7275
type: 'problem',

0 commit comments

Comments
 (0)