Skip to content

Commit

Permalink
copy standard deviations ;) from main eslint config
Browse files Browse the repository at this point in the history
  • Loading branch information
UziTech committed May 4, 2019
1 parent 1a1dd43 commit 30adf16
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 19 deletions.
20 changes: 20 additions & 0 deletions test/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,26 @@
],
"rules": {
"semi": ["error", "always"],
"indent": ["error", 2, {
"SwitchCase": 1,
"VariableDeclarator": { "var": 2 },
"outerIIFEBody": 0,
"MemberExpression": 1,
"FunctionDeclaration": { "parameters": 1, "body": 1 },
"FunctionExpression": { "parameters": 1, "body": 1 },
"CallExpression": { "arguments": 1 },
"ArrayExpression": 1,
"ObjectExpression": 1,
"ImportDeclaration": 1,
"flatTernaryExpressions": false,
"ignoreComments": false
}],
"operator-linebreak": ["error", "before", { "overrides": { "=": "after" } }],
"space-before-function-paren": ["error", "never"],
"no-cond-assign": "off",
"no-useless-escape": "off",
"one-var": "off",
"no-control-regex": "off",
"prefer-const": "error",
"no-var": "error"
},
Expand Down
20 changes: 10 additions & 10 deletions test/bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let marked = require('../');
/**
* Load specs
*/
function load () {
function load() {
const dir = path.resolve(__dirname, './specs/commonmark');
const sections = loadFiles(dir);
let specs = [];
Expand All @@ -22,7 +22,7 @@ function load () {
/**
* Run all benchmarks
*/
function runBench (options) {
function runBench(options) {
options = options || {};
const specs = load();

Expand Down Expand Up @@ -73,7 +73,7 @@ function runBench (options) {
const commonmark = require('commonmark');
const parser = new commonmark.Parser();
const writer = new commonmark.HtmlRenderer();
return function (text) {
return function(text) {
return writer.render(parser.parse(text));
};
})());
Expand Down Expand Up @@ -101,7 +101,7 @@ function runBench (options) {
}
}

function bench (name, specs, engine) {
function bench(name, specs, engine) {
const before = process.hrtime();
for (let i = 0; i < 1e3; i++) {
for (const spec of specs) {
Expand All @@ -127,7 +127,7 @@ function bench (name, specs, engine) {
/**
* A simple one-time benchmark
*/
function time (options) {
function time(options) {
options = options || {};
const specs = load();
if (options.marked) {
Expand All @@ -139,13 +139,13 @@ function time (options) {
/**
* Argument Parsing
*/
function parseArg (argv) {
function parseArg(argv) {
argv = argv.slice(2);

const options = {};
const orphans = [];

function getarg () {
function getarg() {
let arg = argv.shift();

if (arg.indexOf('--') === 0) {
Expand Down Expand Up @@ -222,14 +222,14 @@ function parseArg (argv) {
/**
* Helpers
*/
function camelize (text) {
function camelize(text) {
return text.replace(/(\w)-(\w)/g, (_, a, b) => a + b.toUpperCase());
}

/**
* Main
*/
function main (argv) {
function main(argv) {
const opt = parseArg(argv);

if (opt.minified) {
Expand All @@ -246,7 +246,7 @@ function main (argv) {
/**
* returns time to millisecond granularity
*/
function prettyElapsedTime (hrtimeElapsed) {
function prettyElapsedTime(hrtimeElapsed) {
const seconds = hrtimeElapsed[0];
const frac = Math.round(hrtimeElapsed[1] / 1e3) / 1e3;
return seconds * 1e3 + frac;
Expand Down
10 changes: 5 additions & 5 deletions test/helpers/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ const fs = require('fs');
const path = require('path');
const fm = require('front-matter');

function node4Polyfills () {
function node4Polyfills() {
// https://github.com/uxitten/polyfill/blob/master/string.polyfill.js
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd
if (!String.prototype.padEnd) {
// eslint-disable-next-line no-extend-native
String.prototype.padEnd = function padEnd (targetLength, padString) {
String.prototype.padEnd = function padEnd(targetLength, padString) {
targetLength = targetLength >> 0; // floor if number or convert non-number to 0;
padString = String((typeof padString !== 'undefined' ? padString : ' '));
if (this.length > targetLength) {
Expand All @@ -28,7 +28,7 @@ function node4Polyfills () {
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart
if (!String.prototype.padStart) {
// eslint-disable-next-line no-extend-native
String.prototype.padStart = function padStart (targetLength, padString) {
String.prototype.padStart = function padStart(targetLength, padString) {
targetLength = targetLength >> 0; // truncate if number, or convert non-number to 0;
padString = String(typeof padString !== 'undefined' ? padString : ' ');
if (this.length >= targetLength) {
Expand All @@ -45,7 +45,7 @@ function node4Polyfills () {
}
node4Polyfills();

function outputCompletionTable (title, specs) {
function outputCompletionTable(title, specs) {
let longestName = 0;
let maxSpecs = 0;

Expand All @@ -67,7 +67,7 @@ function outputCompletionTable (title, specs) {
console.log();
}

function loadFiles (dir) {
function loadFiles(dir) {
const files = fs.readdirSync(dir);

return files.reduce((obj, file) => {
Expand Down
2 changes: 1 addition & 1 deletion test/specs/run-spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const path = require('path');
const load = require('../helpers/load.js');

function runSpecs (title, dir, showCompletionTable, options) {
function runSpecs(title, dir, showCompletionTable, options) {
options = options || {};
const specs = load.loadFiles(path.resolve(__dirname, dir));

Expand Down
6 changes: 3 additions & 3 deletions test/update-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ const htmlDiffer = require('./helpers/html-differ.js');
const fs = require('fs');
const path = require('path');

function removeFiles (dir) {
function removeFiles(dir) {
fs.readdirSync(dir).forEach(file => {
fs.unlinkSync(path.join(dir, file));
});
}

function updateCommonmark (dir) {
function updateCommonmark(dir) {
return fetch('https://raw.githubusercontent.com/commonmark/commonmark.js/master/package.json')
.then(res => res.json())
.then(pkg => pkg.version.replace(/^(\d+\.\d+).*$/, '$1'))
Expand All @@ -35,7 +35,7 @@ function updateCommonmark (dir) {
});
}

function updateGfm (dir) {
function updateGfm(dir) {
return fetch('https://github.github.com/gfm/')
.then(res => res.text())
.then(html => cheerio.load(html))
Expand Down

0 comments on commit 30adf16

Please sign in to comment.