-
-
Notifications
You must be signed in to change notification settings - Fork 773
chore: update maintenance dependencies #1079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| import { FlatCompat } from '@eslint/eslintrc'; | ||
| import js from '@eslint/js'; | ||
| import tsEslintPlugin from '@typescript-eslint/eslint-plugin'; | ||
| import { createRequire } from 'node:module'; | ||
| import path from 'node:path'; | ||
| import { fileURLToPath } from 'node:url'; | ||
|
|
||
| const __filename = fileURLToPath(import.meta.url); | ||
| const __dirname = path.dirname(__filename); | ||
| const require = createRequire(import.meta.url); | ||
|
|
||
| const compat = new FlatCompat({ | ||
| baseDirectory: __dirname, | ||
| recommendedConfig: js.configs.recommended, | ||
| allConfig: js.configs.all, | ||
| }); | ||
|
|
||
| const recommendedTsRules = new Set( | ||
| Object.keys(tsEslintPlugin.configs.recommended.rules || {}), | ||
| ); | ||
| const noopRule = { | ||
| meta: { type: 'problem', docs: {}, schema: [] }, | ||
| create: () => ({}), | ||
| }; | ||
|
|
||
| function normalizeConfig(config) { | ||
| const next = { ...config }; | ||
|
|
||
| if (next.plugins?.['@typescript-eslint']) { | ||
| next.plugins = { ...next.plugins }; | ||
| delete next.plugins['@typescript-eslint']; | ||
| } | ||
|
|
||
| if (next.rules) { | ||
| next.rules = Object.fromEntries( | ||
| Object.entries(next.rules).filter(([ruleName]) => { | ||
| if (!ruleName.startsWith('@typescript-eslint/')) { | ||
| return true; | ||
| } | ||
| return ( | ||
| recommendedTsRules.has(ruleName) || | ||
| ruleName === '@typescript-eslint/ban-types' | ||
| ); | ||
| }), | ||
| ); | ||
| } | ||
|
|
||
| return next; | ||
| } | ||
|
|
||
| export default [ | ||
| { | ||
| ignores: [ | ||
| 'node_modules/', | ||
| 'coverage/', | ||
| 'es/', | ||
| 'lib/', | ||
| 'dist/', | ||
| 'docs-dist/', | ||
| '.dumi/', | ||
| '.doc/', | ||
| '.vercel/', | ||
| '.eslintrc.js', | ||
| 'src/index.d.ts', | ||
| ], | ||
| }, | ||
| { | ||
| plugins: { | ||
| '@typescript-eslint': { | ||
| ...tsEslintPlugin, | ||
| rules: { | ||
| ...tsEslintPlugin.rules, | ||
| 'ban-types': noopRule, | ||
| 'consistent-type-exports': noopRule, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| ...compat.config(require('./.eslintrc.js')).map(normalizeConfig), | ||
| { | ||
| rules: { | ||
| '@typescript-eslint/ban-types': 'off', | ||
| '@typescript-eslint/no-empty-object-type': 'off', | ||
| '@typescript-eslint/no-unsafe-function-type': 'off', | ||
| '@typescript-eslint/no-unused-vars': 'off', | ||
| }, | ||
| }, | ||
| ]; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| /// <reference types="jest" /> | ||
| /// <reference types="node" /> | ||
| /// <reference types="react" /> | ||
| /// <reference types="react-dom" /> | ||
| /// <reference types="@testing-library/jest-dom" /> | ||
|
|
||
| declare module '*.css'; | ||
| declare module '*.less'; | ||
| declare module 'jsonp'; | ||
|
|
||
| declare namespace JSX { | ||
| type Element = React.JSX.Element; | ||
| interface ElementClass extends React.JSX.ElementClass {} | ||
| interface ElementAttributesProperty extends React.JSX.ElementAttributesProperty {} | ||
| interface ElementChildrenAttribute extends React.JSX.ElementChildrenAttribute {} | ||
| type LibraryManagedAttributes<C, P> = React.JSX.LibraryManagedAttributes<C, P>; | ||
| interface IntrinsicAttributes extends React.JSX.IntrinsicAttributes {} | ||
| interface IntrinsicClassAttributes<T> extends React.JSX.IntrinsicClassAttributes<T> {} | ||
| interface IntrinsicElements extends React.JSX.IntrinsicElements {} | ||
| } | ||
|
|
||
| declare namespace jest { | ||
| interface Matchers<R> { | ||
| lastCalledWith(...expected: unknown[]): R; | ||
| nthCalledWith(nthCall: number, ...expected: unknown[]): R; | ||
| toBeCalled(): R; | ||
| toBeCalledTimes(expected: number): R; | ||
| toBeCalledWith(...expected: unknown[]): R; | ||
| } | ||
| } | ||
|
|
||
| declare const vi: { | ||
| fn: <T extends (...args: any[]) => any = (...args: any[]) => any>(implementation?: T) => jest.MockedFunction<T>; | ||
| mock: (moduleName: string, factory?: (importOriginal: <T>() => Promise<T>) => unknown) => void; | ||
| spyOn: typeof jest.spyOn; | ||
| useFakeTimers: () => void; | ||
| useRealTimers: () => void; | ||
| advanceTimersByTime: (msToRun: number) => void; | ||
| clearAllTimers: () => void; | ||
| runAllTimers: () => void; | ||
| importActual: <T>(moduleName: string) => Promise<T>; | ||
| clearAllMocks: () => void; | ||
| resetAllMocks: () => void; | ||
| restoreAllMocks: () => void; | ||
| }; | ||
|
|
||
|
|
||
| declare module 'moment/locale/zh-cn'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import * as React from 'react'; | ||
|
|
||
| declare module 'react' { | ||
| type ReactText = string | number; | ||
| function useRef<T = undefined>(): React.MutableRefObject<T | undefined>; | ||
| function isValidElement<P = any>(object: {} | null | undefined): object is React.ReactElement<P>; | ||
| function cloneElement<P = any>( | ||
| element: React.ReactElement<P>, | ||
| props?: (Partial<P> & React.Attributes) | null, | ||
| ...children: React.ReactNode[] | ||
| ): React.ReactElement<P>; | ||
| } | ||
|
|
||
| declare module 'react-dom' { | ||
| function hydrate(element: React.ReactNode, container: Element | DocumentFragment): void; | ||
| } | ||
|
Comment on lines
+14
to
+16
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shimming hydrate in react-dom for React 19 is unsafe. React 19 has completely removed hydrate from react-dom (replaced by hydrateRoot in react-dom/client). Shimming the type will allow the code to compile but will result in runtime crashes if hydrate is called. It is recommended to migrate the usage to hydrateRoot instead.
Comment on lines
+14
to
+16
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
rg -nP --glob '!react-compat.d.ts' --type=ts --type=tsx '\bhydrate\s*\(' .Repository: react-component/slider Length of output: 188 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Locate the compatibility file and related React API usages.
git ls-files | rg '(^|/)react-compat\.d\.ts$|(^|/)package\.json$|(^|/)tsconfig.*\.json$|(^|/)react-dom|(^|/)react\.d\.ts$'
printf '\n--- react-compat.d.ts ---\n'
cat -n react-compat.d.ts
printf '\n--- hydrate / hydrateRoot usages ---\n'
rg -n --glob '*.ts' --glob '*.tsx' --glob '*.d.ts' '\bhydrateRoot\b|\bhydrate\s*\(' .
printf '\n--- useRef overloads/usages in compat file ---\n'
rg -n --glob '*.d.ts' '\buseRef\b' react-compat.d.tsRepository: react-component/slider Length of output: 1200 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '\n--- package.json ---\n'
cat -n package.json
printf '\n--- tsconfig.json ---\n'
cat -n tsconfig.jsonRepository: react-component/slider Length of output: 5326 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Check whether the repo targets React 18/19 or ships its own typings shim.
rg -n --glob 'package.json' '"react"|"react-dom"|"`@types/react`"|"`@types/react-dom`"'Repository: react-component/slider Length of output: 160 🏁 Script executed: #!/bin/bash
set -euo pipefail
cat -n package.jsonRepository: react-component/slider Length of output: 3886 不要把 🤖 Prompt for AI Agents |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: react-component/slider
Length of output: 219
🏁 Script executed:
Repository: react-component/slider
Length of output: 3863
🏁 Script executed:
Repository: react-component/slider
Length of output: 20999
🌐 Web query:
@typescript-eslint/eslint-plugin recommended rules no-explicit-any no-empty-interface no-inferrable-types💡 Result:
In the
@typescript-eslint/eslint-plugin, the inclusion of these rules in the recommended configuration is as follows: -@typescript-eslint/no-explicit-any: Included in the recommended configuration [1]. -@typescript-eslint/no-empty-interface: Historically included in the recommended configuration, but this rule is now deprecated in favor of@typescript-eslint/no-empty-object-type[2], which is included in the recommended configuration [1]. -@typescript-eslint/no-inferrable-types: This rule is not included in the recommended configuration [1][3]. It is part of the stylistic configuration [4]. Summary Table Rule | Recommended Config | Notes --- | --- | ---@typescript-eslint/no-explicit-any| Yes [1] | -@typescript-eslint/no-empty-interface| Deprecated [2] | Replaced by@typescript-eslint/no-empty-object-type(included) [1][2]@typescript-eslint/no-inferrable-types| No [1][3] | Included in stylistic config [4] As of June 2026, typescript-eslint recommends using shared configurations such as recommended, strict, or stylistic [5][6]. The recommended configuration focuses on rules for code correctness, while the stylistic configuration contains rules that enforce consistent coding patterns without necessarily catching bugs [5].Citations:
别静默丢掉自定义 TS 规则 这里会把
.eslintrc.js里的@typescript-eslint/no-inferrable-types过滤掉;@typescript-eslint/no-empty-interface也需要单独迁移/映射到@typescript-eslint/no-empty-object-type,否则不会自动保留等价约束。🤖 Prompt for AI Agents