Skip to content

Commit

Permalink
more linting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
spencermountain committed Jul 31, 2024
1 parent 6ece280 commit 405eda8
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 24 deletions.
6 changes: 0 additions & 6 deletions .eslintignore

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions src/input/formats/01-ymd.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Check failure on line 11 in src/input/formats/01-ymd.js

View workflow job for this annotation

GitHub Actions / build (18.x)

The quantifier '[0-9.:]+' can exchange characters with '[0-9-+:]+'. Using any string accepted by /[\d:]+/i, this can be exploited to cause at least polynomial backtracking. This might cause exponential backtracking

Check failure on line 11 in src/input/formats/01-ymd.js

View workflow job for this annotation

GitHub Actions / build (18.x)

The quantifier '[0-9.:]+' can exchange characters ([\d:]) with '[0-9-+:]+'. This makes the capturing group misleading, because the quantifier will capture fewer characters than its pattern suggests

Check failure on line 11 in src/input/formats/01-ymd.js

View workflow job for this annotation

GitHub Actions / build (22.x)

The quantifier '[0-9.:]+' can exchange characters with '[0-9-+:]+'. Using any string accepted by /[\d:]+/i, this can be exploited to cause at least polynomial backtracking. This might cause exponential backtracking

Check failure on line 11 in src/input/formats/01-ymd.js

View workflow job for this annotation

GitHub Actions / build (22.x)

The quantifier '[0-9.:]+' can exchange characters ([\d:]) with '[0-9-+:]+'. This makes the capturing group misleading, because the quantifier will capture fewer characters than its pattern suggests
parse: (s, m) => {
let obj = {
year: m[1],
Expand All @@ -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],
Expand All @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions src/input/formats/02-mdy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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),
Expand Down
6 changes: 3 additions & 3 deletions src/input/formats/03-dmy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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),
Expand All @@ -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]),
Expand Down
2 changes: 1 addition & 1 deletion src/input/formats/04-misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
4 changes: 2 additions & 2 deletions src/input/formats/parseOffset.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/, '')
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/input/formats/parseTime.js
Original file line number Diff line number Diff line change
Expand Up @@ -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})?/)

Check failure on line 23 in src/input/formats/parseTime.js

View workflow job for this annotation

GitHub Actions / build (18.x)

The quantifier '[0-9]{1,2}' can exchange characters (\d) with '[0-9]{1,2}'. This makes the capturing group misleading, because the quantifier will capture fewer characters than its pattern suggests

Check failure on line 23 in src/input/formats/parseTime.js

View workflow job for this annotation

GitHub Actions / build (18.x)

The quantifier '[0-9]{1,2}' can exchange characters (\d) with '[0-9]{1,4}'. This makes the capturing group misleading, because the quantifier will capture fewer characters than its pattern suggests

Check failure on line 23 in src/input/formats/parseTime.js

View workflow job for this annotation

GitHub Actions / build (18.x)

The quantifier '[0-9]{1,2}' can exchange characters (\d) with '[0-9]{1,4}'. This makes the capturing group misleading, because the quantifier will capture fewer characters than its pattern suggests

Check failure on line 23 in src/input/formats/parseTime.js

View workflow job for this annotation

GitHub Actions / build (22.x)

The quantifier '[0-9]{1,2}' can exchange characters (\d) with '[0-9]{1,2}'. This makes the capturing group misleading, because the quantifier will capture fewer characters than its pattern suggests

Check failure on line 23 in src/input/formats/parseTime.js

View workflow job for this annotation

GitHub Actions / build (22.x)

The quantifier '[0-9]{1,2}' can exchange characters (\d) with '[0-9]{1,4}'. This makes the capturing group misleading, because the quantifier will capture fewer characters than its pattern suggests

Check failure on line 23 in src/input/formats/parseTime.js

View workflow job for this annotation

GitHub Actions / build (22.x)

The quantifier '[0-9]{1,2}' can exchange characters (\d) with '[0-9]{1,4}'. This makes the capturing group misleading, because the quantifier will capture fewer characters than its pattern suggests
if (arr !== null) {
let [, h, m, sec, ms] = arr
//validate it a little
Expand All @@ -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])
}
Expand Down
6 changes: 3 additions & 3 deletions src/methods/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/methods/since/soften.js
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down
1 change: 1 addition & 0 deletions src/timezone/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-console */
import findTz from './find.js'
import inSummerTime from './summerTime.js'

Expand Down
1 change: 1 addition & 0 deletions src/timezone/quick.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 405eda8

Please sign in to comment.