]> source.dussan.org Git - sonarqube.git/commitdiff
[NO JIRA] Upgrade d3-zoom and d3-selection
authorJeremy Davis <jeremy.davis@sonarsource.com>
Wed, 19 Oct 2022 13:12:43 +0000 (15:12 +0200)
committersonartech <sonartech@sonarsource.com>
Mon, 31 Oct 2022 20:03:00 +0000 (20:03 +0000)
server/sonar-web/config/esbuild-config.js
server/sonar-web/jest.config.js
server/sonar-web/package.json
server/sonar-web/src/main/js/components/charts/BubbleChart.tsx
server/sonar-web/src/main/js/components/charts/__tests__/BubbleChart-test.tsx
server/sonar-web/yarn.lock

index 2d5842ada0254759593be2540cddf5d6035a6113..fa892c428ba32cba54dd0f9fec78c8190e43f322 100644 (file)
@@ -17,7 +17,6 @@
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-const path = require('path');
 const autoprefixer = require('autoprefixer');
 const postCssPlugin = require('esbuild-plugin-postcss2').default;
 const postCssCalc = require('postcss-calc');
@@ -25,14 +24,10 @@ const postCssCustomProperties = require('postcss-custom-properties');
 const documentationPlugin = require('./esbuild-documentation-plugin');
 const htmlPlugin = require('./esbuild-html-plugin');
 const htmlTemplate = require('./indexHtmlTemplate');
-const alias = require('esbuild-plugin-alias');
 const { getCustomProperties, TARGET_BROWSERS } = require('./utils');
 
 module.exports = release => {
   const plugins = [
-    alias({
-      'd3-selection': path.resolve(__dirname, '../node_modules/d3-selection/src/index.js')
-    }),
     postCssPlugin({
       plugins: [
         autoprefixer,
index 0dd90fb7d1d6ce1c6035d5b0290695c10a3e5614..626b2d66495b41a55d292661b9643a72aebaa8af 100644 (file)
@@ -26,7 +26,7 @@ module.exports = {
   testPathIgnorePatterns: ['<rootDir>/config', '<rootDir>/node_modules', '<rootDir>/scripts'],
   testRegex: '(/__tests__/.*|\\-test)\\.(ts|tsx|js)$',
   transform: {
-    '^.+\\.tsx?$': [
+    '^.+\\.(t|j)sx?$': [
       '@swc/jest',
       {
         jsc: {
@@ -35,6 +35,7 @@ module.exports = {
       }
     ]
   },
+  transformIgnorePatterns: ['/node_modules/(?!(d3-.+))/'],
   reporters: [
     'default',
     [
index 210b1ecd8fb3d5232e1e53a1d407ee582581b21f..b7eaf64fc639f9d1ddd7a8705fdd7ec62e85a91c 100644 (file)
@@ -13,9 +13,9 @@
     "d3-array": "3.2.0",
     "d3-hierarchy": "3.1.2",
     "d3-scale": "4.0.2",
-    "d3-selection": "1.4.1",
+    "d3-selection": "3.0.0",
     "d3-shape": "3.1.0",
-    "d3-zoom": "1.8.3",
+    "d3-zoom": "3.0.0",
     "date-fns": "2.29.3",
     "diff": "5.1.0",
     "dompurify": "2.4.0",
@@ -48,9 +48,9 @@
     "@types/d3-array": "3.0.3",
     "@types/d3-hierarchy": "3.1.0",
     "@types/d3-scale": "4.0.2",
-    "@types/d3-selection": "1.3.2",
+    "@types/d3-selection": "3.0.3",
     "@types/d3-shape": "3.1.0",
-    "@types/d3-zoom": "1.7.3",
+    "@types/d3-zoom": "3.0.1",
     "@types/diff": "5.0.2",
     "@types/dompurify": "2.3.4",
     "@types/enzyme": "3.10.12",
@@ -71,7 +71,6 @@
     "enzyme-adapter-react-16": "1.15.6",
     "enzyme-to-json": "3.6.2",
     "esbuild": "0.15.11",
-    "esbuild-plugin-alias": "0.2.1",
     "esbuild-plugin-postcss2": "0.1.1",
     "eslint": "8.25.0",
     "eslint-config-sonarqube": "2.1.0",
index bf1f077913f06ddf3e8984f67cb72079a47dd1f2..955d9f6261084cf7894e56ce6736f505cf030aab 100644 (file)
@@ -20,8 +20,8 @@
 import classNames from 'classnames';
 import { max, min } from 'd3-array';
 import { scaleLinear, ScaleLinear } from 'd3-scale';
-import { event, select } from 'd3-selection';
-import { zoom, ZoomBehavior, zoomIdentity } from 'd3-zoom';
+import { select } from 'd3-selection';
+import { D3ZoomEvent, zoom, ZoomBehavior, zoomIdentity } from 'd3-zoom';
 import { sortBy, uniq } from 'lodash';
 import * as React from 'react';
 import { AutoSizer } from 'react-virtualized/dist/commonjs/AutoSizer';
@@ -103,9 +103,9 @@ export default class BubbleChart<T> extends React.PureComponent<Props<T>, State>
     select(this.node).call(this.zoom as any);
   };
 
-  zoomed = () => {
+  zoomed = (event: D3ZoomEvent<SVGSVGElement, void>) => {
     const { padding } = this.props;
-    const { x, y, k } = event.transform as { x: number; y: number; k: number };
+    const { x, y, k } = event.transform;
     this.setState({
       transform: {
         x: x + padding[3] * (k - 1),
index 2ce6a4bc6538e58edabba29369e4d808163ea69e..91bf26bb3ac841c854864ed8fbc1cefd37eb23ea 100644 (file)
@@ -18,7 +18,7 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 import { select } from 'd3-selection';
-import { zoom } from 'd3-zoom';
+import { D3ZoomEvent, zoom } from 'd3-zoom';
 import { shallow } from 'enzyme';
 import * as React from 'react';
 import { AutoSizer, AutoSizerProps } from 'react-virtualized/dist/commonjs/AutoSizer';
@@ -34,14 +34,15 @@ jest.mock('react-virtualized/dist/commonjs/AutoSizer', () => ({
 }));
 
 jest.mock('d3-selection', () => ({
-  event: { transform: { x: 10, y: 10, k: 20 } },
   select: jest.fn().mockReturnValue({ call: jest.fn() })
 }));
 
-jest.mock('d3-zoom', () => ({
-  ...jest.requireActual('d3-zoom'),
-  zoom: jest.fn()
-}));
+jest.mock('d3-zoom', () => {
+  return {
+    zoomidentity: { k: 1, tx: 0, ty: 0 },
+    zoom: jest.fn()
+  };
+});
 
 beforeEach(jest.clearAllMocks);
 
@@ -108,7 +109,11 @@ it('should correctly handle zooming', () => {
     );
 
     // Call zoom event handler.
-    wrapper.instance().zoomed();
+    const mockZoomEvent = { transform: { x: 10, y: 10, k: 20 } } as D3ZoomEvent<
+      SVGSVGElement,
+      void
+    >;
+    wrapper.instance().zoomed(mockZoomEvent);
     expect(wrapper.state().transform).toEqual({
       x: 105,
       y: 105,
index c350ade6d85bb1c520b02285b39fd380e526dc7b..ea8c756f5349e222144e95bfb1cc80ac9fa27ae1 100644 (file)
@@ -1900,10 +1900,10 @@ __metadata:
   languageName: node
   linkType: hard
 
-"@types/d3-selection@npm:1.3.2":
-  version: 1.3.2
-  resolution: "@types/d3-selection@npm:1.3.2"
-  checksum: ef3416f18412afa49d81fb0295aca56ee311bdcef9e743187c2e9b8163494d9388565b9594f4ff17fec79971b5567a44a06f74ee2329d84f1fc3c3fa12fa7bf2
+"@types/d3-selection@npm:3.0.3":
+  version: 3.0.3
+  resolution: "@types/d3-selection@npm:3.0.3"
+  checksum: 24d4ac0b8f76bfdf5d3d90e6724ff7703057375ba482d2924f8d959e5481eaab55e0e39b5ca68a6d4e99bce100561333dee4146f497c9fc3605f1a308a7e713c
   languageName: node
   linkType: hard
 
@@ -1923,13 +1923,13 @@ __metadata:
   languageName: node
   linkType: hard
 
-"@types/d3-zoom@npm:1.7.3":
-  version: 1.7.3
-  resolution: "@types/d3-zoom@npm:1.7.3"
+"@types/d3-zoom@npm:3.0.1":
+  version: 3.0.1
+  resolution: "@types/d3-zoom@npm:3.0.1"
   dependencies:
     "@types/d3-interpolate": "*"
     "@types/d3-selection": "*"
-  checksum: 59fa3ebd0f4b9b20d80e3787c2dd2183534f462b001f61f34b2793d10d680b0ff48fd593ba6e3c93602fdcff5846ce45392426ccfdfdb95a0ccbfa3d3015ec62
+  checksum: f813b3e6f27efc8508d6a2d575c21d0b1ba338160e498b901bc103d813c47ce609f691912a4ef73e9678cdbbdebbee81fecaf7432f777e9a8a54bf4087c21eba
   languageName: node
   linkType: hard
 
@@ -2430,9 +2430,9 @@ __metadata:
     "@types/d3-array": 3.0.3
     "@types/d3-hierarchy": 3.1.0
     "@types/d3-scale": 4.0.2
-    "@types/d3-selection": 1.3.2
+    "@types/d3-selection": 3.0.3
     "@types/d3-shape": 3.1.0
-    "@types/d3-zoom": 1.7.3
+    "@types/d3-zoom": 3.0.1
     "@types/diff": 5.0.2
     "@types/dompurify": 2.3.4
     "@types/enzyme": 3.10.12
@@ -2455,9 +2455,9 @@ __metadata:
     d3-array: 3.2.0
     d3-hierarchy: 3.1.2
     d3-scale: 4.0.2
-    d3-selection: 1.4.1
+    d3-selection: 3.0.0
     d3-shape: 3.1.0
-    d3-zoom: 1.8.3
+    d3-zoom: 3.0.0
     date-fns: 2.29.3
     diff: 5.1.0
     dompurify: 2.4.0
@@ -2465,7 +2465,6 @@ __metadata:
     enzyme-adapter-react-16: 1.15.6
     enzyme-to-json: 3.6.2
     esbuild: 0.15.11
-    esbuild-plugin-alias: 0.2.1
     esbuild-plugin-postcss2: 0.1.1
     eslint: 8.25.0
     eslint-config-sonarqube: 2.1.0
@@ -3669,13 +3668,6 @@ __metadata:
   languageName: node
   linkType: hard
 
-"d3-color@npm:1":
-  version: 1.2.8
-  resolution: "d3-color@npm:1.2.8"
-  checksum: 6ab5596162b2535b2f29c218a079a9df1922c51c73958db1e72fec971a76011944843f8bed427a4d61dbf8fd3f61984996316a5a35f8d44ab7ace549b9b66742
-  languageName: node
-  linkType: hard
-
 "d3-color@npm:1 - 3":
   version: 3.1.0
   resolution: "d3-color@npm:3.1.0"
@@ -3683,27 +3675,27 @@ __metadata:
   languageName: node
   linkType: hard
 
-"d3-dispatch@npm:1":
-  version: 1.0.6
-  resolution: "d3-dispatch@npm:1.0.6"
-  checksum: b4ecb016b6dda8b99aa4263b2d0a0c7b12e7dea93e4b0ce3013c94dca4d360d9ba00f5bdc15dc944cc4543af8e341067bd628f061f7b8deb642257e2ac90d06c
+"d3-dispatch@npm:1 - 3":
+  version: 3.0.1
+  resolution: "d3-dispatch@npm:3.0.1"
+  checksum: fdfd4a230f46463e28e5b22a45dd76d03be9345b605e1b5dc7d18bd7ebf504e6c00ae123fd6d03e23d9e2711e01f0e14ea89cd0632545b9f0c00b924ba4be223
   languageName: node
   linkType: hard
 
-"d3-drag@npm:1":
-  version: 1.2.5
-  resolution: "d3-drag@npm:1.2.5"
+"d3-drag@npm:2 - 3":
+  version: 3.0.0
+  resolution: "d3-drag@npm:3.0.0"
   dependencies:
-    d3-dispatch: 1
-    d3-selection: 1
-  checksum: 6e86e89aa8d511979eea1b5326709c05c2a3c2d43a93a82ed6b6f98528b2ab03b2f58f5e4f66582f2f1c0ae44f9c19f6f4f857249eb66aabc46e4942295fa0a7
+    d3-dispatch: 1 - 3
+    d3-selection: 3
+  checksum: d297231e60ecd633b0d076a63b4052b436ddeb48b5a3a11ff68c7e41a6774565473a6b064c5e9256e88eca6439a917ab9cea76032c52d944ddbf4fd289e31111
   languageName: node
   linkType: hard
 
-"d3-ease@npm:1":
-  version: 1.0.7
-  resolution: "d3-ease@npm:1.0.7"
-  checksum: 117811d51dfc4a126e8d23d249252df792fbbe30a93615e1d67158c482eff69b900e45a4cc92746fe65b1143287455406a89aae04eb4ca1ba5b1dc2a42af5b85
+"d3-ease@npm:1 - 3":
+  version: 3.0.1
+  resolution: "d3-ease@npm:3.0.1"
+  checksum: 06e2ee5326d1e3545eab4e2c0f84046a123dcd3b612e68858219aa034da1160333d9ce3da20a1d3486d98cb5c2a06f7d233eee1bc19ce42d1533458bd85dedcd
   languageName: node
   linkType: hard
 
@@ -3721,16 +3713,7 @@ __metadata:
   languageName: node
   linkType: hard
 
-"d3-interpolate@npm:1":
-  version: 1.4.0
-  resolution: "d3-interpolate@npm:1.4.0"
-  dependencies:
-    d3-color: 1
-  checksum: d98988bd1e2f59d01f100d0a19315ad8f82ef022aa09a65aff76f747a44f9b52f2d64c6578b8f47e01f2b14a8f0ef88f5460d11173c0dd2d58238c217ac0ec03
-  languageName: node
-  linkType: hard
-
-"d3-interpolate@npm:1.2.0 - 3":
+"d3-interpolate@npm:1 - 3, d3-interpolate@npm:1.2.0 - 3":
   version: 3.0.1
   resolution: "d3-interpolate@npm:3.0.1"
   dependencies:
@@ -3759,17 +3742,10 @@ __metadata:
   languageName: node
   linkType: hard
 
-"d3-selection@npm:1, d3-selection@npm:^1.1.0":
-  version: 1.4.2
-  resolution: "d3-selection@npm:1.4.2"
-  checksum: 2484b392259b087a98f546f2610e6a11c90f38dae6b6b20a3fc85171038fcab4c72e702788b1960a4fece88bed2e36f268096358b5b48d3c7f0d35cfbe305da6
-  languageName: node
-  linkType: hard
-
-"d3-selection@npm:1.4.1":
-  version: 1.4.1
-  resolution: "d3-selection@npm:1.4.1"
-  checksum: b421eab2391e2744736f85f1bbcd9f79c85bfdb8d1dfa4aad614868a49decd213fde5e23d5e40c6b8eff31c3b80e0a162c01a6ccf07ea465058197461856cc9f
+"d3-selection@npm:2 - 3, d3-selection@npm:3, d3-selection@npm:3.0.0":
+  version: 3.0.0
+  resolution: "d3-selection@npm:3.0.0"
+  checksum: f4e60e133309115b99f5b36a79ae0a19d71ee6e2d5e3c7216ef3e75ebd2cb1e778c2ed2fa4c01bef35e0dcbd96c5428f5bd6ca2184fe2957ed582fde6841cbc5
   languageName: node
   linkType: hard
 
@@ -3800,37 +3776,38 @@ __metadata:
   languageName: node
   linkType: hard
 
-"d3-timer@npm:1":
-  version: 1.0.10
-  resolution: "d3-timer@npm:1.0.10"
-  checksum: f7040953672deb2dfa03830ace80dbbcb212f80890218eba15dcca6f33f74102d943023ccc2a563295195cd8c63639bb2410ef1691c8fecff4a114fdf5c666f4
+"d3-timer@npm:1 - 3":
+  version: 3.0.1
+  resolution: "d3-timer@npm:3.0.1"
+  checksum: 1cfddf86d7bca22f73f2c427f52dfa35c49f50d64e187eb788dcad6e927625c636aa18ae4edd44d084eb9d1f81d8ca4ec305dae7f733c15846a824575b789d73
   languageName: node
   linkType: hard
 
-"d3-transition@npm:1":
-  version: 1.3.2
-  resolution: "d3-transition@npm:1.3.2"
+"d3-transition@npm:2 - 3":
+  version: 3.0.1
+  resolution: "d3-transition@npm:3.0.1"
   dependencies:
-    d3-color: 1
-    d3-dispatch: 1
-    d3-ease: 1
-    d3-interpolate: 1
-    d3-selection: ^1.1.0
-    d3-timer: 1
-  checksum: 1b4a0cfa7aeb4033ab20e26a310488cfac989de44c6c2bf10e9f0808af915a33add6dca23fbafcefe8c08613fd0d6a933e48b4de24c0779163c2852a1c7c16f4
+    d3-color: 1 - 3
+    d3-dispatch: 1 - 3
+    d3-ease: 1 - 3
+    d3-interpolate: 1 - 3
+    d3-timer: 1 - 3
+  peerDependencies:
+    d3-selection: 2 - 3
+  checksum: cb1e6e018c3abf0502fe9ff7b631ad058efb197b5e14b973a410d3935aead6e3c07c67d726cfab258e4936ef2667c2c3d1cd2037feb0765f0b4e1d3b8788c0ea
   languageName: node
   linkType: hard
 
-"d3-zoom@npm:1.8.3":
-  version: 1.8.3
-  resolution: "d3-zoom@npm:1.8.3"
+"d3-zoom@npm:3.0.0":
+  version: 3.0.0
+  resolution: "d3-zoom@npm:3.0.0"
   dependencies:
-    d3-dispatch: 1
-    d3-drag: 1
-    d3-interpolate: 1
-    d3-selection: 1
-    d3-transition: 1
-  checksum: de408e5dc6df1481ef6854a3d495f8e963dbf5b0de41bcbd35def0602abda55b3f2c1fa751c75c2f0a9bafd3b278f30795c27503fe609b3dbe06a0720d01d5be
+    d3-dispatch: 1 - 3
+    d3-drag: 2 - 3
+    d3-interpolate: 1 - 3
+    d3-selection: 2 - 3
+    d3-transition: 2 - 3
+  checksum: 8056e3527281cfd1ccbcbc458408f86973b0583e9dac00e51204026d1d36803ca437f970b5736f02fafed9f2b78f145f72a5dbc66397e02d4d95d4c594b8ff54
   languageName: node
   linkType: hard
 
@@ -4621,13 +4598,6 @@ __metadata:
   languageName: node
   linkType: hard
 
-"esbuild-plugin-alias@npm:0.2.1":
-  version: 0.2.1
-  resolution: "esbuild-plugin-alias@npm:0.2.1"
-  checksum: afe2d2c8b5f09d5321cb8d9c0825e8a9f6e03c2d50df92f953a291d4620cc29eddb3da9e33b238f6d8f77738e0277bdcb831f127399449fecf78fb84c04e5da9
-  languageName: node
-  linkType: hard
-
 "esbuild-plugin-postcss2@npm:0.1.1":
   version: 0.1.1
   resolution: "esbuild-plugin-postcss2@npm:0.1.1"