Skip to content

Commit 65a59ce

Browse files
committed
chore: update packages
1 parent 300009c commit 65a59ce

File tree

14 files changed

+4169
-4721
lines changed

14 files changed

+4169
-4721
lines changed

.eslintrc.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ parserOptions:
66
ecmaFeatures:
77
jsx: true
88
impliedStrict: true
9-
project: ./tsconfig.json
9+
project: tsconfig-eslint.json
1010
plugins:
1111
- react
1212
- '@typescript-eslint/eslint-plugin'

.github/workflows/master.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- name: Lint Check
1414
run: |
1515
yarn
16-
yarn lint
16+
./checks.sh lint
1717
test:
1818
name: Unit tests
1919
runs-on: ubuntu-latest
@@ -23,6 +23,7 @@ jobs:
2323
- name: Test
2424
run: |
2525
yarn
26+
cd packages/react-date-primitives
2627
yarn test
2728
prettier:
2829
name: Prettier
@@ -33,4 +34,4 @@ jobs:
3334
- name: Prettier Check
3435
run: |
3536
yarn
36-
yarn fmtc
37+
./checks.sh prettier

.github/workflows/pull_request.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- name: Lint Check
1515
run: |
1616
yarn
17-
yarn lint
17+
./checks.sh lint
1818
test:
1919
name: Unit tests
2020
runs-on: ubuntu-latest
@@ -25,6 +25,7 @@ jobs:
2525
- name: Test
2626
run: |
2727
yarn
28+
cd packages/react-date-primitives
2829
yarn test
2930
prettier:
3031
name: Prettier
@@ -36,4 +37,4 @@ jobs:
3637
- name: Prettier Check
3738
run: |
3839
yarn
39-
yarn fmtc
40+
./checks.sh prettier

checks.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
check=$1
5+
root="$(pwd)"
6+
7+
for f in packages/*; do
8+
if [ -d "$f" ]; then
9+
pushd $f >> /dev/null
10+
if [ "$check" == "lint" ]; then
11+
echo "Running ESLint for $f"
12+
npx eslint --ext .ts --ext .tsx --config "$root/.eslintrc.yml" src
13+
elif [ "$check" == "prettier" ]; then
14+
npx prettier --check "src/**/*.{ts,tsx}"
15+
fi
16+
popd >> /dev/null
17+
fi
18+
done

package.json

+15-10
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
{
22
"private": true,
33
"version": "0.1.0",
4+
"engines": {
5+
"node": ">=14.0.0",
6+
"npm": ">=7.0.0"
7+
},
48
"scripts": {
9+
"lint": "eslint --ext .ts --ext .jsx packages/react-date-primitives/src",
510
"postinstall": "husky install"
611
},
712
"workspaces": [
813
"packages/*"
914
],
1015
"devDependencies": {
11-
"@typescript-eslint/eslint-plugin": "^4.9.1",
12-
"@typescript-eslint/parser": "^4.9.1",
13-
"eslint": "^7.15.0",
14-
"eslint-config-prettier": "^8.1.0",
15-
"eslint-plugin-react": "^7.21.5",
16-
"globby": "^11.0.1",
17-
"husky": "^5.1.3",
18-
"lint-staged": "^10.5.3",
19-
"prettier": "^2.2.1",
16+
"@typescript-eslint/eslint-plugin": "^4.28.0",
17+
"@typescript-eslint/parser": "^4.28.0",
18+
"eslint": "^7.29.0",
19+
"eslint-config-prettier": "^8.3.0",
20+
"eslint-plugin-react": "^7.24.0",
21+
"globby": "^11.0.4",
22+
"husky": "^6.0.0",
23+
"lint-staged": "^11.0.0",
24+
"prettier": "^2.3.2",
2025
"rimraf": "~3.0.2",
21-
"typescript": "^4.2.3"
26+
"typescript": "^4.3.4"
2227
},
2328
"lint-staged": {
2429
"*.{ts,tsx}": [
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "use-calendar-hook",
2+
"name": "example-use-calendar-hook",
33
"description": "simple date picker created using react-date-primitives",
44
"version": "0.1.0",
55
"private": true,
@@ -9,15 +9,15 @@
99
},
1010
"dependencies": {
1111
"@vkbansal/react-date-primitives": "2.0.0",
12-
"date-fns": "~2.19.0",
13-
"react": "~17.0.1",
14-
"react-dom": "~17.0.1"
12+
"date-fns": "~2.22.1",
13+
"react": "~17.0.2",
14+
"react-dom": "~17.0.2"
1515
},
1616
"devDependencies": {
1717
"@types/date-fns": "~2.6.0",
18-
"@types/react": "~17.0.3",
19-
"@types/react-dom": "~17.0.2",
20-
"typescript": "~4.2.3",
21-
"vite": "~2.1.2"
18+
"@types/react": "~17.0.11",
19+
"@types/react-dom": "~17.0.8",
20+
"typescript": "~4.3.4",
21+
"vite": "~2.3.8"
2222
}
2323
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"include": ["./src"],
4+
"exclude": ["**/node_modules/**"]
5+
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "use-daterange-hook",
2+
"name": "example-use-daterange-hook",
33
"description": "simple date-range picker created using react-date-primitives",
44
"version": "0.1.0",
55
"private": true,
@@ -9,13 +9,13 @@
99
},
1010
"dependencies": {
1111
"@vkbansal/react-date-primitives": "2.0.0",
12-
"react": "~17.0.1",
13-
"react-dom": "~17.0.1"
12+
"react": "~17.0.2",
13+
"react-dom": "~17.0.2"
1414
},
1515
"devDependencies": {
16-
"@types/react": "~17.0.3",
17-
"@types/react-dom": "~17.0.2",
18-
"typescript": "~4.2.3",
19-
"vite": "~2.1.2"
16+
"@types/react": "~17.0.11",
17+
"@types/react-dom": "~17.0.8",
18+
"typescript": "~4.3.4",
19+
"vite": "~2.3.8"
2020
}
2121
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"include": ["./src"],
4+
"exclude": ["**/node_modules/**"]
5+
}

packages/react-date-primitives/package.json

+12-12
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,18 @@
5050
"react-dom": "^16.8.0 || ^17.0.0"
5151
},
5252
"devDependencies": {
53-
"@testing-library/react": "~11.2.2",
54-
"@testing-library/react-hooks": "~5.1.0",
55-
"@types/jest": "~26.0.18",
56-
"@types/react": "~17.0.0",
57-
"@types/react-dom": "~17.0.0",
53+
"@testing-library/react": "~12.0.0",
54+
"@testing-library/react-hooks": "~7.0.0",
55+
"@types/jest": "~26.0.23",
56+
"@types/react": "~17.0.11",
57+
"@types/react-dom": "~17.0.8",
5858
"handlebars": "^4.7.7",
59-
"jest": "~26.6.3",
60-
"react": "~17.0.1",
61-
"react-dom": "~17.0.1",
62-
"react-test-renderer": "~17.0.1",
63-
"ts-jest": "~26.5.4",
64-
"typescript": "~4.2.3",
65-
"vite": "~2.1.2"
59+
"jest": "~27.0.5",
60+
"react": "~17.0.2",
61+
"react-dom": "~17.0.2",
62+
"react-test-renderer": "~17.0.2",
63+
"ts-jest": "~27.0.3",
64+
"typescript": "~4.3.4",
65+
"vite": "~2.3.8"
6666
}
6767
}

packages/react-date-primitives/src/utils.ts

+34-39
Original file line numberDiff line numberDiff line change
@@ -178,23 +178,20 @@ export function getDaysOfMonth(month: Date, weekStartsOn = DayName.SUNDAY): Mont
178178

179179
const firstDayInCurrentMonth = firstDate.getDay();
180180

181-
const days: Month['days'] = Array.from(
182-
{ length: 6 * 7 },
183-
(_1, i): DayOfMonth => {
184-
const day = addDays(
185-
firstDate,
186-
i - firstDayInCurrentMonth - (dayOffset > firstDayInCurrentMonth ? 7 : 0) + dayOffset
187-
);
188-
189-
return {
190-
__type: DayOfMonthSymbol,
191-
dateObj: day,
192-
dayName: DaysOfTheWeek[(i + dayOffset) % 7],
193-
inCurrentMonth: isSameMonth(firstDate, day),
194-
ISODateString: toISODateString(day)
195-
};
196-
}
197-
);
181+
const days: Month['days'] = Array.from({ length: 6 * 7 }, (_1, i): DayOfMonth => {
182+
const day = addDays(
183+
firstDate,
184+
i - firstDayInCurrentMonth - (dayOffset > firstDayInCurrentMonth ? 7 : 0) + dayOffset
185+
);
186+
187+
return {
188+
__type: DayOfMonthSymbol,
189+
dateObj: day,
190+
dayName: DaysOfTheWeek[(i + dayOffset) % 7],
191+
inCurrentMonth: isSameMonth(firstDate, day),
192+
ISODateString: toISODateString(day)
193+
};
194+
});
198195

199196
const daysOfWeek = DaysOfTheWeek.slice(dayOffset).concat(DaysOfTheWeek.slice(0, dayOffset));
200197

@@ -235,28 +232,26 @@ export function getDaysOfRangeMonth(
235232
accumulator.daysOfWeek = daysOfWeek.slice(0);
236233
}
237234

238-
const daysOfCurrentMonth = days.map(
239-
(day): DayOfRangeMonth => {
240-
const isStart = Boolean(startDate && isSameDay(day.dateObj, startDate));
241-
const isEnd = Boolean(endDate && isSameDay(day.dateObj, endDate));
242-
243-
return {
244-
...day,
245-
__type: DayOfRangeMonthSymbol,
246-
inRange:
247-
isStart ||
248-
isEnd ||
249-
Boolean(
250-
startDate &&
251-
isDayAfter(day.dateObj, startDate) &&
252-
endDate &&
253-
isDayBefore(day.dateObj, endDate)
254-
),
255-
isStart,
256-
isEnd
257-
};
258-
}
259-
);
235+
const daysOfCurrentMonth = days.map((day): DayOfRangeMonth => {
236+
const isStart = Boolean(startDate && isSameDay(day.dateObj, startDate));
237+
const isEnd = Boolean(endDate && isSameDay(day.dateObj, endDate));
238+
239+
return {
240+
...day,
241+
__type: DayOfRangeMonthSymbol,
242+
inRange:
243+
isStart ||
244+
isEnd ||
245+
Boolean(
246+
startDate &&
247+
isDayAfter(day.dateObj, startDate) &&
248+
endDate &&
249+
isDayBefore(day.dateObj, endDate)
250+
),
251+
isStart,
252+
isEnd
253+
};
254+
});
260255

261256
accumulator.months.push({
262257
days: daysOfCurrentMonth,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"include": ["./src"],
4+
"exclude": ["**/node_modules/**"]
5+
}

tsconfig-eslint.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"include": ["./packages/*/src"],
4+
"exclude": ["**/node_modules/**"]
5+
}

0 commit comments

Comments
 (0)