Skip to content

Commit 56d3be2

Browse files
authored
Prettier all the Javascript code & GitHub Action (getredash#4433)
* Prettier all the JS files * Add GitHub Action to autoformat code pushed to master * Fix eslint violation due to formatting. * Remove GitHub actions for styling * Add restyled.io config
1 parent 81b14a5 commit 56d3be2

File tree

375 files changed

+10069
-9198
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

375 files changed

+10069
-9198
lines changed

.github/workflows/black.yml

-31
This file was deleted.

.restyled.yaml

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
enabled: true
2+
3+
auto: false
4+
5+
# Open Restyle PRs?
6+
pull_requests: true
7+
8+
# Leave comments on the original PR linking to the Restyle PR?
9+
comments: true
10+
11+
# Set commit statuses on the original PR?
12+
statuses:
13+
# Red status in the case of differences found
14+
differences: true
15+
# Green status in the case of no differences found
16+
no_differences: true
17+
# Red status if we encounter errors restyling
18+
error: true
19+
20+
# Request review on the Restyle PR?
21+
#
22+
# Possible values:
23+
#
24+
# author: From the author of the original PR
25+
# owner: From the owner of the repository
26+
# none: Don't
27+
#
28+
# One value will apply to both origin and forked PRs, but you can also specify
29+
# separate values.
30+
#
31+
# request_review:
32+
# origin: author
33+
# forked: owner
34+
#
35+
request_review: author
36+
37+
# Add labels to any created Restyle PRs
38+
#
39+
# These can be used to tell other automation to avoid our PRs.
40+
#
41+
labels: ["Skip CI"]
42+
43+
# Labels to ignore
44+
#
45+
# PRs with any of these labels will be ignored by Restyled.
46+
#
47+
# ignore_labels:
48+
# - restyled-ignore
49+
50+
# Restylers to run, and how
51+
restylers:
52+
- name: black:
53+
include:
54+
- redash
55+
- tests
56+
- migrations/versions
57+
- name: prettier:
58+
include:
59+
- client/app/**/*.js
60+
- client/app/**/*.jsx
61+
- client/cypress/**/*.js

client/app/.eslintrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ module.exports = {
77
rules: {
88
"jest/no-focused-tests": "off",
99
},
10-
};
10+
};

client/app/__tests__/enzyme_setup.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { configure } from 'enzyme';
2-
import Adapter from 'enzyme-adapter-react-16';
1+
import { configure } from "enzyme";
2+
import Adapter from "enzyme-adapter-react-16";
33

44
configure({ adapter: new Adapter() });

client/app/__tests__/mocks.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import MockDate from 'mockdate';
1+
import MockDate from "mockdate";
22

3-
const date = new Date('2000-01-01T02:00:00.000');
3+
const date = new Date("2000-01-01T02:00:00.000");
44

55
MockDate.set(date);

client/app/components/AceEditorInput.jsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import React, { forwardRef } from 'react';
2-
import AceEditor from 'react-ace';
1+
import React, { forwardRef } from "react";
2+
import AceEditor from "react-ace";
33

4-
import './AceEditorInput.less';
4+
import "./AceEditorInput.less";
55

66
function AceEditorInput(props, ref) {
77
return (

client/app/components/AutocompleteToggle.jsx

+16-17
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,35 @@
1-
import React from 'react';
2-
import Tooltip from 'antd/lib/tooltip';
3-
import PropTypes from 'prop-types';
4-
import '@/redash-font/style.less';
5-
import recordEvent from '@/services/recordEvent';
1+
import React from "react";
2+
import Tooltip from "antd/lib/tooltip";
3+
import PropTypes from "prop-types";
4+
import "@/redash-font/style.less";
5+
import recordEvent from "@/services/recordEvent";
66

77
export default function AutocompleteToggle({ state, disabled, onToggle }) {
8-
let tooltipMessage = 'Live Autocomplete Enabled';
9-
let icon = 'icon-flash';
8+
let tooltipMessage = "Live Autocomplete Enabled";
9+
let icon = "icon-flash";
1010
if (!state) {
11-
tooltipMessage = 'Live Autocomplete Disabled';
12-
icon = 'icon-flash-off';
11+
tooltipMessage = "Live Autocomplete Disabled";
12+
icon = "icon-flash-off";
1313
}
1414

1515
if (disabled) {
16-
tooltipMessage = 'Live Autocomplete Not Available (Use Ctrl+Space to Trigger)';
17-
icon = 'icon-flash-off';
16+
tooltipMessage = "Live Autocomplete Not Available (Use Ctrl+Space to Trigger)";
17+
icon = "icon-flash-off";
1818
}
1919

20-
const toggle = (newState) => {
21-
recordEvent('toggle_autocomplete', 'screen', 'query_editor', { state: newState });
20+
const toggle = newState => {
21+
recordEvent("toggle_autocomplete", "screen", "query_editor", { state: newState });
2222
onToggle(newState);
2323
};
2424

2525
return (
2626
<Tooltip placement="top" title={tooltipMessage}>
2727
<button
2828
type="button"
29-
className={'btn btn-default m-r-5' + (disabled ? ' disabled' : '')}
29+
className={"btn btn-default m-r-5" + (disabled ? " disabled" : "")}
3030
onClick={() => toggle(!state)}
31-
disabled={disabled}
32-
>
33-
<i className={'icon ' + icon} />
31+
disabled={disabled}>
32+
<i className={"icon " + icon} />
3433
</button>
3534
</Tooltip>
3635
);

client/app/components/BeaconConsent.jsx

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import React, { useState } from 'react';
2-
import Card from 'antd/lib/card';
3-
import Button from 'antd/lib/button';
4-
import Typography from 'antd/lib/typography';
5-
import { clientConfig } from '@/services/auth';
6-
import HelpTrigger from '@/components/HelpTrigger';
7-
import DynamicComponent from '@/components/DynamicComponent';
8-
import OrgSettings from '@/services/organizationSettings';
1+
import React, { useState } from "react";
2+
import Card from "antd/lib/card";
3+
import Button from "antd/lib/button";
4+
import Typography from "antd/lib/typography";
5+
import { clientConfig } from "@/services/auth";
6+
import HelpTrigger from "@/components/HelpTrigger";
7+
import DynamicComponent from "@/components/DynamicComponent";
8+
import OrgSettings from "@/services/organizationSettings";
99

1010
const Text = Typography.Text;
1111

@@ -21,11 +21,11 @@ function BeaconConsent() {
2121
setHide(true);
2222
};
2323

24-
const confirmConsent = (confirm) => {
25-
let message = '🙏 Thank you.';
24+
const confirmConsent = confirm => {
25+
let message = "🙏 Thank you.";
2626

2727
if (!confirm) {
28-
message = 'Settings Saved.';
28+
message = "Settings Saved.";
2929
}
3030

3131
OrgSettings.save({ beacon_consent: confirm }, message)
@@ -40,14 +40,13 @@ function BeaconConsent() {
4040
<DynamicComponent name="BeaconConsent">
4141
<div className="m-t-10 tiled">
4242
<Card
43-
title={(
43+
title={
4444
<>
45-
Would you be ok with sharing anonymous usage data with the Redash team?{' '}
45+
Would you be ok with sharing anonymous usage data with the Redash team?{" "}
4646
<HelpTrigger type="USAGE_DATA_SHARING" />
4747
</>
48-
)}
49-
bordered={false}
50-
>
48+
}
49+
bordered={false}>
5150
<Text>Help Redash improve by automatically sending anonymous usage data:</Text>
5251
<div className="m-t-5">
5352
<ul>
@@ -66,7 +65,8 @@ function BeaconConsent() {
6665
</div>
6766
<div className="m-t-15">
6867
<Text type="secondary">
69-
You can change this setting anytime from the <a href="settings/organization">Organization Settings</a> page.
68+
You can change this setting anytime from the <a href="settings/organization">Organization Settings</a>{" "}
69+
page.
7070
</Text>
7171
</div>
7272
</Card>

client/app/components/BigMessage.jsx

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import React from 'react';
2-
import PropTypes from 'prop-types';
3-
import { react2angular } from 'react2angular';
1+
import React from "react";
2+
import PropTypes from "prop-types";
3+
import { react2angular } from "react2angular";
44

55
export function BigMessage({ message, icon, children, className }) {
66
return (
7-
<div className={'p-15 text-center ' + className}>
7+
<div className={"p-15 text-center " + className}>
88
<h3 className="m-t-0 m-b-0">
9-
<i className={'fa ' + icon} />
9+
<i className={"fa " + icon} />
1010
</h3>
1111
<br />
1212
{message}
@@ -23,13 +23,13 @@ BigMessage.propTypes = {
2323
};
2424

2525
BigMessage.defaultProps = {
26-
message: '',
26+
message: "",
2727
children: null,
28-
className: 'tiled bg-white',
28+
className: "tiled bg-white",
2929
};
3030

3131
export default function init(ngModule) {
32-
ngModule.component('bigMessage', react2angular(BigMessage));
32+
ngModule.component("bigMessage", react2angular(BigMessage));
3333
}
3434

3535
init.init = true;

client/app/components/CodeBlock.jsx

+11-16
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import React from 'react';
2-
import PropTypes from 'prop-types';
3-
import Button from 'antd/lib/button';
4-
import Tooltip from 'antd/lib/tooltip';
5-
import './CodeBlock.less';
1+
import React from "react";
2+
import PropTypes from "prop-types";
3+
import Button from "antd/lib/button";
4+
import Tooltip from "antd/lib/tooltip";
5+
import "./CodeBlock.less";
66

77
export default class CodeBlock extends React.Component {
88
static propTypes = {
@@ -20,7 +20,7 @@ export default class CodeBlock extends React.Component {
2020
constructor(props) {
2121
super(props);
2222
this.ref = React.createRef();
23-
this.copyFeatureEnabled = props.copyable && document.queryCommandSupported('copy');
23+
this.copyFeatureEnabled = props.copyable && document.queryCommandSupported("copy");
2424
this.resetCopyState = null;
2525
}
2626

@@ -36,14 +36,14 @@ export default class CodeBlock extends React.Component {
3636

3737
// copy
3838
try {
39-
const success = document.execCommand('copy');
39+
const success = document.execCommand("copy");
4040
if (!success) {
4141
throw new Error();
4242
}
43-
this.setState({ copied: 'Copied!' });
43+
this.setState({ copied: "Copied!" });
4444
} catch (err) {
4545
this.setState({
46-
copied: 'Copy failed',
46+
copied: "Copy failed",
4747
});
4848
}
4949

@@ -58,13 +58,8 @@ export default class CodeBlock extends React.Component {
5858
const { copyable, children, ...props } = this.props;
5959

6060
const copyButton = (
61-
<Tooltip title={this.state.copied || 'Copy'}>
62-
<Button
63-
icon="copy"
64-
type="dashed"
65-
size="small"
66-
onClick={this.copy}
67-
/>
61+
<Tooltip title={this.state.copied || "Copy"}>
62+
<Button icon="copy" type="dashed" size="small" onClick={this.copy} />
6863
</Tooltip>
6964
);
7065

client/app/components/Collapse.jsx

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
import React from 'react';
2-
import PropTypes from 'prop-types';
3-
import cx from 'classnames';
4-
import AntCollapse from 'antd/lib/collapse';
1+
import React from "react";
2+
import PropTypes from "prop-types";
3+
import cx from "classnames";
4+
import AntCollapse from "antd/lib/collapse";
55

66
export default function Collapse({ collapsed, children, className, ...props }) {
77
return (
8-
<AntCollapse {...props} activeKey={collapsed ? null : 'content'} className={cx(className, 'ant-collapse-headerless')}>
9-
<AntCollapse.Panel key="content" header="">{children}</AntCollapse.Panel>
8+
<AntCollapse
9+
{...props}
10+
activeKey={collapsed ? null : "content"}
11+
className={cx(className, "ant-collapse-headerless")}>
12+
<AntCollapse.Panel key="content" header="">
13+
{children}
14+
</AntCollapse.Panel>
1015
</AntCollapse>
1116
);
1217
}
@@ -20,5 +25,5 @@ Collapse.propTypes = {
2025
Collapse.defaultProps = {
2126
collapsed: true,
2227
children: null,
23-
className: '',
28+
className: "",
2429
};

client/app/components/ColorBox.jsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// ANGULAR_REMOVE_ME
2-
import { react2angular } from 'react2angular';
2+
import { react2angular } from "react2angular";
33

4-
import ColorPicker from '@/components/ColorPicker';
4+
import ColorPicker from "@/components/ColorPicker";
55

6-
import './color-box.less';
6+
import "./color-box.less";
77

88
export default function init(ngModule) {
9-
ngModule.component('colorBox', react2angular(ColorPicker.Swatch));
9+
ngModule.component("colorBox", react2angular(ColorPicker.Swatch));
1010
}
1111

1212
init.init = true;

0 commit comments

Comments
 (0)