Skip to content

Commit

Permalink
chore: add @typescript-eslint/stylistic config and grammar fix in REA…
Browse files Browse the repository at this point in the history
…DME.md (#711)

* chore: add @typescript-eslint/stylistic ESLint config and grammar fix in README.md

* chore: updated examples deps

* chore: updated deps

* reformatted files

* remove empty jsdoc comments
  • Loading branch information
taeh98 authored Oct 1, 2023
1 parent 9c7fd11 commit 69a56ba
Show file tree
Hide file tree
Showing 10 changed files with 1,054 additions and 1,420 deletions.
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';

Check failure on line 2 in examples/example-src-files/typescript-class-example.tsx

View workflow job for this annotation

GitHub Actions / Lint source files

Imports should be sorted alphabetically
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

0 comments on commit 69a56ba

Please sign in to comment.