Skip to content

Commit

Permalink
Merge pull request #123 from mathieudutour/f/prettier
Browse files Browse the repository at this point in the history
add prettier and eslint
  • Loading branch information
hql287 authored Jan 4, 2018
2 parents 17d6c8a + 8d0a747 commit b270a3b
Show file tree
Hide file tree
Showing 161 changed files with 1,817 additions and 1,845 deletions.
23 changes: 0 additions & 23 deletions .eslintrc.json

This file was deleted.

67 changes: 67 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
root: true
extends:
- airbnb
- plugin:import/errors
- prettier
plugins:
- prettier
- jest
env:
node: true
commonjs: true
es6: true
browser: true
globals:
# JEST GLOBALS
jest: false
it: false
describe: false
test: false
expect: false
beforeEach: false
beforeAll: false
afterEach: false
afterAll: false
rules:
# RULES THAT WE CONSCIOUSLY DISABLE
radix: off

# RULES THAT WE SHOULD INVESTIGATE AND PROBABLY ENABLE
prefer-template: off
no-underscore-dangle: off
prefer-destructuring: off
no-use-before-define: off
no-unused-vars: off
global-require: off
one-var: off
no-unused-expressions: off
no-shadow: off
no-plusplus: off
eqeqeq: off
no-multi-assign: off
camelcase: off
no-restricted-syntax: off
no-useless-escape: off
consistent-return: off
no-sequences: off
no-fallthrough: off
class-methods-use-this: off
no-return-assign: off
default-case: off
import/no-extraneous-dependencies: off
import/extensions: off
import/first: off
import/newline-after-import: off
import/prefer-default-export: off
import/no-dynamic-require: off
import/no-named-as-default: off
react/sort-comp: off
react/forbid-prop-types: off
react/no-array-index-key: off
react/prop-types: off
react/no-unused-state: off
react/no-unused-prop-types: off
react/require-default-props: off
react/jsx-filename-extension: off
jsx-a11y/label-has-for: off
jsx-a11y/anchor-is-valid: off
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ before_script:
- git lfs pull

script:
- yarn lint
- yarn test
- |
if [[ $TRAVIS_BRANCH =~ (master|^v[0-9]+.[0-9]+) ]]; then
Expand Down
10 changes: 5 additions & 5 deletions __mocks__/electron.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
module.exports = {
app: jest.fn(),
ipcRenderer: {
send: jest.fn()
send: jest.fn(),
},
remote: {
require: jest.fn((name) => {
require: jest.fn(name => {
if (name === 'electron-settings') {
return {
set: jest.fn(),
get: jest.fn(() => 'someSettings')
}
get: jest.fn(() => 'someSettings'),
};
}
}),
}
},
};
4 changes: 2 additions & 2 deletions __mocks__/pouchdb-browser.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = jest.fn(() => {
module.exports = jest.fn(() => ({
name: 'test',
});;
}));
41 changes: 22 additions & 19 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
console.time('init')
console.time('init');

// Node Libs
const fs = require('fs');
const os = require('os');
const url = require('url');
const path = require('path');
const glob = require('glob');
const fs = require('fs');
const os = require('os');
const url = require('url');
const path = require('path');
const glob = require('glob');
const isDev = require('electron-is-dev');

// Electron Libs
const {app, BrowserWindow, ipcMain} = require('electron');
const { app, BrowserWindow, ipcMain } = require('electron');

// 3rd Party Libs
const appConfig = require('electron-settings');
Expand Down Expand Up @@ -43,7 +43,7 @@ function createTourWindow() {
);
// Add Event Listeners
tourWindow.on('show', event => {
if (isDev) tourWindow.webContents.openDevTools({mode: 'detach'});
if (isDev) tourWindow.webContents.openDevTools({ mode: 'detach' });
});
tourWindow.on('close', event => {
event.preventDefault();
Expand Down Expand Up @@ -83,7 +83,7 @@ function createMainWindow() {

// Add Event Listeners
mainWindow.on('show', event => {
if (isDev) mainWindow.webContents.openDevTools({mode: 'detach'});
if (isDev) mainWindow.webContents.openDevTools({ mode: 'detach' });
});
mainWindow.on('close', event => {
event.preventDefault();
Expand Down Expand Up @@ -122,7 +122,7 @@ function createPreviewWindow() {
);
// Add Event Listener
previewWindow.on('show', event => {
if (isDev) previewWindow.webContents.openDevTools({mode: 'detach'});
if (isDev) previewWindow.webContents.openDevTools({ mode: 'detach' });
});
previewWindow.on('close', event => {
event.preventDefault();
Expand All @@ -132,8 +132,10 @@ function createPreviewWindow() {
}

function addDevToolsExtension() {
if (process.env.REACT_DEV_TOOLS_PATH) BrowserWindow.addDevToolsExtension(process.env.REACT_DEV_TOOLS_PATH);
if (process.env.REDUX_DEV_TOOLS_PATH) BrowserWindow.addDevToolsExtension(process.env.REDUX_DEV_TOOLS_PATH);
if (process.env.REACT_DEV_TOOLS_PATH)
BrowserWindow.addDevToolsExtension(process.env.REACT_DEV_TOOLS_PATH);
if (process.env.REDUX_DEV_TOOLS_PATH)
BrowserWindow.addDevToolsExtension(process.env.REDUX_DEV_TOOLS_PATH);
}

function setInitialValues() {
Expand All @@ -156,7 +158,8 @@ function setInitialValues() {
// Set Default Logo
const logoPath = path.resolve(__dirname, './static/imgs/default_logo.svg');
const logoData = fs.readFileSync(logoPath);
const logoBase64String = 'data:image/svg+xml;base64,' + logoData.toString('base64');
const logoBase64String =
'data:image/svg+xml;base64,' + logoData.toString('base64');
// Other defaults
appConfig.set('profile', {
logo: logoBase64String,
Expand Down Expand Up @@ -189,12 +192,12 @@ function setInitialValues() {
amount: 0,
},
required_fields: {
dueDate: false,
dueDate: false,
currency: false,
discount: false,
tax: false,
note: false,
}
tax: false,
note: false,
},
});
}
}
Expand Down Expand Up @@ -269,13 +272,13 @@ function initialize() {
addEventListeners();
loadMainProcessFiles();
// Show Window
const {showWindow} = require('./main/tour');
const { showWindow } = require('./main/tour');
showWindow('startup');
});

// Reactive the app
app.on('activate', () => {
const {showWindow} = require('./main/tour');
const { showWindow } = require('./main/tour');
showWindow('activate');
});
// Close all windows before quit the app
Expand Down
24 changes: 10 additions & 14 deletions app/App.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Libs
import React, {Component} from 'react';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import {connect} from 'react-redux';
import { connect } from 'react-redux';
const ipc = require('electron').ipcRenderer;

// Actions
Expand All @@ -16,7 +16,7 @@ import AppNav from './components/layout/AppNav';
import AppMain from './components/layout/AppMain';
import AppNoti from './components/layout/AppNoti';
import AppUpdate from './components/layout/AppUpdate';
import {AppWrapper} from './components/shared/Layout';
import { AppWrapper } from './components/shared/Layout';

// Components
class App extends Component {
Expand All @@ -27,7 +27,7 @@ class App extends Component {
}

componentDidMount() {
const {dispatch} = this.props;
const { dispatch } = this.props;
// Get All Data
dispatch(ContactsActions.getAllContacts());
dispatch(InvoicesActions.getInvoices());
Expand Down Expand Up @@ -85,27 +85,23 @@ class App extends Component {
}

changeTab(tabName) {
const {dispatch} = this.props;
const { dispatch } = this.props;
dispatch(UIActions.changeActiveTab(tabName));
}

removeNoti(id) {
const {dispatch} = this.props;
const { dispatch } = this.props;
dispatch(UIActions.removeNoti(id));
}

render() {
const {activeTab, notifications, checkUpdatesMessage} = this.props.ui;
const { activeTab, notifications, checkUpdatesMessage } = this.props.ui;
return (
<AppWrapper>
<AppNav
activeTab={activeTab}
changeTab={this.changeTab} />
<AppNav activeTab={activeTab} changeTab={this.changeTab} />
<AppMain activeTab={activeTab} />
<AppNoti
notifications={notifications}
removeNoti={this.removeNoti} />
<AppUpdate/>
<AppNoti notifications={notifications} removeNoti={this.removeNoti} />
<AppUpdate />
</AppWrapper>
);
}
Expand Down
30 changes: 15 additions & 15 deletions app/actions/__tests__/form.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,52 +31,52 @@ it('updateItem should create UPDATE_ITEM action', () => {
const itemData = {
description: 'Chocolate Cookies',
price: 10,
quantity: 10
}
quantity: 10,
};
expect(actions.updateItem(itemData)).toEqual({
type: ACTION_TYPES.FORM_ITEM_UPDATE,
payload: itemData,
});
});

it('moveRow should create MOVE_ROW action', () => {
expect(actions.moveRow(2,3)).toEqual({
expect(actions.moveRow(2, 3)).toEqual({
type: ACTION_TYPES.FORM_ITEM_MOVE,
payload: {
dragIndex: 2,
hoverIndex: 3,
}
},
});
});

// Form Actions
it('clearForm should create CLEAR_FORM action', () => {
expect(actions.clearForm(null)).toEqual({
type: ACTION_TYPES.FORM_CLEAR,
payload: false
payload: false,
});

expect(actions.clearForm(null, true)).toEqual({
type: ACTION_TYPES.FORM_CLEAR,
payload: true
payload: true,
});
});

it('saveFormData should create FORM_SAVE action', () => {
expect(actions.saveFormData()).toEqual({
type: ACTION_TYPES.FORM_SAVE
type: ACTION_TYPES.FORM_SAVE,
});
});

it('toggleFormSettings should create FORM_SETTING_TOGGLE action', () => {
expect(actions.toggleFormSettings()).toEqual({
type: ACTION_TYPES.FORM_SETTING_TOGGLE
type: ACTION_TYPES.FORM_SETTING_TOGGLE,
});
});

it('closeFormSettings should create FORM_SETTING_CLOSE action', () => {
expect(actions.closeFormSettings()).toEqual({
type: ACTION_TYPES.FORM_SETTING_CLOSE
type: ACTION_TYPES.FORM_SETTING_CLOSE,
});
});

Expand All @@ -88,29 +88,29 @@ it('updateFieldData should create UPDATE_FIELD_DATA action', () => {
payload: {
field,
data,
}
},
});
});

it('toggleField should create TOGGLE_FIELD action', () => {
expect(actions.toggleField('dueDate')).toEqual({
type: ACTION_TYPES.FORM_FIELD_TOGGLE,
payload: 'dueDate'
payload: 'dueDate',
});
expect(actions.toggleField('currency')).toEqual({
type: ACTION_TYPES.FORM_FIELD_TOGGLE,
payload: 'currency'
payload: 'currency',
});
expect(actions.toggleField('discount')).toEqual({
type: ACTION_TYPES.FORM_FIELD_TOGGLE,
payload: 'discount'
payload: 'discount',
});
expect(actions.toggleField('vat')).toEqual({
type: ACTION_TYPES.FORM_FIELD_TOGGLE,
payload: 'vat'
payload: 'vat',
});
expect(actions.toggleField('note')).toEqual({
type: ACTION_TYPES.FORM_FIELD_TOGGLE,
payload: 'note'
payload: 'note',
});
});
Loading

0 comments on commit b270a3b

Please sign in to comment.