Prettify the frontend code (#8648)

* Add Prettier global configs

* Format js/jsx/ts/tsx/less files
This commit is contained in:
Erik Ritter
2019-11-27 14:02:48 -08:00
committed by GitHub
parent e21f768a92
commit 44d919c757
398 changed files with 8700 additions and 6117 deletions

View File

@@ -16,7 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
import AdhocMetric, { EXPRESSION_TYPES } from '../../../src/explore/AdhocMetric';
import AdhocMetric, {
EXPRESSION_TYPES,
} from '../../../src/explore/AdhocMetric';
import { AGGREGATES } from '../../../src/explore/constants';
const valueColumn = { type: 'DOUBLE', column_name: 'value' };
@@ -45,7 +47,9 @@ describe('AdhocMetric', () => {
column: valueColumn,
aggregate: AGGREGATES.SUM,
});
const adhocMetric2 = adhocMetric1.duplicateWith({ aggregate: AGGREGATES.AVG });
const adhocMetric2 = adhocMetric1.duplicateWith({
aggregate: AGGREGATES.AVG,
});
expect(adhocMetric1.column).toBe(adhocMetric2.column);
expect(adhocMetric1.column).toBe(valueColumn);
@@ -83,7 +87,9 @@ describe('AdhocMetric', () => {
label: 'old label',
hasCustomLabel: true,
});
const adhocMetric4 = adhocMetric3.duplicateWith({ sqlExpression: 'COUNT(1)' });
const adhocMetric4 = adhocMetric3.duplicateWith({
sqlExpression: 'COUNT(1)',
});
// eslint-disable-next-line no-unused-expressions
expect(adhocMetric3.equals(adhocMetric4)).toBe(false);
@@ -94,7 +100,9 @@ describe('AdhocMetric', () => {
column: valueColumn,
aggregate: AGGREGATES.SUM,
});
const adhocMetric2 = adhocMetric1.duplicateWith({ aggregate: AGGREGATES.AVG });
const adhocMetric2 = adhocMetric1.duplicateWith({
aggregate: AGGREGATES.AVG,
});
expect(adhocMetric2.label).toBe('AVG(value)');
});
@@ -106,7 +114,9 @@ describe('AdhocMetric', () => {
hasCustomLabel: true,
label: 'label1',
});
const adhocMetric2 = adhocMetric1.duplicateWith({ aggregate: AGGREGATES.AVG });
const adhocMetric2 = adhocMetric1.duplicateWith({
aggregate: AGGREGATES.AVG,
});
expect(adhocMetric2.label).toBe('label1');
});
@@ -160,51 +170,45 @@ describe('AdhocMetric', () => {
expect(adhocMetric5.isValid()).toBe(false);
});
it(
'can translate back from sql expressions to simple expressions when possible',
() => {
const adhocMetric = new AdhocMetric({
expressionType: EXPRESSION_TYPES.SQL,
sqlExpression: 'AVG(my_column)',
hasCustomLabel: true,
label: 'label1',
});
expect(adhocMetric.inferSqlExpressionColumn()).toBe('my_column');
expect(adhocMetric.inferSqlExpressionAggregate()).toBe('AVG');
it('can translate back from sql expressions to simple expressions when possible', () => {
const adhocMetric = new AdhocMetric({
expressionType: EXPRESSION_TYPES.SQL,
sqlExpression: 'AVG(my_column)',
hasCustomLabel: true,
label: 'label1',
});
expect(adhocMetric.inferSqlExpressionColumn()).toBe('my_column');
expect(adhocMetric.inferSqlExpressionAggregate()).toBe('AVG');
const adhocMetric2 = new AdhocMetric({
expressionType: EXPRESSION_TYPES.SQL,
sqlExpression: 'AVG(SUM(my_column)) / MAX(other_column)',
hasCustomLabel: true,
label: 'label1',
});
expect(adhocMetric2.inferSqlExpressionColumn()).toBeNull();
expect(adhocMetric2.inferSqlExpressionAggregate()).toBeNull();
},
);
const adhocMetric2 = new AdhocMetric({
expressionType: EXPRESSION_TYPES.SQL,
sqlExpression: 'AVG(SUM(my_column)) / MAX(other_column)',
hasCustomLabel: true,
label: 'label1',
});
expect(adhocMetric2.inferSqlExpressionColumn()).toBeNull();
expect(adhocMetric2.inferSqlExpressionAggregate()).toBeNull();
});
it(
'will infer columns and aggregates when converting to a simple expression',
() => {
const adhocMetric = new AdhocMetric({
expressionType: EXPRESSION_TYPES.SQL,
sqlExpression: 'AVG(my_column)',
hasCustomLabel: true,
label: 'label1',
});
const adhocMetric2 = adhocMetric.duplicateWith({
expressionType: EXPRESSION_TYPES.SIMPLE,
aggregate: AGGREGATES.SUM,
});
expect(adhocMetric2.aggregate).toBe(AGGREGATES.SUM);
expect(adhocMetric2.column.column_name).toBe('my_column');
it('will infer columns and aggregates when converting to a simple expression', () => {
const adhocMetric = new AdhocMetric({
expressionType: EXPRESSION_TYPES.SQL,
sqlExpression: 'AVG(my_column)',
hasCustomLabel: true,
label: 'label1',
});
const adhocMetric2 = adhocMetric.duplicateWith({
expressionType: EXPRESSION_TYPES.SIMPLE,
aggregate: AGGREGATES.SUM,
});
expect(adhocMetric2.aggregate).toBe(AGGREGATES.SUM);
expect(adhocMetric2.column.column_name).toBe('my_column');
const adhocMetric3 = adhocMetric.duplicateWith({
expressionType: EXPRESSION_TYPES.SIMPLE,
column: valueColumn,
});
expect(adhocMetric3.aggregate).toBe(AGGREGATES.AVG);
expect(adhocMetric3.column.column_name).toBe('value');
},
);
const adhocMetric3 = adhocMetric.duplicateWith({
expressionType: EXPRESSION_TYPES.SIMPLE,
column: valueColumn,
});
expect(adhocMetric3.aggregate).toBe(AGGREGATES.AVG);
expect(adhocMetric3.column.column_name).toBe('value');
});
});