diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index cb7b274b..00000000 --- a/.eslintignore +++ /dev/null @@ -1,6 +0,0 @@ -node_modules/ -builds/ -assets/ -demo/ -*.ts -**/rollup.config.js \ No newline at end of file diff --git a/package.json b/package.json index febeb1c9..d21638c6 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "coverage": "nyc -r lcov -n 'src/**/*' -n 'plugins/**/*' npm run coverage:tests", "coverage:tests": "npm run test", "codecov": "npm run coverage && codecov -t 411de6c7-82d2-41e9-a1cc-9096cdab6c72", - "lint": "eslint ./src --ext .js" + "lint": "eslint ./src" }, "repository": { "type": "git", diff --git a/src/input/formats/01-ymd.js b/src/input/formats/01-ymd.js index e9c7b439..6d59a7d2 100644 --- a/src/input/formats/01-ymd.js +++ b/src/input/formats/01-ymd.js @@ -8,7 +8,7 @@ export default [ // ===== //iso-this 1998-05-30T22:00:00:000Z, iso-that 2017-04-03T08:00:00-0700 { - reg: /^(\-?0?0?[0-9]{3,4})-([0-9]{1,2})-([0-9]{1,2})[T| ]([0-9.:]+)(Z|[0-9\-\+:]+)?$/i, + reg: /^(-?0{0,2}[0-9]{3,4})-([0-9]{1,2})-([0-9]{1,2})[T| ]([0-9.:]+)(Z|[0-9-+:]+)?$/i, parse: (s, m) => { let obj = { year: m[1], @@ -27,7 +27,7 @@ export default [ }, //short-iso "2015-03-25" or "2015/03/25" or "2015/03/25 12:26:14 PM" { - reg: /^([0-9]{4})[\-\/\. ]([0-9]{1,2})[\-\/\. ]([0-9]{1,2})( [0-9]{1,2}(:[0-9]{0,2})?(:[0-9]{0,3})? ?(am|pm)?)?$/i, + reg: /^([0-9]{4})[\-/. ]([0-9]{1,2})[\-/. ]([0-9]{1,2})( [0-9]{1,2}(:[0-9]{0,2})?(:[0-9]{0,3})? ?(am|pm)?)?$/i, parse: (s, m) => { let obj = { year: m[1], @@ -51,7 +51,7 @@ export default [ //text-month "2015-feb-25" { - reg: /^([0-9]{4})[\-\/\. ]([a-z]+)[\-\/\. ]([0-9]{1,2})( [0-9]{1,2}(:[0-9]{0,2})?(:[0-9]{0,3})? ?(am|pm)?)?$/i, + reg: /^([0-9]{4})[\-/. ]([a-z]+)[\-/. ]([0-9]{1,2})( [0-9]{1,2}(:[0-9]{0,2})?(:[0-9]{0,3})? ?(am|pm)?)?$/i, parse: (s, m) => { let obj = { year: parseYear(m[1], s._today), diff --git a/src/input/formats/02-mdy.js b/src/input/formats/02-mdy.js index 2cdaa34d..7278f2d2 100644 --- a/src/input/formats/02-mdy.js +++ b/src/input/formats/02-mdy.js @@ -8,7 +8,7 @@ export default [ // ===== //mm/dd/yyyy - uk/canada "6/28/2019, 12:26:14 PM" { - reg: /^([0-9]{1,2})[\-\/.]([0-9]{1,2})[\-\/.]?([0-9]{4})?( [0-9]{1,2}:[0-9]{2}:?[0-9]{0,2}? ?(am|pm|gmt))?$/i, + reg: /^([0-9]{1,2})[-/.]([0-9]{1,2})[\-/.]?([0-9]{4})?( [0-9]{1,2}:[0-9]{2}:?[0-9]{0,2} ?(am|pm|gmt))?$/i, parse: (s, arr) => { let month = parseInt(arr[1], 10) - 1 let date = parseInt(arr[2], 10) @@ -33,7 +33,7 @@ export default [ }, //alt short format - "feb-25-2015" { - reg: /^([a-z]+)[\-\/\. ]([0-9]{1,2})[\-\/\. ]?([0-9]{4}|'[0-9]{2})?( [0-9]{1,2}(:[0-9]{0,2})?(:[0-9]{0,3})? ?(am|pm)?)?$/i, + reg: /^([a-z]+)[\-/. ]([0-9]{1,2})[\-/. ]?([0-9]{4}|'[0-9]{2})?( [0-9]{1,2}(:[0-9]{0,2})?(:[0-9]{0,3})? ?(am|pm)?)?$/i, parse: (s, arr) => { let obj = { year: parseYear(arr[3], s._today), diff --git a/src/input/formats/03-dmy.js b/src/input/formats/03-dmy.js index cecf6603..dfbf1d62 100644 --- a/src/input/formats/03-dmy.js +++ b/src/input/formats/03-dmy.js @@ -8,7 +8,7 @@ export default [ // ===== //common british format - "25-feb-2015" { - reg: /^([0-9]{1,2})[\-\/]([a-z]+)[\-\/]?([0-9]{4})?$/i, + reg: /^([0-9]{1,2})[-/]([a-z]+)[\-/]?([0-9]{4})?$/i, parse: (s, m) => { let obj = { year: parseYear(m[3], s._today), @@ -26,7 +26,7 @@ export default [ }, // "25 Mar 2015" { - reg: /^([0-9]{1,2})( [a-z]+)( [0-9]{4}| '[0-9]{2})? ?([0-9]{1,2}:[0-9]{2}:?[0-9]{0,2}? ?(am|pm|gmt))?$/i, + reg: /^([0-9]{1,2})( [a-z]+)( [0-9]{4}| '[0-9]{2})? ?([0-9]{1,2}:[0-9]{2}:?[0-9]{0,2} ?(am|pm|gmt))?$/i, parse: (s, m) => { let obj = { year: parseYear(m[3], s._today), @@ -44,7 +44,7 @@ export default [ }, // 01-jan-2020 { - reg: /^([0-9]{1,2})[\. -/]([a-z]+)[\. -/]([0-9]{4})?( [0-9]{1,2}(:[0-9]{0,2})?(:[0-9]{0,3})? ?(am|pm)?)?$/i, + reg: /^([0-9]{1,2})[. \-/]([a-z]+)[. \-/]([0-9]{4})?( [0-9]{1,2}(:[0-9]{0,2})?(:[0-9]{0,3})? ?(am|pm)?)?$/i, parse: (s, m) => { let obj = { date: Number(m[1]), diff --git a/src/input/formats/04-misc.js b/src/input/formats/04-misc.js index cde20e15..d14ba57c 100644 --- a/src/input/formats/04-misc.js +++ b/src/input/formats/04-misc.js @@ -8,7 +8,7 @@ export default [ // '2012-06' month-only { - reg: /^([0-9]{4})[\-\/]([0-9]{2})$/i, + reg: /^([0-9]{4})[\-/]([0-9]{2})$/, parse: (s, m) => { let obj = { year: m[1], diff --git a/src/input/formats/parseOffset.js b/src/input/formats/parseOffset.js index a68acf08..5b017c70 100644 --- a/src/input/formats/parseOffset.js +++ b/src/input/formats/parseOffset.js @@ -9,7 +9,7 @@ const parseOffset = (s, offset) => { let num = 0 // for (+-)hh:mm - if (/^[\+-]?[0-9]{2}:[0-9]{2}$/.test(offset)) { + if (/^[+-]?[0-9]{2}:[0-9]{2}$/.test(offset)) { //support "+01:00" if (/:00/.test(offset) === true) { offset = offset.replace(/:00/, '') @@ -21,7 +21,7 @@ const parseOffset = (s, offset) => { } // for (+-)hhmm - if (/^[\+-]?[0-9]{4}$/.test(offset)) { + if (/^[+-]?[0-9]{4}$/.test(offset)) { offset = offset.replace(/30$/, '.5') } num = parseFloat(offset) diff --git a/src/input/formats/parseTime.js b/src/input/formats/parseTime.js index 489a7086..609fa1a2 100644 --- a/src/input/formats/parseTime.js +++ b/src/input/formats/parseTime.js @@ -20,7 +20,7 @@ const parseTime = (s, str = '') => { // remove all whitespace str = str.replace(/^\s+/, '').toLowerCase() //formal time format - 04:30.23 - let arr = str.match(/([0-9]{1,2}):([0-9]{1,2}):?([0-9]{1,2})?[:\.]?([0-9]{1,4})?/) + let arr = str.match(/([0-9]{1,2}):([0-9]{1,2}):?([0-9]{1,2})?[:.]?([0-9]{1,4})?/) if (arr !== null) { let [, h, m, sec, ms] = arr //validate it a little @@ -37,7 +37,7 @@ const parseTime = (s, str = '') => { s = s.seconds(sec || 0) s = s.millisecond(parseMs(ms)) //parse-out am/pm - let ampm = str.match(/[\b0-9] ?(am|pm)\b/) + let ampm = str.match(/[0-9] ?(am|pm)\b/) if (ampm !== null && ampm[1]) { s = s.ampm(ampm[1]) } diff --git a/src/methods/add.js b/src/methods/add.js index f762b768..aa982726 100644 --- a/src/methods/add.js +++ b/src/methods/add.js @@ -93,7 +93,7 @@ const addMethods = (SpaceTime) => { } //support coercing a week, too if (unit === 'week') { - let sum = old.date() + num * 7 + let sum = old.date() + (num * 7) if (sum <= 28 && sum > 1) { want.date = sum } @@ -118,12 +118,12 @@ const addMethods = (SpaceTime) => { } // ensure a quarter is 3 months over else if (unit === 'quarter') { - want.month = old.month() + num * 3 + want.month = old.month() + (num * 3) want.year = old.year() // handle rollover if (want.month < 0) { let years = Math.floor(want.month / 12) - let remainder = want.month + Math.abs(years) * 12 + let remainder = want.month + (Math.abs(years) * 12) want.month = remainder want.year += years } else if (want.month >= 12) { diff --git a/src/methods/since/soften.js b/src/methods/since/soften.js index 8590fe1d..6a8d27d0 100644 --- a/src/methods/since/soften.js +++ b/src/methods/since/soften.js @@ -1,5 +1,5 @@ //our conceptual 'break-points' for each unit -import { unitsString, } from "../../data/units.js"; +import { unitsString } from "../../data/units.js"; import { almostString, overString } from "../../data/distance.js"; const qualifiers = { diff --git a/src/timezone/index.js b/src/timezone/index.js index 624220bc..313f7d45 100644 --- a/src/timezone/index.js +++ b/src/timezone/index.js @@ -1,3 +1,4 @@ +/* eslint-disable no-console */ import findTz from './find.js' import inSummerTime from './summerTime.js' diff --git a/src/timezone/quick.js b/src/timezone/quick.js index 494b55d7..55ed69ce 100644 --- a/src/timezone/quick.js +++ b/src/timezone/quick.js @@ -1,3 +1,4 @@ +/* eslint-disable no-console */ import isSummer from './summerTime.js' // this method avoids having to do a full dst-calculation on every operation