aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/eslint-local-rules
diff options
context:
space:
mode:
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>2024-02-20 09:34:09 +0100
committersonartech <sonartech@sonarsource.com>2024-02-20 20:02:38 +0000
commit9b925e5931796a04867eb9c524e67fae9da2671a (patch)
treefac07eb88558a647d7794d3ab1628bb4b1bf16c2 /server/sonar-web/eslint-local-rules
parent04c6c92cc775134fc3208ae404e4f36fa9ccb490 (diff)
downloadsonarqube-9b925e5931796a04867eb9c524e67fae9da2671a.tar.gz
sonarqube-9b925e5931796a04867eb9c524e67fae9da2671a.zip
SONAR-19032 MIUI cleanup part 1 (#10627)
Co-authored-by: David Cho-Lerat <david.cho-lerat@sonarsource.com> Co-authored-by: Jeremy Davis <jeremy.davis@sonarsource.com>
Diffstat (limited to 'server/sonar-web/eslint-local-rules')
-rw-r--r--server/sonar-web/eslint-local-rules/__tests__/no-conditional-rendering-of-spinner-test.js (renamed from server/sonar-web/eslint-local-rules/__tests__/no-conditional-rendering-of-deferredspinner-test.js)48
-rw-r--r--server/sonar-web/eslint-local-rules/index.js2
-rw-r--r--server/sonar-web/eslint-local-rules/no-conditional-rendering-of-spinner.js (renamed from server/sonar-web/eslint-local-rules/no-conditional-rendering-of-deferredspinner.js)16
3 files changed, 31 insertions, 35 deletions
diff --git a/server/sonar-web/eslint-local-rules/__tests__/no-conditional-rendering-of-deferredspinner-test.js b/server/sonar-web/eslint-local-rules/__tests__/no-conditional-rendering-of-spinner-test.js
index 99a34407909..bcd456e9f98 100644
--- a/server/sonar-web/eslint-local-rules/__tests__/no-conditional-rendering-of-deferredspinner-test.js
+++ b/server/sonar-web/eslint-local-rules/__tests__/no-conditional-rendering-of-spinner-test.js
@@ -18,7 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
const { RuleTester } = require('eslint');
-const noConditionalRenderingOfDeferredSpinner = require('../no-conditional-rendering-of-deferredspinner');
+const noConditionalRenderingOfSpinner = require('../no-conditional-rendering-of-spinner');
const ruleTester = new RuleTester({
parser: require.resolve('@typescript-eslint/parser'),
@@ -29,44 +29,40 @@ const ruleTester = new RuleTester({
},
});
-ruleTester.run(
- 'no-conditional-rendering-of-deferredspinner',
- noConditionalRenderingOfDeferredSpinner,
- {
- valid: [
- {
- code: `function MyCompontent({ loading }) {
+ruleTester.run('no-conditional-rendering-of-spinner', noConditionalRenderingOfSpinner, {
+ valid: [
+ {
+ code: `function MyCompontent({ loading }) {
return <>
<Spinner loading={loading} />
</>
}`,
- },
- ],
- invalid: [
- {
- code: `function MyCompontent({ loading }) {
+ },
+ ],
+ invalid: [
+ {
+ code: `function MyCompontent({ loading }) {
return <>
{loading && <Spinner />}
</>
}`,
- errors: [{ messageId: 'noConditionalRenderingOfDeferredSpinner' }],
- },
- {
- code: `function MyComponent({ loading }) {
+ errors: [{ messageId: 'noConditionalRenderingOfSpinner' }],
+ },
+ {
+ code: `function MyComponent({ loading }) {
return <>
{loading ? <Spinner /> : <div />}
</>
}`,
- errors: [{ messageId: 'noConditionalRenderingOfDeferredSpinner' }],
- },
- {
- code: `function MyCompontent({ loaded }) {
+ errors: [{ messageId: 'noConditionalRenderingOfSpinner' }],
+ },
+ {
+ code: `function MyCompontent({ loaded }) {
return <>
{loaded ? <div /> : <Spinner />}
</>
}`,
- errors: [{ messageId: 'noConditionalRenderingOfDeferredSpinner' }],
- },
- ],
- }
-);
+ errors: [{ messageId: 'noConditionalRenderingOfSpinner' }],
+ },
+ ],
+});
diff --git a/server/sonar-web/eslint-local-rules/index.js b/server/sonar-web/eslint-local-rules/index.js
index 7d9345d3021..e80671fb5a5 100644
--- a/server/sonar-web/eslint-local-rules/index.js
+++ b/server/sonar-web/eslint-local-rules/index.js
@@ -20,7 +20,7 @@
module.exports = {
'use-jest-mocked': require('./use-jest-mocked'),
'convert-class-to-function-component': require('./convert-class-to-function-component'),
- 'no-conditional-rendering-of-deferredspinner': require('./no-conditional-rendering-of-deferredspinner'),
+ 'no-conditional-rendering-of-spinner': require('./no-conditional-rendering-of-spinner'),
'use-visibility-enum': require('./use-visibility-enum'),
'use-componentqualifier-enum': require('./use-componentqualifier-enum'),
'use-metrickey-enum': require('./use-metrickey-enum'),
diff --git a/server/sonar-web/eslint-local-rules/no-conditional-rendering-of-deferredspinner.js b/server/sonar-web/eslint-local-rules/no-conditional-rendering-of-spinner.js
index 89540719d75..06ed0a9fa55 100644
--- a/server/sonar-web/eslint-local-rules/no-conditional-rendering-of-deferredspinner.js
+++ b/server/sonar-web/eslint-local-rules/no-conditional-rendering-of-spinner.js
@@ -20,7 +20,7 @@
module.exports = {
meta: {
messages: {
- noConditionalRenderingOfDeferredSpinner:
+ noConditionalRenderingOfSpinner:
'For accessibility reasons, you should not conditionally render a <Spinner />. Always render it, and pass a loading prop instead.',
},
},
@@ -30,18 +30,18 @@ module.exports = {
switch (node.expression.type) {
case 'LogicalExpression':
const { right } = node.expression;
- if (isDeferredSpinnerComponent(right)) {
- context.report({ node, messageId: 'noConditionalRenderingOfDeferredSpinner' });
+ if (isSpinnerComponent(right)) {
+ context.report({ node, messageId: 'noConditionalRenderingOfSpinner' });
}
break;
case 'ConditionalExpression':
const { consequent, alternate } = node.expression;
- if (isDeferredSpinnerComponent(consequent)) {
- context.report({ node, messageId: 'noConditionalRenderingOfDeferredSpinner' });
+ if (isSpinnerComponent(consequent)) {
+ context.report({ node, messageId: 'noConditionalRenderingOfSpinner' });
}
- if (isDeferredSpinnerComponent(alternate)) {
- context.report({ node, messageId: 'noConditionalRenderingOfDeferredSpinner' });
+ if (isSpinnerComponent(alternate)) {
+ context.report({ node, messageId: 'noConditionalRenderingOfSpinner' });
}
break;
}
@@ -50,7 +50,7 @@ module.exports = {
},
};
-function isDeferredSpinnerComponent(element) {
+function isSpinnerComponent(element) {
return (
element.type === 'JSXElement' &&
element.openingElement &&