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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust no focused tests to support tables #489

Merged
merged 2 commits into from
Nov 30, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
refactor(no-focused-tests): use isSupportedAccessor utility function
  • Loading branch information
G-Rath committed Nov 30, 2019
commit ee23634431b19fda5285474d2e2701bdcbf6910f
16 changes: 8 additions & 8 deletions src/rules/no-focused-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import {
AST_NODE_TYPES,
TSESTree,
} from '@typescript-eslint/experimental-utils';
import { DescribeAlias, TestCaseName, createRule } from './utils';
import {
DescribeAlias,
TestCaseName,
createRule,
isSupportedAccessor,
} from './utils';

const testFunctions = new Set<string>([
DescribeAlias.describe,
Expand All @@ -17,14 +22,9 @@ const matchesTestFunction = (object: TSESTree.LeftHandSideExpression) =>
const isCallToFocusedTestFunction = (object: TSESTree.Identifier) =>
object.name.startsWith('f') && testFunctions.has(object.name.substring(1));

const isPropertyNamedOnly = (
property: TSESTree.Expression | TSESTree.Identifier,
) =>
('name' in property && property.name === 'only') ||
('value' in property && property.value === 'only');

const isCallToTestOnlyFunction = (callee: TSESTree.MemberExpression) =>
matchesTestFunction(callee.object) && isPropertyNamedOnly(callee.property);
matchesTestFunction(callee.object) &&
isSupportedAccessor(callee.property, 'only');

export default createRule({
name: __filename,
Expand Down