Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single line inline snapshots conflict with babel/quotes in eslint #10164

Closed
cpojer opened this issue Jun 12, 2020 · 4 comments
Closed

Single line inline snapshots conflict with babel/quotes in eslint #10164

cpojer opened this issue Jun 12, 2020 · 4 comments

Comments

@cpojer
Copy link
Member

cpojer commented Jun 12, 2020

When I have an assertion like:

 expect(warningMessages[0]).toMatchInlineSnapshot(
        `"Could not connect to the HTTP cache. Original error: HTTP error: 502"`,
);

eslint will report this issue in some setups:

Strings must use singlequote. (babel/quotes)
Lint code: ESLINT
Lint name: babel/quotes

This is not ideal. Could we change the snapshot inliner to use single-quotes if the result is only a single line?

@SimenB
Copy link
Member

SimenB commented Jun 12, 2020

We use

    "quotes": [
      "error",
      "single",
      { "avoidEscape": true, "allowTemplateLiterals": false }
    ]

At work to work around it. Changing quotation impacts escaping and such, but maybe not an issue?

facebook-github-bot pushed a commit to facebook/metro that referenced this issue May 4, 2021
Summary:
Our ESLint configuration currently disallows template literals that can be expressed using plain string syntax (with single quotes). Jest's inline snapshots feature sometimes produces such template literals. This not only adds unnecessary friction from the linter, but can break subsequent snapshot updates in a test file (after accepting the ESLint autofix).

This conflict between Jest and ESLint is a known issue (jestjs/jest#10164) with no upstream fix. Here we relax the linter's settings to allow all template literals in test files. Ideally we could allow them *only* in inline snapshots, but this is a reasonable approximation.

Changelog: [Internal]

Reviewed By: MichaReiser

Differential Revision: D28120785

fbshipit-source-id: c6c6c0ab8a3b8aca14df06f430b777cef42cd554
facebook-github-bot pushed a commit to facebook/react-native that referenced this issue May 4, 2021
Summary:
Our ESLint configuration currently disallows template literals that can be expressed using plain string syntax (with single quotes). Jest's inline snapshots feature sometimes produces such template literals. This not only adds unnecessary friction from the linter, but can break subsequent snapshot updates in a test file (after accepting the ESLint autofix).

This conflict between Jest and ESLint is a known issue (jestjs/jest#10164) with no upstream fix. Here we relax the linter's settings to allow all template literals in test files. Ideally we could allow them *only* in inline snapshots, but this is a reasonable approximation.

Changelog: [Internal]

Reviewed By: MichaReiser

Differential Revision: D28120785

fbshipit-source-id: c6c6c0ab8a3b8aca14df06f430b777cef42cd554
@github-actions
Copy link

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Feb 17, 2023
@github-actions
Copy link

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 19, 2023
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants