From f3fdc6c09966beba456da970b2384c3a44287cac Mon Sep 17 00:00:00 2001 From: Bryan BERGER Date: Fri, 29 Mar 2024 12:45:51 +0100 Subject: [PATCH] fix(react): fix react jsx rules --- package-lock.json | 4 ++-- package.json | 2 +- react.js | 30 +++++++++++++++++++++++------- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8ab20dc..77b9c25 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "eslint-config-bryanberger", - "version": "1.0.3", + "version": "1.0.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "eslint-config-bryanberger", - "version": "1.0.3", + "version": "1.0.4", "license": "MIT", "dependencies": { "confusing-browser-globals": "^1.0.11" diff --git a/package.json b/package.json index 7939910..70a9b46 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "eslint-config-bryanberger", "description": "My personal ESLint config", - "version": "1.0.3", + "version": "1.0.4", "license": "MIT", "main": "index.js", "homepage": "https://github.com/BryanBerger98/eslint-config-bryanberger", diff --git a/react.js b/react.js index 877aae5..aa87da1 100644 --- a/react.js +++ b/react.js @@ -106,7 +106,13 @@ module.exports = { // Validate props indentation in JSX // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-indent-props.md - 'react/jsx-indent-props': [ 'error', 2 ], + 'react/jsx-indent-props': [ + 'warn', + { + indentMode: 'tab', + ignoreTernaryOperator: true, + }, + ], // Validate JSX has key prop when in array or iterator // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-key.md @@ -247,7 +253,7 @@ module.exports = { // Prevent missing React when using JSX // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md - 'react/react-in-jsx-scope': 'error', + 'react/react-in-jsx-scope': 'off', // Require render() methods to return something // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/require-render-return.md @@ -331,7 +337,14 @@ module.exports = { // Enforce JSX indentation // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-indent.md - 'react/jsx-indent': [ 'error', 2 ], + 'react/jsx-indent': [ + 'warn', + 'tab', + { + indentLogicalExpressions: true, + checkAttributes: true, + }, + ], // Disallow target="_blank" on links // https://github.com/jsx-eslint/eslint-plugin-react/blob/ac102885765be5ff37847a871f239c6703e1c7cc/docs/rules/jsx-no-target-blank.md @@ -540,10 +553,13 @@ module.exports = { // Enforce a specific function type for function components // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/function-component-definition.md - 'react/function-component-definition': [ 'error', { - namedComponents: [ 'function-declaration', 'function-expression' ], - unnamedComponents: 'function-expression', - } ], + 'react/function-component-definition': [ + 'warn', + { + namedComponents: 'arrow-function', + unamedComponents: 'arrow-function', + }, + ], // Enforce a new line after jsx elements and expressions // https://github.com/jsx-eslint/eslint-plugin-react/blob/e2eaadae316f9506d163812a09424eb42698470a/docs/rules/jsx-newline.md