eslint corrections

This commit is contained in:
Jocelyn Badgley (Twipped) 2021-08-25 08:53:42 -07:00
parent 9f812176b3
commit 2ea8297dd5
11 changed files with 1338 additions and 1242 deletions

View File

@ -24,7 +24,6 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
*/ */
'use strict'; 'use strict';
Object.defineProperty(exports, '__esModule', { value: true }); Object.defineProperty(exports, '__esModule', { value: true });
@ -38,13 +37,13 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
var stream__default = /* #__PURE__*/_interopDefaultLegacy(stream); var stream__default = /* #__PURE__*/_interopDefaultLegacy(stream);
const pipeline = util.promisify(stream__default['default'].pipeline); const pipeline = util.promisify(stream__default.default.pipeline);
const mkdir = (f, recursive = true) => fs.promises.mkdir(f, { const mkdir = (f, recursive = true) => fs.promises.mkdir(f, {
recursive recursive,
}); });
const exists = f => fs.promises.access(f).then(() => true, () => false); const exists = (f) => fs.promises.access(f).then(() => true, () => false);
const stat = f => fs.promises.stat(f).catch(() => null); const stat = (f) => fs.promises.stat(f).catch(() => null);
const linkStat = f => fs.promises.lstat(f).catch(() => null); const linkStat = (f) => fs.promises.lstat(f).catch(() => null);
async function isWritable (file) { async function isWritable (file) {
try { try {
await fs.promises.access(file, fs.constants.F_OK | fs.constants.W_OK); await fs.promises.access(file, fs.constants.F_OK | fs.constants.W_OK);
@ -72,9 +71,11 @@ async function touch(file) {
async function remove (file) { async function remove (file) {
const stats = await linkStat(file); const stats = await linkStat(file);
if (!stats) return; if (!stats) return;
if (stats.isDirectory()) return fs.promises.rmdir(file, { if (stats.isDirectory()) {
recursive: true return fs.promises.rmdir(file, {
recursive: true,
}); });
}
return fs.promises.unlink(file); return fs.promises.unlink(file);
} }
async function writeJson (file, object, options) { async function writeJson (file, object, options) {
@ -84,7 +85,7 @@ async function writeJson(file, object, options) {
...ops ...ops
} = { } = {
encoding: 'utf8', encoding: 'utf8',
...options ...options,
}; };
await fs.promises.writeFile(file, `${JSON.stringify(object, replacer, spaces)}\n`, ops); await fs.promises.writeFile(file, `${JSON.stringify(object, replacer, spaces)}\n`, ops);
} }
@ -96,7 +97,7 @@ async function readJson(file, options) {
...ops ...ops
} = { } = {
encoding: 'utf8', encoding: 'utf8',
...options ...options,
}; };
const content = await fs.promises.readFile(file, ops); const content = await fs.promises.readFile(file, ops);

View File

@ -48,7 +48,7 @@ module.exports = exports = class Manifest {
hash ({ action, input, output, ...task }) { hash ({ action, input, output, ...task }) {
if (!isFunction(action)) { if (!isFunction(action)) {
console.error({ action, input, output }); console.error({ action, input, output }); // eslint-disable-line
throw new Error('Task action is not a task action (function).'); throw new Error('Task action is not a task action (function).');
} }

View File

@ -26,7 +26,6 @@
* Portions of the MIT licensed date-fns library are bundled with this * Portions of the MIT licensed date-fns library are bundled with this
* software. https://github.com/date-fns/date-fns#readme * software. https://github.com/date-fns/date-fns#readme
*/ */
'use strict'; 'use strict';
Object.defineProperty(exports, '__esModule', { value: true }); Object.defineProperty(exports, '__esModule', { value: true });

View File

@ -1,6 +1,6 @@
module.exports = exports = { module.exports = exports = {
extends: "twipped/browser", extends: 'twipped/browser',
env: { es6: true, jquery: true }, env: { es6: true, jquery: true },
rules: { rules: {
'indent': [ 2, 2, { 'indent': [ 2, 2, {
@ -8,20 +8,20 @@ module.exports = exports = {
} ], } ],
'prefer-arrow-callback': 0, 'prefer-arrow-callback': 0,
'object-shorthand': 0, 'object-shorthand': 0,
'node/no-unsupported-features/node-builtins': 0 'node/no-unsupported-features/node-builtins': 0,
}, },
overrides: [ overrides: [
{ {
files: '$*.jsx', files: '$*.jsx',
extends: "twipped/react", extends: 'twipped/react',
rules: { rules: {
'react/jsx-indent': [ 2, 2, { checkAttributes: true } ], 'react/jsx-indent': [ 2, 2, { checkAttributes: true } ],
"react/no-unknown-property": [2, { ignore: ['class'] }], 'react/no-unknown-property': [ 2, { ignore: [ 'class' ] } ],
'node/no-unpublished-import': 0, 'node/no-unpublished-import': 0,
"node/no-missing-import": ["error", { 'node/no-missing-import': [ 'error', {
"allowModules": ["svg", 'react'] 'allowModules': [ 'svg', 'react' ],
}] } ],
} },
} },
] ],
}; };

View File

@ -3,7 +3,8 @@
"version": "1.0.0", "version": "1.0.0",
"description": "Code for construction of the GenderDysphoria.fyi website", "description": "Code for construction of the GenderDysphoria.fyi website",
"scripts": { "scripts": {
"test": "eslint ./ --fix" "test": "eslint 'build/**/*.js' 'js/**/*.{js,jsx}' 'terraform/**/*.js' --fix",
"build": "gulp prod"
}, },
"engines": { "engines": {
"node": ">=12.14.0" "node": ">=12.14.0"

View File

@ -1,5 +1,4 @@
/* eslint no-console:0 */ /* eslint no-console:0 */
/* global URLSearchParams */
const AWS = require('aws-sdk'); const AWS = require('aws-sdk');
const zlib = require('zlib'); const zlib = require('zlib');
@ -56,7 +55,6 @@ exports.handler = async (event) => {
if (!query.start) return null; if (!query.start) return null;
const useragent = parseUA(row.cs_user_agent); const useragent = parseUA(row.cs_user_agent);
const { referer } = query;
const sessionStart = Number(query.start); const sessionStart = Number(query.start);
const sessionEnd = query.end === 'null' ? 0 : Number(query.end); const sessionEnd = query.end === 'null' ? 0 : Number(query.end);

View File

@ -4,6 +4,37 @@
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
"aws-sdk": {
"version": "2.975.0",
"resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.975.0.tgz",
"integrity": "sha512-cmRcM+gU+rfW1RZjca3bdbRTQV6WHuCI6NuqnDgd5HoqufylCrNI/wtysPK1IMJLsAhrcsY0U0YRx+Y/hxQNoQ==",
"requires": {
"buffer": "4.9.2",
"events": "1.1.1",
"ieee754": "1.1.13",
"jmespath": "0.15.0",
"querystring": "0.2.0",
"sax": "1.2.1",
"url": "0.10.3",
"uuid": "3.3.2",
"xml2js": "0.4.19"
}
},
"base64-js": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA=="
},
"buffer": {
"version": "4.9.2",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.2.tgz",
"integrity": "sha512-xq+q3SRMOxGivLhBNaUdC64hDTQwejJ+H0T/NB1XMtTVEwNTrfFF3gAxiyW0Bu/xWEGhjVKgUcMhCrUy2+uCWg==",
"requires": {
"base64-js": "^1.0.2",
"ieee754": "^1.1.4",
"isarray": "^1.0.0"
}
},
"cloudfront-log-parser": { "cloudfront-log-parser": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/cloudfront-log-parser/-/cloudfront-log-parser-1.1.0.tgz", "resolved": "https://registry.npmjs.org/cloudfront-log-parser/-/cloudfront-log-parser-1.1.0.tgz",
@ -14,10 +45,73 @@
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.9.0.tgz", "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.9.0.tgz",
"integrity": "sha512-khbFLu/MlzLjEzy9Gh8oY1hNt/Dvxw3J6Rbc28cVoYWQaC1S3YI4xwkF9ZWcjDLscbZlY9hISMr66RFzZagLsA==" "integrity": "sha512-khbFLu/MlzLjEzy9Gh8oY1hNt/Dvxw3J6Rbc28cVoYWQaC1S3YI4xwkF9ZWcjDLscbZlY9hISMr66RFzZagLsA=="
}, },
"events": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz",
"integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ="
},
"ieee754": {
"version": "1.1.13",
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz",
"integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg=="
},
"isarray": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
},
"jmespath": {
"version": "0.15.0",
"resolved": "https://registry.npmjs.org/jmespath/-/jmespath-0.15.0.tgz",
"integrity": "sha1-o/Iiqarp+Wb10nx5ZRDigJF2Qhc="
},
"punycode": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz",
"integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0="
},
"querystring": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz",
"integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA="
},
"sax": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.1.tgz",
"integrity": "sha1-e45lYZCyKOgaZq6nSEgNgozS03o="
},
"ua-parser-js": { "ua-parser-js": {
"version": "0.7.21", "version": "0.7.21",
"resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.21.tgz", "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.21.tgz",
"integrity": "sha512-+O8/qh/Qj8CgC6eYBVBykMrNtp5Gebn4dlGD/kKXVkJNDwyrAwSIqwz8CDf+tsAIWVycKcku6gIXJ0qwx/ZXaQ==" "integrity": "sha512-+O8/qh/Qj8CgC6eYBVBykMrNtp5Gebn4dlGD/kKXVkJNDwyrAwSIqwz8CDf+tsAIWVycKcku6gIXJ0qwx/ZXaQ=="
},
"url": {
"version": "0.10.3",
"resolved": "https://registry.npmjs.org/url/-/url-0.10.3.tgz",
"integrity": "sha1-Ah5NnHcF8hu/N9A861h2dAJ3TGQ=",
"requires": {
"punycode": "1.3.2",
"querystring": "0.2.0"
}
},
"uuid": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz",
"integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA=="
},
"xml2js": {
"version": "0.4.19",
"resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.19.tgz",
"integrity": "sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==",
"requires": {
"sax": ">=0.6.0",
"xmlbuilder": "~9.0.1"
}
},
"xmlbuilder": {
"version": "9.0.7",
"resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz",
"integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0="
} }
} }
} }

View File

@ -9,6 +9,7 @@
"author": "Jocelyn Badgley <joc@twipped.com> (http://twipped.com/)", "author": "Jocelyn Badgley <joc@twipped.com> (http://twipped.com/)",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"aws-sdk": "~2.975.0",
"cloudfront-log-parser": "~1.1.0", "cloudfront-log-parser": "~1.1.0",
"date-fns": "~2.9.0", "date-fns": "~2.9.0",
"ua-parser-js": "~0.7.21" "ua-parser-js": "~0.7.21"

View File

@ -3,7 +3,7 @@
// This should be deployed as a Lambda@Edge connected to the CloudFront Distribution // This should be deployed as a Lambda@Edge connected to the CloudFront Distribution
// Only Node.js 10.x Runtime supports Lambda@Edge for right now, we have to wait for AWS to support 12x and beyond // Only Node.js 10.x Runtime supports Lambda@Edge for right now, we have to wait for AWS to support 12x and beyond
exports.handler = async (event, context) => { exports.handler = async (event) => {
/* /*
* Expand S3 request to have index.html if it ends in / * Expand S3 request to have index.html if it ends in /
*/ */

View File

@ -1,3 +1,5 @@
/* eslint no-console: 0 */
const { gunzip } = require('zlib'); const { gunzip } = require('zlib');
const { promisify } = require('util'); const { promisify } = require('util');
const { S3 } = require('aws-sdk'); const { S3 } = require('aws-sdk');