Skip to content

Commit

Permalink
chore(deps): lock file maintenance (#805)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
3 people committed Apr 3, 2021
1 parent 7a1ab7a commit aeb267f
Show file tree
Hide file tree
Showing 3 changed files with 343 additions and 246 deletions.
101 changes: 80 additions & 21 deletions src/rules/__tests__/unbound-method.test.ts
Expand Up @@ -63,7 +63,7 @@ const invalidTestCases: Array<TSESLint.InvalidTestCase<MessageIds, Options>> = [
errors: [
{
line: 9,
messageId: 'unbound',
messageId: 'unboundWithoutThisAnnotation',
},
],
},
Expand All @@ -72,7 +72,7 @@ const invalidTestCases: Array<TSESLint.InvalidTestCase<MessageIds, Options>> = [
errors: [
{
line: 1,
messageId: 'unbound',
messageId: 'unboundWithoutThisAnnotation',
},
],
},
Expand All @@ -87,7 +87,7 @@ const invalidTestCases: Array<TSESLint.InvalidTestCase<MessageIds, Options>> = [
errors: [
{
line: 10,
messageId: 'unbound',
messageId: 'unboundWithoutThisAnnotation',
},
],
},
Expand All @@ -101,7 +101,7 @@ const invalidTestCases: Array<TSESLint.InvalidTestCase<MessageIds, Options>> = [
errors: [
{
line: 9,
messageId: 'unbound' as const,
messageId: 'unboundWithoutThisAnnotation' as const,
},
],
})),
Expand All @@ -115,7 +115,7 @@ const invalidTestCases: Array<TSESLint.InvalidTestCase<MessageIds, Options>> = [
errors: [
{
line: 9,
messageId: 'unbound' as const,
messageId: 'unboundWithoutThisAnnotation' as const,
},
],
})),
Expand Down Expand Up @@ -237,7 +237,7 @@ function addContainsMethodsClassInvalid(
errors: [
{
line: 18,
messageId: 'unbound',
messageId: 'unboundWithoutThisAnnotation',
},
],
}));
Expand Down Expand Up @@ -460,6 +460,22 @@ class Foo {
}
const { bound } = new Foo();
`,
// https://github.com/typescript-eslint/typescript-eslint/issues/1866
`
class BaseClass {
x: number = 42;
logThis() {}
}
class OtherClass extends BaseClass {
superLogThis: any;
constructor() {
super();
this.superLogThis = super.logThis;
}
}
const oc = new OtherClass();
oc.superLogThis();
`,
],
invalid: [
{
Expand All @@ -477,7 +493,7 @@ Promise.resolve().then(console.log);
errors: [
{
line: 10,
messageId: 'unbound',
messageId: 'unboundWithoutThisAnnotation',
},
],
},
Expand All @@ -489,7 +505,7 @@ const x = console.log;
errors: [
{
line: 3,
messageId: 'unbound',
messageId: 'unboundWithoutThisAnnotation',
},
],
},
Expand All @@ -504,15 +520,15 @@ function foo(arg: ContainsMethods | null) {
errors: [
{
line: 20,
messageId: 'unbound',
messageId: 'unboundWithoutThisAnnotation',
},
{
line: 21,
messageId: 'unbound',
messageId: 'unboundWithoutThisAnnotation',
},
{
line: 22,
messageId: 'unbound',
messageId: 'unboundWithoutThisAnnotation',
},
],
},
Expand Down Expand Up @@ -554,7 +570,7 @@ ContainsMethods.unboundStatic;
errors: [
{
line: 8,
messageId: 'unbound',
messageId: 'unboundWithoutThisAnnotation',
},
],
},
Expand All @@ -569,7 +585,7 @@ const x = CommunicationError.prototype.foo;
errors: [
{
line: 5,
messageId: 'unbound',
messageId: 'unboundWithoutThisAnnotation',
},
],
},
Expand All @@ -579,7 +595,7 @@ const x = CommunicationError.prototype.foo;
errors: [
{
line: 1,
messageId: 'unbound',
messageId: 'unboundWithoutThisAnnotation',
},
],
},
Expand All @@ -598,7 +614,7 @@ instance.unbound = x; // THIS SHOULD NOT
errors: [
{
line: 9,
messageId: 'unbound',
messageId: 'unboundWithoutThisAnnotation',
},
],
},
Expand Down Expand Up @@ -626,7 +642,7 @@ const { unbound } = new Foo();
errors: [
{
line: 5,
messageId: 'unbound',
messageId: 'unboundWithoutThisAnnotation',
},
],
},
Expand Down Expand Up @@ -655,7 +671,7 @@ let unbound;
errors: [
{
line: 6,
messageId: 'unbound',
messageId: 'unboundWithoutThisAnnotation',
},
],
},
Expand Down Expand Up @@ -684,7 +700,7 @@ const { foo } = CommunicationError.prototype;
errors: [
{
line: 5,
messageId: 'unbound',
messageId: 'unboundWithoutThisAnnotation',
},
],
},
Expand All @@ -699,7 +715,7 @@ let foo;
errors: [
{
line: 6,
messageId: 'unbound',
messageId: 'unboundWithoutThisAnnotation',
},
],
},
Expand All @@ -711,7 +727,7 @@ const { log } = console;
errors: [
{
line: 3,
messageId: 'unbound',
messageId: 'unboundWithoutThisAnnotation',
},
],
},
Expand All @@ -720,7 +736,50 @@ const { log } = console;
errors: [
{
line: 1,
messageId: 'unbound',
messageId: 'unboundWithoutThisAnnotation',
},
],
},
// https://github.com/typescript-eslint/typescript-eslint/issues/1866
{
code: `
class BaseClass {
logThis() {}
}
class OtherClass extends BaseClass {
constructor() {
super();
const x = super.logThis;
}
}
`,
errors: [
{
line: 8,
column: 15,
messageId: 'unboundWithoutThisAnnotation',
},
],
},
// https://github.com/typescript-eslint/typescript-eslint/issues/1866
{
code: `
class BaseClass {
logThis() {}
}
class OtherClass extends BaseClass {
constructor() {
super();
let x;
x = super.logThis;
}
}
`,
errors: [
{
line: 9,
column: 9,
messageId: 'unboundWithoutThisAnnotation',
},
],
},
Expand Down
7 changes: 5 additions & 2 deletions src/rules/unbound-method.ts
Expand Up @@ -58,15 +58,18 @@ interface Config {

export type Options = [Config];

export type MessageIds = 'unbound';
export type MessageIds = 'unbound' | 'unboundWithoutThisAnnotation';

const DEFAULT_MESSAGE = 'This rule requires `@typescript-eslint/eslint-plugin`';

export default createRule<Options, MessageIds>({
defaultOptions: [{ ignoreStatic: false }],
...baseRule,
name: __filename,
meta: {
messages: {
unbound: 'This rule requires `@typescript-eslint/eslint-plugin`',
unbound: DEFAULT_MESSAGE,
unboundWithoutThisAnnotation: DEFAULT_MESSAGE,
},
schema: [],
type: 'problem',
Expand Down

0 comments on commit aeb267f

Please sign in to comment.