1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Apply linter config

This commit is contained in:
Laurent Cozic 2019-10-09 21:35:13 +02:00
parent d355169b60
commit a8ae0f8078
37 changed files with 77 additions and 77 deletions

View File

@ -10,8 +10,8 @@ async function handleAutocompletionPromise(line) {
// Auto-complete the command name
const names = await app().commandNames();
let words = getArguments(line);
//If there is only one word and it is not already a command name then you
//should look for commmands it could be
// If there is only one word and it is not already a command name then you
// should look for commmands it could be
if (words.length == 1) {
if (names.indexOf(words[0]) === -1) {
let x = names.filter(n => n.indexOf(words[0]) === 0);
@ -23,29 +23,29 @@ async function handleAutocompletionPromise(line) {
return line;
}
}
//There is more than one word and it is a command
// There is more than one word and it is a command
const metadata = (await app().commandMetadata())[words[0]];
//If for some reason this command does not have any associated metadata
//just don't autocomplete. However, this should not happen.
// If for some reason this command does not have any associated metadata
// just don't autocomplete. However, this should not happen.
if (metadata === undefined) {
return line;
}
//complete an option
// complete an option
let next = words.length > 1 ? words[words.length - 1] : '';
let l = [];
if (next[0] === '-') {
for (let i = 0; i < metadata.options.length; i++) {
const options = metadata.options[i][0].split(' ');
//if there are multiple options then they will be separated by comma and
//space. The comma should be removed
// if there are multiple options then they will be separated by comma and
// space. The comma should be removed
if (options[0][options[0].length - 1] === ',') {
options[0] = options[0].slice(0, -1);
}
if (words.includes(options[0]) || words.includes(options[1])) {
continue;
}
//First two elements are the flag and the third is the description
//Only autocomplete long
// First two elements are the flag and the third is the description
// Only autocomplete long
if (options.length > 1 && options[1].indexOf(next) === 0) {
l.push(options[1]);
} else if (options[0].indexOf(next) === 0) {
@ -59,9 +59,9 @@ async function handleAutocompletionPromise(line) {
ret.prefix = `${toCommandLine(words.slice(0, -1))} `;
return ret;
}
//Complete an argument
//Determine the number of positional arguments by counting the number of
//words that don't start with a - less one for the command name
// Complete an argument
// Determine the number of positional arguments by counting the number of
// words that don't start with a - less one for the command name
const positionalArgs = words.filter(a => a.indexOf('-') !== 0).length - 1;
let cmdUsage = yargParser(metadata.usage)['_'];
@ -155,20 +155,20 @@ function getArguments(line) {
if (line[i] === '"') {
if (inDoubleQuotes) {
inDoubleQuotes = false;
//maybe push word to parsed?
//currentWord += '"';
// maybe push word to parsed?
// currentWord += '"';
} else {
inDoubleQuotes = true;
//currentWord += '"';
// currentWord += '"';
}
} else if (line[i] === '\'') {
if (inSingleQuotes) {
inSingleQuotes = false;
//maybe push word to parsed?
//currentWord += "'";
// maybe push word to parsed?
// currentWord += "'";
} else {
inSingleQuotes = true;
//currentWord += "'";
// currentWord += "'";
}
} else if (/\s/.test(line[i]) && !(inDoubleQuotes || inSingleQuotes)) {
if (currentWord !== '') {

View File

@ -84,8 +84,8 @@ class StatusBarWidget extends BaseWidget {
// On Windows, bgBlueBright is fine and looks dark enough (Windows is probably in the wrong though)
// For now, just don't use any colour at all.
//const textStyle = this.promptActive ? (s) => s : chalk.bgBlueBright.white;
//const textStyle = (s) => s;
// const textStyle = this.promptActive ? (s) => s : chalk.bgBlueBright.white;
// const textStyle = (s) => s;
const textStyle = this.promptActive ? s => s : chalk.gray;
this.term.drawHLine(this.absoluteInnerX, this.absoluteInnerY, this.innerWidth, textStyle(' '));

View File

@ -1027,8 +1027,8 @@ describe('Synchronizer', function() {
// If we try to disable encryption now, it should throw an error because some items are
// currently encrypted. They must be decrypted first so that they can be sent as
// plain text to the sync target.
//let hasThrown = await checkThrowAsync(async () => await encryptionService().disableEncryption());
//expect(hasThrown).toBe(true);
// let hasThrown = await checkThrowAsync(async () => await encryptionService().disableEncryption());
// expect(hasThrown).toBe(true);
// Now supply the password, and decrypt the items
Setting.setObjectKey('encryption.passwordCache', masterKey.id, '123456');

View File

@ -69,11 +69,11 @@ SyncTargetRegistry.addClass(SyncTargetDropbox);
// const syncTargetId_ = SyncTargetRegistry.nameToId("nextcloud");
const syncTargetId_ = SyncTargetRegistry.nameToId('memory');
//const syncTargetId_ = SyncTargetRegistry.nameToId('filesystem');
// const syncTargetId_ = SyncTargetRegistry.nameToId('filesystem');
// const syncTargetId_ = SyncTargetRegistry.nameToId('dropbox');
const syncDir = `${__dirname}/../tests/sync`;
const sleepTime = syncTargetId_ == SyncTargetRegistry.nameToId('filesystem') ? 1001 : 100;//400;
const sleepTime = syncTargetId_ == SyncTargetRegistry.nameToId('filesystem') ? 1001 : 100;// 400;
console.info(`Testing with sync target: ${SyncTargetRegistry.idToName(syncTargetId_)}`);

View File

@ -418,8 +418,8 @@ class Application extends BaseApplication {
},
});
/* We need a dummy entry, otherwise the ternary operator to show a
* menu item only on a specific OS does not work. */
// We need a dummy entry, otherwise the ternary operator to show a
// menu item only on a specific OS does not work.
const noItem = {
type: 'separator',
visible: false,
@ -576,13 +576,13 @@ class Application extends BaseApplication {
}
const rootMenuFile = {
/* Using a dummy entry for macOS here, because first menu
* becomes 'Joplin' and we need a nenu called 'File' later. */
// Using a dummy entry for macOS here, because first menu
// becomes 'Joplin' and we need a nenu called 'File' later.
label: shim.isMac() ? '&JoplinMainMenu' : _('&File'),
/* `&` before one of the char in the label name mean, that
* <Alt + F> will open this menu. It's needed becase electron
* opens the first menu on Alt press if no hotkey assigned.
* Issue: https://github.com/laurent22/joplin/issues/934 */
// `&` before one of the char in the label name mean, that
// <Alt + F> will open this menu. It's needed becase electron
// opens the first menu on Alt press if no hotkey assigned.
// Issue: https://github.com/laurent22/joplin/issues/934
submenu: [{
label: _('About Joplin'),
visible: shim.isMac() ? true : false,

View File

@ -22,7 +22,7 @@ let hash;
try {
branch = execSync('git rev-parse --abbrev-ref HEAD').toString().trim();
hash = execSync('git log --pretty="%h" -1').toString().trim();
} catch(err) {
} catch (err) {
console.warn('Could not get git info', err);
}
if (typeof branch !== 'undefined' && typeof hash !== 'undefined') {

View File

@ -106,7 +106,7 @@ class NotePropertiesDialog extends React.Component {
this.styles_.controlBox = {
marginBottom: '1em',
color: 'black', //This will apply for the calendar
color: 'black', // This will apply for the calendar
};
this.styles_.button = {

View File

@ -1840,7 +1840,7 @@ class NoteTextComponent extends React.Component {
if (this.props.selectedNoteIds.length > 1) {
return this.renderMultiNotes(rootStyle);
} else if (!note || !!note.encryption_applied) {
//|| (note && !this.props.newNote && this.props.noteId && note.id !== this.props.noteId)) { // note.id !== props.noteId is when the note has not been loaded yet, and the previous one is still in the state
// || (note && !this.props.newNote && this.props.noteId && note.id !== this.props.noteId)) { // note.id !== props.noteId is when the note has not been loaded yet, and the previous one is still in the state
return this.renderNoNotes(rootStyle);
}

View File

@ -386,7 +386,7 @@ function themeStyle(theme) {
// For WebView - must correspond to the properties above
htmlFontSize: `${Math.round(15 * zoomRatio)}px`,
htmlLineHeight: '1.6em', //Math.round(20 * zoomRatio) + 'px'
htmlLineHeight: '1.6em', // Math.round(20 * zoomRatio) + 'px'
htmlCodeFontSize: '.9em',
};

View File

@ -20,18 +20,18 @@ ArrayUtils.binarySearch = function(items, value) {
middle = Math.floor((stopIndex + startIndex) / 2);
while (items[middle] != value && startIndex < stopIndex) {
//adjust search area
// adjust search area
if (value < items[middle]) {
stopIndex = middle - 1;
} else if (value > items[middle]) {
startIndex = middle + 1;
}
//recalculate middle
// recalculate middle
middle = Math.floor((stopIndex + startIndex) / 2);
}
//make sure it's the right value
// make sure it's the right value
return items[middle] != value ? -1 : middle;
};

View File

@ -63,7 +63,7 @@ class WebDavApi {
try {
// Note: Non-ASCII passwords will throw an error about Latin1 characters - https://github.com/laurent22/joplin/issues/246
// Tried various things like the below, but it didn't work on React Native:
//return base64.encode(utf8.encode(this.options_.username() + ':' + this.options_.password()));
// return base64.encode(utf8.encode(this.options_.username() + ':' + this.options_.password()));
return base64.encode(`${this.options_.username()}:${this.options_.password()}`);
} catch (error) {
error.message = `Cannot encode username/password: ${error.message}`;

View File

@ -67,7 +67,7 @@ class ItemList extends React.Component {
render() {
const style = this.props.style ? this.props.style : {};
//if (!this.props.itemHeight) throw new Error('itemHeight is required');
// if (!this.props.itemHeight) throw new Error('itemHeight is required');
let itemComps = [];

View File

@ -7,7 +7,7 @@ const styles = {
checkboxIcon: {
fontSize: 20,
height: 22,
//marginRight: 10,
// marginRight: 10,
},
};
@ -57,7 +57,7 @@ class Checkbox extends Component {
if (style && style.display === 'none') return <View />;
//if (style.display) thStyle.display = style.display;
// if (style.display) thStyle.display = style.display;
return (
<TouchableHighlight onPress={() => this.onPress()} style={thStyle}>

View File

@ -96,7 +96,7 @@ class NoteBodyViewer extends Component {
},
paddingBottom: '3.8em', // Extra bottom padding to make it possible to scroll past the action button (so that it doesn't overlap the text)
highlightedKeywords: this.props.highlightedKeywords,
resources: this.props.noteResources, //await shared.attachedResources(bodyToRender),
resources: this.props.noteResources, // await shared.attachedResources(bodyToRender),
codeTheme: theme.codeThemeCss,
postMessageSyntax: 'window.ReactNativeWebView.postMessage',
};

View File

@ -30,7 +30,7 @@ class NoteItemComponent extends Component {
let styles = {
listItem: {
flexDirection: 'row',
//height: 40,
// height: 40,
borderBottomWidth: 1,
borderBottomColor: theme.dividerColor,
alignItems: 'flex-start',
@ -38,7 +38,7 @@ class NoteItemComponent extends Component {
paddingRight: theme.marginRight,
paddingTop: theme.itemMarginTop,
paddingBottom: theme.itemMarginBottom,
//backgroundColor: theme.backgroundColor,
// backgroundColor: theme.backgroundColor,
},
listItemText: {
flex: 1,

View File

@ -61,7 +61,7 @@ class NoteListComponent extends Component {
}
filterNotes(notes) {
const todoFilter = 'all'; //Setting.value('todoFilter');
const todoFilter = 'all'; // Setting.value('todoFilter');
if (todoFilter == 'all') return notes;
const now = time.unixMs();

View File

@ -194,7 +194,7 @@ class ConfigScreenComponent extends BaseScreenComponent {
styles.switchSettingControl = Object.assign({}, styles.settingControl);
delete styles.switchSettingControl.color;
//styles.switchSettingControl.width = '20%';
// styles.switchSettingControl.width = '20%';
styles.switchSettingControl.flex = 0;
this.styles_[themeId] = StyleSheet.create(styles);
@ -366,7 +366,7 @@ class ConfigScreenComponent extends BaseScreenComponent {
</View>
);
} else {
//throw new Error('Unsupported setting type: ' + md.type);
// throw new Error('Unsupported setting type: ' + md.type);
}
return output;

View File

@ -410,7 +410,7 @@ class NoteScreenComponent extends BaseScreenComponent {
const format = mimeType == 'image/png' ? 'PNG' : 'JPEG';
reg.logger().info(`Resizing image ${localFilePath}`);
const resizedImage = await ImageResizer.createResizedImage(localFilePath, dimensions.width, dimensions.height, format, 85); //, 0, targetPath);
const resizedImage = await ImageResizer.createResizedImage(localFilePath, dimensions.width, dimensions.height, format, 85); // , 0, targetPath);
const resizedImagePath = resizedImage.uri;
reg.logger().info('Resized image ', resizedImagePath);

View File

@ -76,7 +76,7 @@ class SideMenuContentComponent extends Component {
styles.folderButtonSelected = Object.assign({}, styles.folderButton);
styles.folderButtonSelected.backgroundColor = theme.selectedColor;
styles.folderIcon = Object.assign({}, theme.icon);
styles.folderIcon.color = theme.colorFaded; //'#0072d5';
styles.folderIcon.color = theme.colorFaded; // '#0072d5';
styles.folderIcon.paddingTop = 3;
styles.sideButton = Object.assign({}, styles.button, { flex: 0 });

View File

@ -6,7 +6,7 @@ class DatabaseDriverReactNative {
}
open(options) {
//SQLite.DEBUG(true);
// SQLite.DEBUG(true);
return new Promise((resolve, reject) => {
SQLite.openDatabase(
{ name: options.name },

View File

@ -97,10 +97,10 @@ class FileApiDriverLocal {
try {
if (options.target === 'file') {
//output = await fs.copy(path, options.path, { overwrite: true });
// output = await fs.copy(path, options.path, { overwrite: true });
output = await this.fsDriver().copy(path, options.path);
} else {
//output = await fs.readFile(path, options.encoding);
// output = await fs.readFile(path, options.encoding);
output = await this.fsDriver().readFile(path, options.encoding);
}
} catch (error) {

View File

@ -148,7 +148,7 @@ class FileApi {
setTimestamp(path, timestampMs) {
this.logger().debug(`setTimestamp ${this.fullPath_(path)}`);
return tryAndRepeat(() => this.driver_.setTimestamp(this.fullPath_(path), timestampMs), this.requestRepeatCount());
//return this.driver_.setTimestamp(this.fullPath_(path), timestampMs);
// return this.driver_.setTimestamp(this.fullPath_(path), timestampMs);
}
mkdir(path) {

View File

@ -173,7 +173,7 @@ class FsDriverNode extends FsDriverBase {
}
async readFileChunk(handle, length, encoding = 'base64') {
//let buffer = new Buffer(length);
// let buffer = new Buffer(length);
let buffer = Buffer.alloc(length);
const result = await fs.read(handle, buffer, 0, length, null);
if (!result.bytesRead) return null;

View File

@ -392,10 +392,10 @@ function isSpanStyleBold(attributes) {
if (style.includes('font-weight: bold;')) {
return true;
} else if (style.search(/font-family:.*,Bold.*;/) != -1) {
//console.debug('font-family regex matched');
// console.debug('font-family regex matched');
return true;
} else {
//console.debug('Found unsupported style(s) in span tag: %s', style);
// console.debug('Found unsupported style(s) in span tag: %s', style);
return false;
}
}
@ -696,7 +696,7 @@ function enexXmlToMdArray(stream, resources) {
if (isSpanWithStyle(nodeAttributes)) {
state.spanAttributes.push(nodeAttributes);
if (isSpanStyleBold(nodeAttributes)) {
//console.debug('Applying style found in span tag: bold')
// console.debug('Applying style found in span tag: bold')
section.lines.push('**');
}
}
@ -884,7 +884,7 @@ function enexXmlToMdArray(stream, resources) {
let attributes = state.spanAttributes.pop();
if (isSpanWithStyle(attributes)) {
if (isSpanStyleBold(attributes)) {
//console.debug('Applying style found in span tag (closing): bold')
// console.debug('Applying style found in span tag (closing): bold')
section.lines.push('**');
}
}

View File

@ -10,7 +10,7 @@ const { time } = require('lib/time-utils.js');
const Levenshtein = require('levenshtein');
const md5 = require('md5');
//const Promise = require('promise');
// const Promise = require('promise');
const fs = require('fs-extra');
function dateToTimestamp(s, zeroIfInvalid = false) {

View File

@ -186,7 +186,7 @@ class OneDriveApi {
let errorResponseText = await response.text();
let errorResponse = null;
try {
errorResponse = JSON.parse(errorResponseText); //await response.json();
errorResponse = JSON.parse(errorResponseText); // await response.json();
} catch (error) {
error.message = `OneDriveApi::exec: Cannot parse JSON error: ${errorResponseText} ${error.message}`;
throw error;
@ -249,12 +249,12 @@ class OneDriveApi {
let response = await this.exec(method, path, query, data);
let errorResponseText = await response.text();
try {
let output = JSON.parse(errorResponseText); //await response.json();
let output = JSON.parse(errorResponseText); // await response.json();
return output;
} catch (error) {
error.message = `OneDriveApi::execJson: Cannot parse JSON: ${errorResponseText} ${error.message}`;
throw error;
//throw new Error('Cannot parse JSON: ' + text);
// throw new Error('Cannot parse JSON: ' + text);
}
}

View File

@ -1,4 +1,4 @@
/*eslint no-useless-escape: 0*/
/* eslint no-useless-escape: 0*/
// parseUri 1.2.2
// (c) Steven Levithan <stevenlevithan.com>

View File

@ -1,4 +1,4 @@
/*eslint no-useless-escape: 0*/
/* eslint no-useless-escape: 0*/
const { _ } = require('lib/locale');

View File

@ -459,7 +459,7 @@ const reducer = (state = defaultState, action) => {
}
}
//newNotes = Note.sortNotes(newNotes, state.notesOrder, newState.settings.uncompletedTodosOnTop);
// newNotes = Note.sortNotes(newNotes, state.notesOrder, newState.settings.uncompletedTodosOnTop);
newNotes = Note.sortNotes(newNotes, stateUtils.notesOrder(state.settings), newState.settings.uncompletedTodosOnTop);
newState = Object.assign({}, state);
newState.notes = newNotes;

View File

@ -10,7 +10,7 @@ reg.syncTargets_ = {};
reg.logger = () => {
if (!reg.logger_) {
//console.warn('Calling logger before it is initialized');
// console.warn('Calling logger before it is initialized');
return new Logger();
}

View File

@ -273,7 +273,7 @@ class EncryptionService {
ks: 128, // Key size - "128 bits should be secure enough"
ts: 64, // ???
mode: 'ocb2', // The cipher mode is a standard for how to use AES and other algorithms to encrypt and authenticate your message. OCB2 mode is slightly faster and has more features, but CCM mode has wider support because it is not patented.
//"adata":"", // Associated Data - not needed?
// "adata":"", // Associated Data - not needed?
cipher: 'aes',
});
} catch (error) {

View File

@ -568,7 +568,7 @@ class Api {
return output;
}
async downloadImage_(url /*, allowFileProtocolImages */) {
async downloadImage_(url /* , allowFileProtocolImages */) {
const tempDir = Setting.value('tempDir');
const isDataUrl = url && url.toLowerCase().indexOf('data:') === 0;

View File

@ -255,7 +255,7 @@ function shimInit() {
shim.fetchBlob = async function(url, options) {
if (!options || !options.path) throw new Error('fetchBlob: target file path is missing');
if (!options.method) options.method = 'GET';
//if (!('maxRetry' in options)) options.maxRetry = 5;
// if (!('maxRetry' in options)) options.maxRetry = 5;
const urlParse = require('url').parse;

View File

@ -548,7 +548,7 @@ class Synchronizer {
if (!BaseItem.isSystemPath(remote.path)) continue; // The delta API might return things like the .sync, .resource or the root folder
const loadContent = async () => {
let task = await this.downloadQueue_.waitForResult(path); //await this.api().get(path);
let task = await this.downloadQueue_.waitForResult(path); // await this.api().get(path);
if (task.error) throw task.error;
if (!task.result) return null;
return await BaseItem.unserialize(task.result);

View File

@ -634,7 +634,7 @@ class AppComponent extends React.Component {
}, 5);
}
} catch(e) {
} catch (e) {
reg.logger().error('Error in ShareExtension.data', e);
}
}

View File

@ -449,7 +449,7 @@ function markdownToHtml(md, templateParams) {
const anchorName = headingTextToAnchorName(token.content, doneNames);
doneNames.push(anchorName);
const anchorTokens = createAnchorTokens(anchorName);
//token.children = anchorTokens.concat(token.children);
// token.children = anchorTokens.concat(token.children);
token.children = token.children.concat(anchorTokens);
}
}

View File

@ -28,7 +28,7 @@ toolUtils.downloadFile = function(url, targetPath) {
if (response.statusCode !== 200) reject(new Error(`HTTP error ${response.statusCode}`));
response.pipe(file);
file.on('finish', function() {
//file.close();
// file.close();
resolve();
});
}).on('error', (error) => {
@ -74,7 +74,7 @@ toolUtils.fileExists = async function(filePath) {
fs.stat(filePath, function(err) {
if (err == null) {
resolve(true);
} else if(err.code == 'ENOENT') {
} else if (err.code == 'ENOENT') {
resolve(false);
} else {
reject(err);