Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: TS + ESlint #265

Merged
merged 4 commits into from
Sep 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,11 @@
"plugins": [
"react",
"jest"
],
"overrides": [
{
"files": [ "**/*.ts", "**/*.tsx" ],
"extends": [ "plugin:@typescript-eslint/recommended" ]
}
]
}
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"start": "react-native start",
"test": "jest",
"lint": "eslint .",
"sync": "/usr/bin/rsync -v -a ../src ../index.js ../package.json ./node_modules/react-native-week-view/",
"sync": "/usr/bin/rsync -v -a ../src ../index.js ../index.d.ts ../package.json ./node_modules/react-native-week-view/",
"install:local": "rm ./node_modules/react-native-week-view && yarn sync"
},
"dependencies": {
Expand Down
29 changes: 23 additions & 6 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ import React from 'react';
import { StyleProp, ViewStyle, TextStyle } from 'react-native';
import { Moment } from 'moment';

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export interface WeekViewEvent extends Record<string, any> {
id: number;
description: string;
startDate: Date;
endDate: Date;
color: string;
style?: StyleProp<ViewStyle>;
disableDrag?: boolean;
disablePress?: boolean;
disableLongPress?: boolean;
}

export interface HeaderComponentProps {
Expand Down Expand Up @@ -113,25 +118,38 @@ export interface WeekViewProps {
* @param newStartDate
* @param newEndDate
*/
onDragEvent?(event: WeekViewEvent, newStartDate: Date, newEndDate: Date): void;
onDragEvent?(
event: WeekViewEvent,
newStartDate: Date,
newEndDate: Date,
): void;

/**
* Callback when an event item is edited by dragging its borders.
* @param event
* @param newStartDate
* @param newEndDate
*/
onEditEvent?(event: WeekViewEvent, newStartDate: Date, newEndDate: Date): void;

editEventConfig?: { bottom: boolean; top: boolean; left: boolean; right: boolean; };
onEditEvent?(
event: WeekViewEvent,
newStartDate: Date,
newEndDate: Date,
): void;

editEventConfig?: {
bottom: boolean;
top: boolean;
left: boolean;
right: boolean;
};

// Week-view customizations
/**
* Vertical position of the week-view in the first render (vertically in the agenda).
*
* Default value: 8 (8 am)
*/
startHour?: number
startHour?: number;

/**
* First day of the week, i.e. day to show at the left of the week-view
Expand Down Expand Up @@ -186,7 +204,6 @@ export interface WeekViewProps {
maxToRenderPerBatch?: number;
updateCellsBatchingPeriod?: number;


// Other props (patch RN bugs)
prependMostRecent?: boolean;
}
Expand Down
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
],
"homepage": "https://github.com/hoangnm/react-native-week-view#readme",
"scripts": {
"lint": "eslint",
"lint": "eslint index.* src",
"test": "jest"
},
"dependencies": {
Expand All @@ -37,6 +37,12 @@
"@babel/preset-env": "^7.13.15",
"@testing-library/jest-native": "^4.0.5",
"@testing-library/react-native": "^9.1.0",
"@types/jest": "^29.0.1",
"@types/react": "^18.0.19",
"@types/react-native": "^0.70.0",
"@types/react-test-renderer": "^18.0.0",
"@typescript-eslint/eslint-plugin": "^5.37.0",
"@typescript-eslint/parser": "^5.37.0",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.6.3",
"eslint": "^7.24.0",
Expand All @@ -55,7 +61,8 @@
"react-native": "0.68.2",
"react-native-gesture-handler": "^2.4.1",
"react-native-reanimated": "^2.8.0",
"react-test-renderer": "17.0.2"
"react-test-renderer": "17.0.2",
"typescript": "^4.8.3"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0",
Expand All @@ -81,4 +88,3 @@
]
}
}

Loading