-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add warnings about using illegal escape sequances (#1478)
* Add warnings about using illegal escape sequances * Fix things * Add changesets * sequance -> sequence
- Loading branch information
Showing
20 changed files
with
7,375 additions
and
8,358 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"releases": [ | ||
{ "name": "@emotion/core", "type": "patch" }, | ||
{ "name": "emotion", "type": "patch" }, | ||
{ "name": "@emotion/serialize", "type": "patch" }, | ||
{ "name": "@emotion/styled-base", "type": "patch" }, | ||
{ "name": "@emotion/styled", "type": "patch" } | ||
], | ||
"dependents": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add warnings about using illegal escape sequences |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"releases": [ | ||
{ "name": "@emotion/babel-preset-css-prop", "type": "patch" }, | ||
{ "name": "@emotion/core", "type": "patch" }, | ||
{ "name": "emotion-theming", "type": "patch" }, | ||
{ "name": "jest-emotion", "type": "patch" }, | ||
{ "name": "@emotion/styled-base", "type": "patch" } | ||
], | ||
"dependents": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Update Babel dependencies |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// @flow | ||
import 'test-utils/legacy-env' | ||
import { css } from 'emotion' | ||
|
||
// $FlowFixMe | ||
console.error = jest.fn() | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks() | ||
}) | ||
|
||
it('warns about illegal escape sequences inside first quasi of template literal', () => { | ||
css` | ||
:before { | ||
content: '\00d7'; | ||
} | ||
` | ||
|
||
expect(console.error.mock.calls[0]).toMatchInlineSnapshot(` | ||
Array [ | ||
"You have illegal escape sequence in your template literal, most likely inside content's property value. | ||
Because you write your CSS inside a JavaScript string you actually have to do double escaping, so for example \\"content: '\\\\00d7';\\" should become \\"content: '\\\\\\\\00d7';\\". | ||
You can read more about this here: | ||
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#ES2018_revision_of_illegal_escape_sequences", | ||
] | ||
`) | ||
}) | ||
|
||
it('warns about illegal escape sequences inside non-first quasi of template literal', () => { | ||
const color = `color: hotpink` | ||
css` | ||
background-color: black; | ||
${color}; | ||
:before { | ||
content: '\00d7'; | ||
} | ||
` | ||
|
||
expect(console.error.mock.calls[0]).toMatchInlineSnapshot(` | ||
Array [ | ||
"You have illegal escape sequence in your template literal, most likely inside content's property value. | ||
Because you write your CSS inside a JavaScript string you actually have to do double escaping, so for example \\"content: '\\\\00d7';\\" should become \\"content: '\\\\\\\\00d7';\\". | ||
You can read more about this here: | ||
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#ES2018_revision_of_illegal_escape_sequences", | ||
] | ||
`) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// @flow | ||
import 'test-utils/legacy-env' | ||
import { css } from '@emotion/core' | ||
import styled from '@emotion/styled' | ||
|
||
// $FlowFixMe | ||
console.error = jest.fn() | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks() | ||
}) | ||
|
||
it('warns about illegal escape sequences inside first quasi of template literal', () => { | ||
styled.div` | ||
:before { | ||
content: '\00d7'; | ||
} | ||
` | ||
|
||
expect(console.error.mock.calls[0]).toMatchInlineSnapshot(` | ||
Array [ | ||
"You have illegal escape sequence in your template literal, most likely inside content's property value. | ||
Because you write your CSS inside a JavaScript string you actually have to do double escaping, so for example \\"content: '\\\\00d7';\\" should become \\"content: '\\\\\\\\00d7';\\". | ||
You can read more about this here: | ||
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#ES2018_revision_of_illegal_escape_sequences", | ||
] | ||
`) | ||
}) | ||
|
||
it('warns about illegal escape sequences inside non-first quasi of template literal', () => { | ||
const color = css` | ||
color: hotpink; | ||
` | ||
styled.div` | ||
background-color: black; | ||
${color}; | ||
:before { | ||
content: '\00d7'; | ||
} | ||
` | ||
|
||
expect(console.error.mock.calls[0]).toMatchInlineSnapshot(` | ||
Array [ | ||
"You have illegal escape sequence in your template literal, most likely inside content's property value. | ||
Because you write your CSS inside a JavaScript string you actually have to do double escaping, so for example \\"content: '\\\\00d7';\\" should become \\"content: '\\\\\\\\00d7';\\". | ||
You can read more about this here: | ||
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#ES2018_revision_of_illegal_escape_sequences", | ||
] | ||
`) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.