Browse Source

[frontend] Upgrade Jest, eslint and core-js

This takes care of a whole bunch of npm audit warnings.
Johan Åhlén 4 năm trước cách đây
mục cha
commit
d6eb81f589

+ 2 - 2
.eslintrc.js

@@ -123,9 +123,9 @@ module.exports = {
   ],
   extends: ['plugin:prettier/recommended'],
   globals: globals,
-  parser: 'babel-eslint',
+  parser: '@babel/eslint-parser',
   parserOptions: {
-    parser: 'babel-eslint',
+    parser: '@babel/eslint-parser',
     ecmaVersion: 2017,
     sourceType: 'module',
     ecmaFeatures: {

+ 0 - 26
NOTICE.txt

@@ -924,7 +924,6 @@ leaflet.heat 0.2.0 : BSD 2-clause "Simplified" License
 Leaflet.markercluster 0.5.0 : MIT License
 LessCss 1.7.0 : Apache License 2.0
 LessCss 3.11.1 : Apache License 2.0
-lesshint 6.3.7 : MIT License
 leven 3.1.0 : MIT License
 levn 0.3.0 : MIT License
 lines-and-columns 1.1.6 : MIT License
@@ -12916,31 +12915,6 @@ OTHER DEALINGS IN THE SOFTWARE
 
 ---
 
-MIT License
-(lesshint 6.3.7)
-
-Copyright (c) Jonathan Wilsson
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE
-
----
-
 MIT License
 (cssom 0.3.6, cssom 0.3.8)
 

+ 10 - 8
desktop/core/src/desktop/js/apps/editor/components/ExecuteButton.test.ts

@@ -14,10 +14,12 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-import { EXECUTABLE_UPDATED_TOPIC, ExecutableUpdatedEvent } from 'apps/editor/execution/events';
-import huePubSub from 'utils/huePubSub';
 import { nextTick } from 'vue';
 import { mount, shallowMount } from '@vue/test-utils';
+
+import { Session } from '../execution/api';
+import { EXECUTABLE_UPDATED_TOPIC, ExecutableUpdatedEvent } from 'apps/editor/execution/events';
+import huePubSub from 'utils/huePubSub';
 import SqlExecutable, { ExecutionStatus } from 'apps/editor/execution/sqlExecutable';
 import sessionManager from 'apps/editor/execution/sessionManager';
 import ExecuteButton from './ExecuteButton.vue';
@@ -30,9 +32,9 @@ describe('ExecuteButton.vue', () => {
   });
 
   it('should show execute once the session is loaded', async () => {
-    const spy = spyOn(sessionManager, 'getSession').and.returnValue(
-      Promise.resolve({ type: 'foo' })
-    );
+    const spy = jest
+      .spyOn(sessionManager, 'getSession')
+      .mockReturnValue(Promise.resolve({ type: 'foo' } as Session));
 
     const mockExecutable = {
       cancel: noop,
@@ -64,9 +66,9 @@ describe('ExecuteButton.vue', () => {
   });
 
   it('should handle execute and stop clicks', async () => {
-    const spy = spyOn(sessionManager, 'getSession').and.returnValue(
-      Promise.resolve({ type: 'foo' })
-    );
+    const spy = jest
+      .spyOn(sessionManager, 'getSession')
+      .mockReturnValue(Promise.resolve({ type: 'foo' } as Session));
     let executeCalled = false;
     let cancelCalled = false;
     const mockExecutable = {

+ 1 - 1
desktop/core/src/desktop/js/apps/editor/components/aceEditor/AceEditor.test.ts

@@ -74,7 +74,7 @@ describe('AceEditor.vue', () => {
     initialValue?: string
   ): Promise<{ element: Element; editor: Ace.Editor }> =>
     new Promise(resolve => {
-      spyOn(dataCatalog, 'getChildren').and.returnValue(CancellablePromise.resolve([]));
+      jest.spyOn(dataCatalog, 'getChildren').mockReturnValue(CancellablePromise.resolve([]));
       const props = {
         initialValue,
         id: 'some-id',

+ 2 - 2
desktop/core/src/desktop/js/catalog/dataCatalogEntry.test.ts

@@ -62,7 +62,7 @@ describe('dataCatalogEntry.ts', () => {
 
   describe('getSample', () => {
     const emptySampleApiSpy = () => {
-      spyOn(CatalogApi, 'fetchSample').and.returnValue(
+      jest.spyOn(CatalogApi, 'fetchSample').mockReturnValue(
         CancellablePromise.resolve<Sample>({
           data: [],
           meta: [],
@@ -110,7 +110,7 @@ describe('dataCatalogEntry.ts', () => {
     });
 
     it('should bubble up exceptions', async () => {
-      spyOn(CatalogApi, 'fetchSample').and.returnValue(CancellablePromise.reject('failed!'));
+      jest.spyOn(CatalogApi, 'fetchSample').mockReturnValue(CancellablePromise.reject('failed!'));
       const entryA = await getEntry('someDb.someTable');
       let caught = false;
       try {

+ 1 - 2
desktop/core/src/desktop/js/ko/components/contextPopover/ko.popoverOnHover.test.js

@@ -25,8 +25,6 @@ import { HIDE_CONTEXT_POPOVER_EVENT } from './ko.contextPopover';
 describe('ko.popoverOnHover.js', () => {
   const setup = koSetup();
 
-  jest.useFakeTimers();
-
   it('should render binding', async () => {
     const wrapper = await setup.renderKo(`<div id="foo" data-bind="${NAME}: () => {}"></div>`, {});
 
@@ -34,6 +32,7 @@ describe('ko.popoverOnHover.js', () => {
   });
 
   it('should call callback on hover and publish on leave', async () => {
+    jest.useFakeTimers('legacy');
     let callbackCalled = false;
     const viewModel = {
       callback: () => {

+ 18 - 16
desktop/core/src/desktop/js/sql/autocompleteResults.test.js

@@ -381,18 +381,20 @@ describe('AutocompleteResults.js', () => {
   it('should handle parse results with functions', async () => {
     subject.entries([]);
 
-    const spy = spyOn(sqlUdfRepository, 'getUdfsWithReturnTypes').and.callFake(async () =>
-      Promise.resolve([
-        {
-          name: 'count',
-          returnTypes: ['BIGINT'],
-          arguments: [[{ type: 'T' }]],
-          signature: 'count(col)',
-          draggable: 'count()',
-          description: 'some desc'
-        }
-      ])
-    );
+    const spy = jest
+      .spyOn(sqlUdfRepository, 'getUdfsWithReturnTypes')
+      .mockImplementation(async () =>
+        Promise.resolve([
+          {
+            name: 'count',
+            returnTypes: ['BIGINT'],
+            arguments: [[{ type: 'T' }]],
+            signature: 'count(col)',
+            draggable: 'count()',
+            description: 'some desc'
+          }
+        ])
+      );
 
     expect(subject.filtered().length).toBe(0);
 
@@ -414,9 +416,9 @@ describe('AutocompleteResults.js', () => {
   it('should handle parse results with udf argument keywords', async () => {
     subject.entries([]);
 
-    const spy = spyOn(sqlUdfRepository, 'getArgumentDetailsForUdf').and.callFake(async () =>
-      Promise.resolve([{ type: 'T', keywords: ['a', 'b'] }])
-    );
+    const spy = jest
+      .spyOn(sqlUdfRepository, 'getArgumentDetailsForUdf')
+      .mockImplementation(async () => Promise.resolve([{ type: 'T', keywords: ['a', 'b'] }]));
 
     expect(subject.filtered().length).toBe(0);
 
@@ -440,7 +442,7 @@ describe('AutocompleteResults.js', () => {
   it('should handle parse results set options', async () => {
     subject.entries([]);
 
-    const spy = spyOn(sqlReferenceRepository, 'getSetOptions').and.callFake(
+    const spy = jest.spyOn(sqlReferenceRepository, 'getSetOptions').mockImplementation(
       async dialect =>
         new Promise(resolve => {
           expect(dialect).toEqual(subject.snippet.connector().dialect);

+ 1 - 1
desktop/core/src/desktop/js/utils/hdfsAutocompleter.test.js

@@ -79,7 +79,7 @@ describe('hdfsAutocompleter.js', () => {
         expect(value).toEqualAutocompleteValues(values);
       }
     };
-    return spyOn(spy, 'cb').and.callThrough();
+    return jest.spyOn(spy, 'cb');
   };
 
   const assertAutoComplete = function (testDefinition) {

+ 1 - 1
jest.config.js

@@ -2,7 +2,7 @@ module.exports = {
   moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'json', 'vue'],
   transform: {
     '^.+\\.(js|ts)$': 'babel-jest',
-    '^.+\\.vue$': 'vue-jest'
+    '^.+\\.vue$': '@vue/vue3-jest'
   },
   moduleNameMapper: {
     '\\.(css|less|scss|sass)$': 'identity-obj-proxy',

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 365 - 346
package-lock.json


+ 8 - 9
package.json

@@ -33,7 +33,7 @@
     "@gethue/sql-formatter": "4.0.3",
     "axios": "0.24.0",
     "clipboard": "1.7.1",
-    "core-js": "^3.4.2",
+    "core-js": "3.19.1",
     "d3": "5.7.0",
     "d3v3": "1.0.3",
     "dropzone": "5.5.1",
@@ -71,6 +71,7 @@
   },
   "devDependencies": {
     "@babel/core": "7.14.3",
+    "@babel/eslint-parser": "7.16.3",
     "@babel/node": "7.14.2",
     "@babel/plugin-proposal-class-properties": "7.13.0",
     "@babel/plugin-proposal-decorators": "7.13.0",
@@ -79,7 +80,7 @@
     "@babel/preset-env": "7.14.4",
     "@babel/preset-typescript": "7.13.0",
     "@types/file-saver": "^2.0.1",
-    "@types/jest": "26.0.0",
+    "@types/jest": "27.0.2",
     "@types/jquery": "3.5.0",
     "@types/knockout": "3.4.67",
     "@types/lodash": "^4.14.161",
@@ -90,9 +91,9 @@
     "@typescript-eslint/eslint-plugin": "4.25.0",
     "@typescript-eslint/parser": "4.25.0",
     "@vue/compiler-sfc": "3.2.0",
+    "@vue/vue3-jest": "27.0.0-alpha.3",
     "@vue/test-utils": "^2.0.0-rc.1",
-    "babel-eslint": "10.1.0",
-    "babel-jest": "26.6.3",
+    "babel-jest": "27.3.1",
     "babel-jscs": "3.0.0-beta1",
     "babel-loader": "8.2.2",
     "babel-plugin-module-resolver": "4.1.0",
@@ -102,7 +103,7 @@
     "css-loader": "5.2.6",
     "eslint": "7.27.0",
     "eslint-config-prettier": "8.3.0",
-    "eslint-plugin-jest": "24.3.6",
+    "eslint-plugin-jest": "25.2.4",
     "eslint-plugin-prettier": "3.4.0",
     "eslint-plugin-vue": "7.10.0",
     "expose-loader": "3.0.0",
@@ -110,11 +111,10 @@
     "grunt-contrib-less": "3.0.0",
     "grunt-contrib-watch": "1.1.0",
     "identity-obj-proxy": "3.0.0",
-    "jest": "26.6.3",
+    "jest": "27.3.1",
     "jsdom": "16.6.0",
     "less": "4.1.1",
     "less-loader": "9.0.0",
-    "lesshint": "6.3.7",
     "license-checker": "25.0.1",
     "load-grunt-tasks": "5.1.0",
     "markdown": "0.5.0",
@@ -126,12 +126,11 @@
     "stylelint": "13.13.1",
     "stylelint-config-standard": "22.0.0",
     "stylelint-scss": "3.19.0",
-    "ts-jest": "26.5.6",
+    "ts-jest": "27.0.7",
     "ts-loader": "9.2.2",
     "typescript": "4.3.2",
     "util": "0.12.4",
     "vti": "0.0.24",
-    "vue-jest": "5.0.0-alpha.10",
     "vue-loader": "16.5.0",
     "webpack": "5.38.1",
     "webpack-bundle-analyzer": "4.4.2",

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác