eslint-plugin-jest
Advanced tools
Comparing version 24.1.10 to 24.2.0
@@ -0,1 +1,8 @@ | ||
# [24.2.0](https://github.com/jest-community/eslint-plugin-jest/compare/v24.1.10...v24.2.0) (2021-03-09) | ||
### Features | ||
* **no-focused-tests:** make fixable ([#787](https://github.com/jest-community/eslint-plugin-jest/issues/787)) ([040871a](https://github.com/jest-community/eslint-plugin-jest/commit/040871a866b7803e5c48b40715d48437d3906b0f)) | ||
## [24.1.10](https://github.com/jest-community/eslint-plugin-jest/compare/v24.1.9...v24.1.10) (2021-03-09) | ||
@@ -2,0 +9,0 @@ |
@@ -29,8 +29,9 @@ "use strict"; | ||
description: 'Disallow focused tests', | ||
recommended: 'error' | ||
recommended: 'error', | ||
suggestion: true | ||
}, | ||
messages: { | ||
focusedTest: 'Unexpected focused test.' | ||
focusedTest: 'Unexpected focused test.', | ||
suggestRemoveFocus: 'Remove focus from test.' | ||
}, | ||
fixable: 'code', | ||
schema: [], | ||
@@ -45,6 +46,16 @@ type: 'suggestion' | ||
if (callee.type === _experimentalUtils.AST_NODE_TYPES.MemberExpression) { | ||
if (callee.object.type === _experimentalUtils.AST_NODE_TYPES.Identifier && isCallToFocusedTestFunction(callee.object)) { | ||
const calleeObject = callee.object; | ||
if (calleeObject.type === _experimentalUtils.AST_NODE_TYPES.Identifier && isCallToFocusedTestFunction(calleeObject)) { | ||
context.report({ | ||
messageId: 'focusedTest', | ||
node: callee.object | ||
node: calleeObject, | ||
suggest: [{ | ||
messageId: 'suggestRemoveFocus', | ||
fix(fixer) { | ||
return fixer.removeRange([calleeObject.range[0], calleeObject.range[0] + 1]); | ||
} | ||
}] | ||
}); | ||
@@ -54,6 +65,18 @@ return; | ||
if (callee.object.type === _experimentalUtils.AST_NODE_TYPES.MemberExpression && isCallToTestOnlyFunction(callee.object)) { | ||
if (calleeObject.type === _experimentalUtils.AST_NODE_TYPES.MemberExpression && isCallToTestOnlyFunction(calleeObject)) { | ||
context.report({ | ||
messageId: 'focusedTest', | ||
node: callee.object.property | ||
node: calleeObject.property, | ||
suggest: [{ | ||
messageId: 'suggestRemoveFocus', | ||
fix(fixer) { | ||
if (calleeObject.property.type === _experimentalUtils.AST_NODE_TYPES.Identifier && calleeObject.property.name === 'only') { | ||
return fixer.removeRange([calleeObject.object.range[1], calleeObject.range[1]]); | ||
} | ||
return fixer.removeRange([calleeObject.range[1], callee.range[1]]); | ||
} | ||
}] | ||
}); | ||
@@ -66,3 +89,11 @@ return; | ||
messageId: 'focusedTest', | ||
node: callee.property | ||
node: callee.property, | ||
suggest: [{ | ||
messageId: 'suggestRemoveFocus', | ||
fix(fixer) { | ||
return fixer.removeRange([calleeObject.range[1], callee.range[1]]); | ||
} | ||
}] | ||
}); | ||
@@ -76,3 +107,11 @@ return; | ||
messageId: 'focusedTest', | ||
node: callee | ||
node: callee, | ||
suggest: [{ | ||
messageId: 'suggestRemoveFocus', | ||
fix(fixer) { | ||
return fixer.removeRange([callee.range[0], callee.range[0] + 1]); | ||
} | ||
}] | ||
}); | ||
@@ -79,0 +118,0 @@ } |
{ | ||
"name": "eslint-plugin-jest", | ||
"version": "24.1.10", | ||
"version": "24.2.0", | ||
"description": "Eslint rules for Jest", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -146,3 +146,3 @@ <div align="center"> | ||
| [no-export](docs/rules/no-export.md) | Disallow using `exports` in files containing tests | ![recommended][] | | | ||
| [no-focused-tests](docs/rules/no-focused-tests.md) | Disallow focused tests | ![recommended][] | ![fixable][] | | ||
| [no-focused-tests](docs/rules/no-focused-tests.md) | Disallow focused tests | ![recommended][] | ![suggest][] | | ||
| [no-hooks](docs/rules/no-hooks.md) | Disallow setup and teardown hooks | | | | ||
@@ -149,0 +149,0 @@ | [no-identical-title](docs/rules/no-identical-title.md) | Disallow identical titles | ![recommended][] | | |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
245269
3989