Prechádzať zdrojové kódy

HUE-8856 [autocomplete] Update eslintignore and fix linting issues

Johan Ahlen 6 rokov pred
rodič
commit
c18c48cb69

+ 3 - 0
.eslintignore

@@ -13,3 +13,6 @@
 /desktop/core/src/desktop/js/parse/sql/impala/impalaSyntaxParser.js
 /desktop/core/src/desktop/js/parse/sql/hive/hiveAutocompleteParser.js
 /desktop/core/src/desktop/js/parse/sql/hive/hiveSyntaxParser.js
+/desktop/core/src/desktop/js/parse/sql/generic/spec/genericAutocompleteParser_Locations_Spec.js
+/desktop/core/src/desktop/js/parse/sql/hive/spec/hiveAutocompleteParser_Locations_Spec.js
+/desktop/core/src/desktop/js/parse/sql/impala/spec/impalaAutocompleteParser_Locations_Spec.js

+ 11 - 4
desktop/core/src/desktop/js/parse/spec/sqlTestUtils.js

@@ -89,11 +89,18 @@ const testUtils = {
             }
           }
 
-          if (((testDefinition.expectedResult && testDefinition.expectedResult.locations) || testDefinition.expectedLocations) && actualResponse.locations) {
-            let expectedLoc =  testDefinition.expectedLocations || testDefinition.expectedResult.locations;
-            let expectsType = expectedLoc.some(location => location.type === 'statementType');
+          if (
+            ((testDefinition.expectedResult && testDefinition.expectedResult.locations) ||
+              testDefinition.expectedLocations) &&
+            actualResponse.locations
+          ) {
+            const expectedLoc =
+              testDefinition.expectedLocations || testDefinition.expectedResult.locations;
+            const expectsType = expectedLoc.some(location => location.type === 'statementType');
             if (!expectsType) {
-              actualResponse.locations = actualResponse.locations.filter(location => location.type !== 'statementType');
+              actualResponse.locations = actualResponse.locations.filter(
+                location => location.type !== 'statementType'
+              );
             }
           }
 

+ 2 - 0
desktop/core/src/desktop/js/parse/sql/generic/spec/genericAutocompleteParser_Locations_Spec.js

@@ -17,6 +17,7 @@
 import SqlTestUtils from 'parse/spec/sqlTestUtils';
 import genericAutocompleteParser from '../genericAutocompleteParser';
 
+// prettier-ignore-start
 describe('genericAutocompleteParser.js locations', () => {
   beforeAll(() => {
     genericAutocompleteParser.yy.parseError = function(msg) {
@@ -419,3 +420,4 @@ describe('genericAutocompleteParser.js locations', () => {
     });
   });
 });
+// prettier-ignore-end

+ 18 - 8
desktop/core/src/desktop/js/parse/sql/impala/spec/impalaAutocompleteParserSpec.js

@@ -265,7 +265,6 @@ describe('impalaAutocompleteParser.js', () => {
   });
 
   describe('SET', () => {
-
     it('should handle "set bla.bla="ble";|"', () => {
       assertAutoComplete({
         beforeCursor: 'set bla.bla="ble";',
@@ -439,7 +438,10 @@ describe('impalaAutocompleteParser.js', () => {
         left: 4,
         right: 0
       });
-      expect(impalaAutocompleteParser.identifyPartials('foo', 'bar')).toEqual({ left: 3, right: 3 });
+      expect(impalaAutocompleteParser.identifyPartials('foo', 'bar')).toEqual({
+        left: 3,
+        right: 3
+      });
       expect(impalaAutocompleteParser.identifyPartials('fo', 'o()')).toEqual({ left: 2, right: 3 });
       expect(impalaAutocompleteParser.identifyPartials('fo', 'o(')).toEqual({ left: 2, right: 2 });
       expect(impalaAutocompleteParser.identifyPartials('fo', 'o(bla bla)')).toEqual({
@@ -447,8 +449,14 @@ describe('impalaAutocompleteParser.js', () => {
         right: 10
       });
       expect(impalaAutocompleteParser.identifyPartials('foo ', '')).toEqual({ left: 0, right: 0 });
-      expect(impalaAutocompleteParser.identifyPartials("foo '", "'")).toEqual({ left: 0, right: 0 });
-      expect(impalaAutocompleteParser.identifyPartials('foo "', '"')).toEqual({ left: 0, right: 0 });
+      expect(impalaAutocompleteParser.identifyPartials("foo '", "'")).toEqual({
+        left: 0,
+        right: 0
+      });
+      expect(impalaAutocompleteParser.identifyPartials('foo "', '"')).toEqual({
+        left: 0,
+        right: 0
+      });
       limitChars.forEach(char => {
         expect(impalaAutocompleteParser.identifyPartials('bar foo' + char, '')).toEqual({
           left: 0,
@@ -458,10 +466,12 @@ describe('impalaAutocompleteParser.js', () => {
           left: 6,
           right: 0
         });
-        expect(impalaAutocompleteParser.identifyPartials('bar foo' + char + 'foofoo ', '')).toEqual({
-          left: 0,
-          right: 0
-        });
+        expect(impalaAutocompleteParser.identifyPartials('bar foo' + char + 'foofoo ', '')).toEqual(
+          {
+            left: 0,
+            right: 0
+          }
+        );
         expect(impalaAutocompleteParser.identifyPartials('', char + 'foo bar')).toEqual({
           left: 0,
           right: 0

+ 1 - 2
desktop/core/src/desktop/js/parse/sql/impala/spec/impalaAutocompleteParser_Alter_Spec.js

@@ -217,8 +217,7 @@ describe('impalaAutocompleteParser.js ALTER statements', () => {
 
     it('should handle "alter table sales_data add partition (zipcode = cast(9021 * 10 as string));|"', () => {
       assertAutoComplete({
-        beforeCursor:
-          'alter table sales_data add partition (zipcode = cast(9021 * 10 as string));',
+        beforeCursor: 'alter table sales_data add partition (zipcode = cast(9021 * 10 as string));',
         afterCursor: '',
         containsKeywords: ['SELECT'],
         expectedResult: {

+ 9 - 18
desktop/core/src/desktop/js/parse/sql/impala/spec/impalaAutocompleteParser_Create_Spec.js

@@ -152,7 +152,7 @@ describe('impalaAutocompleteParser.js CREATE statements', () => {
 
     it(
       "should handle \"CREATE AGGREGATE FUNCTION baa.boo(INT, DOUBLE) RETURNS INT LOCATION '/boo' INIT_FN='cos' UPDATE_FN='sin' " +
-      "MERGE_FN='cos' PREPARE_FN='cos' CLOSE_FN='cos' SERIALIZE_FN='cos' FINALIZE_FN='cos'; |\"",
+        "MERGE_FN='cos' PREPARE_FN='cos' CLOSE_FN='cos' SERIALIZE_FN='cos' FINALIZE_FN='cos'; |\"",
       () => {
         assertAutoComplete({
           beforeCursor:
@@ -169,7 +169,7 @@ describe('impalaAutocompleteParser.js CREATE statements', () => {
 
     it(
       "should handle \"CREATE AGGREGATE FUNCTION baa.boo(INT, DOUBLE) RETURNS INT LOCATION '/boo' INIT_FN='cos' UPDATE_FN='sin' " +
-      "MERGE_FN='cos' PREPARE_FN='cos' CLOSE_FN='cos' SERIALIZE_FN='cos' FINALIZE_FN='cos' INTERMEDIATE bigint; |\"",
+        "MERGE_FN='cos' PREPARE_FN='cos' CLOSE_FN='cos' SERIALIZE_FN='cos' FINALIZE_FN='cos' INTERMEDIATE bigint; |\"",
       () => {
         assertAutoComplete({
           beforeCursor:
@@ -299,8 +299,7 @@ describe('impalaAutocompleteParser.js CREATE statements', () => {
 
     it("should suggest keywords for \"CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION '/boo' INIT_FN='cos' |\"", () => {
       assertAutoComplete({
-        beforeCursor:
-          "CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION '/boo' INIT_FN='cos' ",
+        beforeCursor: "CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION '/boo' INIT_FN='cos' ",
         afterCursor: '',
         expectedResult: {
           lowerCase: false,
@@ -337,7 +336,7 @@ describe('impalaAutocompleteParser.js CREATE statements', () => {
 
     it(
       "should suggest keywords for \"CREATE AGGREGATE FUNCTION boo() RETURNS INT LOCATION '/boo' INIT_FN='cos' UPDATE_FN='sin' MERGE_FN='tan' " +
-      "PREPARE_FN='boo' SERIALIZE_FN='baa' |\"",
+        "PREPARE_FN='boo' SERIALIZE_FN='baa' |\"",
       () => {
         assertAutoComplete({
           beforeCursor:
@@ -927,15 +926,7 @@ describe('impalaAutocompleteParser.js CREATE statements', () => {
         afterCursor: '',
         expectedResult: {
           lowerCase: false,
-          suggestKeywords: [
-            'AVRO',
-            'KUDU',
-            'ORC',
-            'PARQUET',
-            'RCFILE',
-            'SEQUENCEFILE',
-            'TEXTFILE'
-          ]
+          suggestKeywords: ['AVRO', 'KUDU', 'ORC', 'PARQUET', 'RCFILE', 'SEQUENCEFILE', 'TEXTFILE']
         }
       });
     });
@@ -1200,7 +1191,7 @@ describe('impalaAutocompleteParser.js CREATE statements', () => {
 
     it(
       'should handle "CREATE TABLE IF NOT EXISTS tbl (i INT PRIMARY KEY, b INT ENCODING bla COMPRESSION zip DEFAULT 10 BLOCK_SIZE 4 NOT NULL,' +
-      ' PRIMARY KEY (b)) STORED AS KUDU;|"',
+        ' PRIMARY KEY (b)) STORED AS KUDU;|"',
       () => {
         assertAutoComplete({
           beforeCursor:
@@ -1218,7 +1209,7 @@ describe('impalaAutocompleteParser.js CREATE statements', () => {
 
     it(
       'should handle "CREATE TABLE IF NOT EXISTS tbl (i INT PRIMARY KEY, b INT ENCODING bla COMPRESSION zip DEFAULT 10 BLOCK_SIZE 4 NOT NULL,' +
-      ' PRIMARY KEY (b)) PARTITION BY RANGE (a, b) (PARTITION 1 <= VALUES < 2) STORED AS KUDU;|"',
+        ' PRIMARY KEY (b)) PARTITION BY RANGE (a, b) (PARTITION 1 <= VALUES < 2) STORED AS KUDU;|"',
       () => {
         assertAutoComplete({
           beforeCursor:
@@ -1236,7 +1227,7 @@ describe('impalaAutocompleteParser.js CREATE statements', () => {
 
     it(
       'should handle "CREATE TABLE IF NOT EXISTS tbl (i INT PRIMARY KEY, b INT ENCODING bla COMPRESSION zip DEFAULT 10 BLOCK_SIZE 4 NOT NULL,' +
-      ' PRIMARY KEY (b)) PARTITION BY RANGE (a) (PARTITION VALUE = 50, PARTITION 50 < VALUES <= 100) STORED AS KUDU;|"',
+        ' PRIMARY KEY (b)) PARTITION BY RANGE (a) (PARTITION VALUE = 50, PARTITION 50 < VALUES <= 100) STORED AS KUDU;|"',
       () => {
         assertAutoComplete({
           beforeCursor:
@@ -1254,7 +1245,7 @@ describe('impalaAutocompleteParser.js CREATE statements', () => {
 
     it(
       'should handle "CREATE TABLE IF NOT EXISTS tbl (i INT ENCODING bla COMPRESSION zip DEFAULT 10 BLOCK_SIZE 4 NOT NULL,' +
-      ' PRIMARY KEY (b)) PARTITION BY HASH (a, b) PARTITIONS 10 STORED AS KUDU;|"',
+        ' PRIMARY KEY (b)) PARTITION BY HASH (a, b) PARTITIONS 10 STORED AS KUDU;|"',
       () => {
         assertAutoComplete({
           beforeCursor:

+ 1 - 2
desktop/core/src/desktop/js/parse/sql/impala/spec/impalaAutocompleteParser_Drop_Spec.js

@@ -96,8 +96,7 @@ describe('impalaAutocompleteParser.js DROP statements', () => {
 
     it('should handle "DELETE t1 FROM t1 JOIN t2 ON t1.x = t2.x WHERE t1.y = FALSE and t2.z > 100;|"', () => {
       assertAutoComplete({
-        beforeCursor:
-          'DELETE t1 FROM t1 JOIN t2 ON t1.x = t2.x WHERE t1.y = FALSE and t2.z > 100;',
+        beforeCursor: 'DELETE t1 FROM t1 JOIN t2 ON t1.x = t2.x WHERE t1.y = FALSE and t2.z > 100;',
         afterCursor: '',
         noErrors: true,
         containsKeywords: ['SELECT'],

+ 2 - 20
desktop/core/src/desktop/js/parse/sql/impala/spec/impalaAutocompleteParser_Grant_Spec.js

@@ -56,16 +56,7 @@ describe('impalaAutocompleteParser.js GRANT statements', () => {
         noErrors: true,
         expectedResult: {
           lowerCase: false,
-          suggestKeywords: [
-            'ALL',
-            'ALTER',
-            'CREATE',
-            'DROP',
-            'INSERT',
-            'REFRESH',
-            'ROLE',
-            'SELECT'
-          ]
+          suggestKeywords: ['ALL', 'ALTER', 'CREATE', 'DROP', 'INSERT', 'REFRESH', 'ROLE', 'SELECT']
         }
       });
     });
@@ -285,16 +276,7 @@ describe('impalaAutocompleteParser.js GRANT statements', () => {
         noErrors: true,
         expectedResult: {
           lowerCase: false,
-          suggestKeywords: [
-            'ALL',
-            'ALTER',
-            'CREATE',
-            'DROP',
-            'INSERT',
-            'REFRESH',
-            'ROLE',
-            'SELECT'
-          ]
+          suggestKeywords: ['ALL', 'ALTER', 'CREATE', 'DROP', 'INSERT', 'REFRESH', 'ROLE', 'SELECT']
         }
       });
     });

+ 3 - 27
desktop/core/src/desktop/js/parse/sql/impala/spec/impalaAutocompleteParser_Select_Spec.js

@@ -5328,15 +5328,7 @@ describe('impalaAutocompleteParser.js SELECT statements', () => {
         afterCursor: '',
         expectedResult: {
           lowerCase: false,
-          suggestKeywords: [
-            'ASC',
-            'DESC',
-            'NULLS FIRST',
-            'NULLS LAST',
-            'LIMIT',
-            'OFFSET',
-            'UNION'
-          ]
+          suggestKeywords: ['ASC', 'DESC', 'NULLS FIRST', 'NULLS LAST', 'LIMIT', 'OFFSET', 'UNION']
         }
       });
     });
@@ -5347,15 +5339,7 @@ describe('impalaAutocompleteParser.js SELECT statements', () => {
         afterCursor: '',
         expectedResult: {
           lowerCase: false,
-          suggestKeywords: [
-            'ASC',
-            'DESC',
-            'NULLS FIRST',
-            'NULLS LAST',
-            'LIMIT',
-            'OFFSET',
-            'UNION'
-          ]
+          suggestKeywords: ['ASC', 'DESC', 'NULLS FIRST', 'NULLS LAST', 'LIMIT', 'OFFSET', 'UNION']
         }
       });
     });
@@ -5377,15 +5361,7 @@ describe('impalaAutocompleteParser.js SELECT statements', () => {
         afterCursor: '',
         expectedResult: {
           lowerCase: false,
-          suggestKeywords: [
-            'ASC',
-            'DESC',
-            'NULLS FIRST',
-            'NULLS LAST',
-            'LIMIT',
-            'OFFSET',
-            'UNION'
-          ]
+          suggestKeywords: ['ASC', 'DESC', 'NULLS FIRST', 'NULLS LAST', 'LIMIT', 'OFFSET', 'UNION']
         }
       });
     });