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:
@@ -1,11 +1,11 @@
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import classnames from 'classnames';
|
||||
import { noop, pick } from 'lodash';
|
||||
import React, { Component } from "react";
|
||||
import PropTypes from "prop-types";
|
||||
import classnames from "classnames";
|
||||
import { noop, pick } from "lodash";
|
||||
|
||||
import FormField from 'components/forms/FormField';
|
||||
import FormField from "components/forms/FormField";
|
||||
|
||||
const baseClass = 'input-field';
|
||||
const baseClass = "input-field";
|
||||
|
||||
class InputField extends Component {
|
||||
static propTypes = {
|
||||
@@ -20,23 +20,25 @@ class InputField extends Component {
|
||||
onFocus: PropTypes.func,
|
||||
placeholder: PropTypes.string,
|
||||
type: PropTypes.string,
|
||||
value: PropTypes.oneOfType(
|
||||
[PropTypes.bool, PropTypes.string, PropTypes.number],
|
||||
).isRequired,
|
||||
value: PropTypes.oneOfType([
|
||||
PropTypes.bool,
|
||||
PropTypes.string,
|
||||
PropTypes.number,
|
||||
]).isRequired,
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
autofocus: false,
|
||||
inputWrapperClass: '',
|
||||
inputWrapperClass: "",
|
||||
inputOptions: {},
|
||||
label: null,
|
||||
labelClassName: '',
|
||||
labelClassName: "",
|
||||
onFocus: noop,
|
||||
type: 'text',
|
||||
value: '',
|
||||
type: "text",
|
||||
value: "",
|
||||
};
|
||||
|
||||
componentDidMount () {
|
||||
componentDidMount() {
|
||||
const { autofocus } = this.props;
|
||||
const { input } = this;
|
||||
|
||||
@@ -54,9 +56,9 @@ class InputField extends Component {
|
||||
const { onChange } = this.props;
|
||||
|
||||
return onChange(value);
|
||||
}
|
||||
};
|
||||
|
||||
render () {
|
||||
render() {
|
||||
const {
|
||||
disabled,
|
||||
error,
|
||||
@@ -70,19 +72,23 @@ class InputField extends Component {
|
||||
value,
|
||||
} = this.props;
|
||||
const { onInputChange } = this;
|
||||
const shouldShowPasswordClass = type === 'password';
|
||||
const shouldShowPasswordClass = type === "password";
|
||||
const inputClasses = classnames(baseClass, inputClassName, {
|
||||
[`${baseClass}--password`]: shouldShowPasswordClass,
|
||||
[`${baseClass}--disabled`]: disabled,
|
||||
[`${baseClass}--error`]: error,
|
||||
[`${baseClass}__textarea`]: type === 'textarea',
|
||||
[`${baseClass}__textarea`]: type === "textarea",
|
||||
});
|
||||
|
||||
const formFieldProps = pick(this.props, ['hint', 'label', 'error', 'name']);
|
||||
const formFieldProps = pick(this.props, ["hint", "label", "error", "name"]);
|
||||
|
||||
if (type === 'textarea') {
|
||||
if (type === "textarea") {
|
||||
return (
|
||||
<FormField {...formFieldProps} type="textarea" className={inputWrapperClass}>
|
||||
<FormField
|
||||
{...formFieldProps}
|
||||
type="textarea"
|
||||
className={inputWrapperClass}
|
||||
>
|
||||
<textarea
|
||||
name={name}
|
||||
id={name}
|
||||
@@ -90,7 +96,9 @@ class InputField extends Component {
|
||||
className={inputClasses}
|
||||
disabled={disabled}
|
||||
placeholder={placeholder}
|
||||
ref={(r) => { this.input = r; }}
|
||||
ref={(r) => {
|
||||
this.input = r;
|
||||
}}
|
||||
type={type}
|
||||
{...inputOptions}
|
||||
value={value}
|
||||
@@ -109,7 +117,9 @@ class InputField extends Component {
|
||||
onFocus={onFocus}
|
||||
className={inputClasses}
|
||||
placeholder={placeholder}
|
||||
ref={(r) => { this.input = r; }}
|
||||
ref={(r) => {
|
||||
this.input = r;
|
||||
}}
|
||||
type={type}
|
||||
{...inputOptions}
|
||||
value={value}
|
||||
@@ -120,4 +130,3 @@ class InputField extends Component {
|
||||
}
|
||||
|
||||
export default InputField;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
font-size: $small;
|
||||
padding: $pad-xsmall 12px;
|
||||
color: $core-medium-blue-grey;
|
||||
font-family: 'Nunito Sans', sans-serif;
|
||||
font-family: "Nunito Sans", sans-serif;
|
||||
box-sizing: border-box;
|
||||
height: 40px;
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
color: $core-blue;
|
||||
background-color: $ui-medium-grey;
|
||||
padding: 2px;
|
||||
font-family: 'SourceCodePro', $monospace;
|
||||
font-family: "SourceCodePro", $monospace;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
export { default } from './InputField';
|
||||
export { default } from "./InputField";
|
||||
|
||||
Reference in New Issue
Block a user