Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): lock file maintenance #805

Merged
merged 2 commits into from Apr 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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