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

docs: Fix and standardize JSX code examples #17591

Merged
merged 1 commit into from Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions docs/src/rules/jsx-quotes.md
Expand Up @@ -37,9 +37,9 @@ This rule has a string option:

Examples of **incorrect** code for this rule with the default `"prefer-double"` option:

:::incorrect
:::incorrect { "ecmaFeatures": { "jsx": true } }

```xml
```jsx
/*eslint jsx-quotes: ["error", "prefer-double"]*/

<a b='c' />
Expand All @@ -49,9 +49,9 @@ Examples of **incorrect** code for this rule with the default `"prefer-double"`

Examples of **correct** code for this rule with the default `"prefer-double"` option:

:::correct
:::correct { "ecmaFeatures": { "jsx": true } }

```xml
```jsx
/*eslint jsx-quotes: ["error", "prefer-double"]*/

<a b="c" />
Expand All @@ -64,9 +64,9 @@ Examples of **correct** code for this rule with the default `"prefer-double"` op

Examples of **incorrect** code for this rule with the `"prefer-single"` option:

:::incorrect
:::incorrect { "ecmaFeatures": { "jsx": true } }

```xml
```jsx
/*eslint jsx-quotes: ["error", "prefer-single"]*/

<a b="c" />
Expand All @@ -76,9 +76,9 @@ Examples of **incorrect** code for this rule with the `"prefer-single"` option:

Examples of **correct** code for this rule with the `"prefer-single"` option:

:::correct
:::correct { "ecmaFeatures": { "jsx": true } }

```xml
```jsx
/*eslint jsx-quotes: ["error", "prefer-single"]*/

<a b='c' />
Expand Down
8 changes: 4 additions & 4 deletions docs/src/rules/keyword-spacing.md
Expand Up @@ -58,9 +58,9 @@ if (foo) {

Examples of **correct** code for this rule with the default `{ "before": true }` option:

::: correct
::: correct { "ecmaFeatures": { "jsx": true } }

```js
```jsx
/*eslint keyword-spacing: ["error", { "before": true }]*/
/*eslint-env es6*/

Expand Down Expand Up @@ -173,9 +173,9 @@ if(foo) {

Examples of **correct** code for this rule with the default `{ "after": true }` option:

::: correct
::: correct { "ecmaFeatures": { "jsx": true } }

```js
```jsx
/*eslint keyword-spacing: ["error", { "after": true }]*/

if (foo) {
Expand Down
20 changes: 10 additions & 10 deletions docs/src/rules/no-extra-parens.md
Expand Up @@ -214,9 +214,9 @@ foo ? bar : (baz || qux);

Examples of **correct** code for this rule with the `all` and `{ "ignoreJSX": "all" }` options:

::: correct
::: correct { "ecmaFeatures": { "jsx": true } }

```js
```jsx
/* eslint no-extra-parens: ["error", "all", { ignoreJSX: "all" }] */
const Component = (<div />)
const Component = (
Expand All @@ -230,9 +230,9 @@ const Component = (

Examples of **incorrect** code for this rule with the `all` and `{ "ignoreJSX": "multi-line" }` options:

::: incorrect
::: incorrect { "ecmaFeatures": { "jsx": true } }

```js
```jsx
/* eslint no-extra-parens: ["error", "all", { ignoreJSX: "multi-line" }] */
const Component = (<div />)
const Component = (<div><p /></div>)
Expand All @@ -242,9 +242,9 @@ const Component = (<div><p /></div>)

Examples of **correct** code for this rule with the `all` and `{ "ignoreJSX": "multi-line" }` options:

::: correct
::: correct { "ecmaFeatures": { "jsx": true } }

```js
```jsx
/* eslint no-extra-parens: ["error", "all", { ignoreJSX: "multi-line" }] */
const Component = (
<div>
Expand All @@ -262,9 +262,9 @@ const Component = (

Examples of **incorrect** code for this rule with the `all` and `{ "ignoreJSX": "single-line" }` options:

::: incorrect
::: incorrect { "ecmaFeatures": { "jsx": true } }

```js
```jsx
/* eslint no-extra-parens: ["error", "all", { ignoreJSX: "single-line" }] */
const Component = (
<div>
Expand All @@ -282,9 +282,9 @@ const Component = (

Examples of **correct** code for this rule with the `all` and `{ "ignoreJSX": "single-line" }` options:

::: correct
::: correct { "ecmaFeatures": { "jsx": true } }

```js
```jsx
/* eslint no-extra-parens: ["error", "all", { ignoreJSX: "single-line" }] */
const Component = (<div />)
const Component = (<div><p /></div>)
Expand Down
8 changes: 4 additions & 4 deletions docs/src/rules/no-inline-comments.md
Expand Up @@ -54,9 +54,9 @@ Comments inside the curly braces in JSX are allowed to be on the same line as th

Examples of **incorrect** code for this rule:

::: incorrect
::: incorrect { "ecmaFeatures": { "jsx": true } }

```js
```jsx
/*eslint no-inline-comments: "error"*/

var foo = <div>{ /* On the same line with other code */ }<h1>Some heading</h1></div>;
Expand All @@ -74,9 +74,9 @@ var bar = (

Examples of **correct** code for this rule:

::: correct
::: correct { "ecmaFeatures": { "jsx": true } }

```js
```jsx
/*eslint no-inline-comments: "error"*/

var foo = (
Expand Down
4 changes: 2 additions & 2 deletions docs/src/rules/no-irregular-whitespace.md
Expand Up @@ -197,9 +197,9 @@ function thing() {

Examples of additional **correct** code for this rule with the `{ "skipJSXText": true }` option:

::: correct
::: correct { "ecmaFeatures": { "jsx": true } }

```js
```jsx
/*eslint no-irregular-whitespace: ["error", { "skipJSXText": true }]*/
/*eslint-env es6*/

Expand Down
4 changes: 2 additions & 2 deletions docs/src/rules/no-unused-expressions.md
Expand Up @@ -251,7 +251,7 @@ JSX is most-commonly used in the React ecosystem, where it is compiled to `React

Examples of **incorrect** code for the `{ "enforceForJSX": true }` option:

::: incorrect
::: incorrect { "ecmaFeatures": { "jsx": true } }

```jsx
/*eslint no-unused-expressions: ["error", { "enforceForJSX": true }]*/
Expand All @@ -265,7 +265,7 @@ Examples of **incorrect** code for the `{ "enforceForJSX": true }` option:

Examples of **correct** code for the `{ "enforceForJSX": true }` option:

::: correct
::: correct { "ecmaFeatures": { "jsx": true } }

```jsx
/*eslint no-unused-expressions: ["error", { "enforceForJSX": true }]*/
Expand Down