mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-05 04:04:38 +08:00
fix(lint): various linter fixes
This commit is contained in:
parent
d961b1e4d4
commit
4fed2b452e
10 changed files with 73 additions and 67 deletions
|
@ -34,7 +34,7 @@
|
|||
"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"]}],
|
||||
"import/no-unresolved": ["error", {"ignore": ["nylas-exports", "nylas-component-kit", "electron", "nylas-store", "react-dom/server", "nylas-observables"]}],
|
||||
"react/no-multi-comp": "off",
|
||||
"react/prop-types": ["error", {"ignore": ["children"]}],
|
||||
"react/sort-comp": "error"
|
||||
|
|
|
@ -16,13 +16,13 @@ class AttachmentComponent extends Component {
|
|||
messageClientId: PropTypes.string,
|
||||
};
|
||||
|
||||
static containerRequired = false;
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
this.state = {progressPercent: 0}
|
||||
}
|
||||
|
||||
static containerRequired = false;
|
||||
|
||||
_isDownloading() {
|
||||
const {download} = this.props
|
||||
const state = download ? download.state : null
|
||||
|
|
|
@ -246,7 +246,8 @@ export default class CategoryPickerPopover extends Component {
|
|||
<RetinaImg
|
||||
name={`${item.name}.png`}
|
||||
fallback={'folder.png'}
|
||||
mode={RetinaImg.Mode.ContentIsMask} />
|
||||
mode={RetinaImg.Mode.ContentIsMask}
|
||||
/>
|
||||
)
|
||||
};
|
||||
|
||||
|
@ -263,7 +264,8 @@ export default class CategoryPickerPopover extends Component {
|
|||
className="check-img dash"
|
||||
name="tagging-conflicted.png"
|
||||
mode={RetinaImg.Mode.ContentPreserve}
|
||||
onClick={() => this._onSelectCategory(item)}/>
|
||||
onClick={() => this._onSelectCategory(item)}
|
||||
/>
|
||||
)
|
||||
} else {
|
||||
checkStatus = (
|
||||
|
@ -271,7 +273,8 @@ export default class CategoryPickerPopover extends Component {
|
|||
className="check-img check"
|
||||
name="tagging-checkmark.png"
|
||||
mode={RetinaImg.Mode.ContentPreserve}
|
||||
onClick={() => this._onSelectCategory(item)}/>
|
||||
onClick={() => this._onSelectCategory(item)}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -281,7 +284,8 @@ export default class CategoryPickerPopover extends Component {
|
|||
className="check-img check"
|
||||
name="tagging-checkbox.png"
|
||||
mode={RetinaImg.Mode.ContentPreserve}
|
||||
onClick={() => this._onSelectCategory(item)}/>
|
||||
onClick={() => this._onSelectCategory(item)}
|
||||
/>
|
||||
{checkStatus}
|
||||
</div>
|
||||
)
|
||||
|
@ -299,7 +303,8 @@ export default class CategoryPickerPopover extends Component {
|
|||
<RetinaImg
|
||||
name={`${picName}.png`}
|
||||
className={`category-create-new-${picName}`}
|
||||
mode={RetinaImg.Mode.ContentIsMask} />
|
||||
mode={RetinaImg.Mode.ContentIsMask}
|
||||
/>
|
||||
<div className="category-display-name">
|
||||
<strong>“{searchValue}”</strong> (create new)
|
||||
</div>
|
||||
|
@ -348,7 +353,8 @@ export default class CategoryPickerPopover extends Component {
|
|||
className="search"
|
||||
placeholder={placeholder}
|
||||
value={this.state.searchValue}
|
||||
onChange={this._onSearchValueChange} />,
|
||||
onChange={this._onSearchValueChange}
|
||||
/>,
|
||||
]
|
||||
|
||||
return (
|
||||
|
|
|
@ -42,6 +42,7 @@ class EmojiButtonPopover extends React.Component {
|
|||
if (!emojiName) return null;
|
||||
EmojiActions.selectEmoji({emojiName: emojiName, replaceSelection: false});
|
||||
Actions.closePopover();
|
||||
return null
|
||||
}
|
||||
|
||||
onScroll = () => {
|
||||
|
@ -51,12 +52,10 @@ class EmojiButtonPopover extends React.Component {
|
|||
if (emojiContainer.scrollTop === 0) {
|
||||
this.setState({activeTab: Object.keys(this.state.categorizedEmoji)[0]});
|
||||
} else {
|
||||
for (const category in this.state.categoryPositions) {
|
||||
if (this.state.categoryPositions.hasOwnProperty(category)) {
|
||||
if (emojiContainer.scrollTop >= this.state.categoryPositions[category].top &&
|
||||
emojiContainer.scrollTop <= this.state.categoryPositions[category].bottom) {
|
||||
this.setState({activeTab: category});
|
||||
}
|
||||
for (const category of Object.keys(this.state.categoryPositions)) {
|
||||
if (emojiContainer.scrollTop >= this.state.categoryPositions[category].top &&
|
||||
emojiContainer.scrollTop <= this.state.categoryPositions[category].bottom) {
|
||||
this.setState({activeTab: category});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -118,10 +117,8 @@ class EmojiButtonPopover extends React.Component {
|
|||
const frequentlyUsedEmoji = EmojiStore.frequentlyUsedEmoji();
|
||||
if (frequentlyUsedEmoji.length > 0) {
|
||||
categorizedEmoji = {'Frequently Used': frequentlyUsedEmoji};
|
||||
for (const category in categorizedEmojiList) {
|
||||
if (categorizedEmojiList.hasOwnProperty(category)) {
|
||||
categorizedEmoji[category] = categorizedEmojiList[category];
|
||||
}
|
||||
for (const category of Object.keys(categorizedEmojiList)) {
|
||||
categorizedEmoji[category] = categorizedEmojiList[category];
|
||||
}
|
||||
categoryNames = ["Frequently Used"].concat(categoryNames);
|
||||
}
|
||||
|
@ -131,14 +128,12 @@ class EmojiButtonPopover extends React.Component {
|
|||
categoryPositions[name] = {top: 0, bottom: 0};
|
||||
}
|
||||
let verticalPos = 25;
|
||||
for (const category in categoryPositions) {
|
||||
if (categoryPositions.hasOwnProperty(category)) {
|
||||
const height = Math.ceil(categorizedEmoji[category].length / 8) * 24;
|
||||
categoryPositions[category].top = verticalPos;
|
||||
verticalPos += height;
|
||||
categoryPositions[category].bottom = verticalPos;
|
||||
verticalPos += 24;
|
||||
}
|
||||
for (const category of Object.keys(categoryPositions)) {
|
||||
const height = Math.ceil(categorizedEmoji[category].length / 8) * 24;
|
||||
categoryPositions[category].top = verticalPos;
|
||||
verticalPos += height;
|
||||
categoryPositions[category].bottom = verticalPos;
|
||||
verticalPos += 24;
|
||||
}
|
||||
return {
|
||||
categoryNames: categoryNames,
|
||||
|
@ -184,22 +179,20 @@ class EmojiButtonPopover extends React.Component {
|
|||
}
|
||||
|
||||
calcEmojiByPosition = (position) => {
|
||||
for (const category in this.state.categoryPositions) {
|
||||
if (this.state.categoryPositions.hasOwnProperty(category)) {
|
||||
const LEFT_BOUNDARY = 8;
|
||||
const RIGHT_BOUNDARY = 204;
|
||||
const EMOJI_WIDTH = 24.5;
|
||||
const EMOJI_HEIGHT = 24;
|
||||
const EMOJI_PER_ROW = 8;
|
||||
if (position.x >= LEFT_BOUNDARY &&
|
||||
position.x <= RIGHT_BOUNDARY &&
|
||||
position.y >= this.state.categoryPositions[category].top &&
|
||||
position.y <= this.state.categoryPositions[category].bottom) {
|
||||
const x = Math.round((position.x + 5) / EMOJI_WIDTH);
|
||||
const y = Math.round((position.y - this.state.categoryPositions[category].top + 10) / EMOJI_HEIGHT);
|
||||
const index = x + (y - 1) * EMOJI_PER_ROW - 1;
|
||||
return this.state.categorizedEmoji[category][index];
|
||||
}
|
||||
for (const category of Object.keys(this.state.categoryPositions)) {
|
||||
const LEFT_BOUNDARY = 8;
|
||||
const RIGHT_BOUNDARY = 204;
|
||||
const EMOJI_WIDTH = 24.5;
|
||||
const EMOJI_HEIGHT = 24;
|
||||
const EMOJI_PER_ROW = 8;
|
||||
if (position.x >= LEFT_BOUNDARY &&
|
||||
position.x <= RIGHT_BOUNDARY &&
|
||||
position.y >= this.state.categoryPositions[category].top &&
|
||||
position.y <= this.state.categoryPositions[category].bottom) {
|
||||
const x = Math.round((position.x + 5) / EMOJI_WIDTH);
|
||||
const y = Math.round((position.y - this.state.categoryPositions[category].top + 10) / EMOJI_HEIGHT);
|
||||
const index = x + (y - 1) * EMOJI_PER_ROW - 1;
|
||||
return this.state.categorizedEmoji[category][index];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -219,7 +212,8 @@ class EmojiButtonPopover extends React.Component {
|
|||
className={className}
|
||||
name={`icon-emojipicker-${(category.replace(/ /g, '-')).toLowerCase()}.png`}
|
||||
mode={RetinaImg.Mode.ContentIsMask}
|
||||
onMouseDown={() => this.scrollToCategory(category)} />
|
||||
onMouseDown={() => this.scrollToCategory(category)}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
@ -250,7 +244,8 @@ class EmojiButtonPopover extends React.Component {
|
|||
renderNextCategory();
|
||||
}
|
||||
|
||||
renderCategory(category, i, ctx, position, callback) {
|
||||
renderCategory(category, i, ctx, pos, callback) {
|
||||
const position = pos
|
||||
if (i > 0) {
|
||||
position.x = 18;
|
||||
position.y += 48;
|
||||
|
@ -304,7 +299,8 @@ class EmojiButtonPopover extends React.Component {
|
|||
</div>
|
||||
<ScrollRegion
|
||||
className="emoji-finder-container"
|
||||
onScroll={this.onScroll}>
|
||||
onScroll={this.onScroll}
|
||||
>
|
||||
<div className="emoji-search-container">
|
||||
<input
|
||||
type="text"
|
||||
|
@ -320,7 +316,8 @@ class EmojiButtonPopover extends React.Component {
|
|||
onMouseDown={this.onMouseDown}
|
||||
onMouseOut={this.onMouseOut}
|
||||
onMouseMove={this.onHover}
|
||||
style={{zoom: "0.5"}}>
|
||||
style={{zoom: "0.5"}}
|
||||
>
|
||||
</canvas>
|
||||
</ScrollRegion>
|
||||
<div className="emoji-name">
|
||||
|
|
|
@ -7,10 +7,6 @@ import EmojiButtonPopover from './emoji-button-popover';
|
|||
class EmojiButton extends React.Component {
|
||||
static displayName = 'EmojiButton';
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
onClick = () => {
|
||||
const buttonRect = ReactDOM.findDOMNode(this).getBoundingClientRect();
|
||||
Actions.openPopover(
|
||||
|
@ -22,7 +18,7 @@ class EmojiButton extends React.Component {
|
|||
render() {
|
||||
return (
|
||||
<button tabIndex={-1} className="btn btn-toolbar" title="Insert emoji…" onClick={this.onClick}>
|
||||
<RetinaImg name="icon-composer-emoji.png" mode={RetinaImg.Mode.ContentIsMask}/>
|
||||
<RetinaImg name="icon-composer-emoji.png" mode={RetinaImg.Mode.ContentIsMask} />
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -130,6 +130,7 @@ class EmojiComposerExtension extends ComposerExtension {
|
|||
EmojiComposerExtension._onSelectEmoji(args);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
static applyTransformsToDraft = ({draft}) => {
|
||||
|
@ -214,6 +215,7 @@ class EmojiComposerExtension extends ComposerExtension {
|
|||
style="margin-top: -5px;">`;
|
||||
editor.insertHTML(html, {selectInsertion: false});
|
||||
EmojiActions.useEmoji({emojiName: emojiName, emojiChar: emojiChar});
|
||||
return null;
|
||||
};
|
||||
|
||||
static _emojiPickerWidth(emojiOptions) {
|
||||
|
|
|
@ -4,7 +4,8 @@ import {MessageViewExtension, RegExpUtils} from 'nylas-exports';
|
|||
import EmojiStore from './emoji-store';
|
||||
import emoji from 'node-emoji';
|
||||
|
||||
function makeIntoEmojiTag(node, emojiName) {
|
||||
function makeIntoEmojiTag(nodeArg, emojiName) {
|
||||
const node = nodeArg;
|
||||
node.src = EmojiStore.getImagePath(emojiName);
|
||||
node.className = `emoji ${emojiName}`;
|
||||
node.width = 14;
|
||||
|
|
|
@ -36,20 +36,25 @@ class EmojiPicker extends React.Component {
|
|||
this.props.emojiOptions.forEach((emojiOption, i) => {
|
||||
const emojiClass = emojiIndex === i ? "btn btn-icon emoji-option" : "btn btn-icon";
|
||||
let emojiChar = emoji.get(emojiOption);
|
||||
emojiChar = (<img
|
||||
src={EmojiStore.getImagePath(emojiOption)}
|
||||
width="16"
|
||||
height="16"
|
||||
style={{marginTop: "-4px", marginRight: "3px"}} />);
|
||||
emojiChar = (
|
||||
<img
|
||||
alt={emojiOption}
|
||||
src={EmojiStore.getImagePath(emojiOption)}
|
||||
width="16"
|
||||
height="16"
|
||||
style={{marginTop: "-4px", marginRight: "3px"}}
|
||||
/>
|
||||
);
|
||||
emojiButtons.push(
|
||||
<button
|
||||
key={emojiOption}
|
||||
onMouseDown={() => this.onMouseDown(emojiOption)}
|
||||
className={emojiClass}>
|
||||
className={emojiClass}
|
||||
>
|
||||
{emojiChar} :{emojiOption}:
|
||||
</button>
|
||||
);
|
||||
emojiButtons.push(<br key={emojiOption + " br"} />);
|
||||
emojiButtons.push(<br key={`${emojiOption} br`} />);
|
||||
});
|
||||
}
|
||||
return (
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
/* eslint global-require: "off" */
|
||||
|
||||
import NylasStore from 'nylas-store';
|
||||
import Rx from 'rx-lite';
|
||||
import _ from 'underscore';
|
||||
import fs from 'fs';
|
||||
|
||||
import {DatabaseStore} from 'nylas-exports';
|
||||
import EmojiActions from './emoji-actions';
|
||||
|
@ -19,7 +20,7 @@ class EmojiStore extends NylasStore {
|
|||
activate = () => {
|
||||
const query = DatabaseStore.findJSONBlob(EmojiJSONBlobKey);
|
||||
this._subscription = Rx.Observable.fromQuery(query).subscribe((emoji) => {
|
||||
this._emoji = emoji ? emoji : [];
|
||||
this._emoji = emoji || [];
|
||||
this.trigger();
|
||||
});
|
||||
this.listenTo(EmojiActions.useEmoji, this._onUseEmoji);
|
||||
|
@ -59,10 +60,8 @@ class EmojiStore extends NylasStore {
|
|||
return curEmoji.emojiChar === emoji.emojiChar;
|
||||
});
|
||||
if (savedEmoji) {
|
||||
for (const key in emoji) {
|
||||
if (emoji.hasOwnProperty(key)) {
|
||||
savedEmoji[key] = emoji[key];
|
||||
}
|
||||
for (const key of Object.keys(emoji)) {
|
||||
savedEmoji[key] = emoji[key];
|
||||
}
|
||||
savedEmoji.frequency++;
|
||||
} else {
|
||||
|
|
2
src/pro
2
src/pro
|
@ -1 +1 @@
|
|||
Subproject commit 6b0b9cff9b710a73ad3ba4e274ffe1ba448f145b
|
||||
Subproject commit dc53549b1016214a33724035a447c2545a2b5d07
|
Loading…
Add table
Reference in a new issue