Skip to content

Commit

Permalink
HUE-8856 [autocomplete] Update eslintignore and fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanAhlen committed Jul 10, 2019
1 parent a6f19f8 commit c18c48c
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 81 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Expand Up @@ -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
15 changes: 11 additions & 4 deletions desktop/core/src/desktop/js/parse/spec/sqlTestUtils.js
Expand Up @@ -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'
);
}
}

Expand Down
Expand Up @@ -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) {
Expand Down Expand Up @@ -419,3 +420,4 @@ describe('genericAutocompleteParser.js locations', () => {
});
});
});
// prettier-ignore-end
Expand Up @@ -265,7 +265,6 @@ describe('impalaAutocompleteParser.js', () => {
});

describe('SET', () => {

it('should handle "set bla.bla="ble";|"', () => {
assertAutoComplete({
beforeCursor: 'set bla.bla="ble";',
Expand Down Expand Up @@ -439,16 +438,25 @@ 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({
left: 2,
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,
Expand All @@ -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
Expand Down
Expand Up @@ -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: {
Expand Down
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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']
}
});
});
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down
Expand Up @@ -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'],
Expand Down
Expand Up @@ -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']
}
});
});
Expand Down Expand Up @@ -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']
}
});
});
Expand Down
Expand Up @@ -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']
}
});
});
Expand All @@ -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']
}
});
});
Expand All @@ -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']
}
});
});
Expand Down

0 comments on commit c18c48c

Please sign in to comment.