Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
veritem committed Dec 31, 2024
1 parent 5ea6ec0 commit 7f69731
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
23 changes: 11 additions & 12 deletions src/rules/valid-title.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ type Options = {
allowArguments?: boolean
disallowedWords?: string[]
mustNotMatch?:
| Partial<Record<MatcherGroups, string | MatcherAndMessage>>
| MatcherAndMessage
| string
| Partial<Record<MatcherGroups, string | MatcherAndMessage>>
| MatcherAndMessage
| string
mustMatch?:
| Partial<Record<MatcherGroups, string | MatcherAndMessage>>
| MatcherAndMessage
| string
| Partial<Record<MatcherGroups, string | MatcherAndMessage>>
| MatcherAndMessage
| string
}[]

type CompiledMatcherAndMessage = [matcher: RegExp, message?: string]
Expand Down Expand Up @@ -91,7 +91,7 @@ const compileMatcherPatterns = (matchers:
| Partial<Record<MatcherGroups, string | MatcherAndMessage>>
| MatcherAndMessage
| string): Record<MatcherGroups, CompiledMatcherAndMessage | null> &
Record<string, CompiledMatcherAndMessage | null> => {
Record<string, CompiledMatcherAndMessage | null> => {
if (typeof matchers === 'string' || Array.isArray(matchers)) {
const compiledMatcher = compileMatcherPattern(matchers)

Expand Down Expand Up @@ -197,13 +197,12 @@ export default createEslintRule<Options, MESSAGE_IDS>({

if (vitestFnCall?.type !== 'describe' && vitestFnCall?.type !== 'test' && vitestFnCall?.type !== 'it') return


// check if extend keyword have been used
if (
vitestFnCall.members &&
vitestFnCall.members[0] &&
vitestFnCall.members[0].type === AST_NODE_TYPES.Identifier &&
vitestFnCall.members[0].name === 'extend'
vitestFnCall.members
&& vitestFnCall.members[0]
&& vitestFnCall.members[0].type === AST_NODE_TYPES.Identifier
&& vitestFnCall.members[0].name === 'extend'
) {
return
}
Expand Down
4 changes: 2 additions & 2 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface PluginDocs {

export function createEslintRule<TOptions extends readonly unknown[], TMessageIds extends string>(rule: Readonly<ESLintUtils.RuleWithMetaAndName<TOptions, TMessageIds, PluginDocs>>): RuleModule<TMessageIds, TOptions, PluginDocs, RuleListener> {
const createRule = ESLintUtils.RuleCreator<PluginDocs>(
(ruleName) =>
ruleName =>
`https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/${ruleName}.md`
)
return createRule(rule)
Expand Down Expand Up @@ -211,4 +211,4 @@ export const isParsedInstanceOfMatcherCall = (
&& expectFnCall.args.length === 1
&& isSupportedAccessor(expectFnCall.args[0], classArg)
)
}
}

0 comments on commit 7f69731

Please sign in to comment.