Skip to content

Commit

Permalink
chore(lint): implement new lint setup for skyring
Browse files Browse the repository at this point in the history
This updates the lint package to the most recent and enables it for a
mono-repo.

Semver: patch
  • Loading branch information
esatterwhite committed Jan 3, 2021
1 parent 21e9bb1 commit b185cbf
Show file tree
Hide file tree
Showing 27 changed files with 164 additions and 147 deletions.
2 changes: 1 addition & 1 deletion examples/manual-config/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/mongo-storage/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/scylla-storage/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"version": "1.0.0",
"scripts": {
"pnpm": "pnpm",
"lint": "eslint .",
"lint:fix": "npm run lint -- --fix",
"lint": "pnpm run -r --if-present lint",
"lint:fix": "pnpm run -r --if-present lint:fix",
"tap": "tap",
"nyc": "nyc",
"test:all": "npm run local tap -- --coverage-report=text --coverage-report=json -Rclassic",
Expand Down
3 changes: 1 addition & 2 deletions packages/ringpop/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/scylladown/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions packages/skyring/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict'
module.exports = {
'root': true
, 'extends': 'eslint-config-codedependant'
, 'parserOptions': {
ecmaVersion: 2019
}
, 'ignorePatterns': [
'node_modules/'
, 'coverage/'
]
, 'rules': {
'sensible/check-require': [2, 'always', {
root: __dirname
}]
}
}
42 changes: 20 additions & 22 deletions packages/skyring/bin/commands/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,56 +21,56 @@ module.exports = new seeli.Command({
/* eslint-enable max-len */
]
, flags: {
seeds: {
'seeds': {
type: [String, Array]
, shorthand: 's'
, required: true
, description: 'Nodes in the ring to use as seed nodes'
}
, transport: {
, 'transport': {
type: [String, Array]
, shorthand: 't'
, description: 'Custom transports to load into the server at start up time'
}

, 'channel:host': {
type: String
'type': String
, 'default': '127.0.0.1'
, description: 'Host name or ip this node should bind on'
, 'description': 'Host name or ip this node should bind on'
}

, 'channel:port': {
type: Number
'type': Number
, 'default': 3455
, description: 'The port this node should bind on'
, 'description': 'The port this node should bind on'
}

, 'storage:backend': {
type: String
'type': String
, 'default': 'memdown'
, description: 'A levelup compatible module for levelup. Must be requirable'
, 'description': 'A levelup compatible module for levelup. Must be requirable'
}
, 'storage:path': {
type: String
, description: 'A directory path where data can be stored.'
}
, port: {
shorthand: 'p'
, type: Number
, 'port': {
'shorthand': 'p'
, 'type': Number
, 'default': 3000
, description: 'The port the HTTP Server should listen on'
, 'description': 'The port the HTTP Server should listen on'
}

, daemon: {
shorthand: 'd'
, type: Boolean
, 'daemon': {
'shorthand': 'd'
, 'type': Boolean
, 'default': false
, description: 'Run the process in the background as a daemon'
, 'description': 'Run the process in the background as a daemon'
}
, 'nats:hosts': {
type: String
'type': String
, 'default': 'localhost:4222'
, description: 'a comma seperated list of nats servers to connect to'
, 'description': 'a comma seperated list of nats servers to connect to'
}
}

Expand All @@ -91,15 +91,13 @@ module.exports = new seeli.Command({
})
}

const env = Object.assign({}, process.env, {
PORT: data.port
const env = {...process.env, PORT: data.port
, seeds: data.seeds.join(',')
, nats__hosts: data.nats.hosts
, channel__host: data.channel.host
, channel__port: data.channel.port
, storage__backend: data.storage.backend
, storage__path: data.storage.path || ''
})
, storage__path: data.storage.path || ''}

const skyring = child.spawn(
process.execPath
Expand Down
2 changes: 1 addition & 1 deletion packages/skyring/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ if (require.main === module) {
log.info('server listening on port %d', server.address().port)
})

const onSignal = () => {
function onSignal() {
log.info('shutdown signal received')
server.close(() => {
log.info('server shutdown complete')
Expand Down
6 changes: 3 additions & 3 deletions packages/skyring/lib/server/api/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict'

module.exports = {
post: require('./post_timer')
'post': require('./post_timer')
, 'delete': require('./delete_timer')
, put: require('./put_timer')
, ping: require('./get_ping')
, 'put': require('./put_timer')
, 'ping': require('./get_ping')
}
2 changes: 1 addition & 1 deletion packages/skyring/lib/server/api/validators/timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = function(data = {}, cb) {
}

const type = typeOf(data.data)
if (data.data != null) {
if (data.data != null) { // eslint-disable-line no-eq-null
if (type !== 'String' && type !== 'Object') {
const err = new TypeError(
`data is required and must be a string or object. Got ${type}`
Expand Down
4 changes: 3 additions & 1 deletion packages/skyring/lib/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ const Router = require('./router')
const Timer = require('../timer')
const conf = require('../../conf')
const log = require('../log').child({name: 'skyring:server'})
const noop = () => {}

function noop() {}

function isFunction(fn) {
return typeof fn === 'function'
}
Expand Down
3 changes: 2 additions & 1 deletion packages/skyring/lib/timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const storage = Symbol('storage')
const shutdown = Symbol.for('kShutdown')
const kNode = Symbol('nodeid')
const kRemove = Symbol('remove')
const noop = () => {}
const REBALANCE_SUB = 'skyring.rebalance'
const EVENT_STATUS = {
CREATED: 'create'
Expand All @@ -48,6 +47,8 @@ const EVENT_STATUS = {
, EVICT: 'evict'
}

function noop() {}

function generateId(id) {
if (!id) return crypto.randomBytes(10).toString('hex')
return crypto.createHash('sha1').update(id).digest('hex')
Expand Down
2 changes: 1 addition & 1 deletion packages/skyring/lib/transports/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ module.exports = class Transports extends Map {

[kShutdown](cb) {
const keys = Array.from(this.values())
const run = () => {
function run() {
if (!keys.length) return cb()
const transport = keys.pop()
if (typeof transport.shutdown === 'function') {
Expand Down
3 changes: 2 additions & 1 deletion packages/skyring/lib/transports/transport.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

const log = require('../log')
const kType = Symbol.for('SkyringTransport')
const noop = () => {}
const TRANSPORT = 'transport'
function noop() {}

module.exports = class Transport {
constructor(opts) {
Expand All @@ -30,3 +30,4 @@ module.exports = class Transport {
return 'SkyringTransport'
}
}

20 changes: 4 additions & 16 deletions packages/skyring/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"scripts": {
"test": "npm run tap test",
"tap": "tap",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"coverage": "tap --coverage-report=text-lcov | ./node_modules/.bin/codeclimate-test-reporter",
"check": "check-pkg -d !docs -d !node_modules -d !examples -d !.git",
"test:ci": "docker-compose -f compose/test.yml up --exit-code-from node-5 --build",
Expand All @@ -30,20 +32,6 @@
"email": "esatterwhite@wi.rr.com",
"url": "https://github.com/esatterwhite/skyring/issues"
},
"eslintConfig": {
"root": true,
"extends": "eslint-config-codedependant",
"rules": {
"sensible/check-require": 0
},
"parserOptions": {
"ecmaVersion": 2019
},
"ignorePatterns": [
"node_modules/",
"coverage/"
]
},
"dependencies": {
"@esatterwhite/micromock": "^2.0.0",
"@skyring/ringpop": "^11.1.0",
Expand All @@ -65,14 +53,14 @@
"uuid": "^3.2.1"
},
"optionalDependencies": {
"@vendor/test-core": "workspace:^1.0.0"
},
"devDependencies": {
"@vendor/test-core": "workspace:^1.0.0",
"async": "^3.2.0",
"check-pkg": "^2.1.1",
"codeclimate-test-reporter": "^0.5.1",
"eslint": "^7.8.1",
"eslint-config-codedependant": "^1.0.0",
"eslint-config-codedependant": "^2.1.0",
"sinon": "^9.0.2",
"supertest": "^3.1.0",
"tap": "^14.10.8"
Expand Down

0 comments on commit b185cbf

Please sign in to comment.