Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added editor config based on styleguide - #1205 #1206

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"presets": [
"@babel/react",
"@babel/env"
],
"plugins": ["@babel/plugin-transform-object-assign", "@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-proposal-class-properties", "babel-plugin-array-includes","@babel/plugin-transform-async-to-generator"]
"presets": ["@babel/react", "@babel/env"],
"plugins": [
"@babel/plugin-transform-object-assign",
"@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-proposal-class-properties",
"babel-plugin-array-includes",
"@babel/plugin-transform-async-to-generator"
]
}
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true
popojargo marked this conversation as resolved.
Show resolved Hide resolved

[*]
charset = utf-8
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_new_line = true
end_of_line = lf
17 changes: 6 additions & 11 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,23 @@
"root": true,
"parser": "babel-eslint",

"plugins": [
"react"
],
"plugins": ["react", "prettier"],

"extends": [
"eslint:recommended",
"plugin:react/recommended"
],
"extends": ["eslint:recommended", "plugin:react/recommended", "prettier", "prettier/react"],

"rules": {
"semi": ["error", "always"],
"keyword-spacing": "error",
"space-infix-ops": "error",
"space-before-blocks": "error",
"array-bracket-spacing": ["error", "never"],
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
"brace-style": ["error", "1tbs", {"allowSingleLine": true}],
"comma-spacing": ["error", {"before": false, "after": true}],
"computed-property-spacing": ["error", "never"],
"eol-last": "error",
"indent": ["error", 2, { "SwitchCase": 1, "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } }],
"indent": ["error", 2, {"SwitchCase": 1, "VariableDeclarator": {"var": 2, "let": 2, "const": 3}}],
"no-case-declarations": "off",
"no-console": [1, { "allow": ["warn", "error", "info"] }],
"no-console": [1, {"allow": ["warn", "error", "info"]}],
"no-else-return": "error",
"no-mixed-spaces-and-tabs": ["error", "smart-tabs"],
"no-trailing-spaces": "error",
Expand All @@ -33,7 +28,7 @@
"no-unused-vars": ["error", {"varsIgnorePattern": "ReactDOM"}],
"react/display-name": "off",
// disabling for now since there are too many components without PropTypes
"react/prop-types": "off"
"react/prop-types": "off"
},

"parserOptions": {
Expand Down
9 changes: 9 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
dist/
test/
assets/

app/**/*.react.js
app/addons/.module-cache
app/addons/**/assets/*
app/addons/**/dependencies/*
app/load_addons.js
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"trailingComma": "es5",
"semi": true,
"singleQuote": true,
"bracketSpacing": false,
"printWidth": 120
}
24 changes: 9 additions & 15 deletions app/addons/activetasks/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,16 @@
// License for the specific language governing permissions and limitations under
// the License.

import { connect } from 'react-redux';
import {connect} from 'react-redux';
import Controller from './layout';
import {
init,
setSearchTerm,
sortByColumnHeader,
switchTab,
runPollingUpdate
} from './actions';
import {init, setSearchTerm, sortByColumnHeader, switchTab, runPollingUpdate} from './actions';
import {
getTasks,
getHeaderIsAscending,
getSelectedRadio,
getSortByHeader,
getSearchTerm,
getIsLoading
getIsLoading,
} from './reducers';

const mapStateToProps = ({activetasks}) => {
Expand All @@ -35,17 +29,17 @@ const mapStateToProps = ({activetasks}) => {
selectedRadio: getSelectedRadio(activetasks),
sortByHeader: getSortByHeader(activetasks),
searchTerm: getSearchTerm(activetasks),
isLoading: getIsLoading(activetasks)
isLoading: getIsLoading(activetasks),
};
};

const mapDispatchToProps = (dispatch) => {
const mapDispatchToProps = dispatch => {
return {
init: () => dispatch(init()),
setSearchTerm: (term) => dispatch(setSearchTerm(term)),
sortByColumnHeader: (column) => dispatch(sortByColumnHeader(column)),
switchTab: (tab) => dispatch(switchTab(tab)),
runPollingUpdate: () => dispatch(runPollingUpdate())
setSearchTerm: term => dispatch(setSearchTerm(term)),
sortByColumnHeader: column => dispatch(sortByColumnHeader(column)),
switchTab: tab => dispatch(switchTab(tab)),
runPollingUpdate: () => dispatch(runPollingUpdate()),
};
};

Expand Down
6 changes: 2 additions & 4 deletions app/addons/components/__tests__/accordion.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@
// License for the specific language governing permissions and limitations under
// the License.

import { Accordion, AccordionItem } from '../components/accordion';
import { mount } from 'enzyme';
import {Accordion, AccordionItem} from '../components/accordion';
import {mount} from 'enzyme';
import React from 'react';
import sinon from 'sinon';

describe('Accordion', () => {

it('Shows and hides content after clicking on header', () => {
const el = mount(
<Accordion>
Expand Down Expand Up @@ -44,5 +43,4 @@ describe('Accordion', () => {
el.find('.faux--accordion__item-header').simulate('click');
sinon.assert.called(spy);
});

});
38 changes: 14 additions & 24 deletions app/addons/components/components/accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@

import PropTypes from 'prop-types';
import React from 'react';
import { Collapse } from 'react-bootstrap';
import {Collapse} from 'react-bootstrap';
import classnames from 'classnames';

export const Accordion = (props) => {
const { children, className, style } = props;
export const Accordion = props => {
const {children, className, style} = props;
const classNames = classnames('faux--accordion', className);
return (
<ul className={classNames} style={style}>
Expand All @@ -27,46 +27,36 @@ export const Accordion = (props) => {

export class AccordionItem extends React.Component {
static propTypes = {
title: PropTypes.string.isRequired
title: PropTypes.string.isRequired,
};

static defaultProps = {
onClick: () => { }
onClick: () => {},
};

state = {
open: false
open: false,
};

handleClick = (event) => {
handleClick = event => {
const newOpen = !this.state.open;
this.setState({ open: newOpen });
this.props.onClick({ isOpen: newOpen, event });
this.setState({open: newOpen});
this.props.onClick({isOpen: newOpen, event});
};

render() {
const { children, title } = this.props;
const {children, title} = this.props;
const icon = this.state.open ? 'fonticon-down-open' : 'fonticon-right-open';
const contentClassNames = classnames(
'faux--accordion__item-content', 'collapse',
{in: this.state.open}
);
const contentClassNames = classnames('faux--accordion__item-content', 'collapse', {in: this.state.open});

return (
<li
className='faux--accordion__item'
onClick={this.handleClick}>
<button
type="button"
className={`faux--accordion__item-header`}
onClick={this.handleClick}>
<li className="faux--accordion__item" onClick={this.handleClick}>
<button type="button" className={`faux--accordion__item-header`} onClick={this.handleClick}>
<i className={icon}></i>
<span>{title}</span>
</button>
<Collapse in={this.state.open}>
<div className={contentClassNames}>
{ children }
</div>
<div className={contentClassNames}>{children}</div>
</Collapse>
</li>
);
Expand Down
4 changes: 2 additions & 2 deletions app/addons/components/components/apibar.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
// License for the specific language governing permissions and limitations under
// the License.

import React from "react";
import ReactDOM from "react-dom";
import React from 'react';
import ReactDOM from 'react-dom';

export const JSONLink = ({endpoint}) => {
if (!endpoint) {
Expand Down
Loading