Skip to content
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

feat: 支持 React 18 (兼容 React 16/17) #2373

Merged
merged 12 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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: 3 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = {
},
parser: '@typescript-eslint/parser',
parserOptions: { tsconfigRootDir: __dirname },
plugins: ['prettier', '@typescript-eslint', 'import', 'vue'],
plugins: ['@typescript-eslint', 'import', 'vue'],
settings: {
jest: {
version: 26,
Expand Down Expand Up @@ -131,6 +131,8 @@ module.exports = {
curly: [2, 'all'],
'guard-for-in': 0,
'vue/multi-word-component-names': 0,
'vue/no-reserved-component-names': 0,
'vue/prefer-import-from-vue': 1,
'no-nested-ternary': [2],
'no-restricted-imports': [
2,
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/auto-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

- uses: pnpm/action-setup@v2
with:
version: 7
version: 8

- name: Use Node.js 16
uses: actions/setup-node@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:

- uses: pnpm/action-setup@v2
with:
version: 7
version: 8

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
Expand Down
1 change: 1 addition & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"no-duplicate-heading": false,
"link-fragments": false,
"code-block-style": false,
"no-bare-urls": false,
"MD003": {
"style": "atx"
},
Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
npm_config_legacy_peer_deps=true
side-effects-cache=false
prefer-workspace-packages=true
auto-install-peers=false
Copy link
Member Author

@lijinke666 lijinke666 Oct 17, 2023

Choose a reason for hiding this comment

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

pnpm/pnpm#6649 (comment)

CI 升级到 pnpm 8 后安装依赖报错的解决方案

1 change: 1 addition & 0 deletions .stylelintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"alpha-value-notation": null,
"color-function-notation": null,
"import-notation": null,
"media-feature-range-notation": "prefix",
"function-no-unknown": [
true,
{
Expand Down
126 changes: 63 additions & 63 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,92 +79,92 @@
"eslint --fix"
],
"*.less": [
"stylelint --syntax --fix"
"stylelint --custom-syntax --fix"
]
},
"devDependencies": {
"@babel/core": "^7.17.9",
"@commitlint/cli": "^17.2.0",
"@commitlint/config-conventional": "^17.2.0",
"@microsoft/api-extractor": "^7.33.6",
"@babel/core": "^7.23.2",
"@commitlint/cli": "^17.8.0",
"@commitlint/config-conventional": "^17.8.0",
"@microsoft/api-extractor": "^7.38.0",
"@originjs/vite-plugin-commonjs": "^1.0.3",
"@rollup/plugin-alias": "^3.1.9",
"@rollup/plugin-commonjs": "^21.1.0",
"@rollup/plugin-node-resolve": "^13.2.1",
"@rollup/plugin-replace": "^3.0.0",
"@rollup/plugin-terser": "^0.3.0",
"@rollup/plugin-typescript": "^8.2.5",
"@rushstack/eslint-patch": "^1.2.0",
"@semantic-release/changelog": "^6.0.1",
"@rollup/plugin-alias": "^5.0.1",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-replace": "^5.0.4",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.5",
"@rushstack/eslint-patch": "^1.5.1",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@swc/core": "^1.3.25",
"@swc/jest": "^0.2.24",
"@swc/core": "^1.3.93",
"@swc/jest": "^0.2.29",
"@types/jest": "^27.5.2",
"@types/lodash": "4.14.186",
"@types/node": "^18.11.9",
"@types/rollup-plugin-peer-deps-external": "^2.2.1",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"@vitejs/plugin-react": "^3.0.1",
"@vitejs/plugin-vue": "^4.0.0",
"@vitejs/plugin-vue-jsx": "^3.0.0",
"@vue/eslint-config-prettier": "^7.0.0",
"@vue/eslint-config-typescript": "^10.0.0",
"@vue/vue3-jest": "^29.2.0",
"@types/lodash": "4.14.199",
"@types/node": "^20.8.6",
"@types/rollup-plugin-peer-deps-external": "^2.2.2",
"@typescript-eslint/eslint-plugin": "^6.8.0",
"@typescript-eslint/parser": "^6.8.0",
"@vitejs/plugin-react": "^4.1.0",
"@vitejs/plugin-vue": "^4.4.0",
"@vitejs/plugin-vue-jsx": "^3.0.2",
"@vue/eslint-config-prettier": "^8.0.0",
"@vue/eslint-config-typescript": "^12.0.0",
"@vue/vue3-jest": "^29.2.6",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^26.6.3",
"babel-jest": "^29.7.0",
"bundlesize": "^0.18.1",
"case-police": "^0.5.10",
"concurrently": "^7.5.0",
"case-police": "^0.6.1",
"concurrently": "^8.2.1",
"cpx": "^1.5.0",
"cross-env": "^7.0.3",
"eslint": "^7.32.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-jest": "^25.0.5",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.26.1",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-vue": "^8.5.0",
"eslint": "^8.51.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-jest": "^27.4.2",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-vue": "^9.17.0",
"gh-pages": "^3.2.3",
"glob": "^8.0.3",
"husky": "^8.0.2",
"inquirer": "^8.2.0",
"inquirer-autocomplete-prompt": "^2.0.0",
"glob": "^10.3.10",
"husky": "^8.0.3",
"inquirer": "^9.2.11",
"inquirer-autocomplete-prompt": "^3.0.1",
"jest": "^26.6.3",
"jest-electron": "^0.1.12",
"jest-extended": "^0.11.5",
"jest-less-loader": "^0.2.0",
"jest-raw-loader": "^1.0.1",
"jest-url-loader": "^0.1.0",
"less": "^4.1.3",
"lint-staged": "^13.0.3",
"less": "^4.2.0",
"lint-staged": "^15.0.1",
"lodash-es": "^4.17.21",
"markdownlint-cli": "^0.32.2",
"markdownlint-cli": "^0.37.0",
"npm-run-all": "^4.1.5",
"ora": "^6.1.2",
"postcss": "^8.4.19",
"ora": "^7.0.1",
"postcss": "^8.4.31",
"postcss-less": "^6.0.0",
"prettier": "2.7.1",
"rimraf": "^3.0.2",
"rollup": "^2.70.2",
"prettier": "3.0.3",
"rimraf": "^5.0.5",
"rollup": "^4.1.4",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-postcss": "^4.0.2",
"rollup-plugin-typescript2": "^0.34.1",
"rollup-plugin-visualizer": "^5.6.0",
"semantic-release": "^19.0.5",
"rollup-plugin-typescript2": "^0.36.0",
"rollup-plugin-visualizer": "^5.9.2",
"semantic-release": "^22.0.5",
"semantic-release-monorepo": "^7.0.5",
"semver": "^7.3.8",
"stylelint": "^14.14.1",
"stylelint-config-prettier": "^9.0.4",
"stylelint-config-standard": "^29.0.0",
"ts-jest": "^29.0.3",
"tslib": "^2.4.1",
"typescript": "^4.9.4",
"vite": "^4.0.4",
"vite-plugin-imp": "^2.3.1",
"semver": "^7.5.4",
"stylelint": "^15.10.3",
"stylelint-config-prettier": "^9.0.5",
"stylelint-config-standard": "^34.0.0",
"ts-jest": "^29.1.1",
"tslib": "^2.6.2",
"typescript": "^5.2.2",
"vite": "^4.4.11",
"vite-plugin-imp": "^2.4.0",
"vue-jest": "^5.0.0-alpha.10"
},
"license": "MIT",
Expand Down
6 changes: 3 additions & 3 deletions packages/s2-core/__tests__/spreadsheet/row-link-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ describe('Row Text Link Tests', () => {
},
} as any);

expect(linkFieldJump).toBeCalledWith({
expect(linkFieldJump).toHaveBeenCalledWith({
field: 'province',
cellData: rowNode,
record: {
Expand All @@ -122,7 +122,7 @@ describe('Row Text Link Tests', () => {
},
} as any);

expect(linkFieldJump).toBeCalledWith({
expect(linkFieldJump).toHaveBeenCalledWith({
field: 'city',
cellData: rowNode,
record: {
Expand All @@ -149,7 +149,7 @@ describe('Row Text Link Tests', () => {
},
} as any);

expect(linkFieldJump).toBeCalledWith({
expect(linkFieldJump).toHaveBeenCalledWith({
field: 'province',
cellData: rowNode,
record: {
Expand Down
4 changes: 2 additions & 2 deletions packages/s2-core/__tests__/spreadsheet/spread-sheet-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ describe('SpreadSheet Tests', () => {

s2.destroy();

expect(destroyFn).toBeCalled();
expect(destroyFn).toHaveBeenCalled();
expect(container.querySelectorAll('canvas')).toHaveLength(0);
expect(document.body.style.overscrollBehavior).toBeFalsy();
},
Expand Down Expand Up @@ -398,7 +398,7 @@ describe('SpreadSheet Tests', () => {
}, 1000);
});

expect(destroyFn).toBeCalled();
expect(destroyFn).toHaveBeenCalled();
expect(container.querySelectorAll('canvas')).toHaveLength(0);

s2.destroy();
Expand Down
30 changes: 15 additions & 15 deletions packages/s2-core/__tests__/spreadsheet/theme-spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
/* eslint-disable jest/expect-expect */
import { createPivotSheet } from 'tests/util/helpers';
import { Text, type Group } from '@antv/g';
import { get } from 'lodash';
import { Text, type Group, type Image } from '@antv/g';
import type {
TextBaseline,
TextTheme,
ThemeCfg,
} from '@/common/interface/theme';
import type { PivotSheet } from '@/sheet-type';
import { createPivotSheet } from 'tests/util/helpers';
import type { RowCell } from '@/cell';
import {
CellType,
EXTRA_COLUMN_FIELD,
Expand All @@ -16,8 +11,13 @@
type S2DataConfig,
type TextAlign,
} from '@/common';
import type { RowCell } from '@/cell';
import type {
TextBaseline,
TextTheme,
ThemeCfg,
} from '@/common/interface/theme';
import type { Node } from '@/facet/layout/node';
import type { PivotSheet } from '@/sheet-type';

describe('SpreadSheet Theme Tests', () => {
let s2: PivotSheet;
Expand Down Expand Up @@ -164,8 +164,8 @@
});
await s2.render();
const rowCell = s2.facet.rowHeader!.children[0] as RowCell;
const actionIcon = get(rowCell, 'actionIcons.[0]') as GuiIcon;
const actionIcon = get(rowCell, 'actionIcons.[0]') as unknown as GuiIcon;
// @ts-ignore

Check warning on line 168 in packages/s2-core/__tests__/spreadsheet/theme-spec.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Do not use "@ts-ignore" because it alters compilation errors
const cfg = actionIcon.cfg;

expect(actionIcon.name).toEqual(iconInfo.name);
Expand Down Expand Up @@ -201,15 +201,15 @@

const rowCell = s2.facet.rowHeader!.children[0] as RowCell;

const rowCellWidth = get(rowCell, 'meta.width');
const actionIcon = get(rowCell, 'actionIcons.[0]') as Image;
const rowCellWidth = rowCell.getMeta().width;
const actionIcon = rowCell.getActionIcons()[0];
// @ts-ignore

Check warning on line 206 in packages/s2-core/__tests__/spreadsheet/theme-spec.ts

View workflow job for this annotation

GitHub Actions / lint (18)

Do not use "@ts-ignore" because it alters compilation errors
const actionIconCfg = actionIcon.cfg;

expect(actionIconCfg.x).toBeGreaterThanOrEqual(0);
expect(actionIconCfg.x! + actionIconCfg.width!).toBeLessThanOrEqual(
rowCellWidth,
);
expect(
(actionIconCfg.x as number) + (actionIconCfg.width as number),
).toBeLessThanOrEqual(rowCellWidth);
},
);
});
Expand Down
3 changes: 2 additions & 1 deletion packages/s2-core/__tests__/unit/cell/col-cell-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@

set(colCell, 'actualTextWidth', actualTextWidth); // 文字总长度

const getTextPosition = get(colCell, 'getTextPosition').bind(colCell);
// @ts-ignore
const getTextPosition = colCell.getTextPosition.bind(colCell);

expect(getTextPosition()).toEqual({
x: textX,
Expand Down Expand Up @@ -107,7 +108,7 @@
});

describe('Condition Tests', () => {
const s2 = createPivotSheet({

Check warning on line 111 in packages/s2-core/__tests__/unit/cell/col-cell-spec.ts

View workflow job for this annotation

GitHub Actions / lint (18)

's2' is already declared in the upper scope on line 16 column 7
conditions: {
text: [
{
Expand Down
8 changes: 4 additions & 4 deletions packages/s2-core/__tests__/unit/cell/data-cell-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
const linkLength = maxX - minX;

expect(
Math.abs(linkLength - get(dataCell, 'actualTextWidth')),
Math.abs(linkLength - dataCell.getActualTextWidth()),
).toBeLessThanOrEqual(2);

// link shape 的中点坐标与 text 中点对齐
Expand Down Expand Up @@ -125,7 +125,7 @@
});

test('should return correct formatted value', () => {
const formatter: Formatter = (_, data) => `${get(data, 'value') * 10}`;
const formatter: Formatter = (_, data) => `${get(data, 'value')! * 10}`;

jest.spyOn(s2.dataSet, 'getFieldFormatter').mockReturnValue(formatter);
const dataCell = new DataCell(meta, s2);
Expand Down Expand Up @@ -210,7 +210,7 @@
});
});
describe('Condition by formattedValue Tests', () => {
const s2 = createPivotSheet(

Check warning on line 213 in packages/s2-core/__tests__/unit/cell/data-cell-spec.ts

View workflow job for this annotation

GitHub Actions / lint (18)

's2' is already declared in the upper scope on line 52 column 7
{
conditions: {
text: [
Expand Down Expand Up @@ -256,7 +256,7 @@
});
});
describe('Condition Tests', () => {
const s2 = createPivotSheet({

Check warning on line 259 in packages/s2-core/__tests__/unit/cell/data-cell-spec.ts

View workflow job for this annotation

GitHub Actions / lint (18)

's2' is already declared in the upper scope on line 52 column 7
conditions: {
text: [
{
Expand Down Expand Up @@ -348,7 +348,7 @@
const dataCell = findDataCell(s2, 'cost');

expect(
(get(dataCell, 'backgroundShape') as Rect).parsedStyle.fill,
(get(dataCell, 'backgroundShape') as unknown as Rect).parsedStyle.fill,
).toBeColor('#fffae6');
expect(dataCell?.getTextShape().parsedStyle.fill).toBeColor(
DEFAULT_FONT_COLOR,
Expand Down Expand Up @@ -392,7 +392,7 @@
const dataCell = new DataCell(anotherMeta, s2);

expect(
get(dataCell, 'conditionIntervalShape.parsedStyle.width') +
get(dataCell, 'conditionIntervalShape.parsedStyle.width')! +
s2.theme.dataCell!.cell!.horizontalBorderWidth,
).toEqual(cellWidth);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/s2-core/__tests__/unit/cell/row-cell-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('Row Cell Tests', () => {
const linkLength = maxX - minX;

expect(
Math.abs(linkLength - get(provinceCell, 'actualTextWidth')),
Math.abs(linkLength - provinceCell.getActualTextWidth()),
).toBeLessThanOrEqual(2);

// link shape 的中点坐标与 text 中点对齐
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe('PanelBBox Tests', () => {
...extraOptions,
},
},
} as unknown as BaseFacet);
}) as unknown as BaseFacet;

test('should return correct bbox when no scroll bar exist(small dataset)', () => {
const facet = getMockFacet(200, 200);
Expand Down
Loading
Loading