Загрузка данных


{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "noEmit": false,              
    "declaration": true,
    "emitDeclarationOnly": true,
    "declarationDir": "types",
    "rootDir": "src",
    "outDir": "types"       
  },
  "include": ["src"],             
  "exclude": ["stories", ".storybook", "**/*.stories.*"]
}

{
  "compilerOptions": {
    "jsx": "react-jsx",
    "target": "es2022",
    "module": "esnext",
    "moduleResolution": "bundler",
    "baseUrl": "./",
    "plugins": [
      {
        "name": "typescript-plugin-css-modules",
        "options": {
          "allowUnknownClassnames": true
        }
      }
    ],
    "paths": {
      "@src/*": ["src/*"],
      "@src": ["src"],
      "@core/*": ["src/core/*"],
      "@core": ["src/core"],
      "@components/*": ["src/components/*"],
      "@components": ["src/components"],
      "@lib/*": ["moex-chart/*", "src/*"],
      "@lib": ["moex-chart", "src"]
    },
    "noEmit": true,
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "resolveJsonModule": true,
    "sourceMap": true,
  },
  "include": ["src", "stories", ".storybook"],
  "exclude": ["dist", "node_modules"]
}


import { readFileSync } from 'fs';

// eslint-disable-next-line import/no-extraneous-dependencies
import JSON5 from 'json5';
// eslint-disable-next-line import/no-extraneous-dependencies
import { pathsToModuleNameMapper } from 'ts-jest';

import type { Config } from '@jest/types';

const fileContent = readFileSync('./tsconfig.json');
const fileContentJSON = JSON5.parse(fileContent.toString());

const config: Config.InitialOptions = {
  // нужен пакет, который поддержит резолв scss модуля
  // transform: {
  //   "\\.scss$": "jest-sass",
  // },
  clearMocks: true,
  resetMocks: true,
  restoreMocks: true,
  preset: 'ts-jest',
  transform: {
    '^.+\\.tsx?$': 'ts-jest',
  },
  testEnvironment: 'jsdom',
  moduleDirectories: ['node_modules', '<rootDir>'],
  moduleNameMapper: {
    ...pathsToModuleNameMapper(fileContentJSON.compilerOptions.paths),
    '\\.(css|scss|module.scss)$': '<rootDir>/__mocks__/styleMock.js',
  },
  coverageDirectory: '<rootDir>/coverage',
  coverageReporters: ['text', 'lcov'],
};

export default config;


module.exports = {
  env: {
    browser: true,
    es2021: true,
    'jest/globals': true,
  },
  extends: [
    'plugin:react/recommended',
    'plugin:react-hooks/recommended',
    'plugin:jest/recommended',
    'airbnb',
    'plugin:@typescript-eslint/recommended',
    // Удаление конфликтующих с prettier правил
    'prettier',
    'plugin:eslint-comments/recommended',
  ],
  parser: '@typescript-eslint/parser',
  ignorePatterns: ['**/*.module.css', '**/*.scss', '**/*.md', '**/*.mdx', '**/*worker.ts', '**/*Worker.ts'],
  parserOptions: {
    ecmaFeatures: {
      jsx: true,
    },
    project: './tsconfig.json',
    ecmaVersion: 'latest',
    sourceType: 'module',
    warnOnUnsupportedTypeScriptVersion: false,
  },
  reportUnusedDisableDirectives: true,
  plugins: ['react', 'jest', '@typescript-eslint', 'prettier', 'react-hooks'],
  settings: {
    'import/resolver': {
      typescript: {},
      node: {
        extensions: ['.js', '.jsx', '.ts', '.tsx'],
      },
      webpack: {
        config: 'webpack.lib.config.cjs',
        env: { NODE_ENV: 'local', production: true, development: true },
      },
    },
  },
  rules: {
    'react/require-default-props': 'off',
    'jsx-a11y/click-events-have-key-events': 'off',
    'jsx-a11y/no-noninteractive-element-interactions': 'off',
    'jsx-a11y/no-static-element-interactions': 'off',
    'jsx-a11y/control-has-associated-label': 'off',
    'import/no-extraneous-dependencies': [
      'error',
      { devDependencies: ['**/*.test.js', '**/*.spec.js', '**/*.config.js'] },
    ],
    // 'prettier/prettier': 'warn',
    'react/jsx-filename-extension': [2, { extensions: ['.js', '.jsx', '.ts', '.tsx'] }],
    'no-continue': 'off',
    'default-param-last': 'error',
    '@typescript-eslint/default-param-last': 'error',
    'no-undef': 'off',
    'no-underscore-dangle': 'off',
    'no-nested-ternary': 'off',
    'class-methods-use-this': 'off',
    'import/prefer-default-export': 'off',
    'func-names': ['error', 'as-needed'],
    'import/extensions': [
      'error',
      'ignorePackages',
      {
        js: 'never',
        jsx: 'never',
        ts: 'never',
        tsx: 'never',
      },
    ],
    'react/jsx-props-no-spreading': 'off',
    'arrow-body-style': 'off',
    'max-classes-per-file': ['error', 3],
    'no-plusplus': 'off',
    'no-shadow': 'off',
    '@typescript-eslint/no-empty-function': 'off',
    '@typescript-eslint/no-shadow': 'error',
    // Не обращаем внимания на символы конца строки
    'linebreak-style': 'off',
    // Отступы пока не проверяем
    indent: 'off',
    // Пустая строка в конце файла
    'eol-last': 'off',
    curly: ['error', 'multi-line'],
    'object-curly-spacing': ['warn', 'always'],
    'no-use-before-define': 'off',
    '@typescript-eslint/no-use-before-define': 'off',
    // Максимальная длина строки 120
    'max-len': [1, { code: 120 }],
    // Двойные кавычки в jsx
    'jsx-quotes': [1, 'prefer-double'],
    // Все остальные кавычки одинарные
    quotes: [1, 'single'],
    // Не включать пока не разберёмся в тонкостях правила
    'react/function-component-definition': [
      'off',
      {
        namedComponents: 'arrow-function',
      },
    ],
    'import/order': [
      'warn',
      {
        groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object', 'type'],
        alphabetize: {
          order: 'asc',
          caseInsensitive: true,
        },
        named: true,
        'newlines-between': 'always-and-inside-groups',
      },
    ],
    // Отключаем пока не определились с prop-types
    'react/prop-types': 'off',
    // '@typescript-eslint/ban-ts-comments': ['error', {
    //   'ts-check': false,
    //   'ts-expect-error': 'allow-with-description',
    //   'ts-ignore': true,
    //   'ts-nocheck': true,
    // }],
    '@typescript-eslint/array-type': ['error', { deafult: 'array', readonly: 'array' }],
    // '@typescript-eslint/no-magic-number': 'error',
    // '@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
    '@typescript-eslint/no-unused-vars': 'warn',
    'react/no-unused-prop-types': 'off',
    // Использование деструктуризации
    'react/destructuring-assignment': 'off',
    // Стрелочная функция может возвращать undefined
    'consistent-return': 'off',
    // Не обязательно использовать все зависимости в useEffect
    'react-hooks/exhaustive-deps': 'warn',
    // Проверка на наличие ключей в jsx,
    'react/jsx-key': 'error',
    // Использование any
    '@typescript-eslint/no-explicit-any': 'warn',
    'eslint-comments/require-description': 'off',
    'no-param-reassign': 'off',
    'no-useless-constructor': 'off',
    'react/react-in-jsx-scope': 'off',
    'no-restricted-syntax': 'off',
    'lines-between-class-members': [
      'error',
      'always',
      {
        exceptAfterSingleLine: true,
      },
    ],
    'eslint-comments/disable-enable-pair': 'off',
    'no-console': 'off',
  },
  overrides: [
    {
      // Особые правила для сторибука
      files: ['*.stories.tsx'],
      rules: {
        // В сторях можно писать any
        '@typescript-eslint/no-explicit-any': 'off',
      },
    },
  ],
};