formatting and linting

This commit is contained in:
Valeriy
2018-09-13 22:09:12 +03:00
committed by Mrugesh Mohapatra
parent 9ca50d56a8
commit a083334079
9 changed files with 73 additions and 75 deletions

View File

@@ -6,11 +6,7 @@ import { createStore } from './src/redux/store';
export const wrapRootElement = ({ element }) => { export const wrapRootElement = ({ element }) => {
const store = createStore(); const store = createStore();
const ConnectedRootElement = ( const ConnectedRootElement = <Provider store={store}>{element}</Provider>;
<Provider store={store}>
{element}
</Provider>
);
return ConnectedRootElement; return ConnectedRootElement;
}; };

View File

@@ -107,7 +107,8 @@ const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
exports.onCreateWebpackConfig = ({ stage, rules, plugins, actions }) => { exports.onCreateWebpackConfig = ({ stage, rules, plugins, actions }) => {
actions.setWebpackConfig({ actions.setWebpackConfig({
module: { module: {
rules: [rules.js({ rules: [
rules.js({
/* eslint-disable max-len */ /* eslint-disable max-len */
exclude: modulePath => { exclude: modulePath => {
return ( return (
@@ -136,9 +137,7 @@ exports.onCreateWebpackConfig = ({ stage, rules, plugins, actions }) => {
}); });
if (stage !== 'build-html') { if (stage !== 'build-html') {
actions.setWebpackConfig({ actions.setWebpackConfig({
plugins: [ plugins: [new MonacoWebpackPlugin()]
new MonacoWebpackPlugin()
]
}); });
} }
if (stage === 'build-html') { if (stage === 'build-html') {

View File

@@ -6,10 +6,7 @@ import headComponents from './src/head';
import { createStore } from './src/redux/store'; import { createStore } from './src/redux/store';
export const replaceRenderer = ({ export const replaceRenderer = ({ bodyComponent, replaceBodyHTMLString }) => {
bodyComponent,
replaceBodyHTMLString
}) => {
const store = createStore(); const store = createStore();
const ConnectedBody = () => ( const ConnectedBody = () => (

View File

@@ -1,18 +1,15 @@
/* eslint-disable */ /* eslint-disable */
import React from 'react'; import React from 'react';
export default (props) => { export default props => {
const { width = '100%', height = '100%' } = props; const { width = '100%', height = '100%' } = props;
const fixedWidth = width.toString().indexOf('%') !== -1 ? const fixedWidth =
width : `${width}px`; width.toString().indexOf('%') !== -1 ? width : `${width}px`;
const fixedHeight = height.toString().indexOf('%') !== -1 ? const fixedHeight =
height : `${height}px`; height.toString().indexOf('%') !== -1 ? height : `${height}px`;
const style = { const style = {
width: fixedWidth, width: fixedWidth,
height: fixedHeight height: fixedHeight
}; return ( };
<div return <div style={style} className="react-monaco-editor-container" />;
style={style} };
className="react-monaco-editor-container" />
);
}

View File

@@ -1,8 +1,7 @@
import React from 'react'; import React from 'react';
const cdnAddr = const cdnAddr =
'https://cdnjs.cloudflare.com/ajax/libs/sass.js/' + 'https://cdnjs.cloudflare.com/ajax/libs/sass.js/0.10.9/sass.sync.min.js';
'0.10.9/sass.sync.min.js';
const sassjs = [<script key='sassjs' src={cdnAddr} type='text/javascript' />]; const sassjs = [<script key='sassjs' src={cdnAddr} type='text/javascript' />];

View File

@@ -1,3 +1,6 @@
/* eslint-disable-next-line max-len */
import { composeWithDevTools } from 'redux-devtools-extension/logOnlyInProduction';
import { import {
createStore as reduxCreateStore, createStore as reduxCreateStore,
combineReducers, combineReducers,
@@ -6,9 +9,6 @@ import {
import { combineEpics, createEpicMiddleware } from 'redux-observable'; import { combineEpics, createEpicMiddleware } from 'redux-observable';
import { reducer as formReducer } from 'redux-form'; import { reducer as formReducer } from 'redux-form';
import {
composeWithDevTools
} from 'redux-devtools-extension/logOnlyInProduction';
import { reducer as app, epics as appEpics } from './app'; import { reducer as app, epics as appEpics } from './app';
import { import {
@@ -50,6 +50,5 @@ const composeEnhancers = composeWithDevTools({
export const createStore = () => export const createStore = () =>
reduxCreateStore( reduxCreateStore(
rootReducer, rootReducer,
composeEnhancers( composeEnhancers(applyMiddleware(epicMiddleware))
applyMiddleware(epicMiddleware) );
));

View File

@@ -76,10 +76,13 @@ export class CompletionModal extends PureComponent {
const showDownloadButton = Object.keys(files).length; const showDownloadButton = Object.keys(files).length;
const filesForDownload = Object.keys(files) const filesForDownload = Object.keys(files)
.map(key => files[key]) .map(key => files[key])
.reduce((allFiles, { path, contents }) => ({ .reduce(
(allFiles, { path, contents }) => ({
...allFiles, ...allFiles,
[path]: contents [path]: contents
}), {}); }),
{}
);
const dashedName = dasherize(title); const dashedName = dasherize(title);
return ( return (
<Modal <Modal
@@ -111,8 +114,8 @@ export class CompletionModal extends PureComponent {
> >
Submit and go to next challenge (Ctrl + Enter) Submit and go to next challenge (Ctrl + Enter)
</Button> </Button>
{showDownloadButton {showDownloadButton ? (
? <Button <Button
block={true} block={true}
bsSize='lg' bsSize='lg'
bsStyle='primary' bsStyle='primary'
@@ -124,8 +127,7 @@ export class CompletionModal extends PureComponent {
> >
Download my solution Download my solution
</Button> </Button>
: null ) : null}
}
</Modal.Footer> </Modal.Footer>
</Modal> </Modal>
); );

View File

@@ -52,14 +52,20 @@ export class SidePanel extends PureComponent {
} }
componentDidMount() { componentDidMount() {
MathJax.Hub.Queue(['Typeset', MathJax.Hub, MathJax.Hub.Queue([
document.querySelector('.rosetta-code')]); 'Typeset',
MathJax.Hub,
document.querySelector('.rosetta-code')
]);
this.props.initConsole(''); this.props.initConsole('');
} }
componentDidUpdate(prevProps) { componentDidUpdate(prevProps) {
MathJax.Hub.Queue(['Typeset', MathJax.Hub, MathJax.Hub.Queue([
document.querySelector('.rosetta-code')]); 'Typeset',
MathJax.Hub,
document.querySelector('.rosetta-code')
]);
const { title, initConsole } = this.props; const { title, initConsole } = this.props;
if (title !== prevProps.title) { if (title !== prevProps.title) {
initConsole(''); initConsole('');

View File

@@ -99,13 +99,16 @@ const htmlSassTransformCode = file => {
return vinyl.transformContents(() => doc.body.innerHTML, file); return vinyl.transformContents(() => doc.body.innerHTML, file);
} }
return styleTags.reduce((obs, style) => { return styleTags.reduce((obs, style) => {
return obs.flatMap(file => new Promise(resolve => { return obs.flatMap(
file =>
new Promise(resolve => {
window.Sass.compile(style.innerHTML, function(result) { window.Sass.compile(style.innerHTML, function(result) {
style.type = 'text/css'; style.type = 'text/css';
style.innerHTML = result.text; style.innerHTML = result.text;
resolve(vinyl.transformContents(() => doc.body.innerHTML, file)); resolve(vinyl.transformContents(() => doc.body.innerHTML, file));
}); });
})); })
);
}, Observable.of(file)); }, Observable.of(file));
}; };