-
-
Notifications
You must be signed in to change notification settings - Fork 160
chore: update maintenance dependencies #317
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
+3
to
+16
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. Globally overriding and augmenting core React types (like |
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,26 +1,34 @@ | ||||||
| { | ||||||
| "compilerOptions": { | ||||||
| "target": "esnext", | ||||||
| "moduleResolution": "node", | ||||||
| "baseUrl": "./", | ||||||
| "moduleResolution": "bundler", | ||||||
| "jsx": "react", | ||||||
| "declaration": true, | ||||||
| "skipLibCheck": true, | ||||||
|
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. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🌐 Web query:
💡 Result: Yes, TypeScript's skipLibCheck option applies to all declaration files (.d.ts) included in your compilation, including project-local ones [1]. When skipLibCheck is enabled, it instructs the compiler to skip the "check each top-level statement or declaration" step for all.d.ts files [2][3]. This behavior has several specific implications for module augmentation and declaration merging: 1. Scope of Effect: The option does not distinguish between files in node_modules and your own project-local.d.ts files [1][4]. If a declaration file is part of your compilation (e.g., included via tsconfig), it will be skipped regardless of its location [1]. 2. Impact on Type Checking: skipLibCheck does not mean that.d.ts files are completely ignored [5]. TypeScript will still process and use the types contained within them when you reference them in your source code [6][5]. However, it prevents the compiler from performing a full, proactive validation of every declaration within those files [6][2]. 3. Module Augmentation and Merging: Because skipLibCheck skips the explicit validation of.d.ts files, it may hide errors that would otherwise be caught during declaration merging or module augmentation [1]. For example, if your module augmentation in a.ts file conflicts with a definition in a.d.ts file, the compiler might suppress or fail to report errors related to that.d.ts file's internal consistency [1][7]. 4. No Partial Control: There is currently no built-in mechanism in TypeScript to enable skipLibCheck for node_modules while keeping it disabled for project-local declaration files [8][1]. In practice, if you need to ensure that your local declaration files are rigorously checked—especially when performing complex module augmentation or merging—you should keep skipLibCheck set to false [9]. The performance cost of checking project-local.d.ts files is generally significantly lower than the cost of checking the entire node_modules directory [8]. Citations:
不要用
建议修改- "skipLibCheck": true,
+ "skipLibCheck": false,📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| "esModuleInterop": true, | ||||||
| "paths": { | ||||||
| "@/*": [ | ||||||
| "src/*" | ||||||
| "./src/*" | ||||||
| ], | ||||||
| "@@/*": [ | ||||||
| ".dumi/tmp/*" | ||||||
| "./.dumi/tmp/*" | ||||||
| ], | ||||||
| "@rc-component/progress": [ | ||||||
| "src/index.ts" | ||||||
| "./src/index.ts" | ||||||
| ] | ||||||
| }, | ||||||
| "ignoreDeprecations": "5.0" | ||||||
| "noImplicitAny": false, | ||||||
| "strictNullChecks": false, | ||||||
| "strictPropertyInitialization": false, | ||||||
| "strictFunctionTypes": false, | ||||||
| "strict": false, | ||||||
| "noImplicitThis": false, | ||||||
| "strictBindCallApply": false, | ||||||
| "module": "ESNext" | ||||||
| }, | ||||||
| "include": [ | ||||||
| "react-compat.d.ts", | ||||||
| "global.d.ts", | ||||||
| ".fatherrc.ts", | ||||||
| ".dumirc.ts", | ||||||
| "src", | ||||||
|
|
||||||
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/progress
Length of output: 944
🏁 Script executed:
Repository: react-component/progress
Length of output: 3317
🏁 Script executed:
Repository: react-component/progress
Length of output: 539
🏁 Script executed:
Repository: react-component/progress
Length of output: 539
保留
@typescript-eslint/no-explicit-any的迁移规则.eslintrc.js:11里有显式关闭,但eslint.config.mjs:42-46只保留 recommended 里的 TS 规则和@typescript-eslint/ban-types,这个 override 会在迁移时被丢掉;后面的全局rules里也没有再关回去。可把它补进 allowlist,或在 flat config 末尾显式关闭。🤖 Prompt for AI Agents