/
githubmirror
/
client
Обзор
Документация
Войти
/
githubmirror
/
client
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
shared/eslint.config.mjs
284 строки
10 KB
chrisnojima
fix(mobile): migrate off expo 57 legacy shims, add deprecation lint (#29436)
20 июл 2026, 17:55
Не верифицирован
20 июл 2026, 17:55
ea83197
Код
Авторство
О чём код?
import {fixupConfigRules} from '@eslint/compat' import eslint from '@eslint/js' import pluginPromise from 'eslint-plugin-promise' import reactPlugin from 'eslint-plugin-react' import reactHooks from 'eslint-plugin-react-hooks' import tseslint from 'typescript-eslint' const ignores = [ '**/*.d.ts', 'babel.config.js', 'common-adapters/icon.constants-gen.desktop.tsx', 'common-adapters/icon.constants-gen.native.tsx', 'common-adapters/icon.constants-gen.shared.tsx', 'coverage-ts/**', 'desktop/build/**', 'desktop/dist/**', 'desktop/release/**', 'desktop/renderer/renderer-load.desktop.js', 'desktop/webpack.config.mts', 'lodash.4.17.5.strict/**', 'markdown/parser.js', 'metro.config.js', 'node_modules/**', 'override-d.ts', 'react-native/react-native-contacts', 'react-native/wipe-cache.js', 'rn-cli.config.js', 'rn-transformer.js', 'tests/results/**', ] const rules = { '@typescript-eslint/await-thenable': 'error', '@typescript-eslint/ban-ts-comment': [ 'error', { minimumDescriptionLength: 3, 'ts-check': false, 'ts-expect-error': 'allow-with-description', 'ts-ignore': true, 'ts-nocheck': true, }, ], '@typescript-eslint/class-literal-property-style': 'error', '@typescript-eslint/consistent-type-assertions': 'error', '@typescript-eslint/consistent-type-exports': 'error', '@typescript-eslint/consistent-type-imports': 'error', '@typescript-eslint/default-param-last': 'error', '@typescript-eslint/method-signature-style': 'error', '@typescript-eslint/no-array-constructor': 'error', '@typescript-eslint/no-base-to-string': 'error', '@typescript-eslint/no-dupe-class-members': 'error', '@typescript-eslint/no-dynamic-delete': 'error', '@typescript-eslint/no-empty-object-type': 'warn', '@typescript-eslint/no-deprecated': 'error', '@typescript-eslint/no-explicit-any': 'warn', '@typescript-eslint/no-extra-non-null-assertion': 'error', '@typescript-eslint/no-extraneous-class': 'error', '@typescript-eslint/no-floating-promises': 'error', '@typescript-eslint/no-for-in-array': 'error', '@typescript-eslint/no-implied-eval': 'error', '@typescript-eslint/no-invalid-void-type': ['error', {allowInGenericTypeArguments: true}], '@typescript-eslint/no-loop-func': 'error', '@typescript-eslint/no-meaningless-void-operator': 'error', '@typescript-eslint/no-misused-new': 'error', '@typescript-eslint/no-misused-promises': 'error', '@typescript-eslint/no-namespace': 'error', '@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error', '@typescript-eslint/no-non-null-asserted-optional-chain': 'error', '@typescript-eslint/no-redeclare': 'error', '@typescript-eslint/no-redundant-type-constituents': 'error', '@typescript-eslint/no-require-imports': 'off', '@typescript-eslint/no-restricted-imports': [ 'error', { paths: [ { message: 'Deprecated legacy API; use the class-based API from expo-contacts', name: 'expo-contacts/legacy', }, { message: 'Deprecated legacy API; use the class-based API from expo-media-library', name: 'expo-media-library/legacy', }, { message: 'Deprecated legacy API; use File/Directory from expo-file-system', name: 'expo-file-system/legacy', }, ], }, ], '@typescript-eslint/no-this-alias': 'error', '@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error', '@typescript-eslint/no-unnecessary-condition': ['error', {allowConstantLoopConditions: true}], '@typescript-eslint/no-unnecessary-qualifier': 'error', '@typescript-eslint/no-unnecessary-type-arguments': 'error', '@typescript-eslint/no-unnecessary-type-assertion': 'warn', '@typescript-eslint/no-unnecessary-type-constraint': 'error', '@typescript-eslint/no-unsafe-argument': 'warn', '@typescript-eslint/no-unsafe-assignment': 'warn', '@typescript-eslint/no-unsafe-call': 'warn', '@typescript-eslint/no-unsafe-enum-comparison': 'warn', '@typescript-eslint/no-unsafe-member-access': 'warn', '@typescript-eslint/no-unsafe-return': 'warn', '@typescript-eslint/no-unused-expressions': 'error', '@typescript-eslint/no-unused-vars': [ 'error', {argsIgnorePattern: '^_', varsIgnorePattern: '^_', ignoreRestSiblings: true}, ], '@typescript-eslint/no-useless-constructor': 'error', '@typescript-eslint/only-throw-error': 'error', '@typescript-eslint/prefer-as-const': 'error', '@typescript-eslint/prefer-for-of': 'error', '@typescript-eslint/prefer-function-type': 'error', '@typescript-eslint/prefer-includes': 'error', '@typescript-eslint/prefer-literal-enum-member': 'error', '@typescript-eslint/prefer-namespace-keyword': 'error', '@typescript-eslint/prefer-optional-chain': 'error', '@typescript-eslint/prefer-promise-reject-errors': 'error', '@typescript-eslint/prefer-reduce-type-parameter': 'warn', '@typescript-eslint/prefer-return-this-type': 'error', '@typescript-eslint/prefer-string-starts-ends-with': 'error', '@typescript-eslint/promise-function-async': 'error', '@typescript-eslint/require-await': 'error', '@typescript-eslint/restrict-plus-operands': [ 'error', { allowAny: false, allowBoolean: false, allowNullish: false, allowNumberAndString: false, allowRegExp: false, }, ], '@typescript-eslint/restrict-template-expressions': 'error', '@typescript-eslint/switch-exhaustiveness-check': ['error', {considerDefaultExhaustiveForUnions: true}], '@typescript-eslint/triple-slash-reference': 'error', '@typescript-eslint/unbound-method': 'error', '@typescript-eslint/unified-signatures': 'error', 'array-callback-return': 'error', 'no-constant-condition': ['warn', {checkLoops: false}], 'no-empty': ['error', {allowEmptyCatch: true}], 'no-implied-eval': 'error', 'no-script-url': 'error', 'no-self-compare': 'error', 'no-sequences': 'error', 'prefer-const': 'error', 'promise/catch-or-return': 'error', 'promise/no-new-statics': 'error', 'promise/no-return-in-finally': 'error', 'promise/always-return': ['error', {ignoreLastCallback: true}], 'promise/no-return-wrap': 'error', 'promise/param-names': 'error', 'promise/valid-params': 'error', 'promise/no-nesting': 'error', 'react-hooks/exhaustive-deps': 'error', 'react-hooks/rules-of-hooks': 'error', 'react/boolean-prop-naming': 'error', 'react/jsx-boolean-value': ['error', 'always'], 'react/jsx-fragments': ['error', 'syntax'], 'react/jsx-key': 'error', 'react/jsx-no-comment-textnodes': 'error', 'react/jsx-no-duplicate-props': 'error', 'react/jsx-no-target-blank': 'error', 'react/jsx-no-undef': 'error', 'react/jsx-uses-vars': 'warn', 'react/no-access-state-in-setstate': 'error', 'react/no-children-prop': 'off', 'react/no-danger': 'error', 'react/no-danger-with-children': 'error', 'react/no-deprecated': 'error', 'react/no-did-mount-set-state': 'warn', 'react/no-did-update-set-state': 'warn', 'react/no-direct-mutation-state': 'error', 'react/no-find-dom-node': 'warn', 'react/no-is-mounted': 'error', 'react/no-redundant-should-component-update': 'error', 'react/no-render-return-value': 'error', 'react/no-string-refs': 'error', 'react/no-this-in-sfc': 'error', 'react/no-typos': 'warn', 'react/no-unknown-property': 'error', 'react/no-unsafe': 'error', 'react/no-unused-state': 'error', 'react/no-will-update-set-state': 'warn', 'react/prefer-stateless-function': 'error', 'react/prop-types': 'off', 'react/react-in-jsx-scope': 'off', 'react/style-prop-object': 'error', 'react/void-dom-elements-no-children': 'error', 'sort-keys': 'off', strict: ['error', 'global'], 'react-hooks/refs': 'error', } export default [ {name: 'ignores', ignores}, { name: 'eslint generic', ...eslint.configs.recommended, ignores: [...ignores, '**/*.js'], }, ...tseslint.configs.recommended.map(config => ({ ...config, files: ['**/*.mts', '**/*.ts', '**/*.tsx', '**/*.d.ts', '**/*.native.tsx', '**/*.desktop.tsx'], })), ...tseslint.configs.recommendedTypeChecked.map(config => ({ ...config, files: ['**/*.mts', '**/*.ts', '**/*.tsx', '**/*.native.tsx', '**/*.desktop.tsx'], languageOptions: { ...config.languageOptions, parserOptions: { project: ['./tsconfig.native.json', './tsconfig.desktop.json', './tests/e2e/ios-appium/tsconfig.json'], }, }, })), { name: 'react-hooks', ...reactHooks.configs.flat.recommended, }, pluginPromise.configs['flat/recommended'], ...fixupConfigRules({ name: 'react', ...reactPlugin.configs.flat.recommended, settings: { ...reactPlugin.configs.flat.recommended.settings, react: {version: 'detect'}, }, }), ...fixupConfigRules({ name: 'react-jsx', ...reactPlugin.configs.flat['jsx-runtime'], }), { ignores: [...ignores, '**/*.js'], files: ['**/*.mts', '**/*.ts', '**/*.tsx', '**/*.d.ts', '**/*.native.tsx', '**/*.desktop.tsx'], languageOptions: { ecmaVersion: 2022, sourceType: 'module', globals: { __DEV__: false, __HOT__: false, __FILE_SUFFIX__: false, cancelAnimationFrame: 'readonly', requestAnimationFrame: 'readonly', }, }, linterOptions: { reportUnusedDisableDirectives: true, }, name: 'kblint', rules, settings: { react: {version: 'detect'}, }, }, { name: 'js', ignores: [...ignores, '**/*.tsx', '**/*.ts', '**/*.d.ts'], files: ['**/*.js'], rules: { 'array-callback-return': 'error', 'no-constant-condition': ['warn', {checkLoops: false}], 'no-empty': ['error', {allowEmptyCatch: true}], 'no-implied-eval': 'error', 'no-script-url': 'error', 'no-self-compare': 'error', 'no-sequences': 'error', 'no-undef': 'error', 'no-unused-expressions': 'error', 'prefer-const': 'error', 'sort-keys': ['error', 'asc', {caseSensitive: true, natural: false}], strict: ['error', 'global'], }, }, { // vendored from react-native-zoom-toolkit; tracks upstream, don't hold it to our deprecation rule files: ['util/zoom-toolkit/**'], name: 'zoom-toolkit-vendored', rules: { '@typescript-eslint/no-deprecated': 'off', }, }, ]