Skip to content

Commit

Permalink
Prevent accidentally committing focused test selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
sarayourfriend committed May 25, 2023
1 parent 8cbe4e3 commit 741ff93
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ const i18nDestructureRules = ["t", "tc", "te", "td", "d", "n"].map(
})
)

const testFunctionNameSelector = "/(test|it|describe)/"
const testOnlyRules = [
// Covers `test.only`, `test.concurrent.only` and variations
`CallExpression > MemberExpression:matches([object.name=${testFunctionNameSelector}], [object.object.name=${testFunctionNameSelector}])[property.name='only']`,
// Covers `test.only.each` and variations
`CallExpression > MemberExpression[object.object.name=${testFunctionNameSelector}][object.property.name='only']`,
].map((selector) => ({
selector,
message: "Remove `.only` test selector before committing.",
}))

module.exports = {
root: true,
env: {
Expand Down Expand Up @@ -98,6 +109,7 @@ module.exports = {
"no-restricted-syntax": [
"error",
...i18nDestructureRules,
...testOnlyRules,
{
selector:
"ImportDeclaration[source.value='@vue/test-utils']:has(ImportSpecifier[local.name='shallowMount'])",
Expand Down

0 comments on commit 741ff93

Please sign in to comment.