diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..39963d3 --- /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, { "SwitchCase": 1 }], + "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 81e6de7..0000000 --- a/.jshintrc +++ /dev/null @@ -1,19 +0,0 @@ -{ - "bitwise": true, - "eqeqeq": true, - "forin": true, - "freeze": true, - "funcscope": true, - "futurehostile": true, - "strict": "global", - "latedef": true, - "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 a79fb8b..7f150a3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,21 +1,15 @@ language: node_js dist: trusty sudo: required -node_js: 6 -env: - - PATH=$HOME/purescript:$PATH +node_js: stable install: - - TAG=$(wget -q -O - https://github.com/purescript/purescript/releases/latest --server-response --max-redirect 0 2>&1 | sed -n -e 's/.*Location:.*tag\///p') - - wget -O $HOME/purescript.tar.gz https://github.com/purescript/purescript/releases/download/$TAG/linux64.tar.gz - - tar -xvf $HOME/purescript.tar.gz -C $HOME/ - - chmod a+x $HOME/purescript - npm install -g bower - npm install -script: - bower install --production +script: - npm run -s build - bower install - - npm test + - npm -s test after_success: - >- test $TRAVIS_TAG && diff --git a/package.json b/package.json index c477226..5a71519 100644 --- a/package.json +++ b/package.json @@ -2,14 +2,14 @@ "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", "test": "pulp test" }, "devDependencies": { - "jscs": "^2.11.0", - "jshint": "^2.9.4", + "eslint": "^3.19.0", "pulp": "^11.0.0", "purescript-psa": "^0.5.0", + "purescript": "^0.11.1", "rimraf": "^2.6.1" } } diff --git a/src/Data/JSDate.purs b/src/Data/JSDate.purs index d2e685e..7c1bd0c 100644 --- a/src/Data/JSDate.purs +++ b/src/Data/JSDate.purs @@ -6,7 +6,42 @@ -- | recommended that `DateTime` representation is used instead - `DateTime` -- | offers greater type safety, a more PureScript-friendly interface, and has -- | a `Generic` instance. -module Data.JSDate where +module Data.JSDate + ( JSDate + , LOCALE + , readDate + , isValid + , fromDateTime + , toDateTime + , toDate + , toInstant + , jsdate + , jsdateLocal + , parse + , getTime + , getUTCDate + , getUTCDay + , getUTCFullYear + , getUTCHours + , getUTCMilliseconds + , getUTCMinutes + , getUTCMonth + , getUTCSeconds + , getDate + , getDay + , getFullYear + , getHours + , getMilliseconds + , getMinutes + , getMonth + , getSeconds + , getTimezoneOffset + , toDateString + , toISOString + , toString + , toTimeString + , toUTCString + ) where import Prelude @@ -29,6 +64,11 @@ import Data.Time.Duration (Milliseconds(..)) -- | The type of JavaScript `Date` objects. foreign import data JSDate :: Type +-- | The effect type used when indicating the current machine's date/time locale +-- | is used in computing a value. +foreign import data LOCALE :: Effect + +-- | Attempts to read a `Foreign` value as a `JSDate`. readDate :: Foreign -> F JSDate readDate = unsafeReadTagged "Date" @@ -111,10 +151,6 @@ foreign import dateMethod :: forall a. Fn2 String JSDate a foreign import parse :: forall eff. String -> Eff (locale :: LOCALE | eff) JSDate --- | The effect type used when indicating the current machine's date/time locale --- | is used in computing a value. -foreign import data LOCALE :: Effect - -- | Returns the date as a number of milliseconds since 1970-01-01 00:00:00 UTC. getTime :: JSDate -> Number getTime dt = runFn2 dateMethod "getTime" dt