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: upgraded code to es6 standard #427

Merged
merged 14 commits into from May 2, 2020
66 changes: 9 additions & 57 deletions .eslintrc.json
Expand Up @@ -7,65 +7,17 @@
"jest": true,
"node": true
},
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
"plugins": ["node", "standard"],
"extends": [
"eslint:recommended",
"standard",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we decide to go for a standard eslint preset, I think we should try to get rid of as many custom rules as possible. I would be all in for that!

How did you decide which custom rules to keep and which to drop? Are there maybe more rules we can drop?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll see what rules can be safely removed.

"prettier",
"prettier/standard",
"plugin:prettier/recommended"
awwit marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"extends": ["plugin:prettier/recommended"] already takes care of loading the prettier eslint plugin, so it should not be necessary to specify it again in the plugins array, see: https://prettier.io/docs/en/integrating-with-linters.html#recommended-configuration

],
"globals": {
"msCrypto": true
},
"parser": "babel-eslint",
"rules": {
"array-bracket-spacing": ["warn", "never"],
"arrow-body-style": ["warn", "as-needed"],
"arrow-spacing": "warn",
"brace-style": ["warn", "1tbs"],
"camelcase": "warn",
"comma-spacing": [
"warn",
{
"after": true
}
],
"dot-notation": "warn",
"eqeqeq": ["warn", "smart"],
"indent": [
"warn",
2,
{
"SwitchCase": 1,
"FunctionDeclaration": {
"parameters": 1
},
"MemberExpression": 1,
"CallExpression": {
"arguments": 1
}
}
],
"key-spacing": [
"warn",
{
"beforeColon": false,
"afterColon": true,
"mode": "minimum"
}
],
"keyword-spacing": "warn",
"no-console": "off",
"no-empty": "off",
"no-multi-spaces": "warn",
"no-redeclare": "off",
"no-restricted-globals": ["warn", "Promise"],
"no-trailing-spaces": "warn",
"no-undef": "error",
"no-unused-vars": [
"warn",
{
"args": "none"
}
],
"one-var": ["warn", "never"],
"padded-blocks": ["warn", "never"],
"react/prop-types": "off",
"react/jsx-no-bind": "off",
"semi": ["warn", "always"]
}
"rules": {}
}
2 changes: 1 addition & 1 deletion README_js.md
Expand Up @@ -5,7 +5,7 @@ runmd.onRequire = (path) => {
};

// Shim Date and crypto so generated ids are consistent across doc revisions
runmd.Date.prototype.getTime = () => 1551914748172;
runmd.Date.now = () => 1551914748172;

let seed = 0xdefaced;
require('crypto').randomBytes = function () {
Expand Down
13 changes: 10 additions & 3 deletions examples/benchmark/benchmark.js
@@ -1,3 +1,4 @@
// eslint-disable-next-line no-unused-vars
/* global Benchmark:false, uuidv1:false, uuidv3:false, uuidv4:false, uuidv5:false */
const Benchmark = (typeof window !== 'undefined' && window.Benchmark) || require('benchmark');
const uuidv1 = (typeof window !== 'undefined' && window.uuidv1) || require('uuid').v1;
Expand All @@ -8,7 +9,13 @@ const uuidv5 = (typeof window !== 'undefined' && window.uuidv5) || require('uuid
console.log('Starting. Tests take ~1 minute to run ...');

const array = new Array(16);
const suite = new Benchmark.Suite();

const suite = new Benchmark.Suite({
onError(event) {
console.error(event.target.error);
},
});

suite
.add('uuidv1()', function () {
uuidv1();
Expand All @@ -29,9 +36,9 @@ suite
uuidv5('hello.example.com', uuidv5.DNS);
})
.on('cycle', function (event) {
console.log(String(event.target));
console.log(event.target.toString());
})
.on('complete', function () {
console.log('Fastest is ' + this.filter('fastest').map('name'));
console.log('Fastest is', this.filter('fastest').map('name'));
})
.run();