Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Simplifying Linting, using Prettier
  • Loading branch information
antoinejaussoin committed Sep 16, 2018
1 parent 6785559 commit 04cdd4d
Show file tree
Hide file tree
Showing 78 changed files with 1,458 additions and 2,687 deletions.
64 changes: 19 additions & 45 deletions .eslintrc
@@ -1,46 +1,20 @@
{
"parser": "babel-eslint",
"extends": "airbnb",
"plugins": [
"jsx-a11y"
],
"settings": {
"import/resolver": "webpack"
},
"rules": {
"indent": ["error", 2],
"react/jsx-indent": ["error", 2],
"react/jsx-first-prop-new-line": 0,
"react/require-default-props": 0,
"react/jsx-tag-spacing": [ 0, {
"closingSlash": "never",
"beforeSelfClosing": "always",
"afterOpening": "never"
}],
"jsx-a11y/aria-role": 0,
"jsx-a11y/img-has-alt": 0,
"jsx-a11y/img-redundant-alt": 0,
"jsx-a11y/href-no-hash": 0,
"react/jsx-curly-spacing": 0,
"no-console": 0,
"no-param-reassign": 0,
"comma-dangle": ["error", "never"],
"arrow-parens": 0,
"react/forbid-prop-types": 0,
"linebreak-style": 0,
"object-curly-newline": 0,
"function-paren-newline": 0,
"jsx-a11y/click-events-have-key-events": 0,
"jsx-a11y/anchor-is-valid": 0,
"react/default-props-match-prop-types": 0
},
"parserOptions": {
"ecmaFeatures": {
"jsx": true,
"experimentalObjectRestSpread": true
}
},
"env": {
"jest": true
}
}
"parser": "babel-eslint",
"settings": {
"import/resolver": "webpack"
},
"rules": {
"quotes": [1, "single"],
"max-len": [1, 120]

},
"parserOptions": {
"ecmaFeatures": {
"jsx": true,
"experimentalObjectRestSpread": true
}
},
"env": {
"jest": true
}
}
7 changes: 7 additions & 0 deletions .prettierrc
@@ -0,0 +1,7 @@
{
"useTabs": false,
"printWidth": 120,
"singleQuote": true,
"trailingComma": "all",
"jsxBracketSameLine": false
}
4 changes: 1 addition & 3 deletions app/app.jsx
Expand Up @@ -44,9 +44,7 @@ class Index extends React.Component {
} else {
component = (
<div>
<Provider store={store}>
{routes}
</Provider>
<Provider store={store}>{routes}</Provider>
</div>
);
}
Expand Down
7 changes: 2 additions & 5 deletions app/components/DevTools.jsx
Expand Up @@ -4,10 +4,7 @@ import LogMonitor from 'redux-devtools-log-monitor';
import DockMonitor from 'redux-devtools-dock-monitor';

export default createDevTools(
<DockMonitor toggleVisibilityKey="ctrl-h"
changePositionKey="ctrl-q"
changeMonitorKey="ctrl-m"
>
<DockMonitor toggleVisibilityKey="ctrl-h" changePositionKey="ctrl-q" changeMonitorKey="ctrl-m">
<LogMonitor />
</DockMonitor>
</DockMonitor>,
);
17 changes: 6 additions & 11 deletions app/components/EditableLabel.jsx
Expand Up @@ -24,11 +24,7 @@ export default class EditableLabel extends Component {
renderReadOnlyMode() {
const { value, placeholder } = this.props;

return (
<span className={style.view}>
{ value || placeholder }
</span>
);
return <span className={style.view}>{value || placeholder}</span>;
}

renderViewMode() {
Expand All @@ -43,7 +39,8 @@ export default class EditableLabel extends Component {
className={style.view}
onClick={() => this.setState({ editMode: true }, () => this.inputRef.current.focus())}
>
{ value || placeholder }&nbsp;
{value || placeholder}
&nbsp;
<FontIcon className={style.editIcon} value={icons.create} />
</span>
);
Expand All @@ -70,9 +67,7 @@ export default class EditableLabel extends Component {

render() {
return (
<span className={style.editableLabel}>
{ this.state.editMode ? this.renderEditMode() : this.renderViewMode() }
</span>
<span className={style.editableLabel}>{this.state.editMode ? this.renderEditMode() : this.renderViewMode()}</span>
);
}
}
Expand All @@ -81,12 +76,12 @@ EditableLabel.propTypes = {
value: PropTypes.string,
readOnly: PropTypes.bool,
placeholder: PropTypes.string,
onChange: PropTypes.func
onChange: PropTypes.func,
};

EditableLabel.defaultProps = {
value: '',
readOnly: false,
placeholder: 'nothing',
onChange: noop
onChange: noop,
};
6 changes: 3 additions & 3 deletions app/components/EnterInput.jsx
Expand Up @@ -9,7 +9,7 @@ class EnterInput extends Component {
constructor(props) {
super(props);
this.state = {
value: ''
value: '',
};
}

Expand Down Expand Up @@ -40,14 +40,14 @@ EnterInput.propTypes = {
onEnter: PropTypes.func,
icon: PropTypes.string,
placeholder: PropTypes.string,
maxLength: PropTypes.number
maxLength: PropTypes.number,
};

EnterInput.defaultProps = {
onEnter: noop,
icon: 'add',
placeholder: 'Type something',
maxLength: null
maxLength: null,
};

export default EnterInput;
8 changes: 3 additions & 5 deletions app/components/Input.jsx
Expand Up @@ -10,9 +10,9 @@ class ImprovedInput extends Component {
this.inputRef = null;
}

setInputRef = (node) => {
setInputRef = node => {
this.inputRef = node;
}
};

focus() {
// This is an ugly hack, until I replace react-toolbox by something that's maintained
Expand All @@ -22,9 +22,7 @@ class ImprovedInput extends Component {
}

render() {
return (
<Input ref={this.setInputRef} {...this.props} />
);
return <Input ref={this.setInputRef} {...this.props} />;
}
}

Expand Down
22 changes: 13 additions & 9 deletions app/components/LanguagePicker.jsx
Expand Up @@ -13,20 +13,21 @@ import { getCurrentLanguage } from 'modules/user/selectors';
import style from './LanguagePicker.scss';

const stateToProps = state => ({
currentLanguage: getCurrentLanguage(state)
currentLanguage: getCurrentLanguage(state),
});

const actionsToProps = dispatch => ({
onChangeLanguage: lang => dispatch(changeLanguage(lang))
onChangeLanguage: lang => dispatch(changeLanguage(lang)),
});

const renderItem = item => (
<div>
<div className={ classNames(`flag-icon flag-icon-${item.iso}`, style.flag) }>
<div className={classNames(`flag-icon flag-icon-${item.iso}`, style.flag)}>
<div className={style.overlay} />
</div>
<div>
<strong>{item.name}</strong><br />
<strong>{item.name}</strong>
<br />
<small>{item.englishName}</small>
</div>
</div>
Expand All @@ -46,20 +47,23 @@ const LanguagePicker = ({ strings, currentLanguage, onChangeLanguage }) => (
LanguagePicker.propTypes = {
strings: PropTypes.object,
currentLanguage: PropTypes.string,
onChangeLanguage: PropTypes.func
onChangeLanguage: PropTypes.func,
};

LanguagePicker.defaultProps = {
currentLanguage: 'en',
onChangeLanguage: noop,
strings: {
header: 'Choose a language'
}
header: 'Choose a language',
},
};

const decorators = flow([
connect(stateToProps, actionsToProps),
translate('LanguagePicker')
connect(
stateToProps,
actionsToProps,
),
translate('LanguagePicker'),
]);

export default decorators(LanguagePicker);
18 changes: 7 additions & 11 deletions app/components/SessionTile.jsx
Expand Up @@ -11,7 +11,7 @@ import translate from 'i18n/Translate';
import icons from 'constants/icons';

const stateToProps = state => ({
languageInfo: getCurrentLanguageInfo(state)
languageInfo: getCurrentLanguageInfo(state),
});

const getGravatar = client => `https://www.gravatar.com/avatar/${md5(client)}?d=identicon`;
Expand All @@ -25,35 +25,31 @@ const SessionTile = ({ session, strings, languageInfo, onClick }) => {
return (
<ListItem
avatar={getGravatar(name)}
caption={ name }
legend={ lastJoined }
caption={name}
legend={lastJoined}
rightIcon={icons.open_in_new}
onClick={onClick}
selectable
/>
);
};


SessionTile.propTypes = {
session: PropTypes.object.isRequired,
languageInfo: PropTypes.object,
strings: PropTypes.object,
onClick: PropTypes.func
onClick: PropTypes.func,
};

SessionTile.defaultProps = {
session: null,
languageInfo: null,
onClick: noop,
strings: {
defaultSessionName: 'My Retrospective'
}
defaultSessionName: 'My Retrospective',
},
};

const decorators = flow([
connect(stateToProps),
translate('SessionName')
]);
const decorators = flow([connect(stateToProps), translate('SessionName')]);

export default decorators(SessionTile);
36 changes: 18 additions & 18 deletions app/constants/icons.js
@@ -1,22 +1,22 @@
// All of this to avoid a pesky corporate firewall

export default {
thumb_up: String.fromCharCode(0xE8DC),
thumb_down: String.fromCharCode(0xE8DB),
sentiment_very_satisfied: String.fromCharCode(0xE815),
sentiment_very_dissatisfied: String.fromCharCode(0xE814),
lightbulb_outline: String.fromCharCode(0xE90F),
add_circle: String.fromCharCode(0xE147),
person: String.fromCharCode(0xE7FD),
people: String.fromCharCode(0xE7FB),
delete_forever: String.fromCharCode(0xE92B),
settings: String.fromCharCode(0xE8B8),
exit_to_app: String.fromCharCode(0xE879),
power_settings_new: String.fromCharCode(0xE8AC),
create: String.fromCharCode(0xE150),
code: String.fromCharCode(0xE86F),
open_in_new: String.fromCharCode(0xE89E),
question_answer: String.fromCharCode(0xE8AF),
content_copy: String.fromCharCode(0xE14D),
group_add: String.fromCharCode(0xE7F0)
thumb_up: String.fromCharCode(0xe8dc),
thumb_down: String.fromCharCode(0xe8db),
sentiment_very_satisfied: String.fromCharCode(0xe815),
sentiment_very_dissatisfied: String.fromCharCode(0xe814),
lightbulb_outline: String.fromCharCode(0xe90f),
add_circle: String.fromCharCode(0xe147),
person: String.fromCharCode(0xe7fd),
people: String.fromCharCode(0xe7fb),
delete_forever: String.fromCharCode(0xe92b),
settings: String.fromCharCode(0xe8b8),
exit_to_app: String.fromCharCode(0xe879),
power_settings_new: String.fromCharCode(0xe8ac),
create: String.fromCharCode(0xe150),
code: String.fromCharCode(0xe86f),
open_in_new: String.fromCharCode(0xe89e),
question_answer: String.fromCharCode(0xe8af),
content_copy: String.fromCharCode(0xe14d),
group_add: String.fromCharCode(0xe7f0),
};
19 changes: 5 additions & 14 deletions app/i18n/Translate.jsx
Expand Up @@ -21,36 +21,27 @@ const languages = { en, es, fr, hu, pl, ptbr, nl, ru, zhtw, zhcn, ar, ja };
export default function translate(key) {
return Component => {
const stateToProps = state => ({
currentLanguage: state.user.lang
currentLanguage: state.user.lang,
});

class TranslationComponent extends React.Component {
render() {
const strings = languages[this.props.currentLanguage][key];
const merged = {
...this.props.strings,
...strings
...strings,
};
if (strings) {
return (
<Component {...this.props}
strings={merged}
currentLanguage={this.props.currentLanguage}
/>
);
return <Component {...this.props} strings={merged} currentLanguage={this.props.currentLanguage} />;
}

return (
<Component {...this.props}
currentLanguage={this.props.currentLanguage}
/>
);
return <Component {...this.props} currentLanguage={this.props.currentLanguage} />;
}
}

TranslationComponent.propTypes = {
strings: PropTypes.object,
currentLanguage: PropTypes.string
currentLanguage: PropTypes.string,
};

return connect(stateToProps)(TranslationComponent);
Expand Down

0 comments on commit 04cdd4d

Please sign in to comment.