Skip to content
This repository has been archived by the owner on Dec 17, 2021. It is now read-only.

feat: Add reasonable linter configuration and lint everything #87

Open
wants to merge 5 commits into
base: staging
Choose a base branch
from

Conversation

QEDK
Copy link
Member

@QEDK QEDK commented Nov 29, 2021

There is no reason for us to have an absurd linter configuration that ignores most technical debt. I am using the one that Next.js officially recommends (which is eslint-config-next and incorporates the React plugins as well.
✖ 163 problems (147 errors, 16 warnings) We should probably focus on fixing the errors first, the warnings are mostly trivial.

./pages/_app.js
13:9  Error: 'SubMenu' is assigned a value but never used.  no-unused-vars

./pages/api/image-storage.js
2:10  Error: 'NextApiRequest' is defined but never used.  no-unused-vars
2:26  Error: 'NextApiResponse' is defined but never used.  no-unused-vars
9:14  Error: 'Promise' is not defined.  no-undef
34:22  Error: 'Promise' is not defined.  no-undef

./pages/api/json-storage.js
2:10  Error: 'NextApiRequest' is defined but never used.  no-unused-vars
2:26  Error: 'NextApiResponse' is defined but never used.  no-unused-vars
3:8  Error: 'multiparty' is defined but never used.  no-unused-vars
5:13  Error: 'fs' is defined but never used.  no-unused-vars

./pages/index.js
1:17  Error: 'useCallback' is defined but never used.  no-unused-vars
2:10  Error: 'Core' is defined but never used.  no-unused-vars
3:8  Error: 'axios' is defined but never used.  no-unused-vars
6:3  Error: 'Code' is defined but never used.  no-unused-vars
7:3  Error: 'HStack' is defined but never used.  no-unused-vars
8:3  Error: 'InputGroup' is defined but never used.  no-unused-vars
9:3  Error: 'InputLeftElement' is defined but never used.  no-unused-vars
10:3  Error: 'Box' is defined but never used.  no-unused-vars
13:3  Error: 'VStack' is defined but never used.  no-unused-vars
22:10  Error: 'CeramicClient' is defined but never used.  no-unused-vars
23:10  Error: 'ModelManager' is defined but never used.  no-unused-vars
24:10  Error: 'DID' is defined but never used.  no-unused-vars
25:10  Error: 'Ed25519Provider' is defined but never used.  no-unused-vars
26:10  Error: 'getResolver' is defined but never used.  no-unused-vars
27:10  Error: 'fromString' is defined but never used.  no-unused-vars
27:22  Error: 'toString' is defined but never used.  no-unused-vars
28:10  Error: 'DataModel' is defined but never used.  no-unused-vars
29:10  Error: 'DIDDataStore' is defined but never used.  no-unused-vars
30:10  Error: 'EthereumAuthProvider' is defined but never used.  no-unused-vars
30:32  Error: 'SelfID' is defined but never used.  no-unused-vars
30:40  Error: 'WebClient' is defined but never used.  no-unused-vars
31:10  Error: 'Table' is defined but never used.  no-unused-vars
31:17  Error: 'Modal' is defined but never used.  no-unused-vars
31:24  Error: 'Form' is defined but never used.  no-unused-vars
31:37  Error: 'Divider' is defined but never used.  no-unused-vars
31:46  Error: 'InputNumber' is defined but never used.  no-unused-vars
31:59  Error: 'Select' is defined but never used.  no-unused-vars
31:67  Error: 'Typography' is defined but never used.  no-unused-vars
31:79  Error: 'Tag' is defined but never used.  no-unused-vars
31:84  Error: 'Space' is defined but never used.  no-unused-vars
31:91  Error: 'PageHeader' is defined but never used.  no-unused-vars
32:10  Error: 'randomBytes' is defined but never used.  no-unused-vars
33:10  Error: 'ethers' is defined but never used.  no-unused-vars
35:8  Error: 'modelAliases' is defined but never used.  no-unused-vars
36:30  Error: 'CERAMIC_TESTNET' is defined but never used.  no-unused-vars
41:10  Error: 'FiSearch' is defined but never used.  no-unused-vars
59:13  Error: 'ethereum' is not defined.  no-undef
68:17  Error: 'ethereum' is not defined.  no-undef
81:10  Error: 'inputEmail' is assigned a value but never used.  no-unused-vars
81:22  Error: 'setInputEmail' is assigned a value but never used.  no-unused-vars
82:10  Error: 'recipients' is assigned a value but never used.  no-unused-vars
82:22  Error: 'setRecipients' is assigned a value but never used.  no-unused-vars
98:10  Error: 'store' is assigned a value but never used.  no-unused-vars
98:17  Error: 'setStore' is assigned a value but never used.  no-unused-vars
99:10  Error: 'prevNote' is assigned a value but never used.  no-unused-vars
99:20  Error: 'setPrevNote' is assigned a value but never used.  no-unused-vars
117:5  Warning: React Hook useEffect has a missing dependency: 'handleSearch'. Either include it or remove the dependency array.  react-hooks/exhaustive-deps
128:33  Error: 'Promise' is not defined.  no-undef
129:39  Error: 'Set' is not defined.  no-undef
131:35  Error: 'Promise' is not defined.  no-undef
169:6  Warning: React Hook useEffect has a missing dependency: 'init'. Either include it or remove the dependency array.  react-hooks/exhaustive-deps

./pages/profile/approval/index.js
3:10  Error: 'EthereumAuthProvider' is defined but never used.  no-unused-vars
3:32  Error: 'SelfID' is defined but never used.  no-unused-vars
3:40  Error: 'WebClient' is defined but never used.  no-unused-vars
6:30  Error: 'CERAMIC_TESTNET' is defined but never used.  no-unused-vars
7:8  Error: 'modelAliases' is defined but never used.  no-unused-vars
23:10  Error: 'accessRequests' is assigned a value but never used.  no-unused-vars
23:26  Error: 'setAccessRequests' is assigned a value but never used.  no-unused-vars
36:13  Error: 'addresses' is assigned a value but never used.  no-unused-vars
46:35  Error: 'Promise' is not defined.  no-undef
49:39  Error: 'Promise' is not defined.  no-undef
72:6  Warning: React Hook useEffect has a missing dependency: 'init'. Either include it or remove the dependency array.  react-hooks/exhaustive-deps
97:15  Error: 'receipt' is assigned a value but never used.  no-unused-vars
118:5  Warning: React Hook useCallback has missing dependencies: 'contract' and 'toast'. Either include them or remove the dependency array.  react-hooks/exhaustive-deps
130:21  Error: React Hook "useColorModeValue" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function.  react-hooks/rules-of-hooks
145:42  Error: React Hook "useColorModeValue" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function.  react-hooks/rules-of-hooks
157:53  Error: React Hook "useColorModeValue" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function.  react-hooks/rules-of-hooks
164:44  Error: React Hook "useColorModeValue" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function.  react-hooks/rules-of-hooks
167:44  Error: React Hook "useColorModeValue" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function.  react-hooks/rules-of-hooks

./pages/profile/edit-private-profile.js
1:74  Error: 'Image' is defined but never used.  no-unused-vars
1:81  Error: 'Textarea' is defined but never used.  no-unused-vars
5:10  Error: 'EthereumAuthProvider' is defined but never used.  no-unused-vars
5:32  Error: 'SelfID' is defined but never used.  no-unused-vars
5:40  Error: 'WebClient' is defined but never used.  no-unused-vars
7:8  Error: 'modelAliases' is defined but never used.  no-unused-vars
8:10  Error: 'ceramicCoreFactory' is defined but never used.  no-unused-vars
8:30  Error: 'CERAMIC_TESTNET' is defined but never used.  no-unused-vars
8:47  Error: 'CERAMIC_TESTNET_NODE_URL' is defined but never used.  no-unused-vars
9:10  Error: 'useHistory' is defined but never used.  no-unused-vars
10:8  Error: 'PhoneNumberInput' is defined but never used.  no-unused-vars
13:10  Error: 'getNetwork' is defined but never used.  no-unused-vars
20:10  Error: 'imageURL' is assigned a value but never used.  no-unused-vars
28:9  Error: 'countryOptions' is assigned a value but never used.  no-unused-vars
62:6  Warning: React Hook useEffect has a missing dependency: 'setValue'. Either include it or remove the dependency array.  react-hooks/exhaustive-deps
64:9  Error: 'onFileChange' is assigned a value but never used.  no-unused-vars

./pages/profile/edit-profile.js
15:10  Error: 'EthereumAuthProvider' is defined but never used.  no-unused-vars
15:32  Error: 'SelfID' is defined but never used.  no-unused-vars
15:40  Error: 'WebClient' is defined but never used.  no-unused-vars
18:8  Error: 'modelAliases' is defined but never used.  no-unused-vars
19:10  Error: 'ceramicCoreFactory' is defined but never used.  no-unused-vars
19:30  Error: 'CERAMIC_TESTNET' is defined but never used.  no-unused-vars
19:47  Error: 'CERAMIC_TESTNET_NODE_URL' is defined but never used.  no-unused-vars
26:20  Error: 'targetNetwork' is assigned a value but never used.  no-unused-vars
69:6  Warning: React Hook useEffect has a missing dependency: 'setValue'. Either include it or remove the dependency array.  react-hooks/exhaustive-deps
108:13  Error: 'refs' is assigned a value but never used.  no-unused-vars
164:15  Warning: Image elements must have an alt prop, either with meaningful text, or an empty string for decorative images.  jsx-a11y/alt-text
179:15  Warning: Image elements must have an alt prop, either with meaningful text, or an empty string for decorative images.  jsx-a11y/alt-text

./pages/profile/edit-public-profile.js
9:3  Error: 'Image' is defined but never used.  no-unused-vars
17:3  Error: 'IconButton' is defined but never used.  no-unused-vars
19:17  Error: 'useCallback' is defined but never used.  no-unused-vars
21:10  Error: 'EthereumAuthProvider' is defined but never used.  no-unused-vars
21:32  Error: 'SelfID' is defined but never used.  no-unused-vars
21:40  Error: 'WebClient' is defined but never used.  no-unused-vars
24:8  Error: 'modelAliases' is defined but never used.  no-unused-vars
25:10  Error: 'ceramicCoreFactory' is defined but never used.  no-unused-vars
25:30  Error: 'CERAMIC_TESTNET' is defined but never used.  no-unused-vars
25:47  Error: 'CERAMIC_TESTNET_NODE_URL' is defined but never used.  no-unused-vars
29:11  Error: 'address' is assigned a value but never used.  no-unused-vars
29:20  Error: 'targetNetwork' is assigned a value but never used.  no-unused-vars
31:10  Error: 'imageURL' is assigned a value but never used.  no-unused-vars
31:20  Error: 'setImageURL' is assigned a value but never used.  no-unused-vars
32:10  Error: 'backgroundURL' is assigned a value but never used.  no-unused-vars
32:25  Error: 'setBackgroundURL' is assigned a value but never used.  no-unused-vars
33:9  Error: 'image' is assigned a value but never used.  no-unused-vars
34:9  Error: 'background' is assigned a value but never used.  no-unused-vars
79:6  Warning: React Hook useEffect has a missing dependency: 'setValue'. Either include it or remove the dependency array.  react-hooks/exhaustive-deps
97:11  Error: 'me' is assigned a value but never used.  no-unused-vars

./components/Account.jsx
58:13  Error: 'result' is assigned a value but never used.  no-unused-vars

./components/DevUI.jsx
2:10  Error: 'Row' is defined but never used.  no-unused-vars
2:15  Error: 'Col' is defined but never used.  no-unused-vars
2:20  Error: 'Button' is defined but never used.  no-unused-vars
3:19  Error: 'Ramp' is defined but never used.  no-unused-vars
3:25  Error: 'GasGauge' is defined but never used.  no-unused-vars
3:35  Error: 'Faucet' is defined but never used.  no-unused-vars
4:10  Error: 'NETWORKS' is defined but never used.  no-unused-vars

./components/Faucet.jsx
81:5  Warning: React Hook useCallback has unnecessary dependencies: 'ensProvider' and 'onChange'. Either exclude them or remove the dependency array.  react-hooks/exhaustive-deps

./components/L2Bridge.jsx
28:23  Error: 'setEnvironment' is assigned a value but never used.  no-unused-vars
59:6  Warning: React Hook useEffect has missing dependencies: 'activeConfig.L1' and 'activeConfig.L2'. Either include them or remove the dependency array.  react-hooks/exhaustive-deps
159:9  Error: 'onReset' is assigned a value but never used.  no-unused-vars

./components/Swap.jsx
48:3  Error: Unreachable code.  no-unreachable
124:6  Warning: React Hook useEffect has missing dependencies: '_tokenListUri' and 'activeChainId'. Either include them or remove the dependency array.  react-hooks/exhaustive-deps
142:16  Error: 'Promise' is not defined.  no-undef
185:6  Warning: React Hook useEffect has a missing dependency: 'getTrades'. Either include it or remove the dependency array.  react-hooks/exhaustive-deps
195:6  Warning: React Hook useEffect has a missing dependency: 'exact'. Either include it or remove the dependency array.  react-hooks/exhaustive-deps
430:11  Warning: Do not use <img>. Use Image from 'next/image' instead. See https://nextjs.org/docs/messages/no-img-element.  @next/next/no-img-element
440:11  Warning: Do not use <img>. Use Image from 'next/image' instead. See https://nextjs.org/docs/messages/no-img-element.  @next/next/no-img-element
465:11  Warning: Do not use <img>. Use Image from 'next/image' instead. See https://nextjs.org/docs/messages/no-img-element.  @next/next/no-img-element
488:17  Warning: Do not use <img>. Use Image from 'next/image' instead. See https://nextjs.org/docs/messages/no-img-element.  @next/next/no-img-element
561:17  Warning: Do not use <img>. Use Image from 'next/image' instead. See https://nextjs.org/docs/messages/no-img-element.  @next/next/no-img-element

./components/ThemeSwitch.jsx
8:35  Error: 'status' is assigned a value but never used.  no-unused-vars

./components/cards/MediaCard.jsx
1:17  Error: 'useCallback' is defined but never used.  no-unused-vars
1:30  Error: 'useContext' is defined but never used.  no-unused-vars
3:37  Error: 'Code' is defined but never used.  no-unused-vars
6:3  Error: 'Popover' is defined but never used.  no-unused-vars
7:3  Error: 'PopoverTrigger' is defined but never used.  no-unused-vars
11:3  Error: 'PopoverContent' is defined but never used.  no-unused-vars
12:3  Error: 'PopoverArrow' is defined but never used.  no-unused-vars
13:3  Error: 'PopoverCloseButton' is defined but never used.  no-unused-vars
14:3  Error: 'PopoverHeader' is defined but never used.  no-unused-vars
17:3  Error: 'SimpleGrid' is defined but never used.  no-unused-vars
19:27  Error: 'InfoIcon' is defined but never used.  no-unused-vars
28:10  Error: 'Web3Context' is defined but never used.  no-unused-vars
42:3  Error: 'primaryActionOnClick' is defined but never used.  no-unused-vars
44:3  Error: 'secondaryActionOnClick' is defined but never used.  no-unused-vars
45:3  Error: 'secondaryAction' is defined but never used.  no-unused-vars
52:9  Error: 'isValidRecipient' is assigned a value but never used.  no-unused-vars
82:13  Error: 'receipt' is assigned a value but never used.  no-unused-vars

./components/inputs/PhoneNumberInput.jsx
7:85  Error: 'setValue' is defined but never used.  no-unused-vars

./components/layout/HomeActions.jsx
2:10  Error: 'Box' is defined but never used.  no-unused-vars
9:9  Error: 'handleJoinAsRecruiter' is assigned a value but never used.  no-unused-vars
16:9  Error: 'handleRouteChange' is assigned a value but never used.  no-unused-vars

To run tests, you can do:

npx eslint --fix .

OR

npx next lint

@QEDK QEDK added the enhancement New feature or request label Nov 29, 2021
@QEDK QEDK requested a review from Cali93 November 29, 2021 16:23
Copy link
Contributor

@Cali93 Cali93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@QEDK QEDK marked this pull request as draft November 29, 2021 21:02
@Dhaiwat10
Copy link
Member

Yo @QEDK I have fixed most if not all of these errors in #86. Mind if I add the changes you did to that branch and create a PR?

@QEDK
Copy link
Member Author

QEDK commented Nov 30, 2021

Yo @QEDK I have fixed most if not all of these errors in #86. Mind if I add the changes you did to that branch and create a PR?

I see, can you merge that branch in this one? Should be effectively the same thing. 🤔

@Dhaiwat10
Copy link
Member

Yeah that'll do

Comment on lines 7 to 10
"no-console": "warn",
"no-undef": "warn",
"react-hooks/rules-of-hooks": "warn",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turned these rules down to 'warn' instead of 'error'.

@Dhaiwat10
Copy link
Member

I think we can merge

"no-restricted-syntax": "off",
"no-plusplus": "off",
"no-console": "warn",
"no-undef": "warn",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be an error as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the thing about no-undef is that it even complains about Promise being undefined, which is a global

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Dhaiwat10 Yeah, that can be resolved by adding the es6 parameter like this:

  env: {
    browser: true,
    es6: true
  },

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. What about the console.logs? I don't think throwing an error for them is a good idea

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything else is okay, just for no-undef :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@Dhaiwat10 Dhaiwat10 marked this pull request as ready for review November 30, 2021 20:39
@QEDK
Copy link
Member Author

QEDK commented Dec 1, 2021

@Dhaiwat10 I am just leaving this open so that we can merge #70 first (I have my attention on here too :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants