mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-12-27 02:23:28 +08:00
fix(lint): Correct more linter errors
This commit is contained in:
parent
3d3b9bf87f
commit
0e2b5501e3
13 changed files with 76 additions and 69 deletions
|
@ -8,6 +8,7 @@
|
|||
"advanceClock": false,
|
||||
"TEST_ACCOUNT_ID": false,
|
||||
"TEST_ACCOUNT_NAME": false,
|
||||
"TEST_ACCOUNT_EMAIL": false,
|
||||
"TEST_ACCOUNT_ALIAS_EMAIL": false
|
||||
},
|
||||
"env": {
|
||||
|
@ -17,6 +18,7 @@
|
|||
},
|
||||
"rules": {
|
||||
"arrow-body-style": "off",
|
||||
"prefer-arrow-callback": ["error", {"allowNamedFunctions": true}],
|
||||
"eqeqeq": ["error", "smart"],
|
||||
"id-length": "off",
|
||||
"object-curly-spacing": "off",
|
||||
|
@ -30,6 +32,7 @@
|
|||
"object-shorthand": "off",
|
||||
"quotes": "off",
|
||||
"quote-props": ["error", "consistent-as-needed", { "keywords": true }],
|
||||
"no-param-reassign": ["error", { "props": false }],
|
||||
"semi": "off",
|
||||
"import/no-unresolved": ["error", {"ignore": ["nylas-exports", "nylas-component-kit", "electron", "nylas-store", "react-dom/server"]}],
|
||||
"react/no-multi-comp": "off",
|
||||
|
|
|
@ -23,22 +23,22 @@ describe('DateInput', function dateInput() {
|
|||
describe('onInputKeyDown', () => {
|
||||
it('should submit the input if Enter or Escape pressed', () => {
|
||||
const onSubmitDate = jasmine.createSpy('onSubmitDate')
|
||||
const dateInput = makeInput({onSubmitDate: onSubmitDate})
|
||||
const inputNode = ReactDOM.findDOMNode(dateInput).querySelector('input')
|
||||
const component = makeInput({onSubmitDate: onSubmitDate})
|
||||
const inputNode = ReactDOM.findDOMNode(component).querySelector('input')
|
||||
const stopPropagation = jasmine.createSpy('stopPropagation')
|
||||
const keys = ['Enter', 'Return']
|
||||
inputNode.value = 'tomorrow'
|
||||
spyOn(DateUtils, 'futureDateFromString').andReturn('someday')
|
||||
spyOn(dateInput, 'setState')
|
||||
spyOn(component, 'setState')
|
||||
|
||||
keys.forEach((key) => {
|
||||
Simulate.keyDown(inputNode, {key, stopPropagation})
|
||||
expect(stopPropagation).toHaveBeenCalled()
|
||||
expect(onSubmitDate).toHaveBeenCalledWith('someday', 'tomorrow')
|
||||
expect(dateInput.setState).toHaveBeenCalledWith({inputDate: null})
|
||||
expect(component.setState).toHaveBeenCalledWith({inputDate: null})
|
||||
stopPropagation.reset()
|
||||
onSubmitDate.reset()
|
||||
dateInput.setState.reset()
|
||||
component.setState.reset()
|
||||
})
|
||||
});
|
||||
});
|
||||
|
@ -49,18 +49,18 @@ describe('DateInput', function dateInput() {
|
|||
});
|
||||
|
||||
it('should render a date interpretation if a date has been inputted', () => {
|
||||
const dateInput = makeInput({initialState: {inputDate: 'something!'}})
|
||||
spyOn(dateInput, 'setState')
|
||||
const dateInterpretation = findDOMNode(findRenderedDOMComponentWithClass(dateInput, 'date-interpretation'))
|
||||
const component = makeInput({initialState: {inputDate: 'something!'}})
|
||||
spyOn(component, 'setState')
|
||||
const dateInterpretation = findDOMNode(findRenderedDOMComponentWithClass(component, 'date-interpretation'))
|
||||
|
||||
expect(dateInterpretation.textContent).toEqual('formatted')
|
||||
});
|
||||
|
||||
it('should not render a date interpretation if no input date available', () => {
|
||||
const dateInput = makeInput({initialState: {inputDate: null}})
|
||||
spyOn(dateInput, 'setState')
|
||||
const component = makeInput({initialState: {inputDate: null}})
|
||||
spyOn(component, 'setState')
|
||||
expect(() => {
|
||||
findRenderedDOMComponentWithClass(dateInput, 'date-interpretation')
|
||||
findRenderedDOMComponentWithClass(component, 'date-interpretation')
|
||||
}).toThrow()
|
||||
});
|
||||
});
|
||||
|
|
|
@ -6,8 +6,13 @@ import {renderIntoDocument} from '../nylas-test-utils'
|
|||
const {Directions: {Up, Down, Left, Right}} = FixedPopover
|
||||
|
||||
const makePopover = (props = {}) => {
|
||||
props.originRect = props.originRect ? props.originRect : {};
|
||||
const popover = renderIntoDocument(<FixedPopover {...props}/>);
|
||||
const originRect = props.originRect ? props.originRect : {};
|
||||
const popover = renderIntoDocument(
|
||||
<FixedPopover
|
||||
{...props}
|
||||
originRect={originRect}
|
||||
/>
|
||||
);
|
||||
if (props.initialState) {
|
||||
popover.setState(props.initialState)
|
||||
}
|
||||
|
|
|
@ -3,10 +3,7 @@ import {InjectedComponentSet} from 'nylas-component-kit';
|
|||
const {renderIntoDocument} = NylasTestUtils;
|
||||
|
||||
const reactStub = (displayName) => {
|
||||
return React.createClass({
|
||||
displayName,
|
||||
render() { return <div className={displayName}></div>; },
|
||||
});
|
||||
return <div className={displayName}></div>;
|
||||
};
|
||||
|
||||
|
||||
|
@ -26,7 +23,8 @@ describe('InjectedComponentSet', function injectedComponentSet() {
|
|||
renderIntoDocument(
|
||||
<InjectedComponentSet
|
||||
matching={{}}
|
||||
onComponentsDidRender={onComponentsDidRender} />
|
||||
onComponentsDidRender={onComponentsDidRender}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import {events} from './fixtures/events'
|
||||
import {NylasCalendar} from 'nylas-component-kit'
|
||||
|
||||
describe('Extended Nylas Calendar Week View', function extendedNylasCalendarWeekView() {
|
||||
});
|
||||
// import {events} from './fixtures/events'
|
||||
// import {NylasCalendar} from 'nylas-component-kit'
|
||||
//
|
||||
// describe('Extended Nylas Calendar Week View', function extendedNylasCalendarWeekView() {
|
||||
// });
|
||||
|
|
|
@ -121,10 +121,8 @@ describe("Nylas Calendar Week View", function weekViewSpec() {
|
|||
|
||||
// See fixtures/events
|
||||
expect(eventsByDay.allDay.length).toBe(numAllDayEvents);
|
||||
for (const day in numByDay) {
|
||||
if (numByDay.hasOwnProperty(day)) {
|
||||
expect(eventsByDay[day].length).toBe(numByDay[day])
|
||||
}
|
||||
for (const day of Object.keys(numByDay)) {
|
||||
expect(eventsByDay[day].length).toBe(numByDay[day])
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -16,11 +16,12 @@ import {
|
|||
SyncbackDraftFilesTask,
|
||||
} from 'nylas-exports';
|
||||
|
||||
import {remote} from 'electron';
|
||||
import DraftFactory from '../../src/flux/stores/draft-factory';
|
||||
|
||||
class TestExtension extends ComposerExtension {
|
||||
static prepareNewDraft({draft}) {
|
||||
draft.body = "Edited by TestExtension!" + draft.body;
|
||||
draft.body = `Edited by TestExtension! ${draft.body}`;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -180,7 +181,7 @@ describe('DraftStore', function draftStore() {
|
|||
},
|
||||
teardown: this.draftSessionTeardown,
|
||||
};
|
||||
DraftStore._draftSessions = {"abc": this.session};
|
||||
DraftStore._draftSessions = {abc: this.session};
|
||||
spyOn(Actions, 'queueTask');
|
||||
});
|
||||
|
||||
|
@ -222,12 +223,14 @@ describe('DraftStore', function draftStore() {
|
|||
|
||||
describe("before unloading", () => {
|
||||
it("should destroy pristine drafts", () => {
|
||||
DraftStore._draftSessions = {"abc": {
|
||||
changes: {},
|
||||
draft() {
|
||||
return {pristine: true};
|
||||
DraftStore._draftSessions = {
|
||||
abc: {
|
||||
changes: {},
|
||||
draft() {
|
||||
return {pristine: true};
|
||||
},
|
||||
},
|
||||
}};
|
||||
};
|
||||
|
||||
spyOn(Actions, 'queueTask');
|
||||
DraftStore._onBeforeUnload();
|
||||
|
@ -239,9 +242,9 @@ describe('DraftStore', function draftStore() {
|
|||
beforeEach(() => {
|
||||
this.resolve = null;
|
||||
DraftStore._draftSessions = {
|
||||
"abc": {
|
||||
abc: {
|
||||
changes: {
|
||||
commit: () => new Promise((resolve) => this.resolve = resolve),
|
||||
commit: () => new Promise((resolve) => { this.resolve = resolve }),
|
||||
},
|
||||
draft() {
|
||||
return {pristine: false};
|
||||
|
@ -262,13 +265,15 @@ describe('DraftStore', function draftStore() {
|
|||
|
||||
describe("when drafts return immediately fulfilled commit promises", () => {
|
||||
beforeEach(() => {
|
||||
DraftStore._draftSessions = {"abc": {
|
||||
changes:
|
||||
{commit: () => Promise.resolve()},
|
||||
draft() {
|
||||
return {pristine: false};
|
||||
DraftStore._draftSessions = {
|
||||
abc: {
|
||||
changes:
|
||||
{commit: () => Promise.resolve()},
|
||||
draft() {
|
||||
return {pristine: false};
|
||||
},
|
||||
},
|
||||
}};
|
||||
};
|
||||
});
|
||||
|
||||
it("should still wait one tick before firing NylasEnv.close again", () => {
|
||||
|
@ -429,7 +434,6 @@ describe('DraftStore', function draftStore() {
|
|||
it("displays a popup in the main window if there's an error", () => {
|
||||
spyOn(NylasEnv, "isMainWindow").andReturn(true);
|
||||
spyOn(FocusedContentStore, "focused").andReturn({id: "t1"});
|
||||
const {remote} = require('electron');
|
||||
spyOn(remote.dialog, "showMessageBox");
|
||||
spyOn(Actions, "composePopoutDraft");
|
||||
DraftStore._draftsSending[this.draft.clientId] = true;
|
||||
|
@ -485,7 +489,7 @@ describe('DraftStore', function draftStore() {
|
|||
},
|
||||
teardown: this.draftTeardown,
|
||||
};
|
||||
DraftStore._draftSessions = {"abc": this.session};
|
||||
DraftStore._draftSessions = {abc: this.session};
|
||||
DraftStore._doneWithSession(this.session);
|
||||
});
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ describe('NylasSyncStatusStore', function nylasSyncStatusStore() {
|
|||
});
|
||||
|
||||
it('returns false otherwise', () => {
|
||||
spyOn(store, 'isSyncCompleteForAccount').andCallFake((acctId) => acctId === 'a1' ? true : false)
|
||||
spyOn(store, 'isSyncCompleteForAccount').andCallFake(acctId => acctId === 'a1')
|
||||
store._statesByAccount = {
|
||||
a1: {},
|
||||
a2: {},
|
||||
|
|
|
@ -22,7 +22,7 @@ export class APITestTask extends Task {
|
|||
}
|
||||
|
||||
export class KillsTaskA extends Task {
|
||||
shouldDequeueOtherTask(other) {return other instanceof TaskSubclassA}
|
||||
shouldDequeueOtherTask(other) { return other instanceof TaskSubclassA }
|
||||
performRemote() { return new Promise(() => {}) }
|
||||
}
|
||||
|
||||
|
@ -50,10 +50,9 @@ export class TaskBB extends Task {
|
|||
}
|
||||
|
||||
export class OKTask extends Task {
|
||||
performRemote() {return Promise.resolve(Task.Status.Retry)}
|
||||
performRemote() { return Promise.resolve(Task.Status.Retry) }
|
||||
}
|
||||
|
||||
export class BadTask extends Task {
|
||||
performRemote() {return Promise.resolve('lalal')}
|
||||
performRemote() { return Promise.resolve('lalal') }
|
||||
}
|
||||
|
||||
|
|
|
@ -13,14 +13,14 @@ describe('TaskFactory', function taskFactory() {
|
|||
beforeEach(() => {
|
||||
this.categories = {
|
||||
'ac-1': {
|
||||
'archive': new Category({name: 'archive'}),
|
||||
'inbox': new Category({name: 'inbox1'}),
|
||||
'trash': new Category({name: 'trash1'}),
|
||||
archive: new Category({name: 'archive'}),
|
||||
inbox: new Category({name: 'inbox1'}),
|
||||
trash: new Category({name: 'trash1'}),
|
||||
},
|
||||
'ac-2': {
|
||||
'archive': new Category({name: 'all'}),
|
||||
'inbox': new Category({name: 'inbox2'}),
|
||||
'trash': new Category({name: 'trash2'}),
|
||||
archive: new Category({name: 'all'}),
|
||||
inbox: new Category({name: 'inbox2'}),
|
||||
trash: new Category({name: 'trash2'}),
|
||||
},
|
||||
}
|
||||
this.accounts = {
|
||||
|
|
|
@ -248,10 +248,9 @@ describe('SendDraftTask', function sendDraftTask() {
|
|||
if (options.body.reply_to_message_id) {
|
||||
const err = new APIError({body: "Invalid message public id"});
|
||||
return Promise.reject(err);
|
||||
} else {
|
||||
if (options.success) { options.success(this.response) }
|
||||
return Promise.resolve(this.response);
|
||||
}
|
||||
if (options.success) { options.success(this.response) }
|
||||
return Promise.resolve(this.response);
|
||||
});
|
||||
|
||||
this.draft.replyToMessageId = "reply-123";
|
||||
|
@ -273,10 +272,9 @@ describe('SendDraftTask', function sendDraftTask() {
|
|||
spyOn(NylasAPI, 'makeRequest').andCallFake((options) => {
|
||||
if (options.body.reply_to_message_id) {
|
||||
return Promise.reject(new APIError({body: "Invalid thread"}));
|
||||
} else {
|
||||
if (options.success) { options.success(this.response) }
|
||||
return Promise.resolve(this.response);
|
||||
}
|
||||
if (options.success) { options.success(this.response) }
|
||||
return Promise.resolve(this.response);
|
||||
});
|
||||
|
||||
this.draft.replyToMessageId = "reply-123";
|
||||
|
@ -356,7 +354,7 @@ describe('SendDraftTask', function sendDraftTask() {
|
|||
body: {
|
||||
message: "Sending to at least one recipient failed.",
|
||||
server_error: "<<Don't know what this looks like >>",
|
||||
type: "api_error"
|
||||
type: "api_error",
|
||||
},
|
||||
})
|
||||
|
||||
|
|
|
@ -67,8 +67,8 @@ describe('SyncbackDraftFilesTask', function syncbackDraftFilesTask() {
|
|||
|
||||
// uploads should be queued, but not the send
|
||||
expect(NylasAPI.makeRequest.callCount).toEqual(2);
|
||||
expect(NylasAPI.makeRequest.calls[0].args[0].formData).toEqual({ file : { value : 'stub', options : { filename : 'test-file-1.png' } } });
|
||||
expect(NylasAPI.makeRequest.calls[1].args[0].formData).toEqual({ file : { value : 'stub', options : { filename : 'test-file-2.png' } } });
|
||||
expect(NylasAPI.makeRequest.calls[0].args[0].formData).toEqual({file: {value: 'stub', options: { filename: 'test-file-1.png' } } });
|
||||
expect(NylasAPI.makeRequest.calls[1].args[0].formData).toEqual({file: {value: 'stub', options: { filename: 'test-file-2.png' } } });
|
||||
|
||||
// finish all uploads
|
||||
expect(taskPromise.isFulfilled()).toBe(false);
|
||||
|
|
|
@ -165,8 +165,8 @@ export default class TimePicker extends React.Component {
|
|||
while (timeIter.isSameOrBefore(endMoment)) {
|
||||
const val = timeIter.valueOf();
|
||||
const className = classnames({
|
||||
option: true,
|
||||
selected: timeIter.isSame(enteredMoment),
|
||||
"option": true,
|
||||
"selected": timeIter.isSame(enteredMoment),
|
||||
"scroll-start": timeIter.isSame(firstVisibleMoment),
|
||||
})
|
||||
|
||||
|
@ -180,7 +180,8 @@ export default class TimePicker extends React.Component {
|
|||
}
|
||||
|
||||
opts.push(
|
||||
<div className={className} key={val}
|
||||
<div
|
||||
className={className} key={val}
|
||||
onMouseDown={() => this._onSelectOption(val)}
|
||||
>
|
||||
{timeIter.format("LT")}{relTxt}
|
||||
|
@ -203,11 +204,12 @@ export default class TimePicker extends React.Component {
|
|||
const className = classnames({
|
||||
"time-picker": true,
|
||||
"no-select-end": true,
|
||||
invalid: !moment(this.state.rawText, "h:ma").isValid(),
|
||||
"invalid": !moment(this.state.rawText, "h:ma").isValid(),
|
||||
})
|
||||
return (
|
||||
<div className="time-picker-wrap">
|
||||
<input className={className}
|
||||
<input
|
||||
className={className}
|
||||
type="text"
|
||||
ref="input"
|
||||
value={this.state.rawText}
|
||||
|
|
Loading…
Reference in a new issue