Skip to content

Commit

Permalink
tech: Fix eslint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
taratatach committed Dec 11, 2024
1 parent c91ddb9 commit 4fe640f
Show file tree
Hide file tree
Showing 178 changed files with 4,387 additions and 2,618 deletions.
24 changes: 13 additions & 11 deletions core/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,37 @@
* @module core/app
* @flow
*/
const autoBind = require('auto-bind')
const fse = require('fs-extra')
const _ = require('lodash')
const https = require('https')
const os = require('os')
const path = require('path')
const url = require('url')
const uuid = require('uuid').v4
const https = require('https')
const { createGzip } = require('zlib')

const autoBind = require('auto-bind')
const fse = require('fs-extra')
const _ = require('lodash')
const semver = require('semver')
const uuid = require('uuid').v4

const { rootCozyUrl } = require('cozy-client')

const pkg = require('../package.json')
const config = require('./config')
const { Pouch } = require('./pouch')
const { migrations, runMigrations } = require('./migrations')
const Ignore = require('./ignore')
const { Local } = require('./local')
const { Merge } = require('./merge')
const { migrations, runMigrations } = require('./migrations')
const { Pouch } = require('./pouch')
const Prep = require('./prep')
const { Local } = require('./local')
const { Remote } = require('./remote')
const Registration = require('./remote/registration')
const { Sync } = require('./sync')
const SyncState = require('./syncstate')
const Registration = require('./remote/registration')
const { baseLogger, logger, LOG_BASENAME } = require('./utils/logger')
const flags = require('./utils/flags')
const { sendToTrash } = require('./utils/fs')
const { baseLogger, logger, LOG_BASENAME } = require('./utils/logger')
const notes = require('./utils/notes')
const web = require('./utils/web')
const flags = require('./utils/flags')

/*::
import type EventEmitter from 'events'
Expand Down
3 changes: 2 additions & 1 deletion core/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
*/

const fs = require('fs')
const path = require('path')

const fse = require('fs-extra')
const _ = require('lodash')
const path = require('path')

const { hideOnWindows } = require('./utils/fs')
const { logger } = require('./utils/logger')
Expand Down
4 changes: 2 additions & 2 deletions core/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
require('../core/utils/modules_stubs').initialize()

require('isomorphic-fetch')

const Promise = require('bluebird')
const WebSocket = require('ws')

global.WebSocket = WebSocket

// We are using bluebird instead of native promises:
// - they are easier to debug with long stack traces
// - they have some nice helpers like Promise.delay, map, race, etc.
// - to help transition from callbacks with asCallback and promisifyAll
const Promise = require('bluebird')
global.Promise = Promise
Promise.longStackTraces()

Expand Down
7 changes: 5 additions & 2 deletions core/ignore.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@
* @flow
*/

const fs = require('fs')
const { basename, dirname, resolve } = require('path')

const { matcher } = require('micromatch')
const fs = require('fs')

const { logger } = require('./utils/logger')

Expand Down Expand Up @@ -128,7 +129,9 @@ function buildPattern(line /*: string */) /*: IgnorePattern */ {

/** Parse many lines and build the corresponding pattern array */
function buildPatternArray(lines /*: string[] */) /*: IgnorePattern[] */ {
return Array.from(lines).filter(isNotBlankOrComment).map(buildPattern)
return Array.from(lines)
.filter(isNotBlankOrComment)
.map(buildPattern)
}

function isNotBlankOrComment(line /*: string */) /*: boolean */ {
Expand Down
37 changes: 17 additions & 20 deletions core/incompatibilities/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,26 +299,23 @@ const detectPathIncompatibilities = (
platform
).map(nameIncompatibility => _.merge({ path }, nameIncompatibility))

const recursivePathIncompatibilities = ancestorNames.reduceRight(
(
previousIncompatibilities /*: Array<PlatformIncompatibility> */,
name /*: string */,
index /*: number */,
pathComponents /*: string[] */
) => {
const path = pathComponents.slice(0, index + 1).join(sep)
const nameIncompatibilities = detectNameIncompatibilities(
name,
'folder',
platform
)

return previousIncompatibilities.concat(
nameIncompatibilities.map(issue => _.merge({ path }, issue))
)
},
pathIncompatibilities
)
const recursivePathIncompatibilities = ancestorNames.reduceRight((
previousIncompatibilities /*: Array<PlatformIncompatibility> */,
name /*: string */,
index /*: number */,
pathComponents /*: string[] */
) => {
const path = pathComponents.slice(0, index + 1).join(sep)
const nameIncompatibilities = detectNameIncompatibilities(
name,
'folder',
platform
)

return previousIncompatibilities.concat(
nameIncompatibilities.map(issue => _.merge({ path }, issue))
)
}, pathIncompatibilities)

return recursivePathIncompatibilities.filter(issue => issue != null)
}
Expand Down
3 changes: 2 additions & 1 deletion core/local/channel_watcher/add_checksum.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
* @flow
*/

const _ = require('lodash')
const path = require('path')

const _ = require('lodash')

const { logger } = require('../../utils/logger')
const { measureTime } = require('../../utils/perfs')

Expand Down
3 changes: 2 additions & 1 deletion core/local/channel_watcher/add_infos.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
* @flow
*/

const _ = require('lodash')
const path = require('path')

const _ = require('lodash')

const { kind } = require('../../metadata')
const { logger } = require('../../utils/logger')
const { measureTime } = require('../../utils/perfs')
Expand Down
2 changes: 1 addition & 1 deletion core/local/channel_watcher/dispatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

const _ = require('lodash')

const { buildDir, buildFile } = require('../../metadata')
const { WINDOWS_DATE_MIGRATION_FLAG } = require('../../config')
const { buildDir, buildFile } = require('../../metadata')
const { logger } = require('../../utils/logger')
const { measureTime } = require('../../utils/perfs')

Expand Down
7 changes: 4 additions & 3 deletions core/local/channel_watcher/incomplete_fixer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@

const path = require('path')

const stater = require('../stater')
const { logger } = require('../../utils/logger')
const { measureTime } = require('../../utils/perfs')
const stater = require('../stater')

const STEP_NAME = 'incompleteFixer'

Expand Down Expand Up @@ -273,8 +273,9 @@ function step(
// (e.g. a temporary document now renamed), we'll want to make sure the old
// document is removed to avoid having 2 documents with the same inode.
// We can do this by keeping the completing renamed event.
const incompleteForExistingDoc /*: ?Metadata */ =
await opts.pouch.byLocalPath(item.event.path)
const incompleteForExistingDoc /*: ?Metadata */ = await opts.pouch.byLocalPath(
item.event.path
)
if (
incompleteForExistingDoc &&
!incompleteForExistingDoc.trashed &&
Expand Down
15 changes: 7 additions & 8 deletions core/local/channel_watcher/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,19 @@ const Promise = require('bluebird')
const _ = require('lodash')

const checksumer = require('./../checksumer')
const Producer = require('./parcel_producer')
const addChecksum = require('./add_checksum')
const addInfos = require('./add_infos')
const awaitWriteFinish = require('./await_write_finish')
const dispatch = require('./dispatch')
const filterIgnored = require('./filter_ignored')
const fireLocatStartEvent = require('./fire_local_start_event')
const winIdenticalRenaming = require('./win_identical_renaming')
const scanFolder = require('./scan_folder')
const awaitWriteFinish = require('./await_write_finish')
const initialDiff = require('./initial_diff')
const addChecksum = require('./add_checksum')
const incompleteFixer = require('./incomplete_fixer')
const initialDiff = require('./initial_diff')
const overwrite = require('./overwrite')
const dispatch = require('./dispatch')
const Producer = require('./parcel_producer')
const scanFolder = require('./scan_folder')
const winIdenticalRenaming = require('./win_identical_renaming')
const { logger } = require('../../utils/logger')

const { LOCAL_WATCHER_FATAL_EVENT } = require('../constants')

/*::
Expand Down
5 changes: 3 additions & 2 deletions core/local/channel_watcher/initial_diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
* @flow
*/

const _ = require('lodash')
const path = require('path')

const _ = require('lodash')

const Channel = require('./channel')
const { WINDOWS_DATE_MIGRATION_FLAG } = require('../../config')
const { kind } = require('../../metadata')
const { logger } = require('../../utils/logger')
const { measureTime } = require('../../utils/perfs')
const Channel = require('./channel')

/*::
import type { Config } from '../../config'
Expand Down
5 changes: 3 additions & 2 deletions core/local/channel_watcher/parcel_producer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
* @flow
*/

const autoBind = require('auto-bind')
const path = require('path')
const Promise = require('bluebird')

const parcel = require('@parcel/watcher')
const autoBind = require('auto-bind')
const Promise = require('bluebird')

const Channel = require('./channel')
const { INITIAL_SCAN_DONE } = require('./event')
Expand Down
2 changes: 1 addition & 1 deletion core/local/channel_watcher/win_identical_renaming.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
const _ = require('lodash')

const Channel = require('./channel')
const { logger } = require('../../utils/logger')
const metadata = require('../../metadata')
const { logger } = require('../../utils/logger')
const { measureTime } = require('../../utils/perfs')

/*::
Expand Down
9 changes: 5 additions & 4 deletions core/local/checksumer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
* @flow
*/

const Promise = require('bluebird')
const async = require('async')
const crypto = require('crypto')
const fs = require('fs')

const async = require('async')
const Promise = require('bluebird')

const { measureTime } = require('../utils/perfs')

/*::
Expand All @@ -27,12 +28,12 @@ function computeChecksum(filePath /*: string */, callback /*: Callback */) {
const stream = fs.createReadStream(filePath)
const checksum = crypto.createHash('md5')
checksum.setEncoding('base64')
stream.on('end', function () {
stream.on('end', function() {
stopMeasure()
checksum.end()
callback(null, checksum.read())
})
stream.on('error', function (err) {
stream.on('error', function(err) {
stopMeasure()
checksum.end()
callback(err)
Expand Down
15 changes: 9 additions & 6 deletions core/local/chokidar/analysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@
*/

const path = require('path')

const _ = require('lodash')

const { getInode } = require('./local_event')
const localChange = require('./local_change')
const { getInode } = require('./local_event')
const metadata = require('../../metadata')
const { logger } = require('../../utils/logger')
const { measureTime } = require('../../utils/perfs')
const metadata = require('../../metadata')

/*::
import type { LocalEvent } from './local_event'
Expand Down Expand Up @@ -234,8 +235,9 @@ function analyseEvent(
localChange.fileUpdate(e)
)
case 'unlink': {
const moveChange /*: ?LocalFileMove */ =
localChange.maybeMoveFile(sameInodeChange)
const moveChange /*: ?LocalFileMove */ = localChange.maybeMoveFile(
sameInodeChange
)
if (moveChange && !moveChange.wip) delete e.old
return (
localChange.fileMoveFromAddUnlink(sameInodeChange, e) ||
Expand All @@ -250,8 +252,9 @@ function analyseEvent(
)
}
case 'unlinkDir': {
const moveChange /*: ?LocalDirMove */ =
localChange.maybeMoveFolder(sameInodeChange)
const moveChange /*: ?LocalDirMove */ = localChange.maybeMoveFolder(
sameInodeChange
)
if (moveChange && !moveChange.wip) delete e.old
return (
localChange.dirMoveFromAddUnlink(sameInodeChange, e) ||
Expand Down
9 changes: 6 additions & 3 deletions core/local/chokidar/initial_scan.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/

const chokidarEvent = require('./event')
const { logger } = require('../../utils/logger')
const metadata = require('../../metadata')
const { logger } = require('../../utils/logger')
const { SYNC_DIR_EMPTY_MESSAGE } = require('../errors')

const log = logger({
Expand Down Expand Up @@ -79,8 +79,11 @@ const step = async (
.filter(e => e.type.startsWith('add'))
.forEach(e => initialScanParams.paths.push(metadata.id(e.path)))

const { offlineEvents, unappliedMoves, emptySyncDir } =
await detectOfflineUnlinkEvents(initialScanParams, pouch)
const {
offlineEvents,
unappliedMoves,
emptySyncDir
} = await detectOfflineUnlinkEvents(initialScanParams, pouch)
events = offlineEvents.concat(events)

events = events.filter(e => {
Expand Down
Loading

0 comments on commit 4fe640f

Please sign in to comment.