Skip to content

Commit

Permalink
eslint airbnb
Browse files Browse the repository at this point in the history
  • Loading branch information
FredericHeem committed Mar 16, 2017
1 parent d3e58d1 commit 05bc41c
Show file tree
Hide file tree
Showing 53 changed files with 634 additions and 602 deletions.
46 changes: 33 additions & 13 deletions client/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"promise",
"jsx-extras"
],
"extends": ["eslint:recommended", "plugin:react/recommended"],
"extends": ["airbnb"],
"env": {
"browser": true,
"es6": true,
Expand Down Expand Up @@ -49,23 +49,43 @@
"no-labels": [2],
"indent": 0,
"no-mixed-spaces-and-tabs": 0,
"vars-on-top": 2,
"camelcase": [2, {"properties": "never"}],
"semi": [0, "always"],
"react/prop-types": 0,
"react/jsx-no-undef": 2,
"react/jsx-uses-react": 2,
"react/jsx-uses-vars": 2,
"react/no-did-mount-set-state": 2,
"react/no-did-update-set-state": 2,
"react/jsx-wrap-multilines": 1,
"react/react-in-jsx-scope": 1,
"react/no-unknown-property": 2,
"react/no-is-mounted": 2,

"jsx-extras/jsx-no-string-literals": 1,

"promise/param-names": 1,
"promise/always-return": 1,
"promise/catch-or-return": 1
"promise/catch-or-return": 1,

"comma-dangle": 0,
"spaced-comment": 0,
"space-before-function-paren": 0,
"keyword-spacing": 0,
"func-names": 0,
"object-curly-spacing": 0,
"arrow-parens": 0,
"space-before-blocks": 0,

"import/no-extraneous-dependencies": 0,
"import/extensions": 0,
"import/first": 0,
"import/newline-after-import": 0,
"import/no-unresolved": 0,

"react/prop-types": 0,
"jsx-quotes": 0,
"react/jsx-tag-spacing": 0,
"react/forbid-prop-types": 0,
"react/jsx-filename-extension": 0,
"react/require-default-props": 0,
"react/no-array-index-key": 0,

"block-spacing": 0,
"no-param-reassign": 0,
"no-underscore-dangle": 0,
"padded-blocks": 0,
"prefer-arrow-callback": 0,
"max-len": 0
}
}
5 changes: 4 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dashboard": "webpack-dashboard -- webpack-dev-server --config webpack.dev.js",
"start": "webpack-dev-server --config webpack.dev.js",
"prestart": "npm run prebuild",
"lint": "eslint src --ext .js --ext .jsx",
"lint": "eslint src --ext .js --ext .jsx --fix",
"cpd": "jscpd",
"prebuild": "npm run lint && npm run cpd",
"build": "webpack --config webpack.prod.js --progress",
Expand Down Expand Up @@ -91,11 +91,14 @@
"css-loader": "0.26.4",
"enzyme": "2.7.1",
"eslint": "3.17.1",
"eslint-config-airbnb": "14.1.0",
"eslint-config-standard": "7.0.1",
"eslint-config-standard-react": "4.3.0",
"eslint-loader": "1.6.3",
"eslint-plugin-babel": "4.1.1",
"eslint-plugin-flow-vars": "0.5.0",
"eslint-plugin-import": "2.2.0",
"eslint-plugin-jsx-a11y": "4.0.0",
"eslint-plugin-jsx-extras": "1.2.1",
"eslint-plugin-mocha": "4.8.0",
"eslint-plugin-promise": "3.5.0",
Expand Down
4 changes: 2 additions & 2 deletions client/src/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ injectTapEventPlugin();

Debug.enable("*,-engine*,-sockjs-client*,-socket*");

let debug = new Debug("app");
const debug = new Debug("app");

export default function() {
debug("App begins");
Expand Down Expand Up @@ -60,7 +60,7 @@ export default function() {
}

async function preAuth() {
let token = localStorage.getItem("JWT");
const token = localStorage.getItem("JWT");
if (token) {
store.dispatch(parts.auth.actions.setToken(token))
}
Expand Down
32 changes: 16 additions & 16 deletions client/src/app/components/alert/alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@ import React from 'react';
import Debug from 'debug';
import './alert.styl';

let debug = new Debug("components:alert");
const debug = new Debug("components:alert");

export default ({tr}) => {
function Alert({className, type, title, name, message, code}){
debug('name: ', name)
return (
<div className={`alert alert-${type} text-center ${className}`} role="alert">
{title && (
<h3>{title}</h3>
<div className={`alert alert-${type} text-center ${className}`} role="alert">
{title && (
<h3>{title}</h3>
)}
{name && (
<div>{tr.t('An error occured')}
<div>{name}</div>
</div>
)}
{message && (
<div>{tr.t(message)}</div>
{name && (
<div>{tr.t('An error occured')}
<div>{name}</div>
</div>
)}
{code && (
<div>
<div>{tr.t('Status Code')}</div>
<div>{code}</div>
</div>
{message && (
<div>{tr.t(message)}</div>
)}
{code && (
<div>
<div>{tr.t('Status Code')}</div>
<div>{code}</div>
</div>
)}
</div>
)
}
Alert.propTypes = {
Expand Down
5 changes: 3 additions & 2 deletions client/src/app/components/alert/alert.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {mount} from 'enzyme';
import {expect} from 'chai';

describe('Alert', () => {
let Alert = alert({
const Alert = alert({
tr: {
t: (text) => text
}
Expand All @@ -13,7 +13,8 @@ describe('Alert', () => {
const component = mount(<Alert
title='Title'
name="NoSuchCode"
message="message"/>);
message="message"
/>);
//console.log(component.props())

expect(component.props().title).to.equal("Title")
Expand Down
1 change: 1 addition & 0 deletions client/src/app/components/alert/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import alert from './alert';

export default alert;
4 changes: 2 additions & 2 deletions client/src/app/components/alertAjax/alertAjax.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import Debug from 'debug';
import alert from '../alert';

let debug = new Debug("components:alertAjax");
const debug = new Debug("components:alertAjax");

// A component to display Axios errors

Expand All @@ -24,7 +24,7 @@ export default (context) => {
if (!message) {
message = error.message
}
return (<Alert type="danger" className={className} message={message}/>)
return (<Alert type="danger" className={className} message={message} />)
}

AlertAjax.propTypes = {
Expand Down
6 changes: 3 additions & 3 deletions client/src/app/components/docTitle.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import Helmet from 'react-helmet';
import config from 'config';

function getDocumentTitle(title = '') {
return title + " - " + config.title;
return `${title} - ${config.title}`;
}

export default function DocTitle({title}){
return (
<Helmet
title = {title}
titleTemplate = {getDocumentTitle(title)}
title={title}
titleTemplate={getDocumentTitle(title)}
/ >
)
}
Expand Down
48 changes: 26 additions & 22 deletions client/src/app/components/restTableComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import segmentize from 'segmentize';
import Spinner from 'components/spinner';
import alertAjax from 'components/alertAjax';
import Debug from 'debug';
let debug = new Debug("components:resttable");
const debug = new Debug("components:resttable");

import 'react-pagify/style.css';

Expand Down Expand Up @@ -51,21 +51,19 @@ export default (context, {getData, columns}) => {

store.selectPage(1);

const Loading = observer(() => {
return store.loading ? <Spinner/> : null;
})
const Loading = observer(() => (store.loading ? <Spinner /> : null))

const Error = observer(() => {
let {error} = store;
const {error} = store;
if (!error) return null;
debug(error)
return <AlertAjax error={error} className='rest-table-error-view'/>
return <AlertAjax error={error} className='rest-table-error-view' />
})

const Pagination = observer(() => {
debug("Pagination:", store.count)
let {count, pagination} = store;
let pages = Math.ceil(count / pagination.perPage);
const {count, pagination} = store;
const pages = Math.ceil(count / pagination.perPage);
if (pages <= 1) {
return null;
}
Expand All @@ -76,32 +74,37 @@ export default (context, {getData, columns}) => {
className="pagify-pagination"
segments={segmentize({
page: pagination.page,
pages: pages,
pages,
beginPages: 3,
endPages: 3,
sidePages: 2
}) }
onSelect={page => store.selectPage(page, getData)}>
})}
onSelect={page => store.selectPage(page, getData)}
>
<Paginator.Button page={pagination.page - 1}>{tr.t('Previous') }</Paginator.Button>

<Paginator.Segment field="beginPages" />

<Paginator.Ellipsis className="ellipsis"
previousField="beginPages" nextField="previousPages" />
<Paginator.Ellipsis
className="ellipsis"
previousField="beginPages" nextField="previousPages"
/>

<Paginator.Segment field="previousPages" />
<Paginator.Segment field="centerPage" className="selected" />
<Paginator.Segment field="nextPages" />

<Paginator.Ellipsis className="ellipsis"
previousField="nextPages" nextField="endPages" />
<Paginator.Ellipsis
className="ellipsis"
previousField="nextPages" nextField="endPages"
/>

<Paginator.Segment field="endPages" />

<Paginator.Button page={pagination.page + 1}>{tr.t('Next') }</Paginator.Button>
</Paginator.Context>

</div>
</div>
</div>
);
})
Expand All @@ -113,12 +116,13 @@ export default (context, {getData, columns}) => {
if (error) return null;
return (
<div>
<Pagination/>
<Pagination />
<Table.Provider
className="table"
columns={columns}
style={{ overflowX: 'auto' }}>
<Table.Header/>
style={{ overflowX: 'auto' }}
>
<Table.Header />
<Table.Body onRow={onRow} rows={data} rowKey="id" />
</Table.Provider>
</div>
Expand All @@ -129,9 +133,9 @@ export default (context, {getData, columns}) => {
debug('RestTable: ', props)
return (
<div>
<Error/>
<Loading/>
<TableView {...props}/>
<Error />
<Loading />
<TableView {...props} />
</div>
)
}
Expand Down
2 changes: 1 addition & 1 deletion client/src/app/components/spinner.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import CircularProgress from 'material-ui/CircularProgress';

export default function Spinner() {
return (
<CircularProgress size={36}/>
<CircularProgress size={36} />
);
}
6 changes: 3 additions & 3 deletions client/src/app/config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import _ from 'lodash';

/* global process */
let env = process.env;
const env = process.env;

let config = {
const config = {

general: {
title: 'StarHackIt',
Expand All @@ -28,4 +28,4 @@ let config = {
}
};

export default _.extend( {}, config.general, config[ env.NODE_ENV ] );
export default _.extend({}, config.general, config[env.NODE_ENV]);
2 changes: 1 addition & 1 deletion client/src/app/configureStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function logger(){
}

function createReducers(modules) {
let reducers = _.reduce(modules, (acc, module, key) => {
const reducers = _.reduce(modules, (acc, module, key) => {
if (module.reducers) {
acc[key] = combineReducers(module.reducers)
}
Expand Down
14 changes: 7 additions & 7 deletions client/src/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import ReactDOM from 'react-dom';
import App from './app'
import Debug from 'debug';

let debug = new Debug("app.entry");
const debug = new Debug("app.entry");

function render(view){
let mountEl = document.getElementById('application');
const mountEl = document.getElementById('application');
ReactDOM.render(
<div>
{view}
</div>
<div>
{view}
</div>
, mountEl);
}

Expand All @@ -21,9 +21,9 @@ function hideLoading(){

async function run(){
try {
let app = App();
const app = App();
await app.start();
let container = app.createContainer();
const container = app.createContainer();
hideLoading();
render(container)
} catch (e) {
Expand Down
Loading

0 comments on commit 05bc41c

Please sign in to comment.