Ver código fonte

[ui-core] Upgrade js/ts linters to the latest possible versions

White space has been adjusted in some files as the default linting rules have changed with the newer versions.

Updated Vue linting rules have been ignored given that new development will be in React only.
Johan Åhlén 1 ano atrás
pai
commit
103385e873
24 arquivos alterados com 480 adições e 413 exclusões
  1. 9 3
      .eslintrc.js
  2. 6 3
      desktop/core/src/desktop/js/api/apiHelper.js
  3. 2 2
      desktop/core/src/desktop/js/apps/editor/components/aceEditor/autocomplete/AutocompleteResults.test.ts
  4. 2 2
      desktop/core/src/desktop/js/apps/editor/components/aceEditor/autocomplete/AutocompleteResults.ts
  5. 7 4
      desktop/core/src/desktop/js/apps/editor/components/variableSubstitution/VariableSubstitution.vue
  6. 1 1
      desktop/core/src/desktop/js/apps/notebook/NotebookViewModel.js
  7. 2 2
      desktop/core/src/desktop/js/apps/notebook/notebook.js
  8. 6 6
      desktop/core/src/desktop/js/apps/notebook/snippet.js
  9. 2 2
      desktop/core/src/desktop/js/jquery/plugins/jquery.huedatatable.js
  10. 3 5
      desktop/core/src/desktop/js/ko/bindings/ace/ko.aceEditor.js
  11. 2 2
      desktop/core/src/desktop/js/ko/bindings/ko.hueSpinner.js
  12. 2 2
      desktop/core/src/desktop/js/ko/bindings/ko.tagsNotAllowed.js
  13. 2 2
      desktop/core/src/desktop/js/ko/components/assist/ko.assistDbPanel.js
  14. 2 2
      desktop/core/src/desktop/js/ko/components/assist/ko.assistEditorContextPanel.js
  15. 2 2
      desktop/core/src/desktop/js/ko/components/ko.deleteDocModal.js
  16. 2 2
      desktop/core/src/desktop/js/ko/components/ko.sentryPrivileges.js
  17. 2 2
      desktop/core/src/desktop/js/ko/components/ko.sessionPanel.js
  18. 2 2
      desktop/core/src/desktop/js/nvd3/nv.d3.growingDiscreteBar.js
  19. 2 2
      desktop/core/src/desktop/js/nvd3/nv.d3.multiBarWithBrushChart.js
  20. 10 0
      desktop/core/src/desktop/js/parse/sqlStatementsParser.d.ts
  21. 0 16
      desktop/core/src/desktop/js/parse/sqlStatementsParser/index.d.ts
  22. 2 2
      desktop/core/src/desktop/js/sql/autocompleteResults.js
  23. 402 339
      package-lock.json
  24. 8 8
      package.json

+ 9 - 3
.eslintrc.js

@@ -60,15 +60,19 @@ const jsTsVueRules = {
   '@typescript-eslint/no-non-null-assertion': 'off',
   '@typescript-eslint/no-explicit-any': 'error',
   '@typescript-eslint/no-this-alias': 'error',
-  '@typescript-eslint/no-unused-vars': 'error',
+  '@typescript-eslint/no-unused-vars': [
+    'error',
+    {
+      varsIgnorePattern: '__webpack.*'
+    }
+  ],
   '@typescript-eslint/explicit-module-boundary-types': 'error',
   'vue/max-attributes-per-line': [
     'error',
     {
       singleline: 10,
       multiline: {
-        max: 1,
-        allowFirstLine: false
+        max: 1
       }
     }
   ],
@@ -80,6 +84,8 @@ const jsTsVueRules = {
       }
     }
   ],
+  'vue/multi-word-component-names': 'off',
+  'vue/require-toggle-inside-transition': 'off',
   'vue/singleline-html-element-content-newline': 'off' // Conflicts with prettier
 };
 

+ 6 - 3
desktop/core/src/desktop/js/api/apiHelper.js

@@ -1638,9 +1638,12 @@ class ApiHelper {
             if (response && response.data) {
               deferred.resolve(response.data);
             } else {
-              const timeout = window.setTimeout(() => {
-                pollForAnalysis();
-              }, 1000 + tries * 500); // TODO: Adjust once fully implemented;
+              const timeout = window.setTimeout(
+                () => {
+                  pollForAnalysis();
+                },
+                1000 + tries * 500
+              ); // TODO: Adjust once fully implemented;
               promise.onCancel(() => {
                 window.clearTimeout(timeout);
               });

+ 2 - 2
desktop/core/src/desktop/js/apps/editor/components/aceEditor/autocomplete/AutocompleteResults.test.ts

@@ -262,7 +262,7 @@ describe('AutocompleteResults.ts', () => {
               source_autocomplete_disabled: false
             }
           }
-        } as HueConfig)
+        }) as HueConfig
     );
 
     const subject = createSubject();
@@ -288,7 +288,7 @@ describe('AutocompleteResults.ts', () => {
               source_autocomplete_disabled: true
             }
           }
-        } as HueConfig)
+        }) as HueConfig
     );
     const subject = createSubject();
     const suggestions: Suggestion[] = [];

+ 2 - 2
desktop/core/src/desktop/js/apps/editor/components/aceEditor/autocomplete/AutocompleteResults.ts

@@ -1543,8 +1543,8 @@ class AutocompleteResults {
         const replaceWith = table.alias
           ? table.alias + '.'
           : suggestAggregateFunctions.tables.length > 1
-          ? table.identifierChain[table.identifierChain.length - 1].name + '.'
-          : '';
+            ? table.identifierChain[table.identifierChain.length - 1].name + '.'
+            : '';
         if (table.identifierChain.length > 1) {
           substitutions.push({
             replace: new RegExp(

+ 7 - 4
desktop/core/src/desktop/js/apps/editor/components/variableSubstitution/VariableSubstitution.vue

@@ -151,10 +151,13 @@
       activeVariables(): void {
         this.$emit(
           'variables-changed',
-          this.activeVariables.reduce((result, variable) => {
-            result[variable.name] = variable;
-            return result;
-          }, <VariableIndex>{})
+          this.activeVariables.reduce(
+            (result, variable) => {
+              result[variable.name] = variable;
+              return result;
+            },
+            <VariableIndex>{}
+          )
         );
       },
       locations(locations?: IdentifierLocation[]): void {

+ 1 - 1
desktop/core/src/desktop/js/apps/notebook/NotebookViewModel.js

@@ -145,7 +145,7 @@ export default class NotebookViewModel {
         });
         $.each(notebook.presentationSnippets(), key => {
           // Dead statements
-          if (!key in statementKeys) {
+          if ((!key) in statementKeys) {
             delete notebook.presentationSnippets()[key];
           }
         });

+ 2 - 2
desktop/core/src/desktop/js/apps/notebook/notebook.js

@@ -695,8 +695,8 @@ class Notebook {
               data.status == -3
                 ? 'expired'
                 : data.status == 0
-                ? data.query_status.status
-                : 'failed';
+                  ? data.query_status.status
+                  : 'failed';
             if (status && item.status() != status) {
               item.status(status);
             }

+ 6 - 6
desktop/core/src/desktop/js/apps/notebook/snippet.js

@@ -963,8 +963,8 @@ class Snippet {
         ? self.selectedStatement()
           ? self.selectedStatement()
           : self.positionStatement() !== null
-          ? self.positionStatement().statement
-          : self.statement_raw()
+            ? self.positionStatement().statement
+            : self.statement_raw()
         : self.statement_raw();
       const variables = self.variables().reduce((variables, variable) => {
         variables[variable.name()] = variable;
@@ -2109,8 +2109,8 @@ class Snippet {
                   match === null
                     ? null
                     : typeof match[3] !== 'undefined'
-                    ? parseInt(match[3])
-                    : null
+                      ? parseInt(match[3])
+                      : null
               });
               self.status('with-sql-analyzer-report');
             }
@@ -2123,8 +2123,8 @@ class Snippet {
                   match === null
                     ? null
                     : typeof match[3] !== 'undefined'
-                    ? parseInt(match[3])
-                    : null
+                      ? parseInt(match[3])
+                      : null
               });
               self.status('with-sql-analyzer-report');
             }

+ 2 - 2
desktop/core/src/desktop/js/jquery/plugins/jquery.huedatatable.js

@@ -444,8 +444,8 @@ $.fn.hueDataTable = function (oInit) {
         const invisibleOffset = $t.data('oInit')['forceInvisible']
           ? $t.data('oInit')['forceInvisible']
           : aoColumns.length < 100
-          ? 10
-          : 1;
+            ? 10
+            : 1;
         const scrollable = $t.parents($t.data('oInit')['scrollable']);
         let visibleRows = Math.ceil(
           (scrollable.height() - Math.max($t.offset().top, 0)) / rowHeight

+ 3 - 5
desktop/core/src/desktop/js/ko/bindings/ace/ko.aceEditor.js

@@ -837,14 +837,12 @@ registerBinding(NAME, {
               'highlighted',
               'line'
             );
-            ace
-              .require('ace/lib/dom')
-              .importCssString(
-                '.highlighted {\
+            ace.require('ace/lib/dom').importCssString(
+              '.highlighted {\
                   background-color: #E3F7FF;\
                   position: absolute;\
               }'
-              );
+            );
             editor.scrollToLine(range.start.row + lineOffset, true, true, () => {});
           }, 0);
         }

+ 2 - 2
desktop/core/src/desktop/js/ko/bindings/ko.hueSpinner.js

@@ -53,8 +53,8 @@ ko.bindingHandlers.hueSpinner = {
         options.overlay
           ? 'hue-spinner-overlay'
           : options.inline
-          ? 'hue-spinner-inline'
-          : 'hue-spinner'
+            ? 'hue-spinner-inline'
+            : 'hue-spinner'
       );
       if (options.blackout) {
         $container.addClass('hue-spinner-blackout');

+ 2 - 2
desktop/core/src/desktop/js/ko/bindings/ko.tagsNotAllowed.js

@@ -24,8 +24,8 @@ ko.bindingHandlers.tagsNotAllowed = {
     const valueObservable = ko.isObservable(params)
       ? params
       : params.textInput
-      ? params.textInput
-      : params.value;
+        ? params.textInput
+        : params.value;
     const value = valueObservable();
     const escaped = value.replace(/<|>/g, '');
     if (escaped !== value) {

+ 2 - 2
desktop/core/src/desktop/js/ko/components/assist/ko.assistDbPanel.js

@@ -227,8 +227,8 @@ const ASSIST_TABLE_TEMPLATES = `
       <li class="assist-entry assist-no-entries"><!-- ko if: catalogEntry.isTableOrView() -->${I18n(
         'No columns found'
       )}<!--/ko--><!-- ko if: catalogEntry.isDatabase() -->${I18n(
-  'No tables found'
-)}<!--/ko--><!-- ko if: catalogEntry.isField() -->${I18n('No results found')}<!--/ko--></li>
+        'No tables found'
+      )}<!--/ko--><!-- ko if: catalogEntry.isField() -->${I18n('No results found')}<!--/ko--></li>
     </ul>
     <!-- /ko -->
     <!-- ko if: ! hasErrors() && hasEntries() && ! loading() && filteredEntries().length > 0 -->

+ 2 - 2
desktop/core/src/desktop/js/ko/components/assist/ko.assistEditorContextPanel.js

@@ -131,8 +131,8 @@ const TEMPLATE =
           <a href="javascript:void(0)" data-bind="visible: activeTables().length > 0, click: function() { uploadTableStats(true) }, attr: { 'title': ('${I18n(
             'Add table'
           )} '  + (isMissingDDL() ? 'DDL' : '') + (isMissingDDL() && isMissingStats() ? ' ${I18n(
-    'and'
-  )} ' : '') + (isMissingStats() ? 'stats' : '')) }">
+            'and'
+          )} ' : '') + (isMissingStats() ? 'stats' : '')) }">
             <i class="fa fa-fw fa-plus-circle"></i> ${I18n('Improve Analysis')}
           </a>
           <!-- /ko -->

+ 2 - 2
desktop/core/src/desktop/js/ko/components/ko.deleteDocModal.js

@@ -55,8 +55,8 @@ const TEMPLATE = `
           )} <a class="pointer" data-bind="hueLink: $data.dependents[1].absoluteUrl, text: $data.dependents[1].name"></a>
             <!-- ko if: $data.dependents.length > 2 -->
               ${I18n('and')} <span data-bind="text: $data.dependents.length - 2"></span> ${I18n(
-  'other'
-)}
+                'other'
+              )}
             <!-- /ko -->
           <!-- /ko -->
           )

+ 2 - 2
desktop/core/src/desktop/js/ko/components/ko.sentryPrivileges.js

@@ -170,8 +170,8 @@ const TEMPLATE = `
       <button data-loading-text="${I18n(
         'Deleting...'
       )}" class="btn btn-danger" data-bind="click: function() { roleToUpdate().savePrivileges(roleToUpdate()); }">${I18n(
-  'Yes, delete'
-)}</button>
+        'Yes, delete'
+      )}</button>
     </div>
   </div>
 `;

+ 2 - 2
desktop/core/src/desktop/js/ko/components/ko.sessionPanel.js

@@ -68,8 +68,8 @@ const TEMPLATE = `
                     <a class="inactive-action pointer margin-left-10" title="${I18n(
                       'Save session settings as default'
                     )}" rel="tooltip" data-bind="click: saveDefaultUserProperties"><i class="fa fa-save"></i> ${I18n(
-  'Set as default settings'
-)}</a>
+                      'Set as default settings'
+                    )}</a>
                   <!-- /ko -->
                   <!-- ko if: session.type === 'impala' && typeof session.http_addr != 'undefined' -->
                     <a class="margin-left-10" data-bind="attr: { 'href': session.http_addr }" target="_blank">

+ 2 - 2
desktop/core/src/desktop/js/nvd3/nv.d3.growingDiscreteBar.js

@@ -290,8 +290,8 @@ nv.models.growingDiscreteBar = function () {
               getY(d, i) < 0
                 ? y(0)
                 : y(0) - y(getY(d, i)) < 1
-                ? y(0) - 1 //make 1 px positive bars show up above y=0
-                : y(getY(d, i));
+                  ? y(0) - 1 //make 1 px positive bars show up above y=0
+                  : y(getY(d, i));
 
           return 'translate(' + left + ', ' + top + ')';
         })

+ 2 - 2
desktop/core/src/desktop/js/nvd3/nv.d3.multiBarWithBrushChart.js

@@ -770,8 +770,8 @@ nv.models.multiBarWithBrushChart = function () {
           x.range()[_l + typeof (isDescending ? -1 : 0)] !== 'undefined'
             ? _l + (isDescending ? -1 : 0)
             : isDescending
-            ? _leftEdges.length - 1
-            : 0;
+              ? _leftEdges.length - 1
+              : 0;
         const _fromRange = typeof x.range()[_l] !== 'undefined' ? x.range()[_l] : 0;
 
         if (isDescending) {

+ 10 - 0
desktop/core/src/desktop/js/parse/sqlStatementsParser.d.ts

@@ -0,0 +1,10 @@
+import { ParsedLocation } from 'parse/types';
+
+export interface ParsedSqlStatement {
+  firstToken: string;
+  statement: string;
+  location: ParsedLocation;
+  type: string;
+}
+
+export function parse(statement: string): ParsedSqlStatement[];

+ 0 - 16
desktop/core/src/desktop/js/parse/sqlStatementsParser/index.d.ts

@@ -1,16 +0,0 @@
-import { ParsedLocation } from 'parse/types';
-
-export = sqlStatementsParser;
-
-declare const sqlStatementsParser = {
-  parse(statement: string): sqlStatementsParser.ParsedSqlStatement[];
-};
-
-declare namespace sqlStatementsParser {
-  export interface ParsedSqlStatement {
-    firstToken: string;
-    statement: string;
-    location: ParsedLocation;
-    type: string;
-  }
-}

+ 2 - 2
desktop/core/src/desktop/js/sql/autocompleteResults.js

@@ -1803,8 +1803,8 @@ class AutocompleteResults {
         const replaceWith = table.alias
           ? table.alias + '.'
           : suggestAggregateFunctions.tables.length > 1
-          ? table.identifierChain[table.identifierChain.length - 1].name + '.'
-          : '';
+            ? table.identifierChain[table.identifierChain.length - 1].name + '.'
+            : '';
         if (table.identifierChain.length > 1) {
           substitutions.push({
             replace: new RegExp(

Diferenças do arquivo suprimidas por serem muito extensas
+ 402 - 339
package-lock.json


+ 8 - 8
package.json

@@ -102,8 +102,8 @@
     "@types/react-dom": "18.0.6",
     "@types/sanitize-html": "1.27.0",
     "@types/webpack": "5.28.0",
-    "@typescript-eslint/eslint-plugin": "4.25.0",
-    "@typescript-eslint/parser": "4.25.0",
+    "@typescript-eslint/eslint-plugin": "7.16.0",
+    "@typescript-eslint/parser": "7.16.0",
     "@vue/compiler-sfc": "3.2.0",
     "@vue/server-renderer": "3.2.0",
     "@vue/test-utils": "2.4.6",
@@ -115,11 +115,11 @@
     "clean-webpack-plugin": "4.0.0",
     "copy-webpack-plugin": "12.0.2",
     "css-loader": "5.2.6",
-    "eslint": "7.27.0",
-    "eslint-config-prettier": "8.3.0",
-    "eslint-plugin-jest": "25.2.4",
-    "eslint-plugin-prettier": "3.4.0",
-    "eslint-plugin-vue": "7.10.0",
+    "eslint": "8.56.0",
+    "eslint-config-prettier": "9.1.0",
+    "eslint-plugin-jest": "28.6.0",
+    "eslint-plugin-prettier": "5.1.3",
+    "eslint-plugin-vue": "9.27.0",
     "expose-loader": "3.0.0",
     "grunt": "1.5.3",
     "grunt-contrib-less": "3.0.0",
@@ -134,7 +134,7 @@
     "load-grunt-tasks": "5.1.0",
     "postcss-less": "6.0.0",
     "postcss-scss": "4.0.3",
-    "prettier": "2.3.0",
+    "prettier": "3.3.3",
     "sass": "1.34.0",
     "sass-loader": "11.1.1",
     "snarkdown": "2.0.0",

Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff