Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
[Dev Deps] update chai, eslint, eslint-config-airbnb-base, `esl…
Browse files Browse the repository at this point in the history
…int-plugin-import`, `in-publish`, `safe-publish-latest`
  • Loading branch information
ljharb committed Apr 26, 2022
1 parent 0971f5d commit e96965c
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 51 deletions.
26 changes: 24 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,34 @@
"root": true,
"extends": "airbnb-base",
"env": {
"node": true
"node": true,
},

"rules": {
"function-paren-newline": 0,
"no-console": 0,
"no-underscore-dangle": 1,
"object-curly-newline": 0,
}
"max-len": 0,
},

"overrides": [
{
"files": "test/**/*",
"env": {
"mocha": true,
},
"rules": {
"indent": 1,
"prefer-promise-reject-errors": 0,
},
},
{
"files": "test/components/**/*",
"rules": {
"object-shorthand": 0,
"func-names": 0,
},
},
],
}
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"description": "A service for server-side rendering your JavaScript views",
"main": "lib/index.js",
"scripts": {
"prepublish": "not-in-publish || safe-publish-latest && npm run build",
"prepublishOnly": "safe-publish-latest && npm run build",
"prepublish": "not-in-publish || npm run prepublishOnly",
"clean": "rimraf lib",
"prebuild": "npm run clean",
"build": "babel src -d lib",
Expand Down Expand Up @@ -50,17 +51,17 @@
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-transform-replace-object-assign": "^1.0.0",
"babel-preset-airbnb": "^2.5.3",
"chai": "^4.2.0",
"cheerio": "^1.0.0-rc.3",
"eslint": "^5.16.0",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-import": "^2.17.3",
"in-publish": "^2.0.0",
"chai": "^4.3.6",
"cheerio": "=1.0.0-rc.3",
"eslint": "^8.14.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.26.0",
"in-publish": "^2.0.1",
"istanbul": "^1.0.0-alpha.2",
"mocha": "^3.5.3",
"mocha-wrap": "^2.1.2",
"rimraf": "^2.6.3",
"safe-publish-latest": "^1.1.2",
"safe-publish-latest": "^2.0.0",
"sinon": "^3.3.0",
"sinon-sandbox": "^1.0.2"
},
Expand Down
2 changes: 1 addition & 1 deletion src/Module.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Module {
function require(filePath) {
return self.require(filePath);
}
require.resolve = request => NativeModule._resolveFilename(request, this);
require.resolve = (request) => NativeModule._resolveFilename(request, this);
require.main = process.mainModule;
require.extensions = moduleExtensions;
require.cache = this.cache;
Expand Down
10 changes: 5 additions & 5 deletions src/coordinator.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function close() {
}

function kill(signal) {
const liveWorkers = Object.values(cluster.workers).filter(worker => !worker.isDead());
const liveWorkers = Object.values(cluster.workers).filter((worker) => !worker.isDead());

if (liveWorkers.length > 0) {
logger.info(`Coordinator killing ${liveWorkers.length} live workers with ${signal}`);
Expand Down Expand Up @@ -74,7 +74,7 @@ function shutdown() {
function workersReady(workerCount) {
const workers = Object.values(cluster.workers);

return workers.length === workerCount && workers.every(worker => worker.isReady);
return workers.length === workerCount && workers.every((worker) => worker.isReady);
}

export default (getCPUs) => {
Expand All @@ -87,11 +87,11 @@ export default (getCPUs) => {
}

if (workersReady(workerCount)) {
Object.values(cluster.workers).forEach(worker => worker.send('healthy'));
Object.values(cluster.workers).forEach((worker) => worker.send('healthy'));
}
}

cluster.on('online', worker => logger.info(`Worker #${worker.id} is now online`));
cluster.on('online', (worker) => logger.info(`Worker #${worker.id} is now online`));

cluster.on('listening', (worker, address) => {
logger.info(`Worker #${worker.id} is now connected to ${address.address}:${address.port}`);
Expand Down Expand Up @@ -128,5 +128,5 @@ export default (getCPUs) => {

Array.from({ length: workerCount }, () => cluster.fork());

Object.values(cluster.workers).forEach(worker => worker.on('message', onWorkerMessage));
Object.values(cluster.workers).forEach((worker) => worker.on('message', onWorkerMessage));
};
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const DATA_ID = 'hypernova-id';
function uuid() {
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(
/[018]/g,
x => (x ^ Math.random() * 16 >> x / 4).toString(16), // eslint-disable-line no-mixed-operators, no-bitwise, max-len
(x) => (x ^ Math.random() * 16 >> x / 4).toString(16), // eslint-disable-line no-mixed-operators, no-bitwise, max-len
);
}

Expand All @@ -42,13 +42,13 @@ function makeValidDataAttribute(attr, value) {
}

function toScript(attrs, data) {
const dataAttributes = Object.keys(attrs).map(name => makeValidDataAttribute(name, attrs[name]));
const dataAttributes = Object.keys(attrs).map((name) => makeValidDataAttribute(name, attrs[name]));
return `<script type="application/json" ${dataAttributes.join(' ')}>${LEFT}${encode(data)}${RIGHT}</script>`; // eslint-disable-line max-len
}

function fromScript(attrs) {
const selectors = Object.keys(attrs)
.map(name => `[${makeValidDataAttribute(name, attrs[name])}]`)
.map((name) => `[${makeValidDataAttribute(name, attrs[name])}]`)
.join('');
const node = document.querySelector(`script${selectors}`);
if (!node) return null;
Expand Down
1 change: 0 additions & 1 deletion src/utils/BatchManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ class BatchManager {
return obj;
}, {});


// Each plugin receives it's own little key-value data store that is scoped privately
// to the plugin for the life time of the request. This is achieved simply through lexical
// closure.
Expand Down
12 changes: 6 additions & 6 deletions src/utils/lifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const PROMISE_TIMEOUT = {};
* @returns {Function} - the resulting predicate function
*/
export function hasMethod(name) {
return obj => typeof obj[name] === 'function';
return (obj) => typeof obj[name] === 'function';
}

/**
Expand Down Expand Up @@ -62,7 +62,7 @@ export function raceTo(promise, ms, msg) {
export function runAppLifecycle(lifecycle, plugins, config, error, ...args) {
try {
const promise = Promise.all(
plugins.filter(hasMethod(lifecycle)).map(plugin => plugin[lifecycle](config, error, ...args)),
plugins.filter(hasMethod(lifecycle)).map((plugin) => plugin[lifecycle](config, error, ...args)),
);

return raceTo(
Expand Down Expand Up @@ -97,7 +97,7 @@ export function runLifecycle(lifecycle, plugins, manager, token) {
const promise = Promise.all(
plugins
.filter(hasMethod(lifecycle))
.map(plugin => plugin[lifecycle](manager.contextFor(plugin, token))),
.map((plugin) => plugin[lifecycle](manager.contextFor(plugin, token))),
);

return raceTo(
Expand All @@ -124,7 +124,7 @@ export function runLifecycle(lifecycle, plugins, manager, token) {
export function runLifecycleSync(lifecycle, plugins, manager, token) {
plugins
.filter(hasMethod(lifecycle))
.forEach(plugin => plugin[lifecycle](manager.contextFor(plugin, token)));
.forEach((plugin) => plugin[lifecycle](manager.contextFor(plugin, token)));
}

/**
Expand All @@ -141,7 +141,7 @@ export function runLifecycleSync(lifecycle, plugins, manager, token) {
export function errorSync(err, plugins, manager, token) {
plugins
.filter(hasMethod('onError'))
.forEach(plugin => plugin.onError(manager.contextFor(plugin, token), err));
.forEach((plugin) => plugin.onError(manager.contextFor(plugin, token), err));
}

/**
Expand Down Expand Up @@ -190,7 +190,7 @@ function processJobsSerially(jobs, plugins, manager) {

function processJobsConcurrently(jobs, plugins, manager) {
return Promise.all(
Object.keys(jobs).map(token => processJob(token, plugins, manager)),
Object.keys(jobs).map((token) => processJob(token, plugins, manager)),
);
}

Expand Down
9 changes: 0 additions & 9 deletions test/.eslintrc

This file was deleted.

4 changes: 2 additions & 2 deletions test/client-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function cheerioToDOM($, className) {
const node = cheerioObj;
node.nodeName = node.name.toUpperCase();
node.innerHTML = $(node).html();
node.getAttribute = attr => $(node).data(attr.replace('data-', ''));
node.getAttribute = (attr) => $(node).data(attr.replace('data-', ''));
return node;
})[0];
}
Expand All @@ -31,7 +31,7 @@ wrap().withGlobal('document', () => ({}))
spy(className);
return cheerioToDOM($, className);
};
global.document.querySelectorAll = classname => [cheerioToDOM($, classname)];
global.document.querySelectorAll = (classname) => [cheerioToDOM($, classname)];

// Calling it again for the client.
load('Component3');
Expand Down
6 changes: 0 additions & 6 deletions test/components/.eslintrc

This file was deleted.

2 changes: 1 addition & 1 deletion test/components/HypernovaExample.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const hypernova = require('../../');
const hypernova = require('../..');

module.exports = hypernova({
server: function () {},
Expand Down
2 changes: 1 addition & 1 deletion test/components/nested/component.bundle.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const hypernova = require('../../../');
const hypernova = require('../../..');

module.exports = hypernova({
server() {},
Expand Down
2 changes: 2 additions & 0 deletions test/renderBatch-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { assert } from 'chai';
import renderBatch from '../lib/utils/renderBatch';

/* eslint max-classes-per-file: 1 */

class Response {
status(status) {
this._status = status;
Expand Down
12 changes: 6 additions & 6 deletions test/server-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ describe('Hypernova server', () => {
beforeEach(() => {
try {
[
'../lib/utils/logger.js',
'../lib/worker.js',
'../lib/server.js',
'../server.js',
].forEach(module => delete require.cache[require.resolve(module)]);
'../lib/utils/logger',
'../lib/worker',
'../lib/server',
'../server',
].forEach((module) => delete require.cache[require.resolve(module)]);

hypernova = require('../server.js'); // eslint-disable-line global-require
hypernova = require('../server'); // eslint-disable-line global-require
} catch (e) {
console.error('Couldnt remove dependecy or load the hypernova module.');
}
Expand Down

0 comments on commit e96965c

Please sign in to comment.