copy standard deviations ;) from main eslint config
This commit is contained in:
parent
1a1dd43ab1
commit
30adf160c2
20
test/.eslintrc.json
vendored
20
test/.eslintrc.json
vendored
@ -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"
|
||||
},
|
||||
|
20
test/bench.js
vendored
20
test/bench.js
vendored
@ -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 = [];
|
||||
@ -22,7 +22,7 @@ function load () {
|
||||
/**
|
||||
* Run all benchmarks
|
||||
*/
|
||||
function runBench (options) {
|
||||
function runBench(options) {
|
||||
options = options || {};
|
||||
const specs = load();
|
||||
|
||||
@ -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));
|
||||
};
|
||||
})());
|
||||
@ -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) {
|
||||
@ -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) {
|
||||
@ -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) {
|
||||
@ -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) {
|
||||
@ -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;
|
||||
|
@ -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) {
|
||||
@ -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) {
|
||||
@ -45,7 +45,7 @@ function node4Polyfills () {
|
||||
}
|
||||
node4Polyfills();
|
||||
|
||||
function outputCompletionTable (title, specs) {
|
||||
function outputCompletionTable(title, specs) {
|
||||
let longestName = 0;
|
||||
let maxSpecs = 0;
|
||||
|
||||
@ -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) => {
|
||||
|
@ -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));
|
||||
|
||||
|
6
test/update-specs.js
vendored
6
test/update-specs.js
vendored
@ -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'))
|
||||
@ -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))
|
||||
|
Loading…
x
Reference in New Issue
Block a user