Skip to content

Commit

Permalink
refactor: Introduce lint rules from fork (#371)
Browse files Browse the repository at this point in the history
  • Loading branch information
fb55 committed Jan 7, 2022
1 parent 85a6154 commit 8e8e936
Show file tree
Hide file tree
Showing 54 changed files with 2,784 additions and 1,437 deletions.
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

0 comments on commit 8e8e936

Please sign in to comment.