-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(outdated docs): improve documentation (#316)
- Loading branch information
Showing
6 changed files
with
82 additions
and
81 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
docs/rules/require-local-test-context-for-concurrent-snapshots.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 23 additions & 23 deletions
46
src/rules/require-local-test-context-for-concurrent-snapshots.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,56 @@ | ||
import { AST_NODE_TYPES, TSESTree } from "@typescript-eslint/utils"; | ||
import { createEslintRule, getNodeName, isSupportedAccessor } from "../utils"; | ||
import { isTypeOfVitestFnCall } from "../utils/parseVitestFnCall"; | ||
import { AST_NODE_TYPES } from '@typescript-eslint/utils' | ||
import { createEslintRule, isSupportedAccessor } from '../utils' | ||
import { isTypeOfVitestFnCall } from '../utils/parseVitestFnCall' | ||
|
||
export const RULE_NAME = "require-local-test-context-for-concurrent-snapshots"; | ||
export const RULE_NAME = 'require-local-test-context-for-concurrent-snapshots' | ||
|
||
export default createEslintRule({ | ||
name: RULE_NAME, | ||
meta: { | ||
docs: { | ||
description: "Require local Test Context for concurrent snapshot tests", | ||
recommended: "error", | ||
description: 'Require local Test Context for concurrent snapshot tests', | ||
recommended: 'error' | ||
}, | ||
messages: { | ||
requireLocalTestContext: "Use local Test Context instead", | ||
requireLocalTestContext: 'Use local Test Context instead' | ||
}, | ||
type: "problem", | ||
schema: [], | ||
type: 'problem', | ||
schema: [] | ||
}, | ||
defaultOptions: [], | ||
create(context) { | ||
return { | ||
CallExpression(node) { | ||
const isNotAnAssertion = !isTypeOfVitestFnCall(node, context, ['expect']) | ||
if (isNotAnAssertion) return; | ||
if (isNotAnAssertion) return | ||
|
||
const isNotASnapshotAssertion = ![ | ||
'toMatchSnapshot', | ||
'toMatchInlineSnapshot' | ||
].includes(node.callee.property.name); | ||
].includes(node.callee.property.name) | ||
|
||
if (isNotASnapshotAssertion) return; | ||
if (isNotASnapshotAssertion) return | ||
|
||
const isInsideSequentialDescribeOrTest = !context.getAncestors().some((ancestor) => { | ||
if (ancestor.type !== AST_NODE_TYPES.CallExpression) return false; | ||
if (ancestor.type !== AST_NODE_TYPES.CallExpression) return false | ||
|
||
const isNotInsideDescribeOrTest = !isTypeOfVitestFnCall(ancestor, context, ["describe", "test"]); | ||
if (isNotInsideDescribeOrTest) return false; | ||
const isNotInsideDescribeOrTest = !isTypeOfVitestFnCall(ancestor, context, ['describe', 'test']) | ||
if (isNotInsideDescribeOrTest) return false | ||
|
||
const isTestRunningConcurrently = | ||
ancestor.callee.type === AST_NODE_TYPES.MemberExpression && | ||
isSupportedAccessor(ancestor.callee.property, "concurrent"); | ||
isSupportedAccessor(ancestor.callee.property, 'concurrent') | ||
|
||
return isTestRunningConcurrently | ||
}); | ||
}) | ||
|
||
if (isInsideSequentialDescribeOrTest) return; | ||
if (isInsideSequentialDescribeOrTest) return | ||
|
||
context.report({ | ||
node, | ||
messageId: "requireLocalTestContext" | ||
messageId: 'requireLocalTestContext' | ||
}) | ||
}, | ||
}; | ||
}, | ||
}); | ||
} | ||
} | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters