From abb4a9374c30cf6637c68b85a3e5e357af975b41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alfonso=20Mart=C3=ADnez?= Date: Tue, 3 Dec 2024 16:17:47 +0100 Subject: [PATCH] Enable ESLint rules: no-unused-expressions & react/no-unused-state --- .eslintrc.js | 8 ++++++-- packages/shared/src/generic/promise-component.tsx | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index a68be04bf..5a7d69328 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -67,6 +67,8 @@ module.exports = { 'react/jsx-indent': 'off', 'react/jsx-no-useless-fragment': ['error', { allowExpressions: true }], 'react/jsx-pascal-case': 'error', + // Enable react/no-unused-prop-types once false positives are addressed: + // https://github.com/jsx-eslint/eslint-plugin-react/issues/3209 'react/no-unused-prop-types': 'off', 'consistent-return': 'off', 'default-case': 'off', @@ -162,7 +164,10 @@ module.exports = { 'no-underscore-dangle': 'off', 'no-unreachable': 'off', 'no-unsafe-optional-chaining': 'off', - 'no-unused-expressions': 'off', + 'no-unused-expressions': [ + 'error', + { allowShortCircuit: true, allowTernary: true, enforceForJSX: true }, + ], 'no-use-before-define': 'off', 'no-useless-catch': 'off', 'no-useless-constructor': 'off', @@ -175,7 +180,6 @@ module.exports = { 'react/jsx-pascal-case': 'off', 'react/jsx-props-no-spreading': 'off', 'react/no-array-index-key': 'off', - 'react/no-unused-state': 'off', 'react/require-default-props': 'off', 'react/sort-comp': 'off', 'no-unused-vars': 'off', diff --git a/packages/shared/src/generic/promise-component.tsx b/packages/shared/src/generic/promise-component.tsx index 9a322a8b1..05090ed27 100644 --- a/packages/shared/src/generic/promise-component.tsx +++ b/packages/shared/src/generic/promise-component.tsx @@ -51,6 +51,7 @@ export class PromiseComponent< > extends React.Component { constructor(props) { super(props); + /* eslint-disable react/no-unused-state */ this.state = { inProgress: false, errorMessage: '', @@ -83,6 +84,7 @@ export class PromiseComponent< inProgress: false, errorMessage, }); + /* eslint-enable react/no-unused-state */ return Promise.reject(errorMessage); } }