Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Introduce lint rules from fork #371

Merged
merged 4 commits into from
Jan 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 22 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,34 @@
"node": true,
"mocha": true
},
"extends": ["eslint:recommended", "prettier"],
"plugins": ["prettier"],
"extends": ["eslint:recommended", "prettier", "plugin:unicorn/recommended"],
"rules": {
"prettier/prettier": "error",
"no-console": "error",
"curly": ["error", "all"],
"prefer-arrow-callback": "error",
"one-var": ["error", "never"],
"no-var": "error",
"prefer-const": "error"
"prefer-const": "error",
"object-shorthand": "error",
"prefer-destructuring": [
"error",
{
"object": true,
"array": false
}
],
"prefer-template": "error",

"unicorn/no-null": "off",
"unicorn/prevent-abbreviations": "off",
"unicorn/prefer-string-slice": "off",
"unicorn/prefer-code-point": "off",
"unicorn/no-array-push-push": "off",
"unicorn/no-array-reduce": "off",
"unicorn/no-for-loop": "off",
"unicorn/consistent-destructuring": "off",
"unicorn/prefer-switch": ["error", { "emptyDefaultCase": "do-nothing-comment" }],
"unicorn/number-literal-case": "off"
},
"parserOptions": {
"sourceType": "module"
Expand Down
2 changes: 1 addition & 1 deletion bench/memory/named-entity-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ async function main() {

const after = process.memoryUsage().rss;

console.log('Initial memory consumption: ', format(after - before, { unit: 'B' }));
console.log('Initial memory consumption:', format(after - before, { unit: 'B' }));
}
12 changes: 6 additions & 6 deletions bench/memory/sax-parser.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as fs from 'fs';
import * as fs from 'node:fs';
import format from 'human-format';
import promisifyEvent from 'promisify-event';
import memwatch from '@airbnb/node-memwatch';
Expand Down Expand Up @@ -58,13 +58,13 @@ function getDuration(startDate, endDate) {
hours: 3600,
});

return format((endDate - startDate) / 1000, { scale: scale });
return format((endDate - startDate) / 1000, { scale });
}

function printResults(parsedDataSize, startDate, endDate, heapDiff, maxMemUsage) {
console.log('Input data size:', format(parsedDataSize, { unit: 'B' }));
console.log('Duration: ', getDuration(startDate, endDate));
console.log('Memory before: ', heapDiff.before.size);
console.log('Memory after: ', heapDiff.after.size);
console.log('Memory max: ', format(maxMemUsage, { unit: 'B' }));
console.log('Duration:', getDuration(startDate, endDate));
console.log('Memory before:', heapDiff.before.size);
console.log('Memory after:', heapDiff.after.size);
console.log('Memory max:', format(maxMemUsage, { unit: 'B' }));
}
6 changes: 3 additions & 3 deletions bench/perf/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { readFileSync, createReadStream, readdirSync } from 'fs';
import { readFileSync, createReadStream, readdirSync } from 'node:fs';
import Benchmark from 'benchmark';
import { loadTreeConstructionTestData } from '../../test/utils/generate-parsing-tests.js';
import { loadSAXParserTestData } from '../../test/utils/load-sax-parser-test-data.js';
Expand Down Expand Up @@ -53,12 +53,12 @@ global.runPages = function (parser) {

// Stream data
global.files = readdirSync(saxPath).map((dirName) => {
return new URL(`./${dirName}/src.html`, saxPath).pathname;
return new URL(`${dirName}/src.html`, saxPath).pathname;
});

// Utils
function getHz(suite, testName) {
return suite.filter((t) => t.name === testName)[0].hz;
return suite.find((t) => t.name === testName).hz;
}

function runBench({ name, workingCopyFn, upstreamFn, defer = false }) {
Expand Down