add prettier and have it format all fleet application code (#625)

* add prettier and have it format all js code except website:
:

* trying running prettier check in CI

* fix runs on in CI

* change CI job name

* fix prettier erros and fix CI
This commit is contained in:
Gabe Hernandez
2021-04-12 14:32:25 +01:00
committed by GitHub
parent df5fa7f515
commit efb35b537a
631 changed files with 31167 additions and 29930 deletions
@@ -1,54 +1,64 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { pull } from 'lodash';
import React, { Component } from "react";
import PropTypes from "prop-types";
import { pull } from "lodash";
import KolideIcon from 'components/icons/KolideIcon';
import Button from 'components/buttons/Button';
import Dropdown from 'components/forms/fields/Dropdown';
import Form from 'components/forms/Form';
import formFieldInterface from 'interfaces/form_field';
import InputField from 'components/forms/fields/InputField';
import validate from 'components/forms/ConfigurePackQueryForm/validate';
import KolideIcon from "components/icons/KolideIcon";
import Button from "components/buttons/Button";
import Dropdown from "components/forms/fields/Dropdown";
import Form from "components/forms/Form";
import formFieldInterface from "interfaces/form_field";
import InputField from "components/forms/fields/InputField";
import validate from "components/forms/ConfigurePackQueryForm/validate";
const baseClass = 'configure-pack-query-form';
const fieldNames = ['query_id', 'interval', 'logging_type', 'platform', 'shard', 'version'];
const baseClass = "configure-pack-query-form";
const fieldNames = [
"query_id",
"interval",
"logging_type",
"platform",
"shard",
"version",
];
const platformOptions = [
{ label: 'All', value: '' },
{ label: 'Windows', value: 'windows' },
{ label: 'Linux', value: 'linux' },
{ label: 'macOS', value: 'darwin' },
{ label: "All", value: "" },
{ label: "Windows", value: "windows" },
{ label: "Linux", value: "linux" },
{ label: "macOS", value: "darwin" },
];
const loggingTypeOptions = [
{ label: 'Differential', value: 'differential' },
{ label: 'Differential (Ignore Removals)', value: 'differential_ignore_removals' },
{ label: 'Snapshot', value: 'snapshot' },
{ label: "Differential", value: "differential" },
{
label: "Differential (Ignore Removals)",
value: "differential_ignore_removals",
},
{ label: "Snapshot", value: "snapshot" },
];
const minOsqueryVersionOptions = [
{ label: 'All', value: '' },
{ label: '4.7.0 +', value: '4.7.0' },
{ label: '4.6.0 +', value: '4.6.0' },
{ label: '4.5.1 +', value: '4.5.1' },
{ label: '4.5.0 +', value: '4.5.0' },
{ label: '4.4.0 +', value: '4.4.0' },
{ label: '4.3.0 +', value: '4.3.0' },
{ label: '4.2.0 +', value: '4.2.0' },
{ label: '4.1.2 +', value: '4.1.2' },
{ label: '4.1.1 +', value: '4.1.1' },
{ label: '4.1.0 +', value: '4.1.0' },
{ label: '4.0.2 +', value: '4.0.2' },
{ label: '4.0.1 +', value: '4.0.1' },
{ label: '4.0.0 +', value: '4.0.0' },
{ label: '3.4.0 +', value: '3.4.0' },
{ label: '3.3.2 +', value: '3.3.2' },
{ label: '3.3.1 +', value: '3.3.1' },
{ label: '3.2.6 +', value: '3.2.6' },
{ label: '2.2.1 +', value: '2.2.1' },
{ label: '2.2.0 +', value: '2.2.0' },
{ label: '2.1.2 +', value: '2.1.2' },
{ label: '2.1.1 +', value: '2.1.1' },
{ label: '2.0.0 +', value: '2.0.0' },
{ label: '1.8.2 +', value: '1.8.2' },
{ label: '1.8.1 +', value: '1.8.1' },
{ label: "All", value: "" },
{ label: "4.7.0 +", value: "4.7.0" },
{ label: "4.6.0 +", value: "4.6.0" },
{ label: "4.5.1 +", value: "4.5.1" },
{ label: "4.5.0 +", value: "4.5.0" },
{ label: "4.4.0 +", value: "4.4.0" },
{ label: "4.3.0 +", value: "4.3.0" },
{ label: "4.2.0 +", value: "4.2.0" },
{ label: "4.1.2 +", value: "4.1.2" },
{ label: "4.1.1 +", value: "4.1.1" },
{ label: "4.1.0 +", value: "4.1.0" },
{ label: "4.0.2 +", value: "4.0.2" },
{ label: "4.0.1 +", value: "4.0.1" },
{ label: "4.0.0 +", value: "4.0.0" },
{ label: "3.4.0 +", value: "3.4.0" },
{ label: "3.3.2 +", value: "3.3.2" },
{ label: "3.3.1 +", value: "3.3.1" },
{ label: "3.2.6 +", value: "3.2.6" },
{ label: "2.2.1 +", value: "2.2.1" },
{ label: "2.2.0 +", value: "2.2.0" },
{ label: "2.1.2 +", value: "2.1.2" },
{ label: "2.1.1 +", value: "2.1.1" },
{ label: "2.0.0 +", value: "2.0.0" },
{ label: "1.8.2 +", value: "1.8.2" },
{ label: "1.8.1 +", value: "1.8.1" },
];
export class ConfigurePackQueryForm extends Component {
@@ -67,11 +77,11 @@ export class ConfigurePackQueryForm extends Component {
onCancel: PropTypes.func,
};
componentWillMount () {
componentWillMount() {
const { fields } = this.props;
if (fields && fields.shard && !fields.shard.value) {
fields.shard.value = '';
fields.shard.value = "";
}
}
@@ -81,24 +91,26 @@ export class ConfigurePackQueryForm extends Component {
const { formData, onCancel: handleCancel } = this.props;
return handleCancel(formData);
}
};
handlePlatformChoice = (value) => {
const { fields: { platform } } = this.props;
const valArray = value.split(',');
const {
fields: { platform },
} = this.props;
const valArray = value.split(",");
// Remove All if another OS is chosen
if (valArray.indexOf('') === 0 && valArray.length > 1) {
return platform.onChange(pull(valArray, '').join(','));
if (valArray.indexOf("") === 0 && valArray.length > 1) {
return platform.onChange(pull(valArray, "").join(","));
}
// Remove OS if All is chosen
if (valArray.length > 1 && valArray.indexOf('') > -1) {
return platform.onChange('');
if (valArray.length > 1 && valArray.indexOf("") > -1) {
return platform.onChange("");
}
return platform.onChange(value);
}
};
renderCancelButton = () => {
const { formData } = this.props;
@@ -109,13 +121,17 @@ export class ConfigurePackQueryForm extends Component {
}
return (
<Button className={`${baseClass}__cancel-btn`} onClick={onCancel} variant="inverse">
<Button
className={`${baseClass}__cancel-btn`}
onClick={onCancel}
variant="inverse"
>
Cancel
</Button>
);
}
};
render () {
render() {
const { fields, handleSubmit } = this.props;
const { handlePlatformChoice, renderCancelButton } = this;
@@ -144,7 +160,11 @@ export class ConfigurePackQueryForm extends Component {
{...fields.version}
options={minOsqueryVersionOptions}
placeholder="- - -"
label={['minimum ', <KolideIcon name="osquery" key="min-osquery-vers" />, ' version']}
label={[
"minimum ",
<KolideIcon name="osquery" key="min-osquery-vers" />,
" version",
]}
wrapperClassName={`${baseClass}__form-field ${baseClass}__form-field--osquer-vers`}
/>
<Dropdown
@@ -163,7 +183,11 @@ export class ConfigurePackQueryForm extends Component {
/>
<div className={`${baseClass}__btn-wrapper`}>
{renderCancelButton()}
<Button className={`${baseClass}__submit-btn`} type="submit" variant="brand">
<Button
className={`${baseClass}__submit-btn`}
type="submit"
variant="brand"
>
Save
</Button>
</div>