mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Chore: Finished applying eqeqeq rule
This commit is contained in:
parent
052d9f03d6
commit
ce02d4c94f
@ -16,6 +16,8 @@ function getAdditionalModulePaths(options = {}) {
|
||||
|
||||
// We need to explicitly check for null and undefined (and not a falsy value) because
|
||||
// TypeScript treats an empty string as `.`.
|
||||
//
|
||||
// eslint-disable-next-line eqeqeq
|
||||
if (baseUrl == null) {
|
||||
// If there's no baseUrl set we respect NODE_PATH
|
||||
// Note that NODE_PATH is deprecated and will be removed
|
||||
|
@ -174,7 +174,7 @@ function useMenuStates(menu: any, props: Props) {
|
||||
menuItemSetChecked(`sort:${type}:${field}`, (props as any)[`${type}.sortOrder.field`] === field);
|
||||
}
|
||||
|
||||
const id = type == 'notes' ? 'toggleNotesSortOrderReverse' : `sort:${type}:reverse`;
|
||||
const id = type === 'notes' ? 'toggleNotesSortOrderReverse' : `sort:${type}:reverse`;
|
||||
menuItemSetChecked(id, (props as any)[`${type}.sortOrder.reverse`]);
|
||||
}
|
||||
|
||||
@ -332,7 +332,7 @@ function useMenu(props: Props) {
|
||||
|
||||
sortItems.push({ type: 'separator' });
|
||||
|
||||
if (type == 'notes') {
|
||||
if (type === 'notes') {
|
||||
sortItems.push(
|
||||
{ ...menuItemDic.toggleNotesSortOrderReverse, type: 'checkbox' },
|
||||
{ ...menuItemDic.toggleNotesSortOrderField, visible: false }
|
||||
|
@ -100,7 +100,7 @@ export function menuItems(dispatch: Function): ContextMenuItems {
|
||||
label: _('Save as %s', 'PNG'),
|
||||
onAction: async (options: ContextMenuOptions) => {
|
||||
// First convert it to png then save
|
||||
if (options.mime != 'image/svg+xml') {
|
||||
if (options.mime !== 'image/svg+xml') {
|
||||
throw new Error(`Unsupported image type: ${options.mime}`);
|
||||
}
|
||||
if (!options.filename) {
|
||||
@ -151,14 +151,14 @@ export function menuItems(dispatch: Function): ContextMenuItems {
|
||||
handleCopyToClipboard(options);
|
||||
options.insertContent('');
|
||||
},
|
||||
isActive: (itemType: ContextMenuItemType, options: ContextMenuOptions) => itemType != ContextMenuItemType.Image && (!options.isReadOnly && (!!options.textToCopy || !!options.htmlToCopy)),
|
||||
isActive: (itemType: ContextMenuItemType, options: ContextMenuOptions) => itemType !== ContextMenuItemType.Image && (!options.isReadOnly && (!!options.textToCopy || !!options.htmlToCopy)),
|
||||
},
|
||||
copy: {
|
||||
label: _('Copy'),
|
||||
onAction: async (options: ContextMenuOptions) => {
|
||||
handleCopyToClipboard(options);
|
||||
},
|
||||
isActive: (itemType: ContextMenuItemType, options: ContextMenuOptions) => itemType != ContextMenuItemType.Image && (!!options.textToCopy || !!options.htmlToCopy),
|
||||
isActive: (itemType: ContextMenuItemType, options: ContextMenuOptions) => itemType !== ContextMenuItemType.Image && (!!options.textToCopy || !!options.htmlToCopy),
|
||||
},
|
||||
paste: {
|
||||
label: _('Paste'),
|
||||
|
@ -342,7 +342,7 @@ const NoteListComponent = (props: Props) => {
|
||||
const keyCode = event.keyCode;
|
||||
const noteIds = props.selectedNoteIds;
|
||||
|
||||
if (noteIds.length > 0 && (keyCode === 40 || keyCode === 38 || keyCode === 33 || keyCode === 34 || keyCode === 35 || keyCode == 36)) {
|
||||
if (noteIds.length > 0 && (keyCode === 40 || keyCode === 38 || keyCode === 33 || keyCode === 34 || keyCode === 35 || keyCode === 36)) {
|
||||
// DOWN / UP / PAGEDOWN / PAGEUP / END / HOME
|
||||
const noteId = noteIds[0];
|
||||
let noteIndex = BaseModel.modelIndexById(props.notes, noteId);
|
||||
|
@ -41,7 +41,7 @@ class NotePropertiesDialog extends React.Component {
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
if (this.state.editedKey == null) {
|
||||
if (this.state.editedKey === null) {
|
||||
this.okButton.current.focus();
|
||||
}
|
||||
}
|
||||
@ -59,7 +59,7 @@ class NotePropertiesDialog extends React.Component {
|
||||
latLongFromLocation(location) {
|
||||
const o = {};
|
||||
const l = location.split(',');
|
||||
if (l.length == 2) {
|
||||
if (l.length === 2) {
|
||||
o.latitude = l[0].trim();
|
||||
o.longitude = l[1].trim();
|
||||
} else {
|
||||
|
@ -121,7 +121,7 @@ async function initialize() {
|
||||
|
||||
class RootComponent extends React.Component<Props, any> {
|
||||
public async componentDidMount() {
|
||||
if (this.props.appState == 'starting') {
|
||||
if (this.props.appState === 'starting') {
|
||||
this.props.dispatch({
|
||||
type: 'APP_STATE_SET',
|
||||
state: 'initializing',
|
||||
|
@ -40,7 +40,7 @@ scrollmap.get_ = () => {
|
||||
// embedded into elements by the renderer.
|
||||
// See also renderer/MdToHtml/rules/source_map.ts.
|
||||
const elems = document.getElementsByClassName('maps-to-line');
|
||||
if (elems.length == 0) return null;
|
||||
if (elems.length === 0) return null;
|
||||
const map = { line: [0], percent: [0], viewHeight: height, lineCount: 0 };
|
||||
// Each map entry is total-ordered.
|
||||
let last = 0;
|
||||
|
@ -131,7 +131,7 @@ app().start(bridge().processArgv()).then((result) => {
|
||||
}).catch((error) => {
|
||||
const env = bridge().env();
|
||||
|
||||
if (error.code == 'flagError') {
|
||||
if (error.code === 'flagError') {
|
||||
bridge().showErrorMessageBox(error.message);
|
||||
} else {
|
||||
// If something goes wrong at this stage we don't have a console or a log file
|
||||
|
@ -214,7 +214,7 @@ class Dialog extends React.PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
modalLayer_onClick(event: any) {
|
||||
if (event.currentTarget == event.target) {
|
||||
if (event.currentTarget === event.target) {
|
||||
this.props.dispatch({
|
||||
pluginName: PLUGIN_NAME,
|
||||
type: 'PLUGINLEGACY_DIALOG_SET',
|
||||
|
@ -19,7 +19,7 @@ export default function(frameWindow: any, onSubmit: Function, onDismiss: Functio
|
||||
// Disable enter key from submitting when a text area is in focus!
|
||||
// https://github.com/laurent22/joplin/issues/4766
|
||||
//
|
||||
if (frameWindow.document.activeElement.tagName != 'TEXTAREA') {
|
||||
if (frameWindow.document.activeElement.tagName !== 'TEXTAREA') {
|
||||
if (onSubmit) onSubmit();
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ let perFieldReverse: { [field: string]: boolean } = null;
|
||||
|
||||
export const notesSortOrderFieldArray = (): string[] => {
|
||||
// The order of the fields is strictly determinate.
|
||||
if (fields == null) {
|
||||
if (fields === null) {
|
||||
fields = Setting.enumOptionValues('notes.sortOrder.field').sort().reverse();
|
||||
}
|
||||
return fields;
|
||||
|
@ -6,7 +6,7 @@ const execCommand = function(command) {
|
||||
return new Promise((resolve, reject) => {
|
||||
exec(command, (error, stdout) => {
|
||||
if (error) {
|
||||
if (error.signal == 'SIGTERM') {
|
||||
if (error.signal === 'SIGTERM') {
|
||||
resolve('Process was killed');
|
||||
} else {
|
||||
reject(error);
|
||||
|
@ -8,7 +8,7 @@ function execCommand(command) {
|
||||
return new Promise((resolve, reject) => {
|
||||
exec(command, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
if (error.signal == 'SIGTERM') {
|
||||
if (error.signal === 'SIGTERM') {
|
||||
resolve('Process was killed');
|
||||
} else {
|
||||
reject(new Error([stdout.trim(), stderr.trim()].join('\n')));
|
||||
|
@ -68,7 +68,7 @@ export default class SelectDateTimeDialog extends React.PureComponent<any, any>
|
||||
}
|
||||
|
||||
UNSAFE_componentWillReceiveProps(newProps: any) {
|
||||
if (newProps.date != this.state.date) {
|
||||
if (newProps.date !== this.state.date) {
|
||||
this.setState({ date: newProps.date });
|
||||
}
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ class FileApiDriverLocal {
|
||||
output = await this.fsDriver().readFile(path, options.encoding);
|
||||
}
|
||||
} catch (error) {
|
||||
if (error.code == 'ENOENT') return null;
|
||||
if (error.code === 'ENOENT') return null;
|
||||
throw this.fsErrorToJsError_(error, path);
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ export default class FileApiDriverMemory {
|
||||
|
||||
itemIndexByPath(path: string) {
|
||||
for (let i = 0; i < this.items_.length; i++) {
|
||||
if (this.items_[i].path == path) return i;
|
||||
if (this.items_[i].path === path) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@ -71,7 +71,7 @@ export default class FileApiDriverMemory {
|
||||
|
||||
for (let i = 0; i < this.items_.length; i++) {
|
||||
const item = this.items_[i];
|
||||
if (item.path == path) continue;
|
||||
if (item.path === path) continue;
|
||||
if (item.path.indexOf(`${path}/`) === 0) {
|
||||
const s = item.path.substr(path.length + 1);
|
||||
if (s.split('/').length === 1) {
|
||||
|
@ -59,7 +59,7 @@ export default class FsDriverNode extends FsDriverBase {
|
||||
lastError = error;
|
||||
// Normally cannot happen with the `overwrite` flag but sometime it still does.
|
||||
// In this case, retry.
|
||||
if (error.code == 'EEXIST') {
|
||||
if (error.code === 'EEXIST') {
|
||||
await time.sleep(1);
|
||||
continue;
|
||||
}
|
||||
@ -95,7 +95,7 @@ export default class FsDriverNode extends FsDriverBase {
|
||||
size: stat.size,
|
||||
};
|
||||
} catch (error) {
|
||||
if (error.code == 'ENOENT') return null;
|
||||
if (error.code === 'ENOENT') return null;
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ const markdownUtils = {
|
||||
const searchUrls = (tokens: any[]) => {
|
||||
for (let i = 0; i < tokens.length; i++) {
|
||||
const token = tokens[i];
|
||||
if ((!onlyType && (token.type === 'link_open' || token.type === 'image')) || (!!onlyType && token.type === onlyType) || (onlyType == 'pdf' && token.type === 'link_open')) {
|
||||
if ((!onlyType && (token.type === 'link_open' || token.type === 'image')) || (!!onlyType && token.type === onlyType) || (onlyType === 'pdf' && token.type === 'link_open')) {
|
||||
// Pdf embeds are a special case, they are represented as 'link_open' tokens but are marked with 'embedded_pdf' as link name by the parser
|
||||
// We are making sure if its in the proper pdf link format, only then we add it to the list
|
||||
if (onlyType === 'pdf' && !(tokens.length > i + 1 && tokens[i + 1].type === 'text' && tokens[i + 1].content === 'embedded_pdf')) continue;
|
||||
|
@ -23,11 +23,11 @@ const mime = {
|
||||
mimeType = mimeType.toLowerCase();
|
||||
for (let i = 0; i < mimeTypes.length; i++) {
|
||||
const t = mimeTypes[i];
|
||||
if (mimeType == t.t) {
|
||||
if (mimeType === t.t) {
|
||||
// Return the first file extension that is 3 characters long
|
||||
// If none exist return the first one in the list.
|
||||
for (let j = 0; j < t.e.length; j++) {
|
||||
if (t.e[j].length == 3) return t.e[j];
|
||||
if (t.e[j].length === 3) return t.e[j];
|
||||
}
|
||||
return t.e[0];
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ class Registry {
|
||||
const newContext = await sync.start(options);
|
||||
Setting.setValue(contextKey, JSON.stringify(newContext));
|
||||
} catch (error) {
|
||||
if (error.code == 'alreadyStarted') {
|
||||
if (error.code === 'alreadyStarted') {
|
||||
this.logger().info(error.message);
|
||||
} else {
|
||||
promiseResolve();
|
||||
|
@ -341,7 +341,7 @@ export default class KeymapService extends BaseService {
|
||||
if (usedAccelerators.has(itemAccelerator)) {
|
||||
const originalItem = (proposedKeymapItem && proposedKeymapItem.accelerator === itemAccelerator)
|
||||
? proposedKeymapItem
|
||||
: Object.values(this.keymap).find(_item => _item.accelerator == itemAccelerator);
|
||||
: Object.values(this.keymap).find(_item => _item.accelerator === itemAccelerator);
|
||||
|
||||
throw new Error(_(
|
||||
'Accelerator "%s" is used for "%s" and "%s" commands. This may lead to unexpected behaviour.',
|
||||
|
@ -432,7 +432,7 @@ export default class InteropService {
|
||||
}
|
||||
|
||||
try {
|
||||
if (itemType == BaseModel.TYPE_RESOURCE) {
|
||||
if (itemType === BaseModel.TYPE_RESOURCE) {
|
||||
const resourcePath = Resource.fullPath(item);
|
||||
context.resourcePaths[item.id] = resourcePath;
|
||||
exporter.updateContext(context);
|
||||
|
@ -104,6 +104,8 @@ export default class InteropService_Exporter_Md_frontmatter extends InteropServi
|
||||
// as numbers i.e 0.000000 is the same as 0.
|
||||
// This is necessary because these fields are officially numbers, but often
|
||||
// contain strings.
|
||||
|
||||
// eslint-disable-next-line eqeqeq
|
||||
if (note.latitude != 0 || note.longitude != 0 || note.altitude != 0) {
|
||||
md['latitude'] = note.latitude;
|
||||
md['longitude'] = note.longitude;
|
||||
|
@ -41,7 +41,7 @@ const calculateScore = (searchString, notes) => {
|
||||
};
|
||||
|
||||
let titleBM25WeightedByLastUpdate = new Array(notes.length).fill(-1);
|
||||
if (avgTokens != 0) {
|
||||
if (avgTokens !== 0) {
|
||||
for (let i = 0; i < notes.length; i++) {
|
||||
titleBM25WeightedByLastUpdate[i] = IDF(notes.length, notesWithWord) * ((freqTitle[i] * (K1 + 1)) / (freqTitle[i] + K1 * (1 - B + B * (numTokens[i] / avgTokens))));
|
||||
titleBM25WeightedByLastUpdate[i] += weightForDaysSinceLastUpdate(notes[i]);
|
||||
|
@ -546,7 +546,7 @@ export default class SearchEngine {
|
||||
console.warn(error);
|
||||
}
|
||||
|
||||
const textQuery = allTerms.filter(x => x.name === 'text' || x.name == 'title' || x.name == 'body').map(x => x.value).join(' ');
|
||||
const textQuery = allTerms.filter(x => x.name === 'text' || x.name === 'title' || x.name === 'body').map(x => x.value).join(' ');
|
||||
const st = scriptType(textQuery);
|
||||
|
||||
if (!Setting.value('db.ftsEnabled')) {
|
||||
|
@ -277,7 +277,7 @@ describe('Synchronizer.basics', function() {
|
||||
|
||||
const localF2 = await Folder.load(remoteF2.id);
|
||||
|
||||
expect(localF2.title == remoteF2.title).toBe(true);
|
||||
expect(localF2.title === remoteF2.title).toBe(true);
|
||||
|
||||
// Then that folder that has been renamed locally should be set in such a way
|
||||
// that synchronizing it applies the title change remotely, and that new title
|
||||
@ -292,7 +292,7 @@ describe('Synchronizer.basics', function() {
|
||||
|
||||
remoteF2 = await Folder.load(remoteF2.id);
|
||||
|
||||
expect(remoteF2.title == localF2.title).toBe(true);
|
||||
expect(remoteF2.title === localF2.title).toBe(true);
|
||||
}));
|
||||
|
||||
it('should create remote items with UTF-8 content', (async () => {
|
||||
|
@ -464,7 +464,7 @@ function shimInit(options = null) {
|
||||
|
||||
url = urlParse(url.trim());
|
||||
const method = options.method ? options.method : 'GET';
|
||||
const http = url.protocol.toLowerCase() == 'http:' ? require('follow-redirects').http : require('follow-redirects').https;
|
||||
const http = url.protocol.toLowerCase() === 'http:' ? require('follow-redirects').http : require('follow-redirects').https;
|
||||
const headers = options.headers ? options.headers : {};
|
||||
const filePath = options.path;
|
||||
|
||||
|
@ -53,7 +53,7 @@ export async function localNotesFoldersSameAsRemote(locals: any[], expect: Funct
|
||||
|
||||
let remoteContent = await fileApi().get(path);
|
||||
|
||||
remoteContent = dbItem.type_ == BaseModel.TYPE_NOTE ? await Note.unserialize(remoteContent) : await Folder.unserialize(remoteContent);
|
||||
remoteContent = dbItem.type_ === BaseModel.TYPE_NOTE ? await Note.unserialize(remoteContent) : await Folder.unserialize(remoteContent);
|
||||
expect(remoteContent.title).toBe(dbItem.title);
|
||||
}
|
||||
} catch (e) {
|
||||
|
@ -145,7 +145,7 @@ function math_inline(state: any, silent: boolean) {
|
||||
}
|
||||
|
||||
// Even number of escapes, potential closing delimiter found
|
||||
if ((match - pos) % 2 == 1) {
|
||||
if ((match - pos) % 2 === 1) {
|
||||
break;
|
||||
}
|
||||
match += 1;
|
||||
|
@ -1,6 +1,6 @@
|
||||
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
||||
function onDocumentReady(fn) {
|
||||
if (document.readyState != 'loading') {
|
||||
if (document.readyState !== 'loading') {
|
||||
fn();
|
||||
} else {
|
||||
document.addEventListener('DOMContentLoaded', fn);
|
||||
|
@ -87,7 +87,7 @@ const later = require('later');
|
||||
if (!numbers || numbers.length <= 1) return 0;
|
||||
|
||||
const expectedStep = numbers[1] - numbers[0];
|
||||
if (numbers.length == 2) return expectedStep;
|
||||
if (numbers.length === 2) return expectedStep;
|
||||
|
||||
// Check that every number is the previous number + the first number
|
||||
return numbers.slice(1).every(function(n,i,a) {
|
||||
|
@ -10,7 +10,7 @@ const execCommand = function(command: string, returnStdErr: boolean = false): Pr
|
||||
return new Promise((resolve, reject) => {
|
||||
exec(command, (error: any, stdout: any, stderr: any) => {
|
||||
if (error) {
|
||||
if (error.signal == 'SIGTERM') {
|
||||
if (error.signal === 'SIGTERM') {
|
||||
resolve('Process was killed');
|
||||
} else {
|
||||
reject(error);
|
||||
@ -39,7 +39,7 @@ async function curl(method: string, path: string, query: object = null, body: an
|
||||
if (options.verbose) curlCmd.push('-v');
|
||||
if (options.output) curlCmd.push(`--output "${options.output}"`);
|
||||
|
||||
if ((['PUT', 'DELETE', 'PATCH'].indexOf(method) >= 0) || (method == 'POST' && !formFields && !body)) {
|
||||
if ((['PUT', 'DELETE', 'PATCH'].indexOf(method) >= 0) || (method === 'POST' && !formFields && !body)) {
|
||||
curlCmd.push('-X');
|
||||
curlCmd.push(method);
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ function serializeTranslation(translation) {
|
||||
|
||||
for (const n in translations) {
|
||||
if (!translations.hasOwnProperty(n)) continue;
|
||||
if (n == '') continue;
|
||||
if (n === '') continue;
|
||||
const t = translations[n];
|
||||
let translated = '';
|
||||
if (t.comments && t.comments.flag && t.comments.flag.indexOf('fuzzy') >= 0) {
|
||||
@ -453,7 +453,7 @@ async function main() {
|
||||
|
||||
const poFilePäth = `${localesDir}/${locale}.po`;
|
||||
const jsonFilePath = `${jsonLocalesDir}/${locale}.json`;
|
||||
if (locale != defaultLocale) await mergePotToPo(potFilePath, poFilePäth);
|
||||
if (locale !== defaultLocale) await mergePotToPo(potFilePath, poFilePäth);
|
||||
buildLocale(poFilePäth, jsonFilePath);
|
||||
|
||||
const stat = await translationStatus(defaultLocale === locale, poFilePäth);
|
||||
|
@ -38,7 +38,7 @@ utils.execCommand = function(command) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (error.signal == 'SIGTERM') {
|
||||
if (error.signal === 'SIGTERM') {
|
||||
resolve('Process was killed');
|
||||
} else {
|
||||
const newError = new Error(`Code: ${error.code}: ${error.message}: ${stdout.trim()}`);
|
||||
|
Loading…
Reference in New Issue
Block a user