From d1e4bf6d77c5a2b7258b5a60af030dacdd6a4bdf Mon Sep 17 00:00:00 2001 From: Gary Burgess Date: Sun, 12 Mar 2017 23:23:06 +0000 Subject: [PATCH 1/2] Update for PureScript 0.11 --- .eslintrc.json | 28 ++++++++++++++++++++++++++++ .gitignore | 3 +-- .jscsrc | 17 ----------------- .jshintrc | 20 -------------------- .travis.yml | 2 +- bower.json | 6 +++--- package.json | 11 +++++------ src/Control/Monad/Eff/Exception.purs | 6 +++--- 8 files changed, 41 insertions(+), 52 deletions(-) create mode 100644 .eslintrc.json delete mode 100644 .jscsrc delete mode 100644 .jshintrc diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..84cef4f --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,28 @@ +{ + "parserOptions": { + "ecmaVersion": 5 + }, + "extends": "eslint:recommended", + "env": { + "commonjs": true + }, + "rules": { + "strict": [2, "global"], + "block-scoped-var": 2, + "consistent-return": 2, + "eqeqeq": [2, "smart"], + "guard-for-in": 2, + "no-caller": 2, + "no-extend-native": 2, + "no-loop-func": 2, + "no-new": 2, + "no-param-reassign": 2, + "no-return-assign": 2, + "no-unused-expressions": 2, + "no-use-before-define": 2, + "radix": [2, "always"], + "indent": [2, 2], + "quotes": [2, "double"], + "semi": [2, "always"] + } +} diff --git a/.gitignore b/.gitignore index e306283..7050558 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ /.* !/.gitignore -!/.jscsrc -!/.jshintrc +!/.eslintrc.json !/.travis.yml /bower_components/ /node_modules/ diff --git a/.jscsrc b/.jscsrc deleted file mode 100644 index 2561ce9..0000000 --- a/.jscsrc +++ /dev/null @@ -1,17 +0,0 @@ -{ - "preset": "grunt", - "disallowSpacesInFunctionExpression": null, - "requireSpacesInFunctionExpression": { - "beforeOpeningRoundBrace": true, - "beforeOpeningCurlyBrace": true - }, - "disallowSpacesInAnonymousFunctionExpression": null, - "requireSpacesInAnonymousFunctionExpression": { - "beforeOpeningRoundBrace": true, - "beforeOpeningCurlyBrace": true - }, - "disallowSpacesInsideObjectBrackets": null, - "requireSpacesInsideObjectBrackets": "all", - "validateQuoteMarks": "\"", - "requireCurlyBraces": null -} diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 620d8d7..0000000 --- a/.jshintrc +++ /dev/null @@ -1,20 +0,0 @@ -{ - "bitwise": true, - "eqeqeq": true, - "forin": true, - "freeze": true, - "funcscope": true, - "futurehostile": true, - "strict": "global", - "latedef": true, - "maxparams": 1, - "noarg": true, - "nocomma": true, - "nonew": true, - "notypeof": true, - "singleGroups": true, - "undef": true, - "unused": true, - "eqnull": true, - "predef": ["exports"] -} diff --git a/.travis.yml b/.travis.yml index f9843c2..27b95cd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: node_js dist: trusty sudo: required -node_js: 6 +node_js: stable env: - PATH=$HOME/purescript:$PATH install: diff --git a/bower.json b/bower.json index 4bfe6bd..7adec04 100644 --- a/bower.json +++ b/bower.json @@ -17,8 +17,8 @@ "package.json" ], "dependencies": { - "purescript-eff": "^2.0.0", - "purescript-either": "^2.0.0", - "purescript-maybe": "^2.0.0" + "purescript-eff": "^3.0.0", + "purescript-either": "^3.0.0", + "purescript-maybe": "^3.0.0" } } diff --git a/package.json b/package.json index b4cf24e..26d81a7 100644 --- a/package.json +++ b/package.json @@ -2,13 +2,12 @@ "private": true, "scripts": { "clean": "rimraf output && rimraf .pulp-cache", - "build": "jshint src && jscs src && pulp build --censor-lib --strict" + "build": "eslint src && pulp build -- --censor-lib --strict" }, "devDependencies": { - "jscs": "^2.8.0", - "jshint": "^2.9.1", - "pulp": "^9.0.1", - "purescript-psa": "^0.3.9", - "rimraf": "^2.5.0" + "eslint": "^3.17.1", + "pulp": "^10.0.4", + "purescript-psa": "^0.5.0-rc.1", + "rimraf": "^2.6.1" } } diff --git a/src/Control/Monad/Eff/Exception.purs b/src/Control/Monad/Eff/Exception.purs index 482d22a..c7bf9ac 100644 --- a/src/Control/Monad/Eff/Exception.purs +++ b/src/Control/Monad/Eff/Exception.purs @@ -15,16 +15,16 @@ module Control.Monad.Eff.Exception import Prelude -import Control.Monad.Eff (Eff) +import Control.Monad.Eff (Eff, kind Effect) import Data.Either (Either(..)) import Data.Maybe (Maybe(..)) -- | This effect is used to annotate code which possibly throws exceptions -foreign import data EXCEPTION :: ! +foreign import data EXCEPTION :: Effect -- | The type of JavaScript errors -foreign import data Error :: * +foreign import data Error :: Type instance showError :: Show Error where show = showErrorImpl From ebb95a4ebe033b2f62feed8833a26fd352595107 Mon Sep 17 00:00:00 2001 From: Gary Burgess Date: Sun, 26 Mar 2017 02:50:05 +0100 Subject: [PATCH 2/2] Use `exception` rather than `err` label --- src/Control/Monad/Eff/Exception.purs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Control/Monad/Eff/Exception.purs b/src/Control/Monad/Eff/Exception.purs index c7bf9ac..f0b79c5 100644 --- a/src/Control/Monad/Eff/Exception.purs +++ b/src/Control/Monad/Eff/Exception.purs @@ -60,7 +60,7 @@ foreign import stackImpl foreign import throwException :: forall a eff . Error - -> Eff (err :: EXCEPTION | eff) a + -> Eff (exception :: EXCEPTION | eff) a -- | Catch an exception by providing an exception handler. -- | @@ -75,12 +75,12 @@ foreign import throwException foreign import catchException :: forall a eff . (Error -> Eff eff a) - -> Eff (err :: EXCEPTION | eff) a + -> Eff (exception :: EXCEPTION | eff) a -> Eff eff a -- | A shortcut allowing you to throw an error in one step. Defined as -- | `throwException <<< error`. -throw :: forall eff a. String -> Eff (err :: EXCEPTION | eff) a +throw :: forall eff a. String -> Eff (exception :: EXCEPTION | eff) a throw = throwException <<< error -- | Runs an Eff and returns eventual Exceptions as a `Left` value. If the @@ -100,5 +100,5 @@ throw = throwException <<< error -- | Console.error ("Couldn't open README.md. Error was: " <> show error) -- | ``` -try :: forall eff a. Eff (err :: EXCEPTION | eff) a -> Eff eff (Either Error a) +try :: forall eff a. Eff (exception :: EXCEPTION | eff) a -> Eff eff (Either Error a) try action = catchException (pure <<< Left) (Right <$> action)