From 118351ce74a6611e7a3805ad7f88ec4e9f3a7748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20C=2E=20Viesca=20Ruiz?= Date: Thu, 2 Apr 2020 17:12:30 +0200 Subject: [PATCH 01/18] feat(rules): add no-interpolation-inline-snapshot rule --- .../rules/no-interpolation-inline-snapshot.md | 54 +++++++++++++++++++ .../__snapshots__/rules.test.ts.snap | 1 + src/__tests__/rules.test.ts | 2 +- .../no-interpolation-inline-snapshot.test.ts | 40 ++++++++++++++ src/rules/no-interpolation-inline-snapshot.ts | 48 +++++++++++++++++ 5 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 docs/rules/no-interpolation-inline-snapshot.md create mode 100644 src/rules/__tests__/no-interpolation-inline-snapshot.test.ts create mode 100644 src/rules/no-interpolation-inline-snapshot.ts diff --git a/docs/rules/no-interpolation-inline-snapshot.md b/docs/rules/no-interpolation-inline-snapshot.md new file mode 100644 index 000000000..def3a9472 --- /dev/null +++ b/docs/rules/no-interpolation-inline-snapshot.md @@ -0,0 +1,54 @@ +# No string interpolation inside inline snapshots (no-interpolation-inline-snapshot) + +Prevents the use of string interpolations within `toMatchInlineSnapshot`. + +## Rule Details + +Interpolation prevents snapshots from being updated. Instead, properties should +be overloaded with a matcher by passing the optional `propertyMatchers` argument +to `toMatchInlineSnapshot`. + +Examples of **incorrect** code for this rule: + +```js +expect(something).toMatchInlineSnapshot( + `Object { + property: ${interpolated} + }`, +); + +expect(something).toMatchInlineSnapshot( + { other: expect.any(Number) }, + `Object { + other: Any, + property: ${interpolated} + }`, +); +``` + +Examples of **correct** code for this rule: + +```js +expect(something).toMatchInlineSnapshot(); + +expect(something).toMatchInlineSnapshot( + `Object { + property: 1 + }`, +); + +expect(something).toMatchInlineSnapshot( + { property: expect.any(Date) }, + `Object { + property: Any + }`, +); +``` + +\*Note that this rule will not trigger if the helper function is never used even +thought the `expect` will not execute. Rely on a rule like no-unused-vars for +this case. + +## When Not To Use It + +Don't use this rule on non-jest test files. diff --git a/src/__tests__/__snapshots__/rules.test.ts.snap b/src/__tests__/__snapshots__/rules.test.ts.snap index 831fe0269..4a750b42b 100644 --- a/src/__tests__/__snapshots__/rules.test.ts.snap +++ b/src/__tests__/__snapshots__/rules.test.ts.snap @@ -23,6 +23,7 @@ Object { "jest/no-hooks": "error", "jest/no-identical-title": "error", "jest/no-if": "error", + "jest/no-interpolation-inline-snapshot": "error", "jest/no-jasmine-globals": "error", "jest/no-jest-import": "error", "jest/no-large-snapshots": "error", diff --git a/src/__tests__/rules.test.ts b/src/__tests__/rules.test.ts index b5ebf1e03..f90174218 100644 --- a/src/__tests__/rules.test.ts +++ b/src/__tests__/rules.test.ts @@ -3,7 +3,7 @@ import { resolve } from 'path'; import plugin from '../'; const ruleNames = Object.keys(plugin.rules); -const numberOfRules = 40; +const numberOfRules = 41; describe('rules', () => { it('should have a corresponding doc for each rule', () => { diff --git a/src/rules/__tests__/no-interpolation-inline-snapshot.test.ts b/src/rules/__tests__/no-interpolation-inline-snapshot.test.ts new file mode 100644 index 000000000..7600302a6 --- /dev/null +++ b/src/rules/__tests__/no-interpolation-inline-snapshot.test.ts @@ -0,0 +1,40 @@ +import { TSESLint } from '@typescript-eslint/experimental-utils'; +import resolveFrom from 'resolve-from'; +import rule from '../no-interpolation-inline-snapshot'; + +const ruleTester = new TSESLint.RuleTester({ + parser: resolveFrom(require.resolve('eslint'), 'espree'), + parserOptions: { + ecmaVersion: 2017, + }, +}); + +ruleTester.run('no-interpolation-inline-snapshot', rule, { + valid: [ + 'expect(something).toMatchInlineSnapshot();', + 'expect(something).toMatchInlineSnapshot(`No interpolation`);', + 'expect(something).toMatchInlineSnapshot({}, `No interpolation`);', + ], + invalid: [ + { + code: 'expect(something).toMatchInlineSnapshot(`${interpolated}`);', + errors: [ + { + endColumn: 58, + column: 41, + messageId: 'noInterpolation', + }, + ], + }, + { + code: 'expect(something).toMatchInlineSnapshot({}, `${interpolated}`);', + errors: [ + { + endColumn: 62, + column: 45, + messageId: 'noInterpolation', + }, + ], + }, + ], +}); diff --git a/src/rules/no-interpolation-inline-snapshot.ts b/src/rules/no-interpolation-inline-snapshot.ts new file mode 100644 index 000000000..85db261c3 --- /dev/null +++ b/src/rules/no-interpolation-inline-snapshot.ts @@ -0,0 +1,48 @@ +import { AST_NODE_TYPES } from '@typescript-eslint/experimental-utils'; +import { createRule } from './utils'; + +export default createRule({ + name: __filename, + meta: { + docs: { + category: 'Best Practices', + description: 'Disallow string interpolation inside inline snapshots.', + recommended: false, + }, + messages: { + noInterpolation: + 'Do not use string interpolation inside of inline snapshots', + }, + schema: [], + type: 'suggestion', + }, + defaultOptions: [], + create(context) { + return { + CallExpression(node) { + const { callee, arguments: nodeArguments } = node; + + if ( + callee.type !== AST_NODE_TYPES.MemberExpression || + callee.property.type !== AST_NODE_TYPES.Identifier || + callee.property.name !== 'toMatchInlineSnapshot' + ) { + return; + } + + // Check all since the optional 'propertyMatchers' argument might be present + nodeArguments.forEach(argument => { + if ( + argument.type === AST_NODE_TYPES.TemplateLiteral && + argument.expressions.length > 0 + ) { + context.report({ + messageId: 'noInterpolation', + node: argument, + }); + } + }); + }, + }; + }, +}); From d96ae670abefe03f412275a4a857fa6bec8e13bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20C=2E=20Viesca=20Ruiz?= Date: Thu, 2 Apr 2020 17:21:50 +0200 Subject: [PATCH 02/18] docs: fix fromat in rule documentation --- docs/rules/no-interpolation-inline-snapshot.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/docs/rules/no-interpolation-inline-snapshot.md b/docs/rules/no-interpolation-inline-snapshot.md index def3a9472..a5e660d89 100644 --- a/docs/rules/no-interpolation-inline-snapshot.md +++ b/docs/rules/no-interpolation-inline-snapshot.md @@ -45,10 +45,6 @@ expect(something).toMatchInlineSnapshot( ); ``` -\*Note that this rule will not trigger if the helper function is never used even -thought the `expect` will not execute. Rely on a rule like no-unused-vars for -this case. - ## When Not To Use It Don't use this rule on non-jest test files. From b6c50ec9a1ae5cdea27c0e6af9002e0c421d15b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20C=2E=20Viesca=20Ruiz?= Date: Mon, 4 May 2020 13:59:03 +0200 Subject: [PATCH 03/18] fix: add chamges requested in review --- .../no-interpolation-inline-snapshot.test.ts | 26 +++++++++++++++++++ src/rules/no-interpolation-inline-snapshot.ts | 15 ++++++----- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/src/rules/__tests__/no-interpolation-inline-snapshot.test.ts b/src/rules/__tests__/no-interpolation-inline-snapshot.test.ts index 7600302a6..81be79169 100644 --- a/src/rules/__tests__/no-interpolation-inline-snapshot.test.ts +++ b/src/rules/__tests__/no-interpolation-inline-snapshot.test.ts @@ -14,6 +14,11 @@ ruleTester.run('no-interpolation-inline-snapshot', rule, { 'expect(something).toMatchInlineSnapshot();', 'expect(something).toMatchInlineSnapshot(`No interpolation`);', 'expect(something).toMatchInlineSnapshot({}, `No interpolation`);', + 'expect(something);', + 'expect(something).not;', + 'expect.toHaveAssertions();', + 'myObjectWants.toMatchInlineSnapshot({}, `${interpolated}`);', + 'toMatchInlineSnapshot({}, `${interpolated}`);', ], invalid: [ { @@ -26,6 +31,16 @@ ruleTester.run('no-interpolation-inline-snapshot', rule, { }, ], }, + { + code: 'expect(something).not.toMatchInlineSnapshot(`${interpolated}`);', + errors: [ + { + endColumn: 62, + column: 45, + messageId: 'noInterpolation', + }, + ], + }, { code: 'expect(something).toMatchInlineSnapshot({}, `${interpolated}`);', errors: [ @@ -36,5 +51,16 @@ ruleTester.run('no-interpolation-inline-snapshot', rule, { }, ], }, + { + code: + 'expect(something).not.toMatchInlineSnapshot({}, `${interpolated}`);', + errors: [ + { + endColumn: 66, + column: 49, + messageId: 'noInterpolation', + }, + ], + }, ], }); diff --git a/src/rules/no-interpolation-inline-snapshot.ts b/src/rules/no-interpolation-inline-snapshot.ts index 85db261c3..d5890712a 100644 --- a/src/rules/no-interpolation-inline-snapshot.ts +++ b/src/rules/no-interpolation-inline-snapshot.ts @@ -1,5 +1,5 @@ import { AST_NODE_TYPES } from '@typescript-eslint/experimental-utils'; -import { createRule } from './utils'; +import { createRule, isExpectCall, parseExpectCall } from './utils'; export default createRule({ name: __filename, @@ -20,18 +20,21 @@ export default createRule({ create(context) { return { CallExpression(node) { - const { callee, arguments: nodeArguments } = node; + if (!isExpectCall(node)) { + return; + } + + const { matcher } = parseExpectCall(node); if ( - callee.type !== AST_NODE_TYPES.MemberExpression || - callee.property.type !== AST_NODE_TYPES.Identifier || - callee.property.name !== 'toMatchInlineSnapshot' + matcher?.name !== 'toMatchInlineSnapshot' || + matcher?.arguments === null ) { return; } // Check all since the optional 'propertyMatchers' argument might be present - nodeArguments.forEach(argument => { + matcher.arguments.forEach(argument => { if ( argument.type === AST_NODE_TYPES.TemplateLiteral && argument.expressions.length > 0 From d8872c27f2e62c23b71a6da1b24ac248f3d0536b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20C=2E=20Viesca=20Ruiz?= Date: Mon, 4 May 2020 14:00:14 +0200 Subject: [PATCH 04/18] test: update number of rules --- src/__tests__/rules.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/__tests__/rules.test.ts b/src/__tests__/rules.test.ts index f90174218..95fc2c88e 100644 --- a/src/__tests__/rules.test.ts +++ b/src/__tests__/rules.test.ts @@ -3,7 +3,7 @@ import { resolve } from 'path'; import plugin from '../'; const ruleNames = Object.keys(plugin.rules); -const numberOfRules = 41; +const numberOfRules = 42; describe('rules', () => { it('should have a corresponding doc for each rule', () => { From ea5644e43a1f9f1b4e01f7335f8fa55ee5688c5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20C=2E=20Viesca=20Ruiz?= Date: Mon, 29 Jun 2020 11:06:50 +0200 Subject: [PATCH 05/18] docs: update docs/rules/no-interpolation-inline-snapshot.md Co-authored-by: Gareth Jones --- docs/rules/no-interpolation-inline-snapshot.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/rules/no-interpolation-inline-snapshot.md b/docs/rules/no-interpolation-inline-snapshot.md index a5e660d89..82468a244 100644 --- a/docs/rules/no-interpolation-inline-snapshot.md +++ b/docs/rules/no-interpolation-inline-snapshot.md @@ -1,4 +1,4 @@ -# No string interpolation inside inline snapshots (no-interpolation-inline-snapshot) +# Disallow string interpolation inside inline snapshots (`no-interpolation-inline-snapshot`) Prevents the use of string interpolations within `toMatchInlineSnapshot`. From 7dc3bd784f90ee9caff3c15adb1bb8366b4868e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20C=2E=20Viesca=20Ruiz?= Date: Mon, 29 Jun 2020 11:23:22 +0200 Subject: [PATCH 06/18] feat: add toThrowErrorMatchingInlineSnapshot --- .../no-interpolation-inline-snapshot.test.ts | 24 +++++++++++++++++++ src/rules/no-interpolation-inline-snapshot.ts | 3 ++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/rules/__tests__/no-interpolation-inline-snapshot.test.ts b/src/rules/__tests__/no-interpolation-inline-snapshot.test.ts index 81be79169..bf0d1ac79 100644 --- a/src/rules/__tests__/no-interpolation-inline-snapshot.test.ts +++ b/src/rules/__tests__/no-interpolation-inline-snapshot.test.ts @@ -19,6 +19,8 @@ ruleTester.run('no-interpolation-inline-snapshot', rule, { 'expect.toHaveAssertions();', 'myObjectWants.toMatchInlineSnapshot({}, `${interpolated}`);', 'toMatchInlineSnapshot({}, `${interpolated}`);', + 'expect(something).toThrowErrorMatchingInlineSnapshot();', + 'expect(something).toThrowErrorMatchingInlineSnapshot(`No interpolation`);', ], invalid: [ { @@ -62,5 +64,27 @@ ruleTester.run('no-interpolation-inline-snapshot', rule, { }, ], }, + { + code: + 'expect(something).toThrowErrorMatchingInlineSnapshot(`${interpolated}`);', + errors: [ + { + endColumn: 71, + column: 54, + messageId: 'noInterpolation', + }, + ], + }, + { + code: + 'expect(something).not.toThrowErrorMatchingInlineSnapshot(`${interpolated}`);', + errors: [ + { + endColumn: 75, + column: 58, + messageId: 'noInterpolation', + }, + ], + }, ], }); diff --git a/src/rules/no-interpolation-inline-snapshot.ts b/src/rules/no-interpolation-inline-snapshot.ts index d5890712a..4c6d448eb 100644 --- a/src/rules/no-interpolation-inline-snapshot.ts +++ b/src/rules/no-interpolation-inline-snapshot.ts @@ -27,7 +27,8 @@ export default createRule({ const { matcher } = parseExpectCall(node); if ( - matcher?.name !== 'toMatchInlineSnapshot' || + (matcher?.name !== 'toMatchInlineSnapshot' && + matcher?.name !== 'toThrowErrorMatchingInlineSnapshot') || matcher?.arguments === null ) { return; From d83c060b7d47c1dfd37879c1b1a5fb92d31116c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20C=2E=20Viesca=20Ruiz?= Date: Mon, 29 Jun 2020 11:36:23 +0200 Subject: [PATCH 07/18] docs: update rules table in README --- README.md | 83 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 42 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index ed5c4f158..c660ed2c9 100644 --- a/README.md +++ b/README.md @@ -127,47 +127,48 @@ installations requiring long-term consistency. -| Rule | Description | Configurations | Fixable | -| ---------------------------------------------------------------------- | --------------------------------------------------------------- | ---------------- | ------------ | -| [consistent-test-it](docs/rules/consistent-test-it.md) | Have control over `test` and `it` usages | | ![fixable][] | -| [expect-expect](docs/rules/expect-expect.md) | Enforce assertion to be made in a test body | ![recommended][] | | -| [lowercase-name](docs/rules/lowercase-name.md) | Enforce lowercase test names | | ![fixable][] | -| [no-alias-methods](docs/rules/no-alias-methods.md) | Disallow alias methods | ![style][] | ![fixable][] | -| [no-commented-out-tests](docs/rules/no-commented-out-tests.md) | Disallow commented out tests | ![recommended][] | | -| [no-conditional-expect](docs/rules/no-conditional-expect.md) | Prevent calling `expect` conditionally | | | -| [no-deprecated-functions](docs/rules/no-deprecated-functions.md) | Disallow use of deprecated functions | | ![fixable][] | -| [no-disabled-tests](docs/rules/no-disabled-tests.md) | Disallow disabled tests | ![recommended][] | | -| [no-duplicate-hooks](docs/rules/no-duplicate-hooks.md) | Disallow duplicate setup and teardown hooks | | | -| [no-export](docs/rules/no-export.md) | Prevent exporting from test files | ![recommended][] | | -| [no-focused-tests](docs/rules/no-focused-tests.md) | Disallow focused tests | ![recommended][] | ![fixable][] | -| [no-hooks](docs/rules/no-hooks.md) | Disallow setup and teardown hooks | | | -| [no-identical-title](docs/rules/no-identical-title.md) | Disallow identical titles | ![recommended][] | | -| [no-if](docs/rules/no-if.md) | Disallow conditional logic | | | -| [no-jasmine-globals](docs/rules/no-jasmine-globals.md) | Disallow Jasmine globals | ![recommended][] | ![fixable][] | -| [no-jest-import](docs/rules/no-jest-import.md) | Disallow importing Jest | ![recommended][] | | -| [no-large-snapshots](docs/rules/no-large-snapshots.md) | disallow large snapshots | | | -| [no-mocks-import](docs/rules/no-mocks-import.md) | Disallow manually importing from **mocks** | ![recommended][] | | -| [no-restricted-matchers](docs/rules/no-restricted-matchers.md) | Disallow specific matchers & modifiers | | | -| [no-standalone-expect](docs/rules/no-standalone-expect.md) | Prevents expects that are outside of an it or test block. | ![recommended][] | | -| [no-test-callback](docs/rules/no-test-callback.md) | Avoid using a callback in asynchronous tests | ![recommended][] | ![suggest][] | -| [no-test-prefixes](docs/rules/no-test-prefixes.md) | Use `.only` and `.skip` over `f` and `x` | ![recommended][] | ![fixable][] | -| [no-test-return-statement](docs/rules/no-test-return-statement.md) | Disallow explicitly returning from tests | | | -| [prefer-called-with](docs/rules/prefer-called-with.md) | Suggest using `toBeCalledWith()` OR `toHaveBeenCalledWith()` | | | -| [prefer-expect-assertions](docs/rules/prefer-expect-assertions.md) | Suggest using `expect.assertions()` OR `expect.hasAssertions()` | | ![suggest][] | -| [prefer-hooks-on-top](docs/rules/prefer-hooks-on-top.md) | Suggest to have all hooks at top level | | | -| [prefer-spy-on](docs/rules/prefer-spy-on.md) | Suggest using `jest.spyOn()` | | ![fixable][] | -| [prefer-strict-equal](docs/rules/prefer-strict-equal.md) | Suggest using toStrictEqual() | | ![suggest][] | -| [prefer-to-be-null](docs/rules/prefer-to-be-null.md) | Suggest using `toBeNull()` | ![style][] | ![fixable][] | -| [prefer-to-be-undefined](docs/rules/prefer-to-be-undefined.md) | Suggest using `toBeUndefined()` | ![style][] | ![fixable][] | -| [prefer-to-contain](docs/rules/prefer-to-contain.md) | Suggest using `toContain()` | ![style][] | ![fixable][] | -| [prefer-to-have-length](docs/rules/prefer-to-have-length.md) | Suggest using `toHaveLength()` | ![style][] | ![fixable][] | -| [prefer-todo](docs/rules/prefer-todo.md) | Suggest using `test.todo` | | ![fixable][] | -| [require-to-throw-message](docs/rules/require-to-throw-message.md) | Require a message for `toThrow()` | | | -| [require-top-level-describe](docs/rules/require-top-level-describe.md) | Prevents test cases and hooks to be outside of a describe block | | | -| [valid-describe](docs/rules/valid-describe.md) | Enforce valid `describe()` callback | ![recommended][] | | -| [valid-expect](docs/rules/valid-expect.md) | Enforce valid `expect()` usage | ![recommended][] | | -| [valid-expect-in-promise](docs/rules/valid-expect-in-promise.md) | Enforce having return statement when testing with promises | ![recommended][] | | -| [valid-title](docs/rules/valid-title.md) | Enforce valid titles | | ![fixable][] | +| Rule | Description | Configurations | Fixable | +| ---------------------------------------------------------------------------------- | --------------------------------------------------------------- | ---------------- | ------------ | +| [consistent-test-it](docs/rules/consistent-test-it.md) | Have control over `test` and `it` usages | | ![fixable][] | +| [expect-expect](docs/rules/expect-expect.md) | Enforce assertion to be made in a test body | ![recommended][] | | +| [lowercase-name](docs/rules/lowercase-name.md) | Enforce lowercase test names | | ![fixable][] | +| [no-alias-methods](docs/rules/no-alias-methods.md) | Disallow alias methods | ![style][] | ![fixable][] | +| [no-commented-out-tests](docs/rules/no-commented-out-tests.md) | Disallow commented out tests | ![recommended][] | | +| [no-conditional-expect](docs/rules/no-conditional-expect.md) | Prevent calling `expect` conditionally | | | +| [no-deprecated-functions](docs/rules/no-deprecated-functions.md) | Disallow use of deprecated functions | | ![fixable][] | +| [no-disabled-tests](docs/rules/no-disabled-tests.md) | Disallow disabled tests | ![recommended][] | | +| [no-duplicate-hooks](docs/rules/no-duplicate-hooks.md) | Disallow duplicate setup and teardown hooks | | | +| [no-export](docs/rules/no-export.md) | Prevent exporting from test files | ![recommended][] | | +| [no-focused-tests](docs/rules/no-focused-tests.md) | Disallow focused tests | ![recommended][] | ![fixable][] | +| [no-hooks](docs/rules/no-hooks.md) | Disallow setup and teardown hooks | | | +| [no-identical-title](docs/rules/no-identical-title.md) | Disallow identical titles | ![recommended][] | | +| [no-if](docs/rules/no-if.md) | Disallow conditional logic | | | +| [no-interpolation-inline-snapshot](docs/rules/no-interpolation-inline-snapshot.md) | Disallow string interpolation inside inline snapshots. | | | +| [no-jasmine-globals](docs/rules/no-jasmine-globals.md) | Disallow Jasmine globals | ![recommended][] | ![fixable][] | +| [no-jest-import](docs/rules/no-jest-import.md) | Disallow importing Jest | ![recommended][] | | +| [no-large-snapshots](docs/rules/no-large-snapshots.md) | disallow large snapshots | | | +| [no-mocks-import](docs/rules/no-mocks-import.md) | Disallow manually importing from **mocks** | ![recommended][] | | +| [no-restricted-matchers](docs/rules/no-restricted-matchers.md) | Disallow specific matchers & modifiers | | | +| [no-standalone-expect](docs/rules/no-standalone-expect.md) | Prevents expects that are outside of an it or test block. | ![recommended][] | | +| [no-test-callback](docs/rules/no-test-callback.md) | Avoid using a callback in asynchronous tests | ![recommended][] | ![suggest][] | +| [no-test-prefixes](docs/rules/no-test-prefixes.md) | Use `.only` and `.skip` over `f` and `x` | ![recommended][] | ![fixable][] | +| [no-test-return-statement](docs/rules/no-test-return-statement.md) | Disallow explicitly returning from tests | | | +| [prefer-called-with](docs/rules/prefer-called-with.md) | Suggest using `toBeCalledWith()` OR `toHaveBeenCalledWith()` | | | +| [prefer-expect-assertions](docs/rules/prefer-expect-assertions.md) | Suggest using `expect.assertions()` OR `expect.hasAssertions()` | | ![suggest][] | +| [prefer-hooks-on-top](docs/rules/prefer-hooks-on-top.md) | Suggest to have all hooks at top level | | | +| [prefer-spy-on](docs/rules/prefer-spy-on.md) | Suggest using `jest.spyOn()` | | ![fixable][] | +| [prefer-strict-equal](docs/rules/prefer-strict-equal.md) | Suggest using toStrictEqual() | | ![suggest][] | +| [prefer-to-be-null](docs/rules/prefer-to-be-null.md) | Suggest using `toBeNull()` | ![style][] | ![fixable][] | +| [prefer-to-be-undefined](docs/rules/prefer-to-be-undefined.md) | Suggest using `toBeUndefined()` | ![style][] | ![fixable][] | +| [prefer-to-contain](docs/rules/prefer-to-contain.md) | Suggest using `toContain()` | ![style][] | ![fixable][] | +| [prefer-to-have-length](docs/rules/prefer-to-have-length.md) | Suggest using `toHaveLength()` | ![style][] | ![fixable][] | +| [prefer-todo](docs/rules/prefer-todo.md) | Suggest using `test.todo` | | ![fixable][] | +| [require-to-throw-message](docs/rules/require-to-throw-message.md) | Require a message for `toThrow()` | | | +| [require-top-level-describe](docs/rules/require-top-level-describe.md) | Prevents test cases and hooks to be outside of a describe block | | | +| [valid-describe](docs/rules/valid-describe.md) | Enforce valid `describe()` callback | ![recommended][] | | +| [valid-expect](docs/rules/valid-expect.md) | Enforce valid `expect()` usage | ![recommended][] | | +| [valid-expect-in-promise](docs/rules/valid-expect-in-promise.md) | Enforce having return statement when testing with promises | ![recommended][] | | +| [valid-title](docs/rules/valid-title.md) | Enforce valid titles | | ![fixable][] | From 8c448e972d01cbcf428e3d9bd3c2caa4e08f8e99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20C=2E=20Viesca=20Ruiz?= Date: Wed, 1 Jul 2020 10:58:26 +0200 Subject: [PATCH 08/18] docs: apply suggestions from code review Co-authored-by: Gareth Jones --- docs/rules/no-interpolation-inline-snapshot.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/rules/no-interpolation-inline-snapshot.md b/docs/rules/no-interpolation-inline-snapshot.md index 82468a244..82b7d41d6 100644 --- a/docs/rules/no-interpolation-inline-snapshot.md +++ b/docs/rules/no-interpolation-inline-snapshot.md @@ -1,12 +1,11 @@ # Disallow string interpolation inside inline snapshots (`no-interpolation-inline-snapshot`) -Prevents the use of string interpolations within `toMatchInlineSnapshot`. +Prevents the use of string interpolations in snapshots. ## Rule Details Interpolation prevents snapshots from being updated. Instead, properties should -be overloaded with a matcher by passing the optional `propertyMatchers` argument -to `toMatchInlineSnapshot`. +be overloaded with a matcher by using [property matchers](https://jestjs.io/docs/en/snapshot-testing#property-matchers). Examples of **incorrect** code for this rule: From 825687e97f5eda7b15e7325e9b8c412740634f4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20C=2E=20Viesca=20Ruiz?= Date: Wed, 1 Jul 2020 11:12:30 +0200 Subject: [PATCH 09/18] docs: fix format in README --- docs/rules/no-interpolation-inline-snapshot.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/rules/no-interpolation-inline-snapshot.md b/docs/rules/no-interpolation-inline-snapshot.md index 82b7d41d6..d71fdb348 100644 --- a/docs/rules/no-interpolation-inline-snapshot.md +++ b/docs/rules/no-interpolation-inline-snapshot.md @@ -5,7 +5,8 @@ Prevents the use of string interpolations in snapshots. ## Rule Details Interpolation prevents snapshots from being updated. Instead, properties should -be overloaded with a matcher by using [property matchers](https://jestjs.io/docs/en/snapshot-testing#property-matchers). +be overloaded with a matcher by using +[property matchers](https://jestjs.io/docs/en/snapshot-testing#property-matchers). Examples of **incorrect** code for this rule: From 96eaf9b56e404c1c6f835792232067fdc7af9151 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20C=2E=20Viesca=20Ruiz?= Date: Wed, 1 Jul 2020 11:17:55 +0200 Subject: [PATCH 10/18] fix: add review suggestions --- .../no-interpolation-inline-snapshot.test.ts | 2 ++ src/rules/no-interpolation-inline-snapshot.ts | 34 +++++++++---------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/rules/__tests__/no-interpolation-inline-snapshot.test.ts b/src/rules/__tests__/no-interpolation-inline-snapshot.test.ts index bf0d1ac79..2099ed19f 100644 --- a/src/rules/__tests__/no-interpolation-inline-snapshot.test.ts +++ b/src/rules/__tests__/no-interpolation-inline-snapshot.test.ts @@ -18,7 +18,9 @@ ruleTester.run('no-interpolation-inline-snapshot', rule, { 'expect(something).not;', 'expect.toHaveAssertions();', 'myObjectWants.toMatchInlineSnapshot({}, `${interpolated}`);', + 'myObjectWants.toMatchInlineSnapshot({}, `${interpolated1} ${interpolated2}`);', 'toMatchInlineSnapshot({}, `${interpolated}`);', + 'toMatchInlineSnapshot({}, `${interpolated1} ${interpolated2}`);', 'expect(something).toThrowErrorMatchingInlineSnapshot();', 'expect(something).toThrowErrorMatchingInlineSnapshot(`No interpolation`);', ], diff --git a/src/rules/no-interpolation-inline-snapshot.ts b/src/rules/no-interpolation-inline-snapshot.ts index 4c6d448eb..b756223d1 100644 --- a/src/rules/no-interpolation-inline-snapshot.ts +++ b/src/rules/no-interpolation-inline-snapshot.ts @@ -27,25 +27,25 @@ export default createRule({ const { matcher } = parseExpectCall(node); if ( - (matcher?.name !== 'toMatchInlineSnapshot' && - matcher?.name !== 'toThrowErrorMatchingInlineSnapshot') || - matcher?.arguments === null + matcher && + [ + 'toMatchInlineSnapshot', + 'toThrowErrorMatchingInlineSnapshot', + ].includes(matcher.name) ) { - return; + // Check all since the optional 'propertyMatchers' argument might be present + matcher.arguments?.forEach(argument => { + if ( + argument.type === AST_NODE_TYPES.TemplateLiteral && + argument.expressions.length > 0 + ) { + context.report({ + messageId: 'noInterpolation', + node: argument, + }); + } + }); } - - // Check all since the optional 'propertyMatchers' argument might be present - matcher.arguments.forEach(argument => { - if ( - argument.type === AST_NODE_TYPES.TemplateLiteral && - argument.expressions.length > 0 - ) { - context.report({ - messageId: 'noInterpolation', - node: argument, - }); - } - }); }, }; }, From a405636f7128de898187ac9dd3b54e90d65529b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20C=2E=20Viesca=20Ruiz?= Date: Wed, 1 Jul 2020 11:29:25 +0200 Subject: [PATCH 11/18] docs: add examples to README --- docs/rules/no-interpolation-inline-snapshot.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/rules/no-interpolation-inline-snapshot.md b/docs/rules/no-interpolation-inline-snapshot.md index d71fdb348..bbef3cf18 100644 --- a/docs/rules/no-interpolation-inline-snapshot.md +++ b/docs/rules/no-interpolation-inline-snapshot.md @@ -24,6 +24,10 @@ expect(something).toMatchInlineSnapshot( property: ${interpolated} }`, ); + +expect(errorThrowingFunction).toThrowErrorMatchingInlineSnapshot( + `${interpolated}`, +); ``` Examples of **correct** code for this rule: @@ -43,6 +47,12 @@ expect(something).toMatchInlineSnapshot( property: Any }`, ); + +expect(errorThrowingFunction).toThrowErrorMatchingInlineSnapshot(); + +expect(errorThrowingFunction).toThrowErrorMatchingInlineSnapshot( + `Error Message`, +); ``` ## When Not To Use It From 3dfd3a65af2e2ed669db359463e545db4c0d1cff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20C=2E=20Viesca=20Ruiz?= Date: Wed, 1 Jul 2020 11:39:12 +0200 Subject: [PATCH 12/18] chore: rename rule to no-interpolation-in-snapshots --- ...on-inline-snapshot.md => no-interpolation-in-snapshots.md} | 2 +- src/__tests__/__snapshots__/rules.test.ts.snap | 2 +- ...snapshot.test.ts => no-interpolation-in-snapshots.test.ts} | 4 ++-- ...on-inline-snapshot.ts => no-interpolation-in-snapshots.ts} | 0 4 files changed, 4 insertions(+), 4 deletions(-) rename docs/rules/{no-interpolation-inline-snapshot.md => no-interpolation-in-snapshots.md} (97%) rename src/rules/__tests__/{no-interpolation-inline-snapshot.test.ts => no-interpolation-in-snapshots.test.ts} (95%) rename src/rules/{no-interpolation-inline-snapshot.ts => no-interpolation-in-snapshots.ts} (100%) diff --git a/docs/rules/no-interpolation-inline-snapshot.md b/docs/rules/no-interpolation-in-snapshots.md similarity index 97% rename from docs/rules/no-interpolation-inline-snapshot.md rename to docs/rules/no-interpolation-in-snapshots.md index bbef3cf18..e6f587b3a 100644 --- a/docs/rules/no-interpolation-inline-snapshot.md +++ b/docs/rules/no-interpolation-in-snapshots.md @@ -1,4 +1,4 @@ -# Disallow string interpolation inside inline snapshots (`no-interpolation-inline-snapshot`) +# Disallow string interpolation inside inline snapshots (`no-interpolation-in-snapshots`) Prevents the use of string interpolations in snapshots. diff --git a/src/__tests__/__snapshots__/rules.test.ts.snap b/src/__tests__/__snapshots__/rules.test.ts.snap index f5b18b2db..d82ca52e3 100644 --- a/src/__tests__/__snapshots__/rules.test.ts.snap +++ b/src/__tests__/__snapshots__/rules.test.ts.snap @@ -25,7 +25,7 @@ Object { "jest/no-hooks": "error", "jest/no-identical-title": "error", "jest/no-if": "error", - "jest/no-interpolation-inline-snapshot": "error", + "jest/no-interpolation-in-snapshots": "error", "jest/no-jasmine-globals": "error", "jest/no-jest-import": "error", "jest/no-large-snapshots": "error", diff --git a/src/rules/__tests__/no-interpolation-inline-snapshot.test.ts b/src/rules/__tests__/no-interpolation-in-snapshots.test.ts similarity index 95% rename from src/rules/__tests__/no-interpolation-inline-snapshot.test.ts rename to src/rules/__tests__/no-interpolation-in-snapshots.test.ts index 2099ed19f..2a729b676 100644 --- a/src/rules/__tests__/no-interpolation-inline-snapshot.test.ts +++ b/src/rules/__tests__/no-interpolation-in-snapshots.test.ts @@ -1,6 +1,6 @@ import { TSESLint } from '@typescript-eslint/experimental-utils'; import resolveFrom from 'resolve-from'; -import rule from '../no-interpolation-inline-snapshot'; +import rule from '../no-interpolation-in-snapshots'; const ruleTester = new TSESLint.RuleTester({ parser: resolveFrom(require.resolve('eslint'), 'espree'), @@ -9,7 +9,7 @@ const ruleTester = new TSESLint.RuleTester({ }, }); -ruleTester.run('no-interpolation-inline-snapshot', rule, { +ruleTester.run('no-interpolation-in-snapshots', rule, { valid: [ 'expect(something).toMatchInlineSnapshot();', 'expect(something).toMatchInlineSnapshot(`No interpolation`);', diff --git a/src/rules/no-interpolation-inline-snapshot.ts b/src/rules/no-interpolation-in-snapshots.ts similarity index 100% rename from src/rules/no-interpolation-inline-snapshot.ts rename to src/rules/no-interpolation-in-snapshots.ts From ab2c365896fe7e61daa8dbd2fd4ccdae29ac5046 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20C=2E=20Viesca=20Ruiz?= Date: Wed, 1 Jul 2020 11:48:58 +0200 Subject: [PATCH 13/18] chore: remove changes from CHANGELOG.md --- CHANGELOG.md | 77 +++++++++++++++++++++------------------------------- 1 file changed, 31 insertions(+), 46 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a4f285e3f..ea3b53ddb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,111 +1,96 @@ ## [23.17.1](https://github.com/jest-community/eslint-plugin-jest/compare/v23.17.0...v23.17.1) (2020-06-23) + ### Bug Fixes -- **lowercase-name:** ignore all top level describes when option is true - ([#614](https://github.com/jest-community/eslint-plugin-jest/issues/614)) - ([624018a](https://github.com/jest-community/eslint-plugin-jest/commit/624018aa181e7c0ce87457a4f9c212c7891987a8)), - closes [#613](https://github.com/jest-community/eslint-plugin-jest/issues/613) +* **lowercase-name:** ignore all top level describes when option is true ([#614](https://github.com/jest-community/eslint-plugin-jest/issues/614)) ([624018a](https://github.com/jest-community/eslint-plugin-jest/commit/624018aa181e7c0ce87457a4f9c212c7891987a8)), closes [#613](https://github.com/jest-community/eslint-plugin-jest/issues/613) # [23.17.0](https://github.com/jest-community/eslint-plugin-jest/compare/v23.16.0...v23.17.0) (2020-06-23) + ### Features -- **lowercase-name:** support `ignoreTopLevelDescribe` option - ([#611](https://github.com/jest-community/eslint-plugin-jest/issues/611)) - ([36fdcc5](https://github.com/jest-community/eslint-plugin-jest/commit/36fdcc553ca40bc2ca2e9ca7e04f8e9e4a315274)), - closes [#247](https://github.com/jest-community/eslint-plugin-jest/issues/247) +* **lowercase-name:** support `ignoreTopLevelDescribe` option ([#611](https://github.com/jest-community/eslint-plugin-jest/issues/611)) ([36fdcc5](https://github.com/jest-community/eslint-plugin-jest/commit/36fdcc553ca40bc2ca2e9ca7e04f8e9e4a315274)), closes [#247](https://github.com/jest-community/eslint-plugin-jest/issues/247) # [23.16.0](https://github.com/jest-community/eslint-plugin-jest/compare/v23.15.0...v23.16.0) (2020-06-21) + ### Features -- create `no-conditional-expect` rule - ([aba53e4](https://github.com/jest-community/eslint-plugin-jest/commit/aba53e4061f3b636ab0c0270e183c355c6f301e0)) -- deprecate `no-try-expect` in favor of `no-conditional-expect` - ([6d07cad](https://github.com/jest-community/eslint-plugin-jest/commit/6d07cadd5f78ed7a64a86792931d49d3cd943d69)) +* create `no-conditional-expect` rule ([aba53e4](https://github.com/jest-community/eslint-plugin-jest/commit/aba53e4061f3b636ab0c0270e183c355c6f301e0)) +* deprecate `no-try-expect` in favor of `no-conditional-expect` ([6d07cad](https://github.com/jest-community/eslint-plugin-jest/commit/6d07cadd5f78ed7a64a86792931d49d3cd943d69)) # [23.15.0](https://github.com/jest-community/eslint-plugin-jest/compare/v23.14.0...v23.15.0) (2020-06-21) + ### Features -- **no-standalone-expect:** support `additionalTestBlockFunctions` - ([#585](https://github.com/jest-community/eslint-plugin-jest/issues/585)) - ([ed220b2](https://github.com/jest-community/eslint-plugin-jest/commit/ed220b2c515f2e97ce639dd1474c18a7f594c06c)) +* **no-standalone-expect:** support `additionalTestBlockFunctions` ([#585](https://github.com/jest-community/eslint-plugin-jest/issues/585)) ([ed220b2](https://github.com/jest-community/eslint-plugin-jest/commit/ed220b2c515f2e97ce639dd1474c18a7f594c06c)) # [23.14.0](https://github.com/jest-community/eslint-plugin-jest/compare/v23.13.2...v23.14.0) (2020-06-20) + ### Bug Fixes -- **no-test-callback:** check argument is an identifier - ([f70612d](https://github.com/jest-community/eslint-plugin-jest/commit/f70612d8b414575725a5831ed9dfad1eaf1e6548)) -- **no-test-callback:** provide suggestion instead of autofix - ([782d8fa](https://github.com/jest-community/eslint-plugin-jest/commit/782d8fa00149143f453e7cb066f90c017e2d3f61)) -- **prefer-strict-equal:** provide suggestion instead of autofix - ([2eaed2b](https://github.com/jest-community/eslint-plugin-jest/commit/2eaed2bf30c72b03ee205910887f8aab304047a5)) +* **no-test-callback:** check argument is an identifier ([f70612d](https://github.com/jest-community/eslint-plugin-jest/commit/f70612d8b414575725a5831ed9dfad1eaf1e6548)) +* **no-test-callback:** provide suggestion instead of autofix ([782d8fa](https://github.com/jest-community/eslint-plugin-jest/commit/782d8fa00149143f453e7cb066f90c017e2d3f61)) +* **prefer-strict-equal:** provide suggestion instead of autofix ([2eaed2b](https://github.com/jest-community/eslint-plugin-jest/commit/2eaed2bf30c72b03ee205910887f8aab304047a5)) + ### Features -- **prefer-expect-assertions:** provide suggestions - ([bad88a0](https://github.com/jest-community/eslint-plugin-jest/commit/bad88a006135258e8da18902a84bdb52a9bb9fa7)) +* **prefer-expect-assertions:** provide suggestions ([bad88a0](https://github.com/jest-community/eslint-plugin-jest/commit/bad88a006135258e8da18902a84bdb52a9bb9fa7)) ## [23.13.2](https://github.com/jest-community/eslint-plugin-jest/compare/v23.13.1...v23.13.2) (2020-05-26) + ### Bug Fixes -- add `fail` to globals - ([#595](https://github.com/jest-community/eslint-plugin-jest/issues/595)) - ([aadc5ec](https://github.com/jest-community/eslint-plugin-jest/commit/aadc5ec5610ec024eac4b0aa6077cc012a0ba98e)) +* add `fail` to globals ([#595](https://github.com/jest-community/eslint-plugin-jest/issues/595)) ([aadc5ec](https://github.com/jest-community/eslint-plugin-jest/commit/aadc5ec5610ec024eac4b0aa6077cc012a0ba98e)) ## [23.13.1](https://github.com/jest-community/eslint-plugin-jest/compare/v23.13.0...v23.13.1) (2020-05-17) + ### Bug Fixes -- **no-if:** use correct syntax for placeholder substitution in message - ([6d1eda8](https://github.com/jest-community/eslint-plugin-jest/commit/6d1eda89ac48c93c2675dcf24a92574a20b2edb9)) +* **no-if:** use correct syntax for placeholder substitution in message ([6d1eda8](https://github.com/jest-community/eslint-plugin-jest/commit/6d1eda89ac48c93c2675dcf24a92574a20b2edb9)) # [23.13.0](https://github.com/jest-community/eslint-plugin-jest/compare/v23.12.0...v23.13.0) (2020-05-16) + ### Features -- **valid-expect:** support `minArgs` & `maxArgs` options - ([#584](https://github.com/jest-community/eslint-plugin-jest/issues/584)) - ([9e0e2fa](https://github.com/jest-community/eslint-plugin-jest/commit/9e0e2fa966b43c1099d11b2424acb1590c241c03)) +* **valid-expect:** support `minArgs` & `maxArgs` options ([#584](https://github.com/jest-community/eslint-plugin-jest/issues/584)) ([9e0e2fa](https://github.com/jest-community/eslint-plugin-jest/commit/9e0e2fa966b43c1099d11b2424acb1590c241c03)) # [23.12.0](https://github.com/jest-community/eslint-plugin-jest/compare/v23.11.0...v23.12.0) (2020-05-16) + ### Features -- deprecate `no-expect-resolves` rule - ([b6a22e5](https://github.com/jest-community/eslint-plugin-jest/commit/b6a22e5aa98abcb57aac217c6d4583d0a3388e7b)) -- deprecate `no-truthy-falsy` rule - ([a67d92d](https://github.com/jest-community/eslint-plugin-jest/commit/a67d92d2834568122f24bf3d8455999166da95ea)) -- deprecate `prefer-inline-snapshots` rule - ([1360e9b](https://github.com/jest-community/eslint-plugin-jest/commit/1360e9b0e840f4f778a9d251371c943919f84600)) +* deprecate `no-expect-resolves` rule ([b6a22e5](https://github.com/jest-community/eslint-plugin-jest/commit/b6a22e5aa98abcb57aac217c6d4583d0a3388e7b)) +* deprecate `no-truthy-falsy` rule ([a67d92d](https://github.com/jest-community/eslint-plugin-jest/commit/a67d92d2834568122f24bf3d8455999166da95ea)) +* deprecate `prefer-inline-snapshots` rule ([1360e9b](https://github.com/jest-community/eslint-plugin-jest/commit/1360e9b0e840f4f778a9d251371c943919f84600)) # [23.11.0](https://github.com/jest-community/eslint-plugin-jest/compare/v23.10.0...v23.11.0) (2020-05-12) + ### Features -- create `no-restricted-matchers` rule - ([#575](https://github.com/jest-community/eslint-plugin-jest/issues/575)) - ([ac926e7](https://github.com/jest-community/eslint-plugin-jest/commit/ac926e779958240506ee506047c9a5364bb70aea)) +* create `no-restricted-matchers` rule ([#575](https://github.com/jest-community/eslint-plugin-jest/issues/575)) ([ac926e7](https://github.com/jest-community/eslint-plugin-jest/commit/ac926e779958240506ee506047c9a5364bb70aea)) # [23.10.0](https://github.com/jest-community/eslint-plugin-jest/compare/v23.9.0...v23.10.0) (2020-05-09) + ### Features -- **no-deprecated-functions:** support jest `version` setting - ([#564](https://github.com/jest-community/eslint-plugin-jest/issues/564)) - ([05f20b8](https://github.com/jest-community/eslint-plugin-jest/commit/05f20b80ecd42b8d1f1f18ca19d4bc9cba45e22e)) +* **no-deprecated-functions:** support jest `version` setting ([#564](https://github.com/jest-community/eslint-plugin-jest/issues/564)) ([05f20b8](https://github.com/jest-community/eslint-plugin-jest/commit/05f20b80ecd42b8d1f1f18ca19d4bc9cba45e22e)) # [23.9.0](https://github.com/jest-community/eslint-plugin-jest/compare/v23.8.2...v23.9.0) (2020-05-04) + ### Features -- create `no-deprecated-functions` - ([#560](https://github.com/jest-community/eslint-plugin-jest/issues/560)) - ([55d0504](https://github.com/jest-community/eslint-plugin-jest/commit/55d0504cadc945b770d7c3b6d3cab425c9b76d0f)) +* create `no-deprecated-functions` ([#560](https://github.com/jest-community/eslint-plugin-jest/issues/560)) ([55d0504](https://github.com/jest-community/eslint-plugin-jest/commit/55d0504cadc945b770d7c3b6d3cab425c9b76d0f)) ## [23.8.2](https://github.com/jest-community/eslint-plugin-jest/compare/v23.8.1...v23.8.2) (2020-03-06) From 3fcf261748d14339cdebddaeea2bcc53ae3e7fed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20C=2E=20Viesca=20Ruiz?= Date: Wed, 1 Jul 2020 11:53:14 +0200 Subject: [PATCH 14/18] docs: update rule table with new name --- README.md | 84 +++++++++++++++++++++++++++---------------------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index c660ed2c9..18e58f4ee 100644 --- a/README.md +++ b/README.md @@ -127,48 +127,48 @@ installations requiring long-term consistency. -| Rule | Description | Configurations | Fixable | -| ---------------------------------------------------------------------------------- | --------------------------------------------------------------- | ---------------- | ------------ | -| [consistent-test-it](docs/rules/consistent-test-it.md) | Have control over `test` and `it` usages | | ![fixable][] | -| [expect-expect](docs/rules/expect-expect.md) | Enforce assertion to be made in a test body | ![recommended][] | | -| [lowercase-name](docs/rules/lowercase-name.md) | Enforce lowercase test names | | ![fixable][] | -| [no-alias-methods](docs/rules/no-alias-methods.md) | Disallow alias methods | ![style][] | ![fixable][] | -| [no-commented-out-tests](docs/rules/no-commented-out-tests.md) | Disallow commented out tests | ![recommended][] | | -| [no-conditional-expect](docs/rules/no-conditional-expect.md) | Prevent calling `expect` conditionally | | | -| [no-deprecated-functions](docs/rules/no-deprecated-functions.md) | Disallow use of deprecated functions | | ![fixable][] | -| [no-disabled-tests](docs/rules/no-disabled-tests.md) | Disallow disabled tests | ![recommended][] | | -| [no-duplicate-hooks](docs/rules/no-duplicate-hooks.md) | Disallow duplicate setup and teardown hooks | | | -| [no-export](docs/rules/no-export.md) | Prevent exporting from test files | ![recommended][] | | -| [no-focused-tests](docs/rules/no-focused-tests.md) | Disallow focused tests | ![recommended][] | ![fixable][] | -| [no-hooks](docs/rules/no-hooks.md) | Disallow setup and teardown hooks | | | -| [no-identical-title](docs/rules/no-identical-title.md) | Disallow identical titles | ![recommended][] | | -| [no-if](docs/rules/no-if.md) | Disallow conditional logic | | | -| [no-interpolation-inline-snapshot](docs/rules/no-interpolation-inline-snapshot.md) | Disallow string interpolation inside inline snapshots. | | | -| [no-jasmine-globals](docs/rules/no-jasmine-globals.md) | Disallow Jasmine globals | ![recommended][] | ![fixable][] | -| [no-jest-import](docs/rules/no-jest-import.md) | Disallow importing Jest | ![recommended][] | | -| [no-large-snapshots](docs/rules/no-large-snapshots.md) | disallow large snapshots | | | -| [no-mocks-import](docs/rules/no-mocks-import.md) | Disallow manually importing from **mocks** | ![recommended][] | | -| [no-restricted-matchers](docs/rules/no-restricted-matchers.md) | Disallow specific matchers & modifiers | | | -| [no-standalone-expect](docs/rules/no-standalone-expect.md) | Prevents expects that are outside of an it or test block. | ![recommended][] | | -| [no-test-callback](docs/rules/no-test-callback.md) | Avoid using a callback in asynchronous tests | ![recommended][] | ![suggest][] | -| [no-test-prefixes](docs/rules/no-test-prefixes.md) | Use `.only` and `.skip` over `f` and `x` | ![recommended][] | ![fixable][] | -| [no-test-return-statement](docs/rules/no-test-return-statement.md) | Disallow explicitly returning from tests | | | -| [prefer-called-with](docs/rules/prefer-called-with.md) | Suggest using `toBeCalledWith()` OR `toHaveBeenCalledWith()` | | | -| [prefer-expect-assertions](docs/rules/prefer-expect-assertions.md) | Suggest using `expect.assertions()` OR `expect.hasAssertions()` | | ![suggest][] | -| [prefer-hooks-on-top](docs/rules/prefer-hooks-on-top.md) | Suggest to have all hooks at top level | | | -| [prefer-spy-on](docs/rules/prefer-spy-on.md) | Suggest using `jest.spyOn()` | | ![fixable][] | -| [prefer-strict-equal](docs/rules/prefer-strict-equal.md) | Suggest using toStrictEqual() | | ![suggest][] | -| [prefer-to-be-null](docs/rules/prefer-to-be-null.md) | Suggest using `toBeNull()` | ![style][] | ![fixable][] | -| [prefer-to-be-undefined](docs/rules/prefer-to-be-undefined.md) | Suggest using `toBeUndefined()` | ![style][] | ![fixable][] | -| [prefer-to-contain](docs/rules/prefer-to-contain.md) | Suggest using `toContain()` | ![style][] | ![fixable][] | -| [prefer-to-have-length](docs/rules/prefer-to-have-length.md) | Suggest using `toHaveLength()` | ![style][] | ![fixable][] | -| [prefer-todo](docs/rules/prefer-todo.md) | Suggest using `test.todo` | | ![fixable][] | -| [require-to-throw-message](docs/rules/require-to-throw-message.md) | Require a message for `toThrow()` | | | -| [require-top-level-describe](docs/rules/require-top-level-describe.md) | Prevents test cases and hooks to be outside of a describe block | | | -| [valid-describe](docs/rules/valid-describe.md) | Enforce valid `describe()` callback | ![recommended][] | | -| [valid-expect](docs/rules/valid-expect.md) | Enforce valid `expect()` usage | ![recommended][] | | -| [valid-expect-in-promise](docs/rules/valid-expect-in-promise.md) | Enforce having return statement when testing with promises | ![recommended][] | | -| [valid-title](docs/rules/valid-title.md) | Enforce valid titles | | ![fixable][] | +| Rule | Description | Configurations | Fixable | +| ---------------------------------------------------------------------------- | --------------------------------------------------------------- | ---------------- | ------------ | +| [consistent-test-it](docs/rules/consistent-test-it.md) | Have control over `test` and `it` usages | | ![fixable][] | +| [expect-expect](docs/rules/expect-expect.md) | Enforce assertion to be made in a test body | ![recommended][] | | +| [lowercase-name](docs/rules/lowercase-name.md) | Enforce lowercase test names | | ![fixable][] | +| [no-alias-methods](docs/rules/no-alias-methods.md) | Disallow alias methods | ![style][] | ![fixable][] | +| [no-commented-out-tests](docs/rules/no-commented-out-tests.md) | Disallow commented out tests | ![recommended][] | | +| [no-conditional-expect](docs/rules/no-conditional-expect.md) | Prevent calling `expect` conditionally | | | +| [no-deprecated-functions](docs/rules/no-deprecated-functions.md) | Disallow use of deprecated functions | | ![fixable][] | +| [no-disabled-tests](docs/rules/no-disabled-tests.md) | Disallow disabled tests | ![recommended][] | | +| [no-duplicate-hooks](docs/rules/no-duplicate-hooks.md) | Disallow duplicate setup and teardown hooks | | | +| [no-export](docs/rules/no-export.md) | Prevent exporting from test files | ![recommended][] | | +| [no-focused-tests](docs/rules/no-focused-tests.md) | Disallow focused tests | ![recommended][] | ![fixable][] | +| [no-hooks](docs/rules/no-hooks.md) | Disallow setup and teardown hooks | | | +| [no-identical-title](docs/rules/no-identical-title.md) | Disallow identical titles | ![recommended][] | | +| [no-if](docs/rules/no-if.md) | Disallow conditional logic | | | +| [no-interpolation-in-snapshots](docs/rules/no-interpolation-in-snapshots.md) | Disallow string interpolation inside inline snapshots. | | | +| [no-jasmine-globals](docs/rules/no-jasmine-globals.md) | Disallow Jasmine globals | ![recommended][] | ![fixable][] | +| [no-jest-import](docs/rules/no-jest-import.md) | Disallow importing Jest | ![recommended][] | | +| [no-large-snapshots](docs/rules/no-large-snapshots.md) | disallow large snapshots | | | +| [no-mocks-import](docs/rules/no-mocks-import.md) | Disallow manually importing from **mocks** | ![recommended][] | | +| [no-restricted-matchers](docs/rules/no-restricted-matchers.md) | Disallow specific matchers & modifiers | | | +| [no-standalone-expect](docs/rules/no-standalone-expect.md) | Prevents expects that are outside of an it or test block. | ![recommended][] | | +| [no-test-callback](docs/rules/no-test-callback.md) | Avoid using a callback in asynchronous tests | ![recommended][] | ![suggest][] | +| [no-test-prefixes](docs/rules/no-test-prefixes.md) | Use `.only` and `.skip` over `f` and `x` | ![recommended][] | ![fixable][] | +| [no-test-return-statement](docs/rules/no-test-return-statement.md) | Disallow explicitly returning from tests | | | +| [prefer-called-with](docs/rules/prefer-called-with.md) | Suggest using `toBeCalledWith()` OR `toHaveBeenCalledWith()` | | | +| [prefer-expect-assertions](docs/rules/prefer-expect-assertions.md) | Suggest using `expect.assertions()` OR `expect.hasAssertions()` | | ![suggest][] | +| [prefer-hooks-on-top](docs/rules/prefer-hooks-on-top.md) | Suggest to have all hooks at top level | | | +| [prefer-spy-on](docs/rules/prefer-spy-on.md) | Suggest using `jest.spyOn()` | | ![fixable][] | +| [prefer-strict-equal](docs/rules/prefer-strict-equal.md) | Suggest using toStrictEqual() | | ![suggest][] | +| [prefer-to-be-null](docs/rules/prefer-to-be-null.md) | Suggest using `toBeNull()` | ![style][] | ![fixable][] | +| [prefer-to-be-undefined](docs/rules/prefer-to-be-undefined.md) | Suggest using `toBeUndefined()` | ![style][] | ![fixable][] | +| [prefer-to-contain](docs/rules/prefer-to-contain.md) | Suggest using `toContain()` | ![style][] | ![fixable][] | +| [prefer-to-have-length](docs/rules/prefer-to-have-length.md) | Suggest using `toHaveLength()` | ![style][] | ![fixable][] | +| [prefer-todo](docs/rules/prefer-todo.md) | Suggest using `test.todo` | | ![fixable][] | +| [require-to-throw-message](docs/rules/require-to-throw-message.md) | Require a message for `toThrow()` | | | +| [require-top-level-describe](docs/rules/require-top-level-describe.md) | Prevents test cases and hooks to be outside of a describe block | | | +| [valid-describe](docs/rules/valid-describe.md) | Enforce valid `describe()` callback | ![recommended][] | | +| [valid-expect](docs/rules/valid-expect.md) | Enforce valid `expect()` usage | ![recommended][] | | +| [valid-expect-in-promise](docs/rules/valid-expect-in-promise.md) | Enforce having return statement when testing with promises | ![recommended][] | | +| [valid-title](docs/rules/valid-title.md) | Enforce valid titles | | ![fixable][] | From 3738c2db8238cb680c2d185285196bc24537fd3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20C=2E=20Viesca=20Ruiz?= Date: Mon, 6 Jul 2020 10:58:30 +0200 Subject: [PATCH 15/18] fix: apply suggestions from code review Co-authored-by: Gareth Jones Co-authored-by: Simen Bekkhus --- docs/rules/no-interpolation-in-snapshots.md | 2 +- src/rules/no-interpolation-in-snapshots.ts | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/rules/no-interpolation-in-snapshots.md b/docs/rules/no-interpolation-in-snapshots.md index e6f587b3a..0ac13540e 100644 --- a/docs/rules/no-interpolation-in-snapshots.md +++ b/docs/rules/no-interpolation-in-snapshots.md @@ -1,4 +1,4 @@ -# Disallow string interpolation inside inline snapshots (`no-interpolation-in-snapshots`) +# Disallow string interpolation inside snapshots (`no-interpolation-in-snapshots`) Prevents the use of string interpolations in snapshots. diff --git a/src/rules/no-interpolation-in-snapshots.ts b/src/rules/no-interpolation-in-snapshots.ts index b756223d1..4daafcaed 100644 --- a/src/rules/no-interpolation-in-snapshots.ts +++ b/src/rules/no-interpolation-in-snapshots.ts @@ -6,7 +6,7 @@ export default createRule({ meta: { docs: { category: 'Best Practices', - description: 'Disallow string interpolation inside inline snapshots.', + description: 'Disallow string interpolation inside inline snapshots', recommended: false, }, messages: { @@ -14,7 +14,7 @@ export default createRule({ 'Do not use string interpolation inside of inline snapshots', }, schema: [], - type: 'suggestion', + type: 'problem', }, defaultOptions: [], create(context) { @@ -26,8 +26,11 @@ export default createRule({ const { matcher } = parseExpectCall(node); + if (!matcher) { + return; + } + if ( - matcher && [ 'toMatchInlineSnapshot', 'toThrowErrorMatchingInlineSnapshot', From f98accfeeace272510b16309bbb6d404110a874b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20C=2E=20Viesca=20Ruiz?= Date: Mon, 6 Jul 2020 11:09:01 +0200 Subject: [PATCH 16/18] test: add test to cover missing branch --- src/rules/__tests__/no-interpolation-in-snapshots.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rules/__tests__/no-interpolation-in-snapshots.test.ts b/src/rules/__tests__/no-interpolation-in-snapshots.test.ts index 2a729b676..b7bbb61fb 100644 --- a/src/rules/__tests__/no-interpolation-in-snapshots.test.ts +++ b/src/rules/__tests__/no-interpolation-in-snapshots.test.ts @@ -11,6 +11,7 @@ const ruleTester = new TSESLint.RuleTester({ ruleTester.run('no-interpolation-in-snapshots', rule, { valid: [ + 'expect("something").toEqual("else");', 'expect(something).toMatchInlineSnapshot();', 'expect(something).toMatchInlineSnapshot(`No interpolation`);', 'expect(something).toMatchInlineSnapshot({}, `No interpolation`);', From 032c8bc24d820d6fc2762188ca4af787a8a067d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20C=2E=20Viesca=20Ruiz?= Date: Mon, 27 Jul 2020 10:22:18 +0200 Subject: [PATCH 17/18] docs: regenerate table with the new script --- README.md | 83 +++++++++++---------- docs/rules/no-interpolation-in-snapshots.md | 2 +- 2 files changed, 43 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index 5223b0cd6..6f65ec668 100644 --- a/README.md +++ b/README.md @@ -128,47 +128,48 @@ installations requiring long-term consistency. -| Rule | Description | Configurations | Fixable | -| ---------------------------------------------------------------------- | --------------------------------------------------------------- | ---------------- | ------------ | -| [consistent-test-it](docs/rules/consistent-test-it.md) | Have control over `test` and `it` usages | | ![fixable][] | -| [expect-expect](docs/rules/expect-expect.md) | Enforce assertion to be made in a test body | ![recommended][] | | -| [lowercase-name](docs/rules/lowercase-name.md) | Enforce lowercase test names | | ![fixable][] | -| [no-alias-methods](docs/rules/no-alias-methods.md) | Disallow alias methods | ![style][] | ![fixable][] | -| [no-commented-out-tests](docs/rules/no-commented-out-tests.md) | Disallow commented out tests | ![recommended][] | | -| [no-conditional-expect](docs/rules/no-conditional-expect.md) | Prevent calling `expect` conditionally | | | -| [no-deprecated-functions](docs/rules/no-deprecated-functions.md) | Disallow use of deprecated functions | | ![fixable][] | -| [no-disabled-tests](docs/rules/no-disabled-tests.md) | Disallow disabled tests | ![recommended][] | | -| [no-duplicate-hooks](docs/rules/no-duplicate-hooks.md) | Disallow duplicate setup and teardown hooks | | | -| [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-hooks](docs/rules/no-hooks.md) | Disallow setup and teardown hooks | | | -| [no-identical-title](docs/rules/no-identical-title.md) | Disallow identical titles | ![recommended][] | | -| [no-if](docs/rules/no-if.md) | Disallow conditional logic | | | -| [no-jasmine-globals](docs/rules/no-jasmine-globals.md) | Disallow Jasmine globals | ![recommended][] | ![fixable][] | -| [no-jest-import](docs/rules/no-jest-import.md) | Disallow importing Jest | ![recommended][] | | -| [no-large-snapshots](docs/rules/no-large-snapshots.md) | disallow large snapshots | | | -| [no-mocks-import](docs/rules/no-mocks-import.md) | Disallow manually importing from `__mocks__` | ![recommended][] | | -| [no-restricted-matchers](docs/rules/no-restricted-matchers.md) | Disallow specific matchers & modifiers | | | -| [no-standalone-expect](docs/rules/no-standalone-expect.md) | Disallow using `expect` outside of `it` or `test` blocks | ![recommended][] | | -| [no-test-callback](docs/rules/no-test-callback.md) | Avoid using a callback in asynchronous tests | ![recommended][] | ![suggest][] | -| [no-test-prefixes](docs/rules/no-test-prefixes.md) | Use `.only` and `.skip` over `f` and `x` | ![recommended][] | ![fixable][] | -| [no-test-return-statement](docs/rules/no-test-return-statement.md) | Disallow explicitly returning from tests | | | -| [prefer-called-with](docs/rules/prefer-called-with.md) | Suggest using `toBeCalledWith()` or `toHaveBeenCalledWith()` | | | -| [prefer-expect-assertions](docs/rules/prefer-expect-assertions.md) | Suggest using `expect.assertions()` OR `expect.hasAssertions()` | | ![suggest][] | -| [prefer-hooks-on-top](docs/rules/prefer-hooks-on-top.md) | Suggest having hooks before any test cases | | | -| [prefer-spy-on](docs/rules/prefer-spy-on.md) | Suggest using `jest.spyOn()` | | ![fixable][] | -| [prefer-strict-equal](docs/rules/prefer-strict-equal.md) | Suggest using `toStrictEqual()` | | ![suggest][] | -| [prefer-to-be-null](docs/rules/prefer-to-be-null.md) | Suggest using `toBeNull()` | ![style][] | ![fixable][] | -| [prefer-to-be-undefined](docs/rules/prefer-to-be-undefined.md) | Suggest using `toBeUndefined()` | ![style][] | ![fixable][] | -| [prefer-to-contain](docs/rules/prefer-to-contain.md) | Suggest using `toContain()` | ![style][] | ![fixable][] | -| [prefer-to-have-length](docs/rules/prefer-to-have-length.md) | Suggest using `toHaveLength()` | ![style][] | ![fixable][] | -| [prefer-todo](docs/rules/prefer-todo.md) | Suggest using `test.todo` | | ![fixable][] | -| [require-to-throw-message](docs/rules/require-to-throw-message.md) | Require a message for `toThrow()` | | | -| [require-top-level-describe](docs/rules/require-top-level-describe.md) | Require test cases and hooks to be inside a `describe` block | | | -| [valid-describe](docs/rules/valid-describe.md) | Enforce valid `describe()` callback | ![recommended][] | | -| [valid-expect](docs/rules/valid-expect.md) | Enforce valid `expect()` usage | ![recommended][] | | -| [valid-expect-in-promise](docs/rules/valid-expect-in-promise.md) | Enforce having return statement when testing with promises | ![recommended][] | | -| [valid-title](docs/rules/valid-title.md) | Enforce valid titles | | ![fixable][] | +| Rule | Description | Configurations | Fixable | +| ---------------------------------------------------------------------------- | --------------------------------------------------------------- | ---------------- | ------------ | +| [consistent-test-it](docs/rules/consistent-test-it.md) | Have control over `test` and `it` usages | | ![fixable][] | +| [expect-expect](docs/rules/expect-expect.md) | Enforce assertion to be made in a test body | ![recommended][] | | +| [lowercase-name](docs/rules/lowercase-name.md) | Enforce lowercase test names | | ![fixable][] | +| [no-alias-methods](docs/rules/no-alias-methods.md) | Disallow alias methods | ![style][] | ![fixable][] | +| [no-commented-out-tests](docs/rules/no-commented-out-tests.md) | Disallow commented out tests | ![recommended][] | | +| [no-conditional-expect](docs/rules/no-conditional-expect.md) | Prevent calling `expect` conditionally | | | +| [no-deprecated-functions](docs/rules/no-deprecated-functions.md) | Disallow use of deprecated functions | | ![fixable][] | +| [no-disabled-tests](docs/rules/no-disabled-tests.md) | Disallow disabled tests | ![recommended][] | | +| [no-duplicate-hooks](docs/rules/no-duplicate-hooks.md) | Disallow duplicate setup and teardown hooks | | | +| [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-hooks](docs/rules/no-hooks.md) | Disallow setup and teardown hooks | | | +| [no-identical-title](docs/rules/no-identical-title.md) | Disallow identical titles | ![recommended][] | | +| [no-if](docs/rules/no-if.md) | Disallow conditional logic | | | +| [no-interpolation-in-snapshots](docs/rules/no-interpolation-in-snapshots.md) | Disallow string interpolation inside inline snapshots | | | +| [no-jasmine-globals](docs/rules/no-jasmine-globals.md) | Disallow Jasmine globals | ![recommended][] | ![fixable][] | +| [no-jest-import](docs/rules/no-jest-import.md) | Disallow importing Jest | ![recommended][] | | +| [no-large-snapshots](docs/rules/no-large-snapshots.md) | disallow large snapshots | | | +| [no-mocks-import](docs/rules/no-mocks-import.md) | Disallow manually importing from `__mocks__` | ![recommended][] | | +| [no-restricted-matchers](docs/rules/no-restricted-matchers.md) | Disallow specific matchers & modifiers | | | +| [no-standalone-expect](docs/rules/no-standalone-expect.md) | Disallow using `expect` outside of `it` or `test` blocks | ![recommended][] | | +| [no-test-callback](docs/rules/no-test-callback.md) | Avoid using a callback in asynchronous tests | ![recommended][] | ![suggest][] | +| [no-test-prefixes](docs/rules/no-test-prefixes.md) | Use `.only` and `.skip` over `f` and `x` | ![recommended][] | ![fixable][] | +| [no-test-return-statement](docs/rules/no-test-return-statement.md) | Disallow explicitly returning from tests | | | +| [prefer-called-with](docs/rules/prefer-called-with.md) | Suggest using `toBeCalledWith()` or `toHaveBeenCalledWith()` | | | +| [prefer-expect-assertions](docs/rules/prefer-expect-assertions.md) | Suggest using `expect.assertions()` OR `expect.hasAssertions()` | | ![suggest][] | +| [prefer-hooks-on-top](docs/rules/prefer-hooks-on-top.md) | Suggest having hooks before any test cases | | | +| [prefer-spy-on](docs/rules/prefer-spy-on.md) | Suggest using `jest.spyOn()` | | ![fixable][] | +| [prefer-strict-equal](docs/rules/prefer-strict-equal.md) | Suggest using `toStrictEqual()` | | ![suggest][] | +| [prefer-to-be-null](docs/rules/prefer-to-be-null.md) | Suggest using `toBeNull()` | ![style][] | ![fixable][] | +| [prefer-to-be-undefined](docs/rules/prefer-to-be-undefined.md) | Suggest using `toBeUndefined()` | ![style][] | ![fixable][] | +| [prefer-to-contain](docs/rules/prefer-to-contain.md) | Suggest using `toContain()` | ![style][] | ![fixable][] | +| [prefer-to-have-length](docs/rules/prefer-to-have-length.md) | Suggest using `toHaveLength()` | ![style][] | ![fixable][] | +| [prefer-todo](docs/rules/prefer-todo.md) | Suggest using `test.todo` | | ![fixable][] | +| [require-to-throw-message](docs/rules/require-to-throw-message.md) | Require a message for `toThrow()` | | | +| [require-top-level-describe](docs/rules/require-top-level-describe.md) | Require test cases and hooks to be inside a `describe` block | | | +| [valid-describe](docs/rules/valid-describe.md) | Enforce valid `describe()` callback | ![recommended][] | | +| [valid-expect](docs/rules/valid-expect.md) | Enforce valid `expect()` usage | ![recommended][] | | +| [valid-expect-in-promise](docs/rules/valid-expect-in-promise.md) | Enforce having return statement when testing with promises | ![recommended][] | | +| [valid-title](docs/rules/valid-title.md) | Enforce valid titles | | ![fixable][] | diff --git a/docs/rules/no-interpolation-in-snapshots.md b/docs/rules/no-interpolation-in-snapshots.md index 0ac13540e..e6f587b3a 100644 --- a/docs/rules/no-interpolation-in-snapshots.md +++ b/docs/rules/no-interpolation-in-snapshots.md @@ -1,4 +1,4 @@ -# Disallow string interpolation inside snapshots (`no-interpolation-in-snapshots`) +# Disallow string interpolation inside inline snapshots (`no-interpolation-in-snapshots`) Prevents the use of string interpolations in snapshots. From 6029742d104c4f372436a376263f9f534522ec55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20C=2E=20Viesca=20Ruiz?= Date: Mon, 27 Jul 2020 10:34:52 +0200 Subject: [PATCH 18/18] fix: edit rule description --- README.md | 2 +- docs/rules/no-interpolation-in-snapshots.md | 2 +- src/rules/no-interpolation-in-snapshots.ts | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6f65ec668..231fa653a 100644 --- a/README.md +++ b/README.md @@ -144,7 +144,7 @@ installations requiring long-term consistency. | [no-hooks](docs/rules/no-hooks.md) | Disallow setup and teardown hooks | | | | [no-identical-title](docs/rules/no-identical-title.md) | Disallow identical titles | ![recommended][] | | | [no-if](docs/rules/no-if.md) | Disallow conditional logic | | | -| [no-interpolation-in-snapshots](docs/rules/no-interpolation-in-snapshots.md) | Disallow string interpolation inside inline snapshots | | | +| [no-interpolation-in-snapshots](docs/rules/no-interpolation-in-snapshots.md) | Disallow string interpolation inside snapshots | | | | [no-jasmine-globals](docs/rules/no-jasmine-globals.md) | Disallow Jasmine globals | ![recommended][] | ![fixable][] | | [no-jest-import](docs/rules/no-jest-import.md) | Disallow importing Jest | ![recommended][] | | | [no-large-snapshots](docs/rules/no-large-snapshots.md) | disallow large snapshots | | | diff --git a/docs/rules/no-interpolation-in-snapshots.md b/docs/rules/no-interpolation-in-snapshots.md index e6f587b3a..0ac13540e 100644 --- a/docs/rules/no-interpolation-in-snapshots.md +++ b/docs/rules/no-interpolation-in-snapshots.md @@ -1,4 +1,4 @@ -# Disallow string interpolation inside inline snapshots (`no-interpolation-in-snapshots`) +# Disallow string interpolation inside snapshots (`no-interpolation-in-snapshots`) Prevents the use of string interpolations in snapshots. diff --git a/src/rules/no-interpolation-in-snapshots.ts b/src/rules/no-interpolation-in-snapshots.ts index 4daafcaed..11d68e38d 100644 --- a/src/rules/no-interpolation-in-snapshots.ts +++ b/src/rules/no-interpolation-in-snapshots.ts @@ -6,12 +6,11 @@ export default createRule({ meta: { docs: { category: 'Best Practices', - description: 'Disallow string interpolation inside inline snapshots', + description: 'Disallow string interpolation inside snapshots', recommended: false, }, messages: { - noInterpolation: - 'Do not use string interpolation inside of inline snapshots', + noInterpolation: 'Do not use string interpolation inside of snapshots', }, schema: [], type: 'problem',