Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
chore: fix linter
Browse files Browse the repository at this point in the history
  • Loading branch information
hugomrdias committed Sep 16, 2019
1 parent 9e83e3f commit d134357
Show file tree
Hide file tree
Showing 28 changed files with 117 additions and 91 deletions.
2 changes: 1 addition & 1 deletion src/cli/commands/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ module.exports = {
print('Daemon is ready')

const cleanup = async () => {
print(`Received interrupt signal, shutting down...`)
print('Received interrupt signal, shutting down...')
await daemon.stop()
process.exit(0)
}
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/file/ls.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
argv.resolve((async () => {
const path = argv.key
// `ipfs file ls` is deprecated. See https://ipfs.io/docs/commands/#ipfs-file-ls
argv.print(`This functionality is deprecated, and will be removed in future versions. If possible, please use 'ipfs ls' instead.`)
argv.print('This functionality is deprecated, and will be removed in future versions. If possible, please use \'ipfs ls\' instead.')

const ipfs = await argv.getIpfs()
let links = await ipfs.ls(path)
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ module.exports = {
})
} catch (err) {
if (err.code === 'EACCES') {
err.message = `EACCES: permission denied, stat $IPFS_PATH/version`
err.message = 'EACCES: permission denied, stat $IPFS_PATH/version'
}
throw err
}
Expand Down
4 changes: 2 additions & 2 deletions src/cli/commands/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ module.exports = {
commit: {
type: 'boolean',
default: false,
describe: `Include the version's commit hash`
describe: 'Include the version\'s commit hash'
},
repo: {
type: 'boolean',
default: false,
describe: `Print only the repo's version number`
describe: 'Print only the repo\'s version number'
},
all: {
type: 'boolean',
Expand Down
2 changes: 1 addition & 1 deletion src/core/components/pin/gc.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function createMarkedSet (ipfs, callback) {
(cb) => ipfs._repo.root.get(MFS_ROOT_KEY, (err, mh) => {
if (err) {
if (err.code === 'ERR_NOT_FOUND') {
log(`No blocks in MFS`)
log('No blocks in MFS')
return cb(null, [])
}
return cb(expErr(err, 'Could not get MFS root from datastore'))
Expand Down
2 changes: 1 addition & 1 deletion src/core/components/pin/pin-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ class PinManager {
this.repo.datastore.get(PIN_DS_KEY, (err, mh) => {
if (err) {
if (err.code === 'ERR_NOT_FOUND') {
this.log(`No pinned blocks`)
this.log('No pinned blocks')
return callback(null, [])
}
return callback(new Error(`Could not get pin sets root from datastore: ${err.message}`))
Expand Down
2 changes: 1 addition & 1 deletion src/core/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const s = superstruct({

return true
},
'multiaddr-ipfs': v => mafmt.IPFS.matches(v) ? true : `multiaddr IPFS invalid`
'multiaddr-ipfs': v => mafmt.IPFS.matches(v) ? true : 'multiaddr IPFS invalid'
}
})

Expand Down
12 changes: 6 additions & 6 deletions src/core/ipns/publisher.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class IpnsPublisher {

_putRecordToRouting (record, peerId, callback) {
if (!(PeerId.isPeerId(peerId))) {
const errMsg = `peerId received is not valid`
const errMsg = 'peerId received is not valid'

log.error(errMsg)
return callback(errcode(new Error(errMsg), 'ERR_INVALID_PEER_ID'))
Expand Down Expand Up @@ -87,7 +87,7 @@ class IpnsPublisher {

_publishEntry (key, entry, peerId, callback) {
if (!(Key.isKey(key))) {
const errMsg = `datastore key does not have a valid format`
const errMsg = 'datastore key does not have a valid format'

log.error(errMsg)
return callback(errcode(new Error(errMsg), 'ERR_INVALID_DATASTORE_KEY'))
Expand Down Expand Up @@ -118,14 +118,14 @@ class IpnsPublisher {

_publishPublicKey (key, publicKey, peerId, callback) {
if ((!Key.isKey(key))) {
const errMsg = `datastore key does not have a valid format`
const errMsg = 'datastore key does not have a valid format'

log.error(errMsg)
return callback(errcode(new Error(errMsg), 'ERR_INVALID_DATASTORE_KEY'))
}

if (!publicKey || !publicKey.bytes) {
const errMsg = `one or more of the provided parameters are not defined`
const errMsg = 'one or more of the provided parameters are not defined'

log.error(errMsg)
return callback(errcode(new Error(errMsg), 'ERR_UNDEFINED_PARAMETER'))
Expand All @@ -149,7 +149,7 @@ class IpnsPublisher {
// If `checkRouting` is true and we have no existing record, this method will check the routing system for any existing records.
_getPublished (peerId, options, callback) {
if (!(PeerId.isPeerId(peerId))) {
const errMsg = `peerId received is not valid`
const errMsg = 'peerId received is not valid'

log.error(errMsg)
return callback(errcode(new Error(errMsg), 'ERR_INVALID_PEER_ID'))
Expand Down Expand Up @@ -209,7 +209,7 @@ class IpnsPublisher {

_updateOrCreateRecord (privKey, value, validity, peerId, callback) {
if (!(PeerId.isPeerId(peerId))) {
const errMsg = `peerId received is not valid`
const errMsg = 'peerId received is not valid'

log.error(errMsg)
return callback(errcode(new Error(errMsg), 'ERR_INVALID_PEER_ID'))
Expand Down
2 changes: 1 addition & 1 deletion src/core/ipns/republisher.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class IpnsRepublisher {
record = ipns.unmarshal(dsVal)
} catch (err) {
log.error(err)
return callback(errcode(new Error(`found ipns record that we couldn't convert to a value`), 'ERR_INVALID_IPNS_RECORD'))
return callback(errcode(new Error('found ipns record that we couldn\'t convert to a value'), 'ERR_INVALID_IPNS_RECORD'))
}

callback(null, record.value)
Expand Down
4 changes: 2 additions & 2 deletions src/core/ipns/resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class IpnsResolver {
ipnsEntry = ipns.unmarshal(record)
} catch (err) {
log.error(err)
return callback(errcode(new Error(`found ipns record that we couldn't convert to a value`), 'ERR_INVALID_RECORD_RECEIVED'))
return callback(errcode(new Error('found ipns record that we couldn\'t convert to a value'), 'ERR_INVALID_RECORD_RECEIVED'))
}

// if the record has a public key validate it
Expand All @@ -131,7 +131,7 @@ class IpnsResolver {
peerId.pubKey = crypto.keys.unmarshalPublicKey(pubKey)
} catch (err) {
log.error(err)
return callback(errcode(new Error(`found public key record that we couldn't convert to a value`), 'ERR_INVALID_PUB_KEY_RECEIVED'))
return callback(errcode(new Error('found public key record that we couldn\'t convert to a value'), 'ERR_INVALID_PUB_KEY_RECEIVED'))
}

this._validateRecord(peerId, ipnsEntry, callback)
Expand Down
4 changes: 2 additions & 2 deletions test/cli/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ describe('file ls', () => runOnAndOff((thing) => {
it('prints a filename', () => {
return ipfs(`file ls ${file}`)
.then((out) => expect(out).to.eql(
`This functionality is deprecated, and will be removed in future versions. If possible, please use 'ipfs ls' instead.\n` +
'This functionality is deprecated, and will be removed in future versions. If possible, please use \'ipfs ls\' instead.\n' +
`${file}\n`
))
})

it('prints the filenames in a directory', () => {
return ipfs(`file ls ${dir}`)
.then((out) => expect(out).to.eql(
`This functionality is deprecated, and will be removed in future versions. If possible, please use 'ipfs ls' instead.\n` +
'This functionality is deprecated, and will be removed in future versions. If possible, please use \'ipfs ls\' instead.\n' +
'QmamKEPmEH9RUsqRQsfNf5evZQDQPYL9KXg1ADeT7mkHkT\n' +
'QmPkWYfSLCEBLZu7BZt4kigGDMe3cpogMbeVf97gN2xJDN\n' +
'QmUqyZtPmsRy1U5Mo8kz2BAMmk1hfJ7yW1KAFTMB2odsFv\n' +
Expand Down
4 changes: 2 additions & 2 deletions test/cli/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ describe('files', () => runOnAndOff((thing) => {
it('add with cid-version=1 and raw-leaves=false < default max chunk size', function () {
this.timeout(30 * 1000)

return ipfs(`add test/fixtures/less-than-default-max-chunk-size --cid-version=1 --raw-leaves=false`)
return ipfs('add test/fixtures/less-than-default-max-chunk-size --cid-version=1 --raw-leaves=false')
.then((out) => {
expect(out)
.to.eql('added bafybeiaoh5okvpnuhndsz4kgdhulnkm566rz7w7il6r2zm6wxu5f5uqlsu less-than-default-max-chunk-size\n')
Expand All @@ -256,7 +256,7 @@ describe('files', () => runOnAndOff((thing) => {
it('add with cid-version=1 and raw-leaves=false > default max chunk size', function () {
this.timeout(30 * 1000)

return ipfs(`add test/fixtures/greater-than-default-max-chunk-size --cid-version=1 --raw-leaves=false`)
return ipfs('add test/fixtures/greater-than-default-max-chunk-size --cid-version=1 --raw-leaves=false')
.then((out) => {
expect(out)
.to.eql('added bafybeiajpcrr2qglyeq3biilzt25ty6kpjs7huy2lfxopqfke6riaaxnim greater-than-default-max-chunk-size\n')
Expand Down
6 changes: 3 additions & 3 deletions test/cli/gc.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('gc', () => {
const errMsg = 'some err'
const printSpy = setupMocks(cids, errMsg)

await cli.parse(`repo gc`)
await cli.parse('repo gc')

const exp = cids.map(c => 'removed ' + c).concat(errMsg)
for (let i = 0; i < exp.length; i++) {
Expand All @@ -49,7 +49,7 @@ describe('gc', () => {
]
const printSpy = setupMocks(cids)

await cli.parse(`repo gc --quiet`)
await cli.parse('repo gc --quiet')

const exp = cids.map(c => c.toString())
for (let i = 0; i < exp.length; i++) {
Expand All @@ -60,7 +60,7 @@ describe('gc', () => {
it('gc with --stream-errors=false does not print errors', async () => {
const printSpy = setupMocks([], 'some err')

await cli.parse(`repo gc --stream-errors=false`)
await cli.parse('repo gc --stream-errors=false')
sinon.assert.notCalled(printSpy)
})
})
4 changes: 2 additions & 2 deletions test/cli/name.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('name', () => {
// Force the next require to not use require cache
clearModule('../../src/cli/commands/name/resolve.js')

await cli.parse(`name resolve test`)
await cli.parse('name resolve test')
sinon.assert.calledWith(resolveFake, 'test', { nocache: false, recursive: true })
})

Expand All @@ -47,7 +47,7 @@ describe('name', () => {
// Force the next require to not use require cache
clearModule('../../src/cli/commands/name/publish.js')

await cli.parse(`name publish test --silent`)
await cli.parse('name publish test --silent')
sinon.assert.calledWith(printSpy, 'Published to name: value')
sinon.assert.calledWith(publishFake, 'test', {
resolve: true,
Expand Down
4 changes: 2 additions & 2 deletions test/cli/swarm.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ describe('swarm', () => {
promise.then(({ data }) => {
expect(data).to.eql([
`${peerInfo.id.toB58String()} (2)`,
`\t/ip4/127.0.0.1/tcp/4001`,
`\t/ip4/127.0.0.1/tcp/4001/ws`
'\t/ip4/127.0.0.1/tcp/4001',
'\t/ip4/127.0.0.1/tcp/4001/ws'
].join('\n'))
done()
})
Expand Down
2 changes: 1 addition & 1 deletion test/core/bitswap.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function addNode (fDaemon, inProcNode, callback) {
initOptions: { bits: 512 },
config: {
Addresses: {
Swarm: [`/ip4/127.0.0.1/tcp/0/ws`]
Swarm: ['/ip4/127.0.0.1/tcp/0/ws']
},
Discovery: {
MDNS: {
Expand Down
2 changes: 1 addition & 1 deletion test/core/circuit-relay.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const wsAddr = (addrs) => addrs.map((a) => a.toString()).find((a) => a.includes(
const tcpAddr = (addrs) => addrs.map((a) => a.toString()).find((a) => !a.includes('/ws'))

describe('circuit relay', () => {
describe(`A <-> R <-> B`, function () {
describe('A <-> R <-> B', function () {
this.timeout(80 * 1000)

let nodeA
Expand Down
2 changes: 1 addition & 1 deletion test/core/pin-set.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ describe('pinSet', function () {
})

describe('walkItems', function () {
it(`fails if node doesn't have a pin-set protobuf header`, function (done) {
it('fails if node doesn\'t have a pin-set protobuf header', function (done) {
createNode('datum', (err, node) => {
expect(err).to.not.exist()

Expand Down
Loading

0 comments on commit d134357

Please sign in to comment.