Skip to content

Commit

Permalink
fix: eslint
Browse files Browse the repository at this point in the history
- enable eslint typescript rules instead of default
- remove namespace as it is not recommended anymore
  • Loading branch information
bc-micah authored and kris-liu-smile committed Jul 22, 2022
1 parent f2459b6 commit 8018f84
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 25 deletions.
1 change: 1 addition & 0 deletions apps/storefront/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
},
"dependencies": {
"@b3/lang": "*",
"@b3/global-b3": "*",
"@emotion/cache": "^11.9.3",
"@emotion/react": "^11.9.3",
"@emotion/styled": "^11.9.3",
Expand Down
5 changes: 4 additions & 1 deletion apps/storefront/src/components/form/B3Picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import Form from './ui'

export const B3Picker = ({
control,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
errors,
...rest
} : Form.B3UIProps) => {
Expand Down Expand Up @@ -63,7 +64,9 @@ export const B3Picker = ({
{...fieldsProps}
render={({
field: {
ref, ...rest
// eslint-disable-next-line @typescript-eslint/no-unused-vars
ref,
...rest
},
}) => (
<DesktopDatePicker
Expand Down
1 change: 1 addition & 0 deletions apps/storefront/src/pages/registered/Registered.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ export default function Registered(props: RegisteredProps) {
}
setLogo(registerLogo)
} catch (e) {
// eslint-disable-next-line no-console
console.log(e)
}
}
Expand Down
1 change: 1 addition & 0 deletions apps/storefront/src/pages/registered/RegisteredAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export default function RegisteredAccount(props: RegisteredAccountProps) {
},
})
}).catch((err: any) => {
// eslint-disable-next-line no-console
console.log(err)
dispatch({
type: 'loading',
Expand Down
4 changes: 3 additions & 1 deletion apps/storefront/src/pages/registered/RegisteredBCToB2B.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ export default function RegisteredBCToB2B() {
}
setLogo(registerLogo)
} catch (e) {
console.log(e)
// eslint-disable-next-line no-console
console.error(e)
}
}

Expand Down Expand Up @@ -219,6 +220,7 @@ export default function RegisteredBCToB2B() {

const handleNext = (event: MouseEvent) => {
handleSubmit(async (data: CustomFieldItems) => {
// eslint-disable-next-line no-console
console.log(data, 'data')
})(event)
}
Expand Down
1 change: 1 addition & 0 deletions apps/storefront/src/shared/service/request/base.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import globalB3 from '@b3/global-b3'

// eslint-disable-next-line no-console
console.log(globalB3, 'globalB3')

const B2B_BASIC_URL = (window as any)?.b3?.setting?.B2B_URL || import.meta.env.VITE_B2B_BASIC_URL
Expand Down
4 changes: 3 additions & 1 deletion packages/eslint-config-b3/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = {
extends: ['react', 'airbnb'],
plugins: ['@typescript-eslint'],
parser: '@typescript-eslint/parser',
rules: {
'no-shadow': 0,
Expand Down Expand Up @@ -45,7 +46,8 @@ module.exports = {
ignore: ['antd-mobile'],
},
],
'no-unused-vars': 1,
'no-unused-vars': 0,
'@typescript-eslint/no-unused-vars': 1,
'consistent-return': 0,
'react/jsx-no-useless-fragment': 0,
'implicit-arrow-linebreak': 0,
Expand Down
8 changes: 2 additions & 6 deletions packages/eslint-config-b3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,19 @@
"name": "eslint-config-b3",
"version": "0.0.0",
"main": "index.js",
"dependencies": {
"eslint-config-react": "^1.1.7",
"eslint-plugin-react": "^7.30.1"
},
"publishConfig": {
"access": "public"
},
"devDependencies": {
"eslint-config-react": "^1.1.7",
"eslint-plugin-react": "^7.30.1",
"@typescript-eslint/eslint-plugin": "^5.30.4",
"@typescript-eslint/parser": "^5.30.4",
"eslint": "^8.2.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react": "^7.28.0",
"eslint-plugin-react-hooks": "^4.3.0",
"typescript": "^4.6.3"
}
}

6 changes: 4 additions & 2 deletions packages/lang/context/LangContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import {
Reducer,
} from 'react'

import B3Utils from '@b3/utils'
import {
LangUtils,
} from '@b3/utils'

interface LangContextState {
lang: string,
Expand All @@ -20,7 +22,7 @@ interface LangContextAction {
}

const initState: LangContextState = {
lang: B3Utils.Lang.getBrowserLanguage(),
lang: LangUtils.getBrowserLanguage(),
}

export const LangContext: Context<{
Expand Down
2 changes: 1 addition & 1 deletion packages/lang/useB3Lang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
} from 'react-intl'

export interface B3Lang {
(id: string, options?: {}): string
(id: string, options?: Record<string, never>): string
}

export const useB3Lang = () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/utils/Lang/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export namespace Lang {
export const getBrowserLanguage = () => {
export const Lang = {
getBrowserLanguage: () => {
const lang = navigator.language
return lang.substring(0, 2)
}
},
}
11 changes: 1 addition & 10 deletions packages/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
// FIXME: no-unused-vars, disabled for export import X = vars
/* eslint-disable no-unused-vars */

import {
export {
Lang as LangUtils,
} from './Lang'

namespace B3Utils {
export import Lang = LangUtils
}

export default B3Utils

0 comments on commit 8018f84

Please sign in to comment.