Skip to content
Permalink
Browse files
fix(require-tothrow-message): rename rule to require-to-throw-message (
…#306)

BREAKING CHANGE: Rename `require-tothrow-message` to `require-to-throw-message`

closes #296
  • Loading branch information
chrisblossom authored and G-Rath committed Oct 27, 2019
1 parent 14cb815 commit 53653c153ffa7412adad77d9fb0488be6728e390
@@ -145,7 +145,7 @@ installations requiring long-term consistency.
| [prefer-to-have-length][] | Suggest using `toHaveLength()` | ![style][] | ![fixable-green][] |
| [prefer-todo][] | Suggest using `test.todo()` | | ![fixable-green][] |
| [require-top-level-describe][] | Require a top-level `describe` block | | |
| [require-tothrow-message][] | Require that `toThrow()` and `toThrowError` includes a message | | |
| [require-to-throw-message][] | Require that `toThrow()` and `toThrowError` includes a message | | |
| [valid-describe][] | Enforce valid `describe()` callback | ![recommended][] | |
| [valid-expect-in-promise][] | Enforce having return statement when testing with promises | ![recommended][] | |
| [valid-expect][] | Enforce valid `expect()` usage | ![recommended][] | |
@@ -200,7 +200,7 @@ https://github.com/dangreenisrael/eslint-plugin-jest-formatting
[prefer-to-have-length]: docs/rules/prefer-to-have-length.md
[prefer-todo]: docs/rules/prefer-todo.md
[require-top-level-describe]: docs/rules/require-top-level-describe.md
[require-tothrow-message]: docs/rules/require-tothrow-message.md
[require-to-throw-message]: docs/rules/require-to-throw-message.md
[valid-describe]: docs/rules/valid-describe.md
[valid-expect-in-promise]: docs/rules/valid-expect-in-promise.md
[valid-expect]: docs/rules/valid-expect.md
File renamed without changes.
@@ -1,6 +1,6 @@
import { TSESLint } from '@typescript-eslint/experimental-utils';
import resolveFrom from 'resolve-from';
import rule from '../require-tothrow-message';
import rule from '../require-to-throw-message';

const ruleTester = new TSESLint.RuleTester({
parser: resolveFrom(require.resolve('eslint'), 'espree'),
@@ -9,7 +9,7 @@ const ruleTester = new TSESLint.RuleTester({
},
});

ruleTester.run('require-tothrow-message', rule, {
ruleTester.run('require-to-throw-message', rule, {
valid: [
// String
"expect(() => { throw new Error('a'); }).toThrow('a');",
@@ -68,8 +68,8 @@ ruleTester.run('require-tothrow-message', rule, {
code: "expect(() => { throw new Error('a'); }).toThrow();",
errors: [
{
messageId: 'requireRethrow',
data: { propertyName: 'toThrow' },
messageId: 'addErrorMessage',
data: { matcherName: 'toThrow' },
column: 41,
line: 1,
},
@@ -80,8 +80,8 @@ ruleTester.run('require-tothrow-message', rule, {
code: "expect(() => { throw new Error('a'); }).toThrowError();",
errors: [
{
messageId: 'requireRethrow',
data: { propertyName: 'toThrowError' },
messageId: 'addErrorMessage',
data: { matcherName: 'toThrowError' },
column: 41,
line: 1,
},
@@ -97,14 +97,14 @@ ruleTester.run('require-tothrow-message', rule, {
})`,
errors: [
{
messageId: 'requireRethrow',
data: { propertyName: 'toThrow' },
messageId: 'addErrorMessage',
data: { matcherName: 'toThrow' },
column: 49,
line: 3,
},
{
messageId: 'requireRethrow',
data: { propertyName: 'toThrowError' },
messageId: 'addErrorMessage',
data: { matcherName: 'toThrowError' },
column: 49,
line: 4,
},
@@ -14,7 +14,7 @@ export default createRule({
recommended: false,
},
messages: {
requireRethrow: 'Add an error message to {{ propertyName }}()',
addErrorMessage: 'Add an error message to {{ propertyName }}()',
},
type: 'suggestion',
schema: [],
@@ -39,8 +39,8 @@ export default createRule({
) {
// Look for `toThrow` calls with no arguments.
context.report({
messageId: 'requireRethrow', // todo: rename to 'addErrorMessage'
data: { propertyName: matcher.name }, // todo: rename to 'matcherName'
messageId: 'addErrorMessage',
data: { matcherName: matcher.name },
node: matcher.node.property,
});
}

0 comments on commit 53653c1

Please sign in to comment.