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(lint): enable IDE linting #3

Merged
merged 3 commits into from
Sep 13, 2020
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
12 changes: 12 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
"extends": [
"react-app",
"prettier/@typescript-eslint",
"plugin:prettier/recommended"
],
"settings": {
"react": {
"version": "detect"
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"react-dom": "^16.13.1",
"tsdx": "^0.13.3",
"tslib": "^2.0.1",
"typescript": "^4.0.2"
"typescript": "^3.9.7"
},
"dependencies": {
"zustand": "^3.1.1"
Expand Down
6 changes: 5 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ export default function create<TState>(
const useZStore: UseStore<StateInValue<TState>> = zcreate(() => ({}));
const reactRoot = document.createElement('div');
ReactDOM.render(
<StoreComponent<TState> hook={hook} hookArgs={hookArgs} useZStore={useZStore} />,
<StoreComponent<TState>
hook={hook}
hookArgs={hookArgs}
useZStore={useZStore}
/>,
reactRoot
);
function internalSelector<U>(selector?: StateSelector<TState, U>) {
Expand Down
16 changes: 12 additions & 4 deletions test/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ describe('create', () => {
expect(screen.getByRole('heading').textContent).toEqual(
'Welcome to the future, React Devs'
);
})
});

test('composition 2', async () => {
const useMsg = () => {
Expand All @@ -232,7 +232,13 @@ describe('create', () => {
return useState('Tim');
};

type useWelcomeMsgState = { welcomeMsg: string, msg: string, name: string, setMsg: Function, setName: Function}
type useWelcomeMsgState = {
welcomeMsg: string;
msg: string;
name: string;
setMsg: Function;
setName: Function;
};
const useWelcomeMsg = create<useWelcomeMsgState>(() => {
const [msg, setMsg] = useMsg();
const [name, setName] = useName();
Expand All @@ -250,7 +256,9 @@ describe('create', () => {
};

const Edit = () => {
const {msg, setMsg, name, setName} = useWelcomeMsg(({ welcomeMsg, ...rest }) => rest);
const { msg, setMsg, name, setName } = useWelcomeMsg(
({ welcomeMsg, ...rest }) => rest
);
return (
<>
<input
Expand Down Expand Up @@ -306,7 +314,7 @@ describe('create', () => {
);

act(() => {
const {setMsg, setName} = useWelcomeMsg.getState();
const { setMsg, setName } = useWelcomeMsg.getState();
setMsg('Welcome to the future');
setName('React Devs');
});
Expand Down
7 changes: 1 addition & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5919,16 +5919,11 @@ type-fest@^0.8.1:
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.8.1.tgz#09e249ebde851d3b1e48d27c105444667f17b83d"
integrity sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==

typescript@^3.7.3:
typescript@^3.7.3, typescript@^3.9.7:
version "3.9.7"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.7.tgz#98d600a5ebdc38f40cb277522f12dc800e9e25fa"
integrity sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==

typescript@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.2.tgz#7ea7c88777c723c681e33bf7988be5d008d05ac2"
integrity sha512-e4ERvRV2wb+rRZ/IQeb3jm2VxBsirQLpQhdxplZ2MEzGvDkkMmPglecnNDfSUBivMjP93vRbngYYDQqQ/78bcQ==

unicode-canonical-property-names-ecmascript@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz#2619800c4c825800efdd8343af7dd9933cbe2818"
Expand Down