Skip to content

Commit

Permalink
Update eslintrc for Node >=8, and remove support for node 4 and 6. Ad…
Browse files Browse the repository at this point in the history
…d 'engines'.
  • Loading branch information
Mike McNeil (mikermcneil, vn0ijxw) committed Aug 10, 2019
1 parent 5a1dbe8 commit 348d8ed
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 29 deletions.
17 changes: 9 additions & 8 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// ╔═╗╔═╗╦ ╦╔╗╔╔╦╗┬─┐┌─┐
// ║╣ ╚═╗║ ║║║║ ║ ├┬┘│
// o╚═╝╚═╝╩═╝╩╝╚╝ ╩ ┴└─└─┘
// A set of basic conventions (similar to .jshintrc) for use within any
// arbitrary JavaScript / Node.js package -- inside or outside Sails.js.
// For the master copy of this file, see the `.eslintrc` template file in
// the `sails-generate` package (https://www.npmjs.com/package/sails-generate.)
// A set of basic conventions for use within any arbitrary Node.js package --
// inside or outside the Sails framework. For the master copy of this file,
// see the `.eslintrc` template file in the `sails-generate` package
// (https://www.npmjs.com/package/sails-generate.)
// Designed for ESLint v4.
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// For more information about any of the rules below, check out the relevant
Expand All @@ -19,8 +19,7 @@
},

"parserOptions": {
"ecmaVersion": 5
// ^^This can be changed to `8` if this package doesn't need to support <= Node v6.
"ecmaVersion": 8
},

"globals": {
Expand All @@ -29,10 +28,11 @@
},

"rules": {
"block-scoped-var": ["error"],
"callback-return": ["error", ["done", "proceed", "next", "onwards", "callback", "cb"]],
"camelcase": ["warn", {"properties": "always"}],
"comma-style": ["warn", "last"],
"curly": ["error"],
"curly": ["warn"],
"eqeqeq": ["error", "always"],
"eol-last": ["warn"],
"handle-callback-err": ["error"],
Expand Down Expand Up @@ -62,8 +62,9 @@
"no-unused-vars": ["warn", {"caughtErrors":"all", "caughtErrorsIgnorePattern": "^unused($|[A-Z].*$)", "argsIgnorePattern": "^unused($|[A-Z].*$)", "varsIgnorePattern": "^unused($|[A-Z].*$)" }],
"no-use-before-define": ["error", {"functions":false}],
"one-var": ["warn", "never"],
"prefer-arrow-callback": ["warn", {"allowNamedFunctions":false}],
"quotes": ["warn", "single", {"avoidEscape":false, "allowTemplateLiterals":true}],
"semi": ["error", "always"],
"semi": ["warn", "always"],
"semi-spacing": ["warn", {"before":false, "after":true}],
"semi-style": ["warn", "last"]
}
Expand Down
37 changes: 22 additions & 15 deletions lib/parley.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ module.exports = function parley(handleExec, explicitCbMaybe, customMethods, tim
// If appropriate, start the 15 second .exec() countdown.
var EXEC_COUNTDOWN_IN_SECONDS = 15;
if (IS_DEBUG_OR_NON_PRODUCTION_ENV) {
π._execCountdown = setTimeout(function(){
π._execCountdown = setTimeout(()=>{
// IWMIH, it means that this Deferred hasn't begun executing,
// even after 15 seconds. This deserves a warning log.
// > See https://trello.com/c/7QnQZ6aC for more background.
Expand Down Expand Up @@ -350,42 +350,49 @@ module.exports = function parley(handleExec, explicitCbMaybe, customMethods, tim
};//ƒ



// FUTURE: finish this:
//
// /**
// * parley.callable()
// *
// * Build a simple function which returns a Deferred object.
// * > This is a shortcut for building simple functions when you don't need the
// * > full customizability of calling parley() to build a Deferred for you on the
// * > fly (e.g. b/c you don't care about support chain-ability)
// * > fly (e.g. b/c as an implementor, you don't care about having custom
// * > chainable methods)
// *
// * CURRENTLY EXPERIMENTAL!
// * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// * @param {AsyncFunction} gracefullyHandleExec
// * @param {Number?} timeout
// * @param {Error?} omen
// *
// * @returns {Function}
// */
// module.exports.callable = function(gracefullyHandleExec, timeout, omen){

// console.warn('WARNING: parley.callable() is currently experimental and should not be relied upon.');
// module.exports.callable = function(gracefullyHandleExec, timeoutMaybe, omenMaybe){

// if (!_.isFunction(gracefullyHandleExec) || gracefullyHandleExec.constructor.name !== 'AsyncFunction') {
// throw new Error('parley.callable() expects an async function (e.g. `async ()=>{}`) to be provided as the first argument. Instead, got: '+require('util').inspect(gracefullyHandleExec));
// throw new Error('parley.callable() expects an async function (e.g. `async ()=>{}`) to be provided as the first argument. Instead, got: '+util.inspect(gracefullyHandleExec, {depth:5}));
// }//•

// return function handleCalling(/*…*/) {
// // ^Note that this function is _deliberately_ NOT an arrow function, so that
// // we can use `this` and `arguments` to simulate gracefullyHandleExec being
// // called exactly as-is. (In most cases, this should not matter. But
// // packages are sometimes used in mysterious, eclectic ways.)
// //
// // Also note that we name this function (handleCalling) so that we can
// // reference it below when we build an omen.

// var parley = module.exports;
// var returnedFnArguments = arguments;
// var returnedFnCtx = this;//« should really never matter, we just do it this way for consistency
// var newCallableFnArguments = arguments;
// var newCallableFnCtx = this;//« should really never matter, we just do it this way for consistency
// omen = omen || flaverr.omen(handleCalling);
// return parley(function(done) {
// gracefullyHandleExec.apply(returnedFnCtx, returnedFnArguments)
// .then(function(result) {
// done(undefined, result);
// return parley((done)=>{
// gracefullyHandleExec.apply(newCallableFnCtx, newCallableFnArguments)
// .then((resultMaybe)=>{
// done(undefined, resultMaybe);
// })
// .catch(function(err) {
// .catch((err)=>{
// done(err);
// });
// }, undefined, undefined, timeout, omen, undefined);
Expand Down
12 changes: 6 additions & 6 deletions lib/private/Deferred.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ Deferred.prototype.exec = function(_cb, handleUncaughtException){
// > Also note that we include a worst-case-scenario spinlock here (but it should never fire!)
var timeoutAlarm;
if (self._timeout && self._timeout > 0) {
timeoutAlarm = setTimeout(function(){
timeoutAlarm = setTimeout(()=>{
if (self._hasFinishedExecuting) {
console.warn(
'WARNING: Consistency violation: Trying to trigger timeout, but execution has\n'+
Expand Down Expand Up @@ -589,7 +589,7 @@ Deferred.prototype.now = function () {
var isFinishedExecuting;
var immediateResult;
var immediateError;
this.exec(function (err, result){
this.exec((err, result)=>{
isFinishedExecuting = true;
immediateError = err;
immediateResult = result;
Expand Down Expand Up @@ -649,7 +649,7 @@ Deferred.prototype.log = function (){
console.log('Running with `.log()`...');
}

this.exec(function(err, result) {
this.exec((err, result)=>{
if (err) {
console.error();
console.error('- - - - - - - - - - - - - - - - - - - - - - - -');
Expand Down Expand Up @@ -954,13 +954,13 @@ function proceedToInterceptsAndChecks (errCbArg, resultCbArg, extraCbArgs, self,
try {
lcPromise = matchingUserlandLC.handler(errCbArg);
} catch (err) { return proceed(err); }
lcPromise.then(function(resultFromHandler){
lcPromise.then((resultFromHandler)=>{
proceed(undefined, resultFromHandler);
}).catch(function(err){
}).catch((err)=>{
proceed(err);
});//_∏_
}
})(function(err, resultFromHandler){
})((err, resultFromHandler)=>{

// Clear spinlock.
self._hasStartedButNotFinishedAfterExecLC = false;
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,8 @@
"benchmark": "2.1.2",
"eslint": "4.19.1",
"mocha": "6.1.3"
},
"engines": {
"node": ">=8"
}
}

0 comments on commit 348d8ed

Please sign in to comment.