Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/react-doctor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,4 @@ jobs:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: millionco/react-doctor@0b4f4f4bd248a154e64eb508a48347f71154b3f3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- uses: millionco/react-doctor@964622bf15fa5f8eef7e05196407aa08dc779087 # v2.2.7
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"docs:deploy": "gh-pages -d docs-dist",
"deploy": "npm run gh-pages",
"gh-pages": "npm run compile && cross-env GH_PAGES=1 npm run docs:build && npm run docs:deploy",
"lint": "eslint src/ --ext .tsx,.ts",
"lint": "eslint src/ tests/ --ext .tsx,.ts,.jsx,.js",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

In ESLint v9+ (and flat config mode, which is active here via eslint.config.mjs), the --ext command-line option has been deprecated and removed. Running eslint with --ext will result in a fatal error. Since flat config automatically determines which files to lint based on the files patterns in your configuration, you can safely remove the --ext option entirely.

Suggested change
"lint": "eslint src/ tests/ --ext .tsx,.ts,.jsx,.js",
"lint": "eslint src tests",

"prepublishOnly": "npm run compile && rc-np",
"prettier": "prettier --write --ignore-unknown .",
"start": "dumi dev",
Expand Down
1 change: 0 additions & 1 deletion src/hooks/useScrollTo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-param-reassign */
import * as React from 'react';
import { raf, useLayoutEffect, warning } from '@rc-component/util';
import type { GetKey, GetSize } from '../interface';
Expand Down
2 changes: 1 addition & 1 deletion tests/scroll.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ describe('List.Scroll', () => {
const holder = container.querySelector('ul');

const event = createEvent.wheel(holder, {
deltaY: 99999999999999999999,
deltaY: 1e20,
});
fireEvent(holder, event);

Expand Down
11 changes: 5 additions & 6 deletions tests/utils/domHook.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/* eslint-disable no-param-reassign */
const NO_EXIST = { __NOT_EXIST: true };

export function spyElementPrototypes(Element, properties) {
const propNames = Object.keys(properties);
const originDescriptors = {};

propNames.forEach(propName => {
propNames.forEach((propName) => {
const originDescriptor = Object.getOwnPropertyDescriptor(Element.prototype, propName);
originDescriptors[propName] = originDescriptor || NO_EXIST;

Expand All @@ -22,9 +21,10 @@ export function spyElementPrototypes(Element, properties) {
...spyProp,
set(value) {
if (spyProp.set) {
return spyProp.set.call(this, originDescriptor, value);
spyProp.set.call(this, originDescriptor, value);
} else {
originDescriptor.set(value);
}
Comment on lines 23 to 27

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

If originDescriptor is undefined (which happens if the property did not exist on Element.prototype originally) or if it is a data descriptor (which does not have a set method), calling originDescriptor.set(value) will throw a TypeError at runtime. Adding a guard check for originDescriptor?.set prevents potential test crashes.

Suggested change
if (spyProp.set) {
return spyProp.set.call(this, originDescriptor, value);
spyProp.set.call(this, originDescriptor, value);
} else {
originDescriptor.set(value);
}
if (spyProp.set) {
spyProp.set.call(this, originDescriptor, value);
} else if (originDescriptor && originDescriptor.set) {
originDescriptor.set(value);
}

return originDescriptor.set(value);
},
get() {
if (spyProp.get) {
Expand All @@ -39,7 +39,7 @@ export function spyElementPrototypes(Element, properties) {

return {
mockRestore() {
propNames.forEach(propName => {
propNames.forEach((propName) => {
const originDescriptor = originDescriptors[propName];
if (originDescriptor === NO_EXIST) {
delete Element.prototype[propName];
Expand All @@ -58,4 +58,3 @@ export function spyElementPrototype(Element, propName, property) {
[propName]: property,
});
}
/* eslint-enable no-param-reassign */
Loading