Skip to content

Commit

Permalink
Merge pull request #744 from chris--jones/eslint-config
Browse files Browse the repository at this point in the history
Eslint config - replace common-style with eslint-config-populist
  • Loading branch information
thornjad committed Oct 15, 2021
2 parents 96aa6e9 + e0dec9d commit 6a360ab
Show file tree
Hide file tree
Showing 6 changed files with 3,754 additions and 6,124 deletions.
11 changes: 11 additions & 0 deletions .eslintrc.json
@@ -0,0 +1,11 @@
{
"extends": "eslint-config-populist",
"rules": {
"strict": "warn",
"indent": ["warn", 2],
"valid-jsdoc": "warn",
"no-undefined": "warn",
"comma-dangle": "warn",
"callback-return": ["warn", ["next"]]
}
}
1 change: 0 additions & 1 deletion lib/core/index.js
Expand Up @@ -228,7 +228,6 @@ module.exports = function createMiddleware(_dir, _options) {
// and brotli special case.
const defaultType = opts.contentType || 'application/octet-stream';
let contentType = mime.lookup(file, defaultType);
let charSet;
const range = (req.headers && req.headers.range);
const lastModified = (new Date(stat.mtime)).toUTCString();
const etag = generateEtag(stat, weakEtags);
Expand Down
8 changes: 4 additions & 4 deletions lib/core/show-dir/last-modified-to-string.js
Expand Up @@ -2,9 +2,9 @@

module.exports = function lastModifiedToString(stat) {
const t = new Date(stat.mtime);
return (("0" + (t.getDate())).slice(-2) + '-' +
t.toLocaleString('default', { month: 'short' }) + '-' +
return (('0' + (t.getDate())).slice(-2) + '-' +
t.toLocaleString('default', { month: 'short' }) + '-' +
t.getFullYear() + ' ' +
("0" + t.getHours()).slice(-2) + ':' +
("0" + t.getMinutes()).slice(-2));
('0' + t.getHours()).slice(-2) + ':' +
('0' + t.getMinutes()).slice(-2));
};
26 changes: 13 additions & 13 deletions lib/http-server.js
@@ -1,13 +1,12 @@
'use strict';

var fs = require('fs'),
union = require('union'),
httpServerCore = require('./core'),
auth = require('basic-auth'),
httpProxy = require('http-proxy'),
corser = require('corser'),
path = require('path'),
secureCompare = require('secure-compare');
union = require('union'),
httpServerCore = require('./core'),
auth = require('basic-auth'),
httpProxy = require('http-proxy'),
corser = require('corser'),
secureCompare = require('secure-compare');

//
// Remark: backwards compatibility for previous
Expand Down Expand Up @@ -35,10 +34,10 @@ function HttpServer(options) {
this.root = options.root;
} else {
try {
// eslint-disable-next-line no-sync
fs.lstatSync('./public');
this.root = './public';
}
catch (err) {
} catch (err) {
this.root = './';
}
}
Expand All @@ -47,11 +46,12 @@ function HttpServer(options) {
this.headers['Accept-Ranges'] = 'bytes';

this.cache = (
// eslint-disable-next-line no-nested-ternary
options.cache === undefined ? 3600 :
// -1 is a special case to turn off caching.
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#Preventing_caching
options.cache === -1 ? 'no-cache, no-store, must-revalidate' :
options.cache // in seconds.
options.cache === -1 ? 'no-cache, no-store, must-revalidate' :
options.cache // in seconds.
);
this.showDir = options.showDir !== 'false';
this.autoIndex = options.autoIndex !== 'false';
Expand Down Expand Up @@ -103,7 +103,7 @@ function HttpServer(options) {
this.headers['Access-Control-Allow-Headers'] = 'Origin, X-Requested-With, Content-Type, Accept, Range';
if (options.corsHeaders) {
options.corsHeaders.split(/\s*,\s*/)
.forEach(function (h) { this.headers['Access-Control-Allow-Headers'] += ', ' + h; }, this);
.forEach(function (h) { this.headers['Access-Control-Allow-Headers'] += ', ' + h; }, this);
}
before.push(corser.create(options.corsHeaders ? {
requestHeaders: this.headers['Access-Control-Allow-Headers'].split(/\s*,\s*/)
Expand Down Expand Up @@ -146,7 +146,7 @@ function HttpServer(options) {
proxy.web(req, res, {
target: options.proxy,
changeOrigin: true
}, function (err, req, res, target) {
}, function (err, req, res) {
if (options.logFn) {
options.logFn(req, res, {
message: err.message,
Expand Down

0 comments on commit 6a360ab

Please sign in to comment.