Skip to content

Commit

Permalink
chore: improve eslint (#6084)
Browse files Browse the repository at this point in the history
* chore: improve eslint

* revert: file

* fix: eslintrc
  • Loading branch information
septs authored Apr 14, 2022
1 parent 6286466 commit fd79d1b
Show file tree
Hide file tree
Showing 24 changed files with 45 additions and 31 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@
"lodash-unified": "1.0.2",
"react": "18.0.0",
"react-dom": "18.0.0",
"ses": "0.15.12",
"react-i18next": "^11.16.5",
"ses": "0.15.12",
"ts-results": "3.3.0",
"web3-core": "1.7.3",
"web3-core-method": "1.7.3"
},
"devDependencies": {
"@commitlint/cli": "^16.2.3",
"@commitlint/config-conventional": "^16.2.1",
"@dimensiondev/eslint-plugin": "^0.0.1-20220117062517-fd3cb01",
"@dimensiondev/eslint-plugin": "^0.0.2-20220414093950-7d54c58",
"@dimensiondev/patch-package": "^6.5.0",
"@jest/globals": "^28.0.0-alpha.8",
"@magic-works/i18n-codegen": "^0.1.0",
Expand Down
18 changes: 11 additions & 7 deletions packages/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,19 @@
"unicorn/prefer-number-properties": "error",
"unicorn/relative-url-style": ["error", "always"],
"unicorn/throw-new-error": "error",
"@dimensiondev/no-jsx-template-literal": "error",
"@dimensiondev/no-locale-case": "error",
"@dimensiondev/array/no-implicit-sort": "error",
"@dimensiondev/browser/prefer-location-assign": "error",
"@dimensiondev/jsx/no-class-component": "error",
"@dimensiondev/jsx/no-template-literal": "error",
"@dimensiondev/no-number-constructor": "off",
"@dimensiondev/no-simple-string-interpolation": "off",
"@dimensiondev/no-simple-template-literal": "error",
"@dimensiondev/no-unneeded-to-string": "error",
"@dimensiondev/prefer-early-return": "error",
"@dimensiondev/prefer-location-assign": "error",
"@dimensiondev/unicode-specific-set": "error",
"@dimensiondev/string/no-interpolation": "off",
"@dimensiondev/string/no-locale-case": "error",
"@dimensiondev/string/no-simple-template-literal": "error",
"@dimensiondev/string/no-unneeded-to-string": "error",
"@dimensiondev/type/no-instanceof-wrapper": "error",
"@dimensiondev/type/no-wrapper-type-reference": "error",
"@dimensiondev/unicode/specific-set": "error",
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/no-base-to-string": "off",
"@typescript-eslint/no-for-in-array": "error",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable @dimensiondev/unicode-specific-set */
/* eslint-disable @dimensiondev/unicode/specific-set */
import { MenuItem } from '@mui/material'
import { useLanguage } from '../api'
import { Services } from '../../../API'
Expand Down
2 changes: 1 addition & 1 deletion packages/dashboard/src/utils/checkLengthExceed.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint @dimensiondev/unicode-specific-set: ["error", { "only": "code" }] */
/* eslint @dimensiondev/unicode/specific-set: ["error", { "only": "code" }] */
export const PERSONA_NAME_MAX_LENGTH = 24
export function isPersonaNameLengthValid(value: string) {
// Array.from(string).length is not equal to string.length.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint @dimensiondev/unicode-specific-set: ["error", { "only": "code" }] */
/* eslint @dimensiondev/unicode/specific-set: ["error", { "only": "code" }] */
import { encodeText, encodeArrayBuffer } from '@dimensiondev/kit'
import { Ok, Option, Result } from 'ts-results'
import type { PayloadWellFormed, Signature } from '..'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint @dimensiondev/unicode-specific-set: ["error", { "only": "code" }] */
/* eslint @dimensiondev/unicode/specific-set: ["error", { "only": "code" }] */
import { EC_Key, PayloadParseResult, EC_KeyCurveEnum, Signature } from '../payload'
import { CryptoException, PayloadException } from '../types'
import { Result, Ok, Some } from 'ts-results'
Expand Down
2 changes: 1 addition & 1 deletion packages/encryption/src/payload_internal/version-39.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint @dimensiondev/unicode-specific-set: ["error", { "only": "code" }] */
/* eslint @dimensiondev/unicode/specific-set: ["error", { "only": "code" }] */
import { parse40 } from './version-40'
import { PayloadException } from '../types'
import type { PayloadParserResult } from '.'
Expand Down
2 changes: 1 addition & 1 deletion packages/encryption/src/payload_internal/version-40.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint @dimensiondev/unicode-specific-set: ["error", { "only": "code" }] */
/* eslint @dimensiondev/unicode/specific-set: ["error", { "only": "code" }] */
import type { PayloadParseResult, Signature } from '../payload'
import { Ok } from 'ts-results'
import { PayloadException } from '../types'
Expand Down
2 changes: 1 addition & 1 deletion packages/mask/background/services/crypto/comment.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { encodeArrayBuffer, decodeText, decodeArrayBuffer, encodeText } from '@dimensiondev/kit'
import type { AESCryptoKey } from '@masknet/shared-base'

// eslint-disable-next-line @dimensiondev/unicode-specific-set
// eslint-disable-next-line @dimensiondev/unicode/specific-set
// * Payload format: 🎶2/4|encrypted_comment:||
export async function encryptComment(postIV: Uint8Array, postContent: string, comment: string): Promise<string> {
const key = await getCommentKey(postIV, postContent)
Expand Down
2 changes: 1 addition & 1 deletion packages/mask/src/plugins/ArtBlocks/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export interface Token {
tokenId: BigInt
tokenId: bigint
contract: Contract
project: Project
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ export function ExchangeTokenPanel(props: ExchangeTokenPanelProps) {
isSell,
dataIndex,
exchangeToken?.address,
// eslint-disable-next-line @dimensiondev/array/no-implicit-sort
excludeTokensAddress.sort().join(),
// eslint-disable-next-line @dimensiondev/array/no-implicit-sort
selectedTokensAddress.sort().join(),
])
// #endregion
Expand Down
1 change: 1 addition & 0 deletions packages/mask/src/plugins/ITO/SNSAdaptor/SwapDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export function SwapDialog(props: SwapDialogProps) {
pickToken,
exchangeTokens
.map((x) => x.address)
// eslint-disable-next-line @dimensiondev/array/no-implicit-sort
.sort()
.join(),
])
Expand Down
1 change: 1 addition & 0 deletions packages/mask/src/plugins/Pets/SNSAdaptor/Drag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ interface DraggableProps {
}

// TODO: move to function components
// eslint-disable-next-line @dimensiondev/jsx/no-class-component -- TODO: need refactor
class Draggable extends React.PureComponent<React.PropsWithChildren<DraggableProps>> {
ref = React.createRef<HTMLDivElement | null>()
mouseMoveFuc = this.onMouseMove.bind(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export function useCurrentDataProvider(availableDataProviders: DataProvider[]) {
setDataProvider(
availableDataProviders.includes(currentDataProvider) ? currentDataProvider : availableDataProviders[0],
)
}, [availableDataProviders.sort().join(), currentDataProvider])
}, [
// eslint-disable-next-line @dimensiondev/array/no-implicit-sort
availableDataProviders.sort().join(),
currentDataProvider,
])
return dataProvider
}
6 changes: 3 additions & 3 deletions packages/mask/src/plugins/UnlockProtocol/Services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface verifyHolderResponse {
}[]
}

const verifyHolder = async <verifyHolderResponse>(_lockAddress: String, _holder: String, _chain: number) => {
const verifyHolder = async <verifyHolderResponse>(_lockAddress: string, _holder: string, _chain: number) => {
const query = gql`
query keyHolders($address: String!) {
keyHolders(where: { address: $address }) {
Expand Down Expand Up @@ -59,7 +59,7 @@ const verifyActiveLock = (data: { lock: string; address: string; chain: number }
})
}

export const verifyPurchase = async (_userAddress: String, _lockAddress: String, _lockChain: number) => {
export const verifyPurchase = async (_userAddress: string, _lockAddress: string, _lockChain: number) => {
const query = gql`
query locks($address: String!) {
locks(where: { address: $address }) {
Expand Down Expand Up @@ -87,7 +87,7 @@ export const verifyPurchase = async (_userAddress: String, _lockAddress: String,
return flag
}

export const getLocks = async <UnlockLocks>(_address1: String) => {
export const getLocks = async <UnlockLocks>(_address1: string) => {
const query = gql`
query lockManager($address: String!) {
lockManagers(where: { address: $address }) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint @dimensiondev/unicode-specific-set: ["error", { "only": "code" }] */
/* eslint @dimensiondev/unicode/specific-set: ["error", { "only": "code" }] */
import type { PostInfo } from '@masknet/plugin-infra/content-script'
import { injectPostInspectorDefault } from '../../../social-network/defaults/inject/PostInspector'
import { twitterEncoding } from '../encoding'
Expand Down
2 changes: 1 addition & 1 deletion packages/mask/src/utils/getTextUILength.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint @dimensiondev/unicode-specific-set: ["error", { "only": "code" }] */
/* eslint @dimensiondev/unicode/specific-set: ["error", { "only": "code" }] */
export function getTextUILength(text: string) {
return Array.from(text).reduce((acc, char) => acc + getCharUILength(char), 0)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/mask/src/utils/type-transform/Payload.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint @dimensiondev/unicode-specific-set: ["error", { "only": "code" }] */
/* eslint @dimensiondev/unicode/specific-set: ["error", { "only": "code" }] */
import type { SocialNetwork } from '../../social-network'
import { isEnvironment, Environment } from '@dimensiondev/holoflows-kit'
import { i18n } from '../../../shared-ui/locales_legacy'
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-infra/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint @dimensiondev/unicode-specific-set: ["error", { "only": "code" }] */
/* eslint @dimensiondev/unicode/specific-set: ["error", { "only": "code" }] */
import type React from 'react'
import type { Option, Result } from 'ts-results'
import type { TypedMessage } from '@masknet/typed-message'
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/example/src/SNSAdaptor/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint @dimensiondev/unicode-specific-set: ["error", { "only": "code" }] */
/* eslint @dimensiondev/unicode/specific-set: ["error", { "only": "code" }] */
import type { Plugin } from '@masknet/plugin-infra'
import { base } from '../base'

Expand Down
1 change: 1 addition & 0 deletions packages/shared-base/src/Identifier/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export abstract class Identifier {
static IdentifiersToString(a: Identifier[], isOrderImportant = false) {
const ax = a.map((x) => x.toText())
if (!isOrderImportant) {
// eslint-disable-next-line @dimensiondev/array/no-implicit-sort
ax.sort()
}
return ax.join(',')
Expand Down
1 change: 1 addition & 0 deletions packages/shared/src/UI/components/ERC20TokenList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export const ERC20TokenList = memo<ERC20TokenListProps>((props) => {
assetsLoading,
assets
.map((x) => x.token.address)
// eslint-disable-next-line @dimensiondev/array/no-implicit-sort
.sort()
.join(),
])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export function useERC20TokensDetailedFromTokenLists(
const { fetchERC20TokensFromTokenLists } = useWeb3Context()
const { value: tokensFromList = EMPTY_LIST, ...asyncResult } = useAsyncRetry(
async () => (!lists || lists.length === 0 ? [] : fetchERC20TokensFromTokenLists(lists, chainId)),
// eslint-disable-next-line @dimensiondev/array/no-implicit-sort
[chainId, lists?.sort().join()],
)
// #endregion
Expand Down
9 changes: 4 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fd79d1b

Please sign in to comment.