Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
koorchik committed Aug 26, 2016
1 parent b2be7fc commit 203e638
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 35 deletions.
4 changes: 2 additions & 2 deletions .eslintrc
@@ -1,7 +1,7 @@
{
"extends": "webbylab",
"rules": {
"webbylab/no-then": 0, // Temporary disable
"webbylab/no-window": 0 // Temporary disable
"more/no-then": 0, // Temporary disable
"more/no-window": 0, // Temporary disable
}
}
1 change: 1 addition & 0 deletions server/utils.js
Expand Up @@ -22,6 +22,7 @@ export function fetchComponentsData({ dispatch, components, params, query, local
}

export function getMetaDataFromState({ route, state, params = {}, query = {}, lang }) {
/* eslint more/no-duplicated-chains: 0 */
if (route === '/activations/:id' || route === '/activations/:id/:title') {
const { name, message, pictureURL } = state.currentActivation.activation;

Expand Down
1 change: 0 additions & 1 deletion shared/components/ExpandableText.jsx
Expand Up @@ -10,7 +10,6 @@ import './ExpandableText.less';
const MAX_CHAR_NUMBER = 300;

export default class ExpandableText extends Component {

static propTypes = {
text : PropTypes.string,
markdownPreset : PropTypes.string,
Expand Down
7 changes: 4 additions & 3 deletions shared/components/Markdown.jsx
Expand Up @@ -14,7 +14,6 @@ import { activationDescriptionPreset } from './Markdown/presets.js';
const MAX_LINK_LENGTH = 35;

class Markdown extends Component {

static propTypes = {
source : PropTypes.string.isRequired,
preset : PropTypes.oneOf([ 'activationDescription' ])
Expand All @@ -38,9 +37,11 @@ class Markdown extends Component {
}

const customRenderer = (tokens, idx, options, env, self) => self.renderToken(tokens, idx, options);
const defaultRender = this.md.renderer.rules.link_open || customRenderer;
const rules = this.md.renderer.rules;

const defaultRender = rules.link_open || customRenderer;

this.md.renderer.rules.link_open = (tokens, idx, options, env, self) => {
rules.link_open = (tokens, idx, options, env, self) => {
const newTokens = tokens;
const aIndex = newTokens[idx].attrIndex('target');

Expand Down
2 changes: 0 additions & 2 deletions shared/components/SearchBox.jsx
Expand Up @@ -9,7 +9,6 @@ import './SearchBox.less';
const ENTER_KEY = 13;

export default class SearchBox extends Component {

static propTypes = {
search : PropTypes.string,
onSearch : PropTypes.func
Expand Down Expand Up @@ -97,4 +96,3 @@ export default class SearchBox extends Component {
);
}
}

1 change: 0 additions & 1 deletion shared/components/layouts/MainLayout.jsx
Expand Up @@ -6,7 +6,6 @@ import Footer from '../../containers/Footer.jsx';
import './MainLayout.less';

export default class MainLayout extends Component {

static propTypes = {
showWelcomeScreen : PropTypes.bool,
showFooter : PropTypes.bool,
Expand Down
22 changes: 13 additions & 9 deletions shared/components/other/ScoreCircle.jsx
Expand Up @@ -15,7 +15,6 @@ const GREEN = '#47D62A';
const PURPLE = '#00bcd4';

class ScoreCircle extends Component {

static propTypes = {
value : PropTypes.number,
size : PropTypes.number
Expand All @@ -27,15 +26,17 @@ class ScoreCircle extends Component {

componentDidMount() {
this.colorUtil = new ColorUtil([RED, ORANGE, GREEN]);
this.scoreColor = '#FFF' || this.colorUtil.getColorCodeByPercent(this.props.value ? this.props.value : 0);
const { value } = this.props;

this.scoreColor = '#FFF' || this.colorUtil.getColorCodeByPercent(value ? value : 0);

this.circle = new ProgressBar.Circle(`#score-${this.id}`, {
color: '#FCB03C',
strokeWidth: 3,
trailWidth: 1,
duration: 1500,
text: {
value: `${this.props.value}%`,
value: `${value}%`,
color: this.scoreColor
},
step: (state, shape) => {
Expand All @@ -45,7 +46,7 @@ class ScoreCircle extends Component {
}
});

this.circle.animate(this.props.value / 100, {
this.circle.animate(value / 100, {
from: { color: PURPLE },
to: { color: this.scoreColor }
});
Expand All @@ -56,11 +57,12 @@ class ScoreCircle extends Component {
}

componentDidUpdate() {
const { value } = this.props;
const prevScoreColor = this.scoreColor;

this.scoreColor = this.colorUtil.getColorCodeByPercent(this.props.value ? this.props.value : 0);
this.scoreColor = this.colorUtil.getColorCodeByPercent(value ? value : 0);

this.circle.animate(this.props.value / 100, {
this.circle.animate(value / 100, {
from : { color: prevScoreColor },
to : { color: this.scoreColor }
});
Expand All @@ -71,10 +73,12 @@ class ScoreCircle extends Component {
}

render() {
const { size } = this.props;

const style = {
width : this.props.size,
height : this.props.size,
fontSize : this.props.size / 3
width : size,
height : size,
fontSize : size / 3
};

return (
Expand Down
30 changes: 19 additions & 11 deletions shared/containers/App.jsx
Expand Up @@ -31,9 +31,11 @@ export default class App extends Component {

componentDidMount() {
initialize();
const routes = this.props.routes;

navigate({
page : this.props.location.pathname,
title : this.props.routes[this.props.routes.length - 1].path
title : routes[routes.length - 1].path
});

embedEvents.subscribe({
Expand All @@ -48,22 +50,26 @@ export default class App extends Component {
}

componentWillReceiveProps(nextProps) {
const isEmbed = Boolean(this.props.location.query.embed);
const isPathnameChanged = this.props.location.pathname !== nextProps.location.pathname;
const isQueryChanged = this.props.location.query !== nextProps.location.query;
const currentLocation = this.props.location;
const nextLocation = nextProps.location;

const isEmbed = Boolean(currentLocation.query.embed);

const isPathnameChanged = currentLocation.pathname !== nextLocation.pathname;
const isQueryChanged = currentLocation.query !== nextLocation.query;

if (isPathnameChanged) {
navigate({
page : nextProps.location.pathname,
page : nextLocation.pathname,
title : nextProps.routes[nextProps.routes.length - 1].path
});

this.sendIframeHeightEvent();
}

if (isEmbed && (isPathnameChanged || isQueryChanged)) {
const pathname = nextProps.location.pathname;
const { category, search, sortType } = nextProps.location.query;
const pathname = nextLocation.pathname;
const { category, search, sortType } = nextLocation.query;

const query = {};

Expand Down Expand Up @@ -113,13 +119,15 @@ export default class App extends Component {
}

handleRedirect = () => {
const { query } = this.props.location;

const newState = {
embed : this.props.location.query.embed,
assigneeId : this.props.location.query.assigneeId
embed : query.embed,
assigneeId : query.assigneeId
};

if (this.props.location.query.search) {
newState.search = this.props.location.query.search;
if (query.search) {
newState.search = query.search;
}

this.props.history.pushState(null, '/activations', newState);
Expand Down
1 change: 0 additions & 1 deletion shared/containers/Footer.jsx
Expand Up @@ -8,7 +8,6 @@ import { footerLinks, quizwallShareLink } from '../config';
import { sendEvent } from '../utils/googleAnalytics';

export default class FooterContainer extends Component {

static contextTypes = { i18n: PropTypes.object };

state = {
Expand Down
2 changes: 0 additions & 2 deletions shared/containers/LoginDialog.jsx
Expand Up @@ -9,7 +9,6 @@ import { socialAuthURL, emailAuthURL } from '../config';
import { sendEvent } from '../utils/googleAnalytics';

export default class LoginDialogContainer extends Component {

static propTypes = {
isOpen : PropTypes.bool.isRequired,
onRequestClose : PropTypes.func
Expand Down Expand Up @@ -69,4 +68,3 @@ export default class LoginDialogContainer extends Component {
);
}
}

7 changes: 4 additions & 3 deletions shared/utils/ColorUtil.js
Expand Up @@ -3,7 +3,6 @@ const G = 1;
const B = 2;

class ColorUtil {

constructor(colorcodes) {
this.colors = [];
this.setGradientColors(colorcodes);
Expand Down Expand Up @@ -41,11 +40,13 @@ class ColorUtil {
}

getColorCodeByPercent(percent) {
const percentPerPart = 100 / (this.colors.length - 1);
const numberOfColors = this.colors.length;

const percentPerPart = 100 / (numberOfColors - 1);
const startColorIndex = parseInt(percent / percentPerPart, 10);
const percentFromPart = (percent % percentPerPart) / percentPerPart;
const startColor = this.colors[startColorIndex];
const endColor = startColorIndex === this.colors.length - 1
const endColor = startColorIndex === numberOfColors - 1
? this.colors[startColorIndex]
: this.colors[startColorIndex + 1];

Expand Down

0 comments on commit 203e638

Please sign in to comment.