diff --git a/superset-frontend/.eslintrc.js b/superset-frontend/.eslintrc.js index 5f4b50ff9d2..5cbc53a4403 100644 --- a/superset-frontend/.eslintrc.js +++ b/superset-frontend/.eslintrc.js @@ -135,6 +135,7 @@ module.exports = { 'icons', 'i18n-strings', 'react-prefer-function-component', + 'react-you-might-not-need-an-effect', 'prettier', ], rules: { @@ -235,6 +236,11 @@ module.exports = { 'jsx-a11y/mouse-events-have-key-events': 0, 'jsx-a11y/no-static-element-interactions': 0, + // React effect best practices + 'react-you-might-not-need-an-effect/no-empty-effect': 'error', + 'react-you-might-not-need-an-effect/no-pass-live-state-to-parent': 'error', + 'react-you-might-not-need-an-effect/no-initialize-state': 'error', + // Lodash 'lodash/import-scope': [2, 'member'], diff --git a/superset-frontend/oxlint.json b/superset-frontend/oxlint.json index fe2360b2219..1a9b1ac3c0b 100644 --- a/superset-frontend/oxlint.json +++ b/superset-frontend/oxlint.json @@ -28,7 +28,8 @@ // === Core ESLint rules === // Error prevention "no-console": "warn", - "no-alert": "warn", + "no-alert": "error", + "constructor-super": "error", "no-debugger": "error", "no-unused-vars": "off", "no-undef": "error", @@ -148,7 +149,8 @@ ], "react/no-array-index-key": "off", "react/no-children-prop": "error", - "react/no-danger": "warn", + "react/no-danger": "error", + "react/forbid-foreign-prop-types": "error", "react/no-danger-with-children": "error", "react/no-deprecated": "error", "react/no-did-update-set-state": "error", @@ -250,6 +252,7 @@ ], // === Unicorn rules (bonus coverage) === + "unicorn/no-invalid-remove-event-listener": "error", "unicorn/filename-case": "off", "unicorn/prevent-abbreviations": "off", "unicorn/no-null": "off", diff --git a/superset-frontend/packages/superset-ui-core/src/models/ExtensibleFunction.ts b/superset-frontend/packages/superset-ui-core/src/models/ExtensibleFunction.ts index 66f82af0499..566b898091f 100644 --- a/superset-frontend/packages/superset-ui-core/src/models/ExtensibleFunction.ts +++ b/superset-frontend/packages/superset-ui-core/src/models/ExtensibleFunction.ts @@ -22,7 +22,8 @@ */ export default class ExtensibleFunction extends Function { - // @ts-expect-error + // @ts-expect-error - intentionally not calling super(), using setPrototypeOf pattern instead + // eslint-disable-next-line constructor-super constructor(fn: Function) { // eslint-disable-next-line @typescript-eslint/no-unsafe-return, no-constructor-return return Object.setPrototypeOf(fn, new.target.prototype); diff --git a/superset-frontend/packages/superset-ui-core/src/utils/html.test.tsx b/superset-frontend/packages/superset-ui-core/src/utils/html.test.tsx index 648b2b68ce7..ea24e0c8c50 100644 --- a/superset-frontend/packages/superset-ui-core/src/utils/html.test.tsx +++ b/superset-frontend/packages/superset-ui-core/src/utils/html.test.tsx @@ -106,6 +106,7 @@ describe('safeHtmlSpan', () => { expect(safeSpan).toEqual( , ); diff --git a/superset-frontend/packages/superset-ui-core/src/utils/html.tsx b/superset-frontend/packages/superset-ui-core/src/utils/html.tsx index de7267c8231..940fc232b6a 100644 --- a/superset-frontend/packages/superset-ui-core/src/utils/html.tsx +++ b/superset-frontend/packages/superset-ui-core/src/utils/html.tsx @@ -167,6 +167,8 @@ export function safeHtmlSpan(possiblyHtmlString: string) { return ( ); diff --git a/superset-frontend/plugins/plugin-chart-ag-grid-table/src/renderers/TextCellRenderer.tsx b/superset-frontend/plugins/plugin-chart-ag-grid-table/src/renderers/TextCellRenderer.tsx index 88e7bc23693..eb52f206a88 100644 --- a/superset-frontend/plugins/plugin-chart-ag-grid-table/src/renderers/TextCellRenderer.tsx +++ b/superset-frontend/plugins/plugin-chart-ag-grid-table/src/renderers/TextCellRenderer.tsx @@ -64,6 +64,8 @@ export const TextCellRenderer = (params: CellRendererProps) => { ); } if (allowRenderHtml && isProbablyHTML(value)) { + // Safe: HTML is sanitized before rendering + // eslint-disable-next-line react/no-danger return
; } } diff --git a/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx b/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx index 08f808bcf23..9aae0231f51 100644 --- a/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx +++ b/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx @@ -1060,17 +1060,19 @@ export default function TableChart