Skip to content

Commit cd5c576

Browse files
committed
Update instructions about eslint config file
1 parent 95a6607 commit cd5c576

File tree

5 files changed

+108
-73
lines changed

5 files changed

+108
-73
lines changed

src/content/1/en/part1a.md

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -385,30 +385,42 @@ Depending on the editor you are using, you may receive the following error messa
385385

386386
![screenshot of vs code showing eslint error: "name is missing in props validation"](../../images/1/1-vite5.png)
387387

388-
It's not an actual error, but a warning caused by the [ESLint](https://eslint.org/) tool. You can silence the warning [react/prop-types](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prop-types.md) by adding to the file <i>.eslintrc .cjs</i> the next line
389-
390-
```js
391-
module.exports = {
392-
root: true,
393-
env: { browser: true, es2020: true },
394-
extends: [
395-
'eslint:recommended',
396-
'plugin:react/recommended',
397-
'plugin:react/jsx-runtime',
398-
'plugin:react-hooks/recommended',
399-
],
400-
ignorePatterns: ['dist', '.eslintrc.cjs'],
401-
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
402-
settings: { react: { version: '18.2' } },
403-
plugins: ['react-refresh'],
404-
rules: {
405-
'react-refresh/only-export-components': [
406-
'warn',
407-
{ allowConstantExport: true },
408-
],
409-
'react/prop-types': 0 // highlight-line
410-
},
411-
}
388+
It's not an actual error, but a warning caused by the [ESLint](https://eslint.org/) tool. You can silence the warning [react/prop-types](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prop-types.md) by adding to the file <i>eslint.config.js</i> the next line
389+
390+
```js
391+
export default [
392+
{ ignores: ['dist'] },
393+
{
394+
files: ['**/*.{js,jsx}'],
395+
languageOptions: {
396+
ecmaVersion: 2020,
397+
globals: globals.browser,
398+
parserOptions: {
399+
ecmaVersion: 'latest',
400+
ecmaFeatures: { jsx: true },
401+
sourceType: 'module',
402+
},
403+
},
404+
settings: { react: { version: '18.3' } },
405+
plugins: {
406+
react,
407+
'react-hooks': reactHooks,
408+
'react-refresh': reactRefresh,
409+
},
410+
rules: {
411+
...js.configs.recommended.rules,
412+
...react.configs.recommended.rules,
413+
...react.configs['jsx-runtime'].rules,
414+
...reactHooks.configs.recommended.rules,
415+
'react/jsx-no-target-blank': 'off',
416+
'react-refresh/only-export-components': [
417+
'warn',
418+
{ allowConstantExport: true },
419+
],
420+
'react/prop-types': 0, // highlight-line
421+
},
422+
},
423+
]
412424
```
413425

414426
We will get to know ESLint in more detail [in part 3](/en/part3/validation_and_es_lint#lint).

src/content/1/es/part1a.md

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -385,30 +385,42 @@ Dependiendo del editor que estés usando, podrías recibir un mensaje de error e
385385

386386
![Captura de pantalla de vs code mostrando un error de eslint: "name is missing in props validation"](../../images/1/1-vite5.png)
387387

388-
Este realmente no es un error, es una advertencia causada por la herramienta [ESLint](https://es.eslint.org/). Puedes silenciar la advertencia [react/prop-types](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prop-types.md) añadiendo la siguiente línea al archivo <i>.eslintrc.cjs</i>
389-
390-
```js
391-
module.exports = {
392-
root: true,
393-
env: { browser: true, es2020: true },
394-
extends: [
395-
'eslint:recommended',
396-
'plugin:react/recommended',
397-
'plugin:react/jsx-runtime',
398-
'plugin:react-hooks/recommended',
399-
],
400-
ignorePatterns: ['dist', '.eslintrc.cjs'],
401-
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
402-
settings: { react: { version: '18.2' } },
403-
plugins: ['react-refresh'],
404-
rules: {
405-
'react-refresh/only-export-components': [
406-
'warn',
407-
{ allowConstantExport: true },
408-
],
409-
'react/prop-types': 0 // highlight-line
410-
},
411-
}
388+
Este realmente no es un error, es una advertencia causada por la herramienta [ESLint](https://es.eslint.org/). Puedes silenciar la advertencia [react/prop-types](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prop-types.md) añadiendo la siguiente línea al archivo <i>eslint.config.js</i>
389+
390+
```js
391+
export default [
392+
{ ignores: ['dist'] },
393+
{
394+
files: ['**/*.{js,jsx}'],
395+
languageOptions: {
396+
ecmaVersion: 2020,
397+
globals: globals.browser,
398+
parserOptions: {
399+
ecmaVersion: 'latest',
400+
ecmaFeatures: { jsx: true },
401+
sourceType: 'module',
402+
},
403+
},
404+
settings: { react: { version: '18.3' } },
405+
plugins: {
406+
react,
407+
'react-hooks': reactHooks,
408+
'react-refresh': reactRefresh,
409+
},
410+
rules: {
411+
...js.configs.recommended.rules,
412+
...react.configs.recommended.rules,
413+
...react.configs['jsx-runtime'].rules,
414+
...reactHooks.configs.recommended.rules,
415+
'react/jsx-no-target-blank': 'off',
416+
'react-refresh/only-export-components': [
417+
'warn',
418+
{ allowConstantExport: true },
419+
],
420+
'react/prop-types': 0, // highlight-line
421+
},
422+
},
423+
]
412424
```
413425

414426
Aprenderemos sobre ESLint más en detalle en la [parte 3](/es/part3/validacion_y_es_lint#lint).

src/content/1/fi/osa1a.md

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -368,30 +368,42 @@ Käyttämästäsi editorista riippuen saatat saada tässä vaiheessa seuraavan v
368368

369369
![](../../images/1/1-vite5.png)
370370

371-
Kyse ei ole varsinaisesta virheestä vaan [ESLint](https://eslint.org/)-työkalun aiheuttamasta varoituksesta. Saat hiljennettyä varoituksen [react/prop-types](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prop-types.md) lisäämällä tiedostoon <i>.eslintrc.cjs</i> seuraavan rivin
372-
373-
```js
374-
module.exports = {
375-
root: true,
376-
env: { browser: true, es2020: true },
377-
extends: [
378-
'eslint:recommended',
379-
'plugin:react/recommended',
380-
'plugin:react/jsx-runtime',
381-
'plugin:react-hooks/recommended',
382-
],
383-
ignorePatterns: ['dist', '.eslintrc.cjs'],
384-
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
385-
settings: { react: { version: '18.2' } },
386-
plugins: ['react-refresh'],
387-
rules: {
388-
'react-refresh/only-export-components': [
389-
'warn',
390-
{ allowConstantExport: true },
391-
],
392-
'react/prop-types': 0 // highlight-line
371+
Kyse ei ole varsinaisesta virheestä vaan [ESLint](https://eslint.org/)-työkalun aiheuttamasta varoituksesta. Saat hiljennettyä varoituksen [react/prop-types](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/prop-types.md) lisäämällä tiedostoon <i>eslint.config.js</i> seuraavan rivin
372+
373+
```js
374+
export default [
375+
{ ignores: ['dist'] },
376+
{
377+
files: ['**/*.{js,jsx}'],
378+
languageOptions: {
379+
ecmaVersion: 2020,
380+
globals: globals.browser,
381+
parserOptions: {
382+
ecmaVersion: 'latest',
383+
ecmaFeatures: { jsx: true },
384+
sourceType: 'module',
385+
},
386+
},
387+
settings: { react: { version: '18.3' } },
388+
plugins: {
389+
react,
390+
'react-hooks': reactHooks,
391+
'react-refresh': reactRefresh,
392+
},
393+
rules: {
394+
...js.configs.recommended.rules,
395+
...react.configs.recommended.rules,
396+
...react.configs['jsx-runtime'].rules,
397+
...reactHooks.configs.recommended.rules,
398+
'react/jsx-no-target-blank': 'off',
399+
'react-refresh/only-export-components': [
400+
'warn',
401+
{ allowConstantExport: true },
402+
],
403+
'react/prop-types': 0, // highlight-line
404+
},
393405
},
394-
}
406+
]
395407
```
396408

397409
Tutustumme ESLintiin tarkemmin [osassa 3](/osa3/validointi_ja_es_lint#lint).

src/content/1/fr/part1a.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,16 +404,15 @@ export default [
404404
...react.configs.recommended.rules,
405405
...react.configs['jsx-runtime'].rules,
406406
...reactHooks.configs.recommended.rules,
407-
'react/prop-types': ['off'], // highlight-line
408407
'react/jsx-no-target-blank': 'off',
409408
'react-refresh/only-export-components': [
410409
'warn',
411410
{ allowConstantExport: true },
412411
],
412+
'react/prop-types': 0, // highlight-line
413413
},
414414
},
415415
]
416-
417416
```
418417

419418
Nous en apprendrons davantage sur ESLint en détail dans [la partie 3](/osa3/validointi_ja_es_lint#lint).

src/content/images/1/1-vite5.png

-97.5 KB
Loading

0 commit comments

Comments
 (0)