Files
Oleg Valiulin f5c7ed2b16 eslint 10 in public repo (#10593)
## Summary

PR 1 - eslint 10 migration
PR 2 - move/update legacy configs

This pull request upgrades the public repository to **ESLint 10** and
aligns the codebase with the newer linting and TypeScript ecosystem
requirements.

## What Changed

- Migrated the project from legacy ESLint configuration toward the new
ESLint 10 setup.
- Added and updated lint-related configuration files, including
`eslint.config.mjs`.
- Replaced deprecated or removed ESLint / `@typescript-eslint` rules
with supported alternatives.
- Introduced `@stylistic` rules where ESLint 10 no longer provides
certain formatting rules directly.
- Tightened several TypeScript lint constraints, including restrictions
around unsafe function typing and overly broad object types.
- Updated dependencies in `package.json` and `yarn.lock` to support the
ESLint 10 migration.
- Enforced previously dead rules onto the codebase + tests

## Codebase Impact

The PR touches a large part of the frontend and shared TypeScript code,
mainly to satisfy the new linting rules and type expectations:

- `cvat-ui`
- `cvat-core`
- `cvat-canvas`
- `cvat-canvas3d`
- Cypress tests and test tooling

Most of the source changes appear to be **compatibility and cleanup
updates** rather than feature work. Examples include:

- formatting and style-rule adjustments
- explicit typing changes
- line-break and class-member spacing fixes
- migration away from deprecated rule patterns
- small compatibility fixes surfaced by newer TypeScript checks

## Notable Technical Adjustments

- `indent` and `lines-between-class-members` were migrated to
`@stylistic/*` equivalents.
- Older `@typescript-eslint` rules such as `ban-types` were replaced
with newer rule patterns like:
  - `@typescript-eslint/no-empty-object-type`
  - `@typescript-eslint/no-restricted-types`
  - `@typescript-eslint/no-unsafe-function-type`
- Some canvas-related code was adjusted to satisfy stricter DOM and
typed-array expectations in newer TypeScript versions.

## Why This PR Matters

This migration helps keep the repository current with the modern
JavaScript / TypeScript linting toolchain. It should make future
maintenance easier, reduce reliance on deprecated configuration
patterns, and surface typing issues earlier in development.

## Scope and Risk

Because the PR changes lint configuration plus many source files across
the repository, the main risk is not feature regression from new logic,
but **broad compatibility fallout** from stricter linting and typing.
The changes are primarily infrastructure-oriented, but they affect many
files and therefore deserve careful validation.

## Testing

The PR body does not currently include testing details.

---------

Co-authored-by: Oleg Valiulin <oleg.valiulin@cvat.ai>
Co-authored-by: Roman Donchenko <roman@cvat.ai>
Co-authored-by: Boris Sekachev <sekachev.bs@gmail.com>
Co-authored-by: Maxim Zhiltsov <maxim@cvat.ai>
Co-authored-by: Maxim Zhiltsov <zhiltsov.max35@gmail.com>
Co-authored-by: Nikolay Borovets <95526773+nikborovets@users.noreply.github.com>
Co-authored-by: Andrey Zhavoronkov <andrey@cvat.ai>
Co-authored-by: Peter Iosipov <61969939+yaizkazani@users.noreply.github.com>
2026-05-18 17:58:57 +01:00

89 lines
3.6 KiB
JavaScript

// Copyright (C) 2018-2022 Intel Corporation
// Copyright (C) CVAT.ai Corporation
//
// SPDX-License-Identifier: MIT
module.exports = {
root: true,
env: {
node: true,
browser: true,
es2020: true,
},
parserOptions: {
sourceType: 'module',
parser: '@typescript-eslint/parser',
},
ignorePatterns: [
'.eslintrc.cjs',
'lint-staged.config.js',
'site/**',
'webpack.config.cjs',
],
plugins: ['@typescript-eslint', '@stylistic', 'security', 'no-unsanitized', 'import'],
extends: [
'eslint:recommended', 'plugin:security/recommended', 'plugin:no-unsanitized/DOM',
'airbnb-base', 'plugin:import/errors', 'plugin:import/warnings',
'plugin:import/typescript', 'plugin:@typescript-eslint/recommended', 'airbnb-typescript/base',
],
rules: {
// 'header/header': [2, 'line', [{
// pattern: ' {1}Copyright \\(C\\) (?:20\\d{2}-)?2022 Intel Corporation',
// template: ' Copyright (C) 2022 Intel Corporation'
// }, '', ' SPDX-License-Identifier: MIT']],
'no-plusplus': 0,
'no-continue': 0,
'no-console': 0,
'no-restricted-syntax': [0, { selector: 'ForOfStatement' }],
'no-await-in-loop': 0,
'@stylistic/indent': ['error', 4, { 'SwitchCase': 1 }],
'max-len': ['error', { code: 120, ignoreStrings: true }],
'func-names': 0,
'valid-typeof': 0,
'quotes': ['error', 'single', { "avoidEscape": true }],
'lines-between-class-members': 'off',
'@stylistic/lines-between-class-members': 0,
'@typescript-eslint/lines-between-class-members': 'off',
'class-methods-use-this': 0,
'no-underscore-dangle': ['error', { allowAfterThis: true }],
'max-classes-per-file': 0,
'operator-linebreak': ['error', 'after'],
'newline-per-chained-call': 0,
'global-require': 0,
'arrow-parens': ['error', 'always'],
'security/detect-object-injection': 0, // the rule is relevant for user input data on the node.js environment
'import/order': ['error', {'groups': ['builtin', 'external', 'internal']}],
'import/no-unresolved': 'off',
'import/prefer-default-export': 0, // works incorrect with interfaces
'no-useless-assignment': 'off',
'preserve-caught-error': 'off',
'react/jsx-indent-props': 0, // new rule, breaks current styling
'react/jsx-indent': 0, // new rule, conflicts with eslint@typescript-eslint/indent eslint@indent, breaks current styling
'function-paren-newline': 0, // new rule, breaks current styling
'@typescript-eslint/default-param-last': 0, // does not really work with redux reducers
'@typescript-eslint/ban-ts-comment': 0,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/explicit-function-return-type': ['warn', { allowExpressions: true }],
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-empty-object-type': [
'error',
{
allowInterfaces: 'always',
allowObjectTypes: 'never',
},
],
'@typescript-eslint/no-unsafe-function-type': 'error',
'@typescript-eslint/no-restricted-types': [
'error',
{
types: {
object: {
message: 'Use a more specific object shape, Record<string, unknown>, or unknown instead of object.',
},
},
},
],
},
};