Skip to content

MAINT: Enable 32 strict type-checked ESLint rules in frontend (#3729) - #4779

Merged
Roman Lutz (romanlutz) merged 3 commits into
microsoft:mainfrom
Kaap10:maint/issue-3729-stage5-eslint-strict-batch
Dec 3, 2026
Merged

Roman Lutz (romanlutz) merged 3 commits into
microsoft:mainfrom
Kaap10:maint/issue-3729-stage5-eslint-strict-batch

Conversation

@Kaap10

Copy link
Copy Markdown
Contributor

Relates to #3729

Summary

  • Enabled 32 additional @typescript-eslint/strict-type-checked rules in frontend/eslint.config.js for src/**/*.{ts,tsx} (excluding tests), with 0 eslint-disable suppressions:
    • 24 zero-violation rules: await-thenable, no-array-delete, no-duplicate-type-constituents, no-extraneous-class, no-for-in-array, no-generated-empty-object-type, no-implied-eval, no-mixed-enums, no-non-null-asserted-nullish-coalescing, no-redundant-type-constituents, no-unnecessary-template-expression, no-unnecessary-type-parameters, no-unsafe-enum-assignment, no-unsafe-enum-comparison, no-unsafe-unary-minus, no-useless-constructor, only-throw-error, prefer-literal-enum-member, prefer-reduce-type-parameter, prefer-return-this-type, related-getter-setter-pairs, restrict-plus-operands, return-await, unified-signatures
    • 8 targeted rules (unbound-method, no-unnecessary-type-arguments, no-useless-default-assignment, no-misused-spread, no-unnecessary-type-conversion, no-meaningless-void-operator, no-unnecessary-boolean-literal-compare, no-unnecessary-type-assertion)
  • Fixed all 27 resulting diagnostics across 21 files in frontend/src/:
    • Replaced detached navigator.clipboard?.writeText in SeedExampleDetail.tsx
    • Omitted redundant type arguments (DatasetActions.tsx) and used querySelectorAll<HTMLElement> (LabelsBar.tsx)
    • Removed redundant Boolean(...) / String(...) wrappers, void operators, default assignments on non-optional properties, boolean literal comparisons, and unnecessary type assertions
    • Replaced string spread [...str].length with Array.from(str).length in attackAnalytics.ts to preserve Unicode code-point counting under ES2020
  • Left require-await, no-unsafe-*, no-deprecated, no-unnecessary-condition, restrict-template-expressions, and no-confusing-void-expression for follow-up PRs.

Verification

Verified in frontend/ after the final edit:

  • npm run lint (eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0): passed (0 errors, 0 warnings)
  • npm run type-check (tsc --noEmit): passed
  • npm run build (tsc && vite build): passed
  • Targeted Jest unit test suites for modified files (--maxWorkers=2): 11/11 suites passed (295/295 tests)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The error guard accepts a non-boolean isAxiosError value such as 'false', causing toApiError to misclassify an error as a network failure and lose its original message.

1 open issue
What changed in this PR

This PR advances the staged frontend type-safety migration in #3729 by enabling 32 additional ESLint rules and updating affected production code without adding suppressions.

Changes:

  • Enables selected strict type-checked rules for production TypeScript files, excluding tests.
  • Removes redundant assertions, conversions, defaults, and void expressions.
  • Adjusts clipboard access and preserves Unicode code-point counting with Array.from.
File Description
frontend/​src/​utils/​targetIdentity.ts Removes a redundant endpoint assertion.
frontend/​src/​utils/​chatDraft.ts Removes redundant metadata assertions.
frontend/​src/​utils/​attackAnalytics.ts Replaces string spread with Unicode-aware Array.from.
frontend/​src/​services/​errors.ts Simplifies the Axios error flag check.
frontend/​src/​hooks/​useScenarioRunEstimate.ts Copies the request and deletes datasets for fallback estimates.
frontend/​src/​hooks/​useChatDraftHandoff.tsx Replaces a discarded version read with a conditional.
frontend/​src/​components/​Scenarios/​ScenarioTechniqueSection.tsx Removes redundant token string conversion.
frontend/​src/​components/​Scenarios/​DatasetActions.tsx Omits a default generic type argument.
frontend/​src/​components/​Registry/​Registry.styles.ts Removes a font-weight assertion.
frontend/​src/​components/​Parameters/​ParameterField.tsx Removes redundant placeholder conversion.
frontend/​src/​components/​Media/​MediaPreview.tsx Removes void from the retry callback.
frontend/​src/​components/​Labels/​LabelsBar.tsx Types queried elements through a generic argument.
frontend/​src/​components/​History/​ScenarioHistory.tsx Simplifies boolean checks for progress and success.
frontend/​src/​components/​History/​HistoryFiltersBar.tsx Removes an input-element assertion.
frontend/​src/​components/​Datasets/​SeedExampleDetail.tsx Calls writeText directly on the clipboard object.
frontend/​src/​components/​Config/​CreateTargetDialog.tsx Removes redundant boolean conversion.
frontend/​src/​components/​Chat/​PromptEditor.styles.ts Removes font-weight assertions.
frontend/​src/​components/​Chat/​MessageList.styles.ts Removes a font-weight assertion.
frontend/​src/​components/​Chat/​ConverterPanel/​ConverterPanel.styles.ts Removes a font-weight assertion.
frontend/​src/​components/​Chat/​ChatInputArea.tsx Removes a default for a required boolean prop.
frontend/​src/​App.tsx Replaces the accounts default with optional indexing.
frontend/​eslint.config.js Enables 32 additional strict type-checked rules.

Review effort: Balanced

Comment thread frontend/src/services/errors.ts Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified in the frontend type-safety changes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@romanlutz Roman Lutz (romanlutz) self-assigned this Dec 3, 2026
@romanlutz
Roman Lutz (romanlutz) added this pull request to the merge queue Dec 3, 2026
Merged via the queue into microsoft:main with commit 4b98678 Dec 3, 2026
1 check passed
hannahwestra25 added a commit to hannahwestra25/PyRIT that referenced this pull request Dec 4, 2026
Resolve conflicts with main's Scanner regrouping (microsoft#4616), dataset
preparation history fields (microsoft#4228), and strict ESLint rules (microsoft#4779):

- Keep the objective scorer picker, unsupported-scorer warning, and
  scorer-aware leave guard in the edit-only scenario editor; route its
  scorer props from App.
- Drop ScannerSuiteSection with main and pass scorer props through the
  new ScannerPresetsPage to LaunchSuiteDialog; take main's ScenarioCatalog.
- Keep both objective_scorer_identifier and dataset_preparation fields on
  ScenarioHistoryRunRecord, and both test imports.
- Drop showInScanner from PresetIdentity with main; keep objectiveScorer.
- Remove an assertion the new no-unnecessary-type-assertion rule rejects.
- Describe per-scenario scorers in the GUI guide with main's preset terms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants