Skip to content
This repository has been archived by the owner on Dec 10, 2021. It is now read-only.

Commit

Permalink
chore: refine prettier config as the main repository (#1456)
Browse files Browse the repository at this point in the history
* change to prettier.config.js

* printWidth to 80

* format

* tweak
  • Loading branch information
zhaoyongjie authored Nov 9, 2021
1 parent 46f3927 commit 887adbd
Show file tree
Hide file tree
Showing 455 changed files with 6,578 additions and 2,073 deletions.
15 changes: 12 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
* under the License.
*/
module.exports = {
extends: ['airbnb', 'prettier', 'prettier/react', 'plugin:react-hooks/recommended'],
extends: [
'airbnb',
'prettier',
'prettier/react',
'plugin:react-hooks/recommended',
],
parser: '@babel/eslint-parser',
parserOptions: {
ecmaFeatures: {
Expand Down Expand Up @@ -82,7 +87,8 @@ module.exports = {
paths: [
{
name: 'antd',
message: 'Please import Ant components from the index of common/components',
message:
'Please import Ant components from the index of common/components',
},
],
},
Expand Down Expand Up @@ -196,7 +202,10 @@ module.exports = {
rules: {
// this is to keep eslint from complaining about storybook addons,
// since they are included as dev dependencies rather than direct dependencies.
'import/no-extraneous-dependencies': ['error', { devDependencies: true }],
'import/no-extraneous-dependencies': [
'error',
{ devDependencies: true },
],
},
},
{
Expand Down
13 changes: 0 additions & 13 deletions .prettierrc

This file was deleted.

5 changes: 4 additions & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@
*/

module.exports = {
extends: ['@commitlint/config-conventional', '@commitlint/config-lerna-scopes'],
extends: [
'@commitlint/config-conventional',
'@commitlint/config-lerna-scopes',
],
};
5 changes: 4 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@

module.exports = {
bail: false,
collectCoverageFrom: ['**/src/**/*.{ts,tsx,js,jsx}', '**/test/**/*.{ts,tsx,js,jsx}'],
collectCoverageFrom: [
'**/src/**/*.{ts,tsx,js,jsx}',
'**/test/**/*.{ts,tsx,js,jsx}',
],
coverageDirectory: './coverage',
coveragePathIgnorePatterns: [
'coverage/',
Expand Down
4 changes: 3 additions & 1 deletion packages/generator-superset/generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ const yosay = require('yosay');
module.exports = class extends Generator {
async prompting() {
// Have Yeoman greet the user.
this.log(yosay(`Welcome to the rad ${chalk.red('generator-superset')} generator!`));
this.log(
yosay(`Welcome to the rad ${chalk.red('generator-superset')} generator!`),
);

this.option('skipInstall');

Expand Down
5 changes: 4 additions & 1 deletion packages/generator-superset/generators/package/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ module.exports = class extends Generator {
this.answers,
);
const ext = this.answers.language === 'typescript' ? 'ts' : 'js';
this.fs.copy(this.templatePath('src/index.txt'), this.destinationPath(`src/index.${ext}`));
this.fs.copy(
this.templatePath('src/index.txt'),
this.destinationPath(`src/index.${ext}`),
);
this.fs.copy(
this.templatePath('test/index.txt'),
this.destinationPath(`test/index.test.${ext}`),
Expand Down
15 changes: 12 additions & 3 deletions packages/generator-superset/generators/plugin-chart/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ module.exports = class extends Generator {
name: 'description',
message: 'Description:',
// Default to current folder name
default: _.upperFirst(_.startCase(this.appname.replace('plugin chart', '').trim())),
default: _.upperFirst(
_.startCase(this.appname.replace('plugin chart', '').trim()),
),
},
{
type: 'list',
Expand Down Expand Up @@ -106,9 +108,16 @@ module.exports = class extends Generator {
['src/MyChart.erb', `src/${packageLabel}.tsx`],
['test/index.erb', 'test/index.test.ts'],
['test/plugin/buildQuery.test.erb', 'test/plugin/buildQuery.test.ts'],
['test/plugin/transformProps.test.erb', 'test/plugin/transformProps.test.ts'],
[
'test/plugin/transformProps.test.erb',
'test/plugin/transformProps.test.ts',
],
].forEach(([src, dest]) => {
this.fs.copyTpl(this.templatePath(src), this.destinationPath(dest), params);
this.fs.copyTpl(
this.templatePath(src),
this.destinationPath(dest),
params,
);
});

['types/external.d.ts', 'src/images/thumbnail.png'].forEach(file => {
Expand Down
7 changes: 6 additions & 1 deletion packages/generator-superset/test/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ describe('generator-superset:app', () => {
});

it('creates files', () => {
assert.file(['package.json', 'README.md', 'src/index.ts', 'test/index.test.ts']);
assert.file([
'package.json',
'README.md',
'src/index.ts',
'test/index.test.ts',
]);
});
});
14 changes: 12 additions & 2 deletions packages/generator-superset/test/package.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ describe('generator-superset:package', () => {
);

it('creates files', () => {
assert.file(['package.json', 'README.md', 'src/index.ts', 'test/index.test.ts']);
assert.file([
'package.json',
'README.md',
'src/index.ts',
'test/index.test.ts',
]);
});
});

Expand All @@ -65,7 +70,12 @@ describe('generator-superset:package', () => {
);

it('creates files', () => {
assert.file(['package.json', 'README.md', 'src/index.js', 'test/index.test.js']);
assert.file([
'package.json',
'README.md',
'src/index.js',
'test/index.test.js',
]);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ function CertifiedIconWithTooltip({
id={`${kebabCase(metricName)}-tooltip`}
title={
<div>
{certifiedBy && <StyledDiv>{t('Certified by %s', certifiedBy)}</StyledDiv>}
{certifiedBy && (
<StyledDiv>{t('Certified by %s', certifiedBy)}</StyledDiv>
)}
<div>{details}</div>
</div>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ export function ColumnOption({
trigger={['hover']}
placement="top"
>
<span className="m-r-5 option-label column-option-label" ref={labelRef}>
<span
className="m-r-5 option-label column-option-label"
ref={labelRef}
>
{column.verbose_name || column.column_name}
</span>
</Tooltip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export type ControlFormItemProps = ControlFormItemSpec & {
onChange?: (fieldValue: JsonValue) => void;
};

export type ControlFormItemNode = FunctionComponentElement<ControlFormItemProps>;
export type ControlFormItemNode =
FunctionComponentElement<ControlFormItemProps>;

/**
* Accept `false` or `0`, but not empty string.
Expand All @@ -53,7 +54,9 @@ export function ControlFormItem({
}: ControlFormItemProps) {
const { gridUnit } = useTheme();
const [hovered, setHovered] = useState(false);
const [value, setValue] = useState(initialValue === undefined ? defaultValue : initialValue);
const [value, setValue] = useState(
initialValue === undefined ? defaultValue : initialValue,
);
const [validationErrors, setValidationErrors] =
useState<ControlHeaderProps['validationErrors']>();

Expand All @@ -66,7 +69,9 @@ export function ControlFormItem({
: e;
const errors =
(validators
?.map(validator => (!required && isEmptyValue(fieldValue) ? false : validator(fieldValue)))
?.map(validator =>
!required && isEmptyValue(fieldValue) ? false : validator(fieldValue),
)
.filter(x => !!x) as string[]) || [];
setValidationErrors(errors);
setValue(fieldValue);
Expand All @@ -87,8 +92,14 @@ export function ControlFormItem({
onMouseLeave={() => setHovered(false)}
>
{controlType === 'Checkbox' ? (
<ControlFormItemComponents.Checkbox checked={value as boolean} onChange={handleChange}>
{label} {hovered && description && <InfoTooltipWithTrigger tooltip={description} />}
<ControlFormItemComponents.Checkbox
checked={value as boolean}
onChange={handleChange}
>
{label}{' '}
{hovered && description && (
<InfoTooltipWithTrigger tooltip={description} />
)}
</ControlFormItemComponents.Checkbox>
) : (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
* under the License.
*/
import React, { FunctionComponentElement, useMemo } from 'react';
import { FAST_DEBOUNCE, JsonObject, JsonValue, useTheme } from '@superset-ui/core';
import {
FAST_DEBOUNCE,
JsonObject,
JsonValue,
useTheme,
} from '@superset-ui/core';
import { debounce } from 'lodash';
import { ControlFormItemNode } from './ControlFormItem';

Expand Down Expand Up @@ -57,7 +62,11 @@ export type ControlFormProps = {
/**
* Light weight form for control panel.
*/
export default function ControlForm({ onChange, value, children }: ControlFormProps) {
export default function ControlForm({
onChange,
value,
children,
}: ControlFormProps) {
const theme = useTheme();
const debouncedOnChange = useMemo(
() =>
Expand Down Expand Up @@ -94,7 +103,10 @@ export default function ControlForm({ onChange, value, children }: ControlFormPr
}
// propagate to the form
if (!(debounceDelay in debouncedOnChange)) {
debouncedOnChange[debounceDelay] = debounce(onChange, debounceDelay);
debouncedOnChange[debounceDelay] = debounce(
onChange,
debounceDelay,
);
}
debouncedOnChange[debounceDelay]({
...value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ export default function ControlHeader({
)}
{validationErrors.length > 0 && (
<span>
<Tooltip id="error-tooltip" placement="top" title={validationErrors.join(' ')}>
<Tooltip
id="error-tooltip"
placement="top"
title={validationErrors.join(' ')}
>
<i className="fa fa-exclamation-circle text-danger" />
</Tooltip>{' '}
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ export function InfoTooltipWithTrigger({
className = 'text-muted',
placement = 'right',
}: InfoTooltipWithTriggerProps) {
const iconClass = `fa fa-${icon} ${className} ${bsStyle ? `text-${bsStyle}` : ''}`;
const iconClass = `fa fa-${icon} ${className} ${
bsStyle ? `text-${bsStyle}` : ''
}`;
const iconEl = (
<i
role="button"
Expand All @@ -64,7 +66,11 @@ export function InfoTooltipWithTrigger({
return iconEl;
}
return (
<Tooltip id={`${kebabCase(label)}-tooltip`} title={tooltip} placement={placement}>
<Tooltip
id={`${kebabCase(label)}-tooltip`}
title={tooltip}
placement={placement}
>
{iconEl}
</Tooltip>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ export function MetricOption({
/>
)}
{showTooltip ? (
<Tooltip id="metric-name-tooltip" title={verbose} trigger={['hover']} placement="top">
<Tooltip
id="metric-name-tooltip"
title={verbose}
trigger={['hover']}
placement="top"
>
<span className="option-label metric-option-label" ref={labelRef}>
{link}
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ export const Tooltip = ({ overlayStyle, color, ...props }: TooltipProps) => {
`}
/>
<BaseTooltip
overlayStyle={{ fontSize: theme.typography.sizes.s, lineHeight: '1.6', ...overlayStyle }}
overlayStyle={{
fontSize: theme.typography.sizes.s,
lineHeight: '1.6',
...overlayStyle,
}}
color={defaultColor || color}
{...props}
/>
Expand Down
4 changes: 3 additions & 1 deletion packages/superset-ui-chart-controls/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ export const TIME_COLUMN_OPTION: ColumnMeta = {
verbose_name: COLUMN_NAME_ALIASES[DTTM_ALIAS],
column_name: DTTM_ALIAS,
type_generic: GenericDataType.TEMPORAL,
description: t('A reference to the [Time] configuration, taking granularity into account'),
description: t(
'A reference to the [Time] configuration, taking granularity into account',
),
};

export const QueryModeLabel = {
Expand Down
6 changes: 5 additions & 1 deletion packages/superset-ui-chart-controls/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ export * from './components/ColumnTypeLabel';
export * from './components/MetricOption';

// React control components
export { sharedControls, dndEntity, dndColumnsControl } from './shared-controls';
export {
sharedControls,
dndEntity,
dndColumnsControl,
} from './shared-controls';
export { default as sharedControlComponents } from './shared-controls/components';
export { legacySortBy } from './shared-controls/legacySortBy';
export * from './shared-controls/emitFilterControl';
Expand Down
Loading

1 comment on commit 887adbd

@vercel
Copy link

@vercel vercel bot commented on 887adbd Nov 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.