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: add @typescript-eslint/stylistic config and grammar fix in README.md #711

Merged
merged 5 commits into from
Oct 1, 2023
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
5 changes: 5 additions & 0 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ extends:
- airbnb/hooks
- eslint:recommended
- plugin:@typescript-eslint/recommended
- plugin:@typescript-eslint/stylistic
- plugin:eslint-comments/recommended
- plugin:import/errors
- plugin:import/recommended
Expand Down Expand Up @@ -42,6 +43,10 @@ plugins:
- react-hooks
- react-native
rules:
'@typescript-eslint/array-type':
- error
- default: 'generic'
readonly: 'generic'
'@typescript-eslint/explicit-function-return-type': error
'@typescript-eslint/explicit-module-boundary-types': error
'@typescript-eslint/no-explicit-any':
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default function App() {

You can find more examples in the `examples` subdirectory. This subdirectory is
a working [Expo](https://github.com/expo/expo) project demonstrating this
library. It shows how to use the library with class components as well as
library. It shows how to use the library with class components as well as with
function components, and in TypeScript as well as in JavaScript. Navigate into
the `examples` subdirectory, run `npm install`, and then run `npx expo start` to
see the examples working.
Expand Down
4 changes: 2 additions & 2 deletions examples/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ const EXAMPLE_COMPONENT_ITEMS: Array<ItemType<ExampleComponent>> = [
];

type Props = Record<string, never>;
type State = {
interface State {
currentExample: ExampleComponent;
examplePickerOpen: boolean;
exampleComponents: Array<ItemType<ExampleComponent>>;
};
}

export default class App extends React.Component<Props, State> {
constructor(props: Readonly<Props>) {
Expand Down
10 changes: 5 additions & 5 deletions examples/example-src-files/typescript-class-example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import React, { Component } from 'react';
import { Button, Text, View } from 'react-native';
import DropDownPicker, { ItemType } from 'react-native-dropdown-picker';

type Props = {
interface Props {
multiple: boolean;
};
type State = {
}
interface State {
open: boolean;
singleValue: string | null;
multiValue: string[] | null;
multiValue: Array<string> | null;
items: Array<ItemType<string>>;
};
}

export default class TypescriptClassExample extends Component<Props, State> {
constructor(props: Readonly<Props>) {
Expand Down
2 changes: 1 addition & 1 deletion examples/example-src-files/typescript-function-example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function TypescriptFunctionExample(props: {
}): JSX.Element {
const [open, setOpen] = useState<boolean>(false);
const [singleValue, setSingleValue] = useState<string | null>(null);
const [multiValue, setMultiValue] = useState<string[] | null>(null);
const [multiValue, setMultiValue] = useState<Array<string> | null>(null);
const [items, setItems] = useState<Array<ItemType<string>>>([
{ label: 'Apple', value: 'apple' },
{ label: 'Banana', value: 'banana' },
Expand Down
1,148 changes: 449 additions & 699 deletions examples/package-lock.json

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions examples/package.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
{
"name": "examples",
"version": "1.0.0",
"private": true,
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"start": "expo start",
"web": "expo start --web"
},
"dependencies": {
"expo": "~49.0.9",
"expo-status-bar": "~1.6.0",
"expo": "^49.0.13",
"expo-status-bar": "~1.7.1",
"react": "18.2.0",
"react-native": "0.72.4",
"react-native": "0.72.5",
"react-native-dropdown-picker": "^5.4.6"
},
"devDependencies": {
"@babel/core": "^7.22.15",
"@types/react": "~18.2.21",
"@babel/core": "^7.23.0",
"@types/react": "~18.2.24",
"typescript": "^5.2.2"
},
"private": true
}
}
4 changes: 2 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ declare module 'react-native-dropdown-picker' {

export type ValueType = string | number | boolean;

export type ItemType<T extends ValueType> = {
export interface ItemType<T extends ValueType> {
containerStyle?: StyleProp<ViewStyle>;
disabled?: boolean;
icon?: () => JSX.Element;
Expand All @@ -32,7 +32,7 @@ declare module 'react-native-dropdown-picker' {
selectable?: boolean;
testID?: string;
value?: T;
};
}

export type ModeType = 'DEFAULT' | 'SIMPLE' | 'BADGE';

Expand Down
Loading