Skip to content

Commit

Permalink
fix: addressed feedback and made necessary corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
y-hsgw committed Apr 29, 2024
1 parent 2c43334 commit b030cc7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 25 deletions.
40 changes: 18 additions & 22 deletions src/rules/__tests__/unbound-method.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,37 +113,33 @@ const invalidTestCases: Array<TSESLint.InvalidTestCase<MessageIds, Options>> = [
],
},
// toThrow matchers call the expected value (which is expected to be a function)
...toThrowMatchers.map<TSESLint.InvalidTestCase<MessageIds, Options>>(
matcher => ({
code: dedent`
...toThrowMatchers.map(matcher => ({
code: dedent`
${ConsoleClassAndVariableCode}
expect(console.log).${matcher}();
`,
errors: [
{
line: 9,
messageId: 'unboundWithoutThisAnnotation',
},
],
}),
),
errors: [
{
line: 9,
messageId: 'unboundWithoutThisAnnotation' as const,
},
],
})),
// toThrow matchers call the expected value (which is expected to be a function)
...toThrowMatchers.map<TSESLint.InvalidTestCase<MessageIds, Options>>(
matcher => ({
code: dedent`
...toThrowMatchers.map(matcher => ({
code: dedent`
${ConsoleClassAndVariableCode}
expect(console.log).not.${matcher}();
`,
errors: [
{
line: 9,
messageId: 'unboundWithoutThisAnnotation',
},
],
}),
),
errors: [
{
line: 9,
messageId: 'unboundWithoutThisAnnotation' as const,
},
],
})),
];

const requireRule = (throwWhenRequiring: boolean) => {
Expand Down
5 changes: 2 additions & 3 deletions src/rules/valid-expect-in-promise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const isPromiseMethodThatUsesValue = (
) {
const nodeName = getNodeName(node.argument);

if (nodeName && ['Promise.all', 'Promise.allSettled'].includes(nodeName)) {
if (['Promise.all', 'Promise.allSettled'].includes(nodeName as string)) {
const [firstArg] = node.argument.arguments;

if (
Expand All @@ -110,8 +110,7 @@ const isPromiseMethodThatUsesValue = (
}

if (
nodeName &&
['Promise.resolve', 'Promise.reject'].includes(nodeName) &&
['Promise.resolve', 'Promise.reject'].includes(nodeName as string) &&
node.argument.arguments.length === 1
) {
return isIdentifier(node.argument.arguments[0], name);
Expand Down

0 comments on commit b030cc7

Please sign in to comment.