Skip to content

Commit

Permalink
Convert to ESLint, fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sallar committed Apr 16, 2017
1 parent 4640fc6 commit c9e8273
Show file tree
Hide file tree
Showing 45 changed files with 293 additions and 444 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
app/*
18 changes: 18 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"parser": "babel-eslint",
"extends": [
"standard",
"standard-react"
],
"env": {
"node": true,
"browser": true,
"es6": true
},
"rules": {
"semi": ["error", "always"],
"space-before-function-paren": ["error", "never"],
"jsx-quotes": "off",
"comma-dangle": "off"
}
}
16 changes: 10 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"package:mac": "build --mac",
"package:win": "build --win --x64",
"package": "build --mac --linux --win --x64",
"package:current": "build"
"package:current": "build",
"lint": "eslint ./src ./config"
},
"build": {
"appId": "pw.buttercup.desktop",
Expand Down Expand Up @@ -134,11 +135,15 @@
"electron-installer-dmg": "^0.1.2",
"electron-json-storage": "^3.0.2",
"electron-rpc": "^2.0.1",
"eslint": "^3.15.0",
"eslint-config-xo-react": "^0.8.0",
"eslint": "^3.19.0",
"eslint-config-standard": "^10.2.1",
"eslint-config-standard-react": "^4.3.0",
"eslint-import-resolver-webpack": "^0.8.1",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-react": "^5.2.2",
"eslint-plugin-node": "^4.2.2",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-react": "^6.10.3",
"eslint-plugin-standard": "^3.0.1",
"extract-text-webpack-plugin": "2.0.0-rc.0",
"file-loader": "^0.10.1",
"fixed-data-table-2": "^0.7.12",
Expand Down Expand Up @@ -192,8 +197,7 @@
"webdav-fs": "^1.0.0-rc7",
"webpack": "2.2.0",
"webpack-dev-server": "2.2.0",
"webpack-merge": "^2.6.0",
"xo": "^0.17.1"
"webpack-merge": "^2.6.0"
},
"xo": {
"parser": "babel-eslint",
Expand Down
16 changes: 8 additions & 8 deletions src/main/lib/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function normalizePath(filePath) {
/**
* Present an open dialog box
* and return the filename if selected
*
*
* @param {BrowserWindow} focusedWindow
* @returns {void}
*/
Expand All @@ -37,7 +37,7 @@ function showOpenDialog(focusedWindow) {
...dialogOptions,
title: 'Load a Buttercup Archive'
});

if (filename && filename.length > 0) {
loadFile(filename[0], focusedWindow);
}
Expand All @@ -46,7 +46,7 @@ function showOpenDialog(focusedWindow) {
/**
* Present a save dialog box
* and return the filename if saved
*
*
* @param {BrowserWindow} focusedWindow
* @returns {void}
*/
Expand All @@ -63,7 +63,7 @@ function showSaveDialog(focusedWindow) {

/**
* Open File helper using Buttercup
*
*
* @param {String} filePath
* @param {BrowserWindow} win
*/
Expand Down Expand Up @@ -93,7 +93,7 @@ export function loadFile(filePath, win, isNew = false) {
/**
* Open a file in current window or a new window
* if the current window is already a loaded archive
*
*
* @param {BrowserWindow} focusedWindow
* @returns {void}
*/
Expand All @@ -112,7 +112,7 @@ export function openFile(focusedWindow) {

/**
* Import a KeePass archive
*
*
* @param {BrowserWindow} focusedWindow
*/
export function openKeepassFile(focusedWindow) {
Expand All @@ -121,7 +121,7 @@ export function openKeepassFile(focusedWindow) {
...keepassDialogOptions,
title: 'Load a Keepass archive'
});

if (filename && filename.length > 0) {
focusedWindow.rpc.emit('import-history-prompt');
focusedWindow.rpc.once('import-history-prompt-resp', password => {
Expand Down Expand Up @@ -156,7 +156,7 @@ export function openKeepassFile(focusedWindow) {
/**
* Create a new file and open it in Buttercup
* then ask the user for a password
*
*
* @param {BrowserWindow} focusedWindow
* @returns {void}
*/
Expand Down
2 changes: 0 additions & 2 deletions src/main/lib/rpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { ipcMain } from 'electron';
import uuid from 'uuid';

class Server extends EventEmitter {

constructor(win) {
super();
this.win = win;
Expand Down Expand Up @@ -48,7 +47,6 @@ class Server extends EventEmitter {
this.destroyed = true;
}
}

}

export function createRPC(win) {
Expand Down
8 changes: 4 additions & 4 deletions src/renderer/components/archive/copyable.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@ class Copyable extends Component {
}

renderPassword(content) {
return (<Password role="content" password={content} concealed={this.state.concealed}/>);
return (<Password role="content" password={content} concealed={this.state.concealed} />);
}

render() {
const { children, type } = this.props;
if (!children) {
return null;
}

return (
<Wrapper onContextMenu={() => this.showContextMenu()}>
<Content role="content">
Expand All @@ -122,12 +122,12 @@ class Copyable extends Component {
<HiddenButtonRow>
{(type || '').toLowerCase() === 'password' &&
<Button
icon={this.state.concealed ? <EyeIcon/> : <EyeSlashIcon/>}
icon={this.state.concealed ? <EyeIcon /> : <EyeSlashIcon />}
title={this.state.concealed ? 'Reveal' : 'Hide'}
onClick={() => this.handleReveal()}
/>}
<Button
icon={<CopyIcon/>}
icon={<CopyIcon />}
title="Copy"
onClick={() => this.handleCopy()}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/archive/entries-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import styles from '../../styles/entries-list';

const List = ({entries, currentEntry, onSelectEntry, onRightClick}) => (
<ul className={styles.list}>
{entries.map(entry =>
{entries.map(entry =>
<li
key={entry.id}
className={(currentEntry && entry.id === currentEntry.id) && styles.active}
Expand Down
15 changes: 10 additions & 5 deletions src/renderer/components/archive/entries.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,20 @@ class Entries extends Component {
}

render() {
const { currentGroup, handleAddEntry, sortMode } = this.props;
const { currentGroup, handleAddEntry, sortMode, filter } = this.props;
const addButton = (
<Button
onClick={handleAddEntry}
disabled={Boolean(currentGroup) !== true}
full
dark
icon={<PlusIcon/>}
icon={<PlusIcon />}
>Add Entry</Button>
);
const filterNode = (
<div className={styles.searchWrapper}>
<SearchField onChange={this.handleFilterChange}/>
<SortButton mode={sortMode} onChange={this.handleSortModeChange}/>
<SearchField onChange={this.handleFilterChange} filter={filter} />
<SortButton mode={sortMode} onChange={this.handleSortModeChange} />
</div>
);

Expand All @@ -61,7 +61,12 @@ class Entries extends Component {
header={filterNode}
footer={addButton}
>
<List {...this.props} onRightClick={entry => this.onRightClick(entry)}/>
<List
entries={this.props.entries}
currentEntry={this.props.currentEntry}
onSelectEntry={this.props.onSelectEntry}
onRightClick={entry => this.onRightClick(entry)}
/>
</Column>
);
}
Expand Down
16 changes: 7 additions & 9 deletions src/renderer/components/archive/entry-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Input from './entry-input';
const renderMeta = ({fields, meta: {touched, error}}) => ( // eslint-disable-line react/prop-types
<div>
<div className={styles.metaWrapper}>
{fields.map((member, index) =>
{fields.map((member, index) =>
<div className={styles.formRow} key={index}>
<div className={styles.labelWrapper}>
<Field
Expand All @@ -27,7 +27,7 @@ const renderMeta = ({fields, meta: {touched, error}}) => ( // eslint-disable-lin
/>
<Button
onClick={() => fields.remove(index)}
icon={<RemoveIcon/>}
icon={<RemoveIcon />}
/>
</div>
)}
Expand All @@ -38,7 +38,7 @@ const renderMeta = ({fields, meta: {touched, error}}) => ( // eslint-disable-lin
e.stopPropagation();
e.preventDefault();
}}
icon={<PlusIcon/>}
icon={<PlusIcon />}
>Add New Field</Button>
{touched && error && <span>{error}</span>}
</div>
Expand All @@ -53,26 +53,24 @@ class EntryForm extends Component {
>
<div className={styles.formRow}>
<label className={styles.labelWrapper} htmlFor="properties.title">Title</label>
<Field name="properties.title" component={Input} type="text" placeholder="Untitled"/>
<Field name="properties.title" component={Input} type="text" placeholder="Untitled" />
</div>
<div className={styles.formRow}>
<label className={styles.labelWrapper} htmlFor="properties.username">Username</label>
<Field name="properties.username" component={Input} type="text" placeholder="@username..."/>
<Field name="properties.username" component={Input} type="text" placeholder="@username..." />
</div>
<div className={styles.formRow}>
<label className={styles.labelWrapper} htmlFor="properties.password">Password</label>
<Field name="properties.password" component={Input} type="password" placeholder="Secure password..."/>
<Field name="properties.password" component={Input} type="password" placeholder="Secure password..." />
</div>
<h6 className={styles.heading}>Custom Fields:</h6>
<FieldArray name="meta" component={renderMeta}/>
<FieldArray name="meta" component={renderMeta} />
</form>
);
}
}

EntryForm.propTypes = {
entry: PropTypes.object,
dirty: PropTypes.bool,
handleSubmit: PropTypes.func
};

Expand Down
10 changes: 4 additions & 6 deletions src/renderer/components/archive/entry-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ BareInput.propTypes = {
placeholder: PropTypes.string,
name: PropTypes.string,
input: PropTypes.object,
meta: PropTypes.object,
type: PropTypes.string
};

export default class Input extends Component {

static propTypes = {
type: PropTypes.string,
input: PropTypes.object
Expand All @@ -52,19 +50,19 @@ export default class Input extends Component {
const { type, input } = this.props;
return (
<div className={styles.wrapper}>
<BareInput {...this.props}/>
{type === 'password' &&
<BareInput {...this.props} />
{type === 'password' &&
<Generator
onGenerate={pwd => this.receivePassword(pwd)}
isOpen={this.state.isGeneratorOpen}
preferPlace="below"
>
<div className={cx(styles.generator, this.state.isGeneratorOpen && styles.generatorActive)}>
<MagicIcon onClick={this.handleGeneratorToggle.bind(this)}/>
<MagicIcon onClick={() => this.handleGeneratorToggle()} />
</div>
</Generator>
}
{type === 'password' && <Meter input={input.value}/>}
{type === 'password' && <Meter input={input.value} />}
</div>
);
}
Expand Down
8 changes: 4 additions & 4 deletions src/renderer/components/archive/entry-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const EntryView = ({entry}) => (
</div>
))}
<h6 className={heading}>Custom Fields:</h6>
{entry.meta.length > 0 ?
(<div className={metaWrapper}>
{entry.meta.length > 0
? (<div className={metaWrapper}>
{entry.meta.map(meta => (
<div className={formRow} key={meta.key}>
<div className={labelWrapper}>{meta.key}</div>
Expand All @@ -26,8 +26,8 @@ const EntryView = ({entry}) => (
</div>
</div>
))}
</div>) :
(<EmptyView
</div>)
: (<EmptyView
caption="No custom fields yet. Why not add one?"
imageSrc={bubbleImage}
/>)
Expand Down
8 changes: 4 additions & 4 deletions src/renderer/components/archive/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Entry extends Component {
<div>
<Button
onClick={() => this.props.onDelete(this.props.entry.id)}
icon={<TrashIcon/>}
icon={<TrashIcon />}
danger
>Delete</Button>
</div>
Expand Down Expand Up @@ -76,14 +76,14 @@ class Entry extends Component {

renderViewMode() {
return {
content: <EntryView entry={this.props.entry}/>,
footer: <Button onClick={this.props.handleEditMode} icon={<EditIcon/>}>Edit</Button>
content: <EntryView entry={this.props.entry} />,
footer: <Button onClick={this.props.handleEditMode} icon={<EditIcon />}>Edit</Button>
};
}

renderIdleMode() {
return {
content: <EmptyView caption="Select or Create an Entry" imageSrc={bench}/>,
content: <EmptyView caption="Select or Create an Entry" imageSrc={bench} />,
footer: null
};
}
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/components/archive/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ const Archive = ({ onColumnSizeChange, columnSizes }) => (
defaultSize={columnSizes ? columnSizes.tree : 230}
onChange={throttle(size => onColumnSizeChange({name: 'tree', size}), 1000)}
>
<TreeView/>
<TreeView />
<SplitPane
split="vertical"
minSize={150}
maxSize={500}
defaultSize={columnSizes ? columnSizes.entries : 230}
onChange={throttle(size => onColumnSizeChange({name: 'entries', size}), 1000)}
>
<Entries/>
<Entry/>
<Entries />
<Entry />
</SplitPane>
</SplitPane>
);
Expand Down
Loading

0 comments on commit c9e8273

Please sign in to comment.