-
Notifications
You must be signed in to change notification settings - Fork 397
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
81e1a58
commit 841c872
Showing
32 changed files
with
1,632 additions
and
163 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
const isDev = process.env.NODE_ENV !== 'production'; | ||
const jsRules = { | ||
// eslint-disable-next-line global-require | ||
'prettier/prettier': ['error', require('./.prettierrc.js')], | ||
'no-unused-vars': 'off', | ||
'no-use-before-define': 'off', | ||
'no-shadow': 'off', | ||
'import/no-extraneous-dependencies': 'off', | ||
'no-restricted-exports': 'off', | ||
'func-names': 'off', | ||
'class-methods-use-this': 'off', | ||
'import/extensions': 'off', | ||
'react/function-component-definition': 'off', | ||
'react/jsx-props-no-spreading': 'off', | ||
'react/no-unused-prop-types': 'off', | ||
'react/no-unstable-nested-components': 'warn', | ||
'react/jsx-no-useless-fragment': ['error', { allowExpressions: true }], | ||
'react-hooks/exhaustive-deps': [ | ||
'warn', | ||
{ | ||
'additionalHooks': '(usePromiseResult|useAsyncCall)', | ||
}, | ||
], | ||
'global-require': 'off', | ||
'import/no-unresolved': 'off', // tsc can check this | ||
'no-promise-executor-return': 'off', | ||
'default-param-last': 'off', | ||
'import/no-cycle': 'error', | ||
// 'no-console': [isDev ? 'warn' : 'off'], | ||
}; | ||
const tsRules = { | ||
'@typescript-eslint/default-param-last': 'off', | ||
'@typescript-eslint/consistent-type-imports': [ | ||
'error', | ||
{ disallowTypeAnnotations: false }, | ||
], | ||
'@typescript-eslint/no-var-requires': 'off', | ||
'@typescript-eslint/no-unused-vars': [isDev ? 'warn' : 'error'], | ||
'@typescript-eslint/no-use-before-define': ['error'], | ||
'@typescript-eslint/no-shadow': ['error'], | ||
'@typescript-eslint/explicit-module-boundary-types': 'off', | ||
'@typescript-eslint/ban-ts-comment': 'off', | ||
'@typescript-eslint/no-unsafe-assignment': 'off', | ||
'@typescript-eslint/no-unsafe-argument': 'off', | ||
'sort-imports': [ | ||
'error', | ||
{ | ||
'ignoreMemberSort': false, | ||
'ignoreDeclarationSort': true, | ||
}, | ||
], | ||
'import/order': [ | ||
'warn', | ||
{ | ||
'groups': [ | ||
'builtin', | ||
'internal', | ||
'index', | ||
'external', | ||
'parent', | ||
'sibling', | ||
'object', | ||
'type', | ||
], | ||
'pathGroups': [ | ||
{ | ||
'pattern': 'react', | ||
'group': 'builtin', | ||
'position': 'before', | ||
}, | ||
{ | ||
'pattern': '@onekeyhq/**', | ||
'group': 'external', | ||
'position': 'after', | ||
}, | ||
], | ||
'alphabetize': { | ||
'order': 'asc', | ||
'caseInsensitive': true, | ||
}, | ||
'newlines-between': 'always', | ||
'pathGroupsExcludedImportTypes': ['builtin'], | ||
'warnOnUnassignedImports': true, | ||
}, | ||
], | ||
'no-restricted-syntax': [ | ||
'error', | ||
{ | ||
selector: | ||
"ImportDeclaration[source.value='react'][specifiers.0.type='ImportDefaultSpecifier']", | ||
message: 'Default React import not allowed', | ||
}, | ||
], | ||
}; | ||
module.exports = { | ||
ignorePatterns: [ | ||
'packages/components/src/Icon/*', | ||
'packages/desktop/public/static/js-sdk/*', | ||
// 临时忽略以下目录的检查,迭代后会逐步开启 | ||
'packages/app', | ||
'packages/blockchain-libs', | ||
'packages/kit/src/store', | ||
'packages/desktop', | ||
'packages/engine', | ||
'packages/ext', | ||
'packages/kit-bg', | ||
'packages/shared', | ||
'packages/web', | ||
'packages/web-embed', | ||
], | ||
env: { | ||
browser: true, | ||
es6: true, | ||
webextensions: true, | ||
serviceworker: true, | ||
worker: true, | ||
}, | ||
overrides: [ | ||
{ | ||
files: ['*.js', '*.jsx', '*.text-js'], | ||
extends: ['wesbos'], | ||
rules: { | ||
...jsRules, | ||
}, | ||
}, | ||
{ | ||
files: ['*.ts', '*.tsx'], | ||
extends: ['wesbos/typescript'], | ||
rules: { | ||
...jsRules, | ||
...tsRules, | ||
}, | ||
}, | ||
// test files rules must be at LAST | ||
{ | ||
files: ['test/**/*.js', 'test/**/*.ts', '**/*.test.ts'], | ||
extends: ['plugin:jest/recommended'], | ||
env: { | ||
jest: true, | ||
}, | ||
rules: { | ||
'jest/expect-expect': 'off', | ||
'jest/no-disabled-tests': 'off', | ||
'jest/no-conditional-expect': 'off', | ||
'jest/valid-title': 'off', | ||
'jest/no-interpolation-in-snapshots': 'off', | ||
'jest/no-export': 'off', | ||
'@typescript-eslint/no-unsafe-member-access': 'off', | ||
'@typescript-eslint/no-use-before-define': 'off', | ||
'@typescript-eslint/no-unsafe-assignment': 'off', | ||
'@typescript-eslint/no-unsafe-call': 'off', | ||
}, | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
'**/*': 'prettier --write --ignore-unknown', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
singleQuote: true, | ||
trailingComma: 'all', | ||
quoteProps: 'preserve', // let eslint fix quoteProps | ||
// "printWidth": 120, | ||
// "tabWidth": 8, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* eslint-disable no-var,vars-on-top */ | ||
import type { LocaleIds } from '@onekeyhq/components/src/locale'; | ||
import type { IBackgroundApi } from '@onekeyhq/kit-bg/src/IBackgroundApi'; | ||
|
||
import type { JsBridgeBase } from '@onekeyfe/cross-inpage-provider-core'; | ||
import type { ProviderPrivate } from '@onekeyfe/onekey-private-provider'; | ||
import type { EnhancedStore } from '@reduxjs/toolkit'; | ||
import type WebView from 'react-native-webview'; | ||
|
||
declare const self: ServiceWorkerGlobalScope; | ||
|
||
type IWindowOneKeyHub = { | ||
$private: ProviderPrivate; | ||
}; | ||
declare global { | ||
// eslint-disable-next-line | ||
// var onekey: WindowOneKey; | ||
|
||
var $appIsReduxReady: boolean; | ||
var $onekey: IWindowOneKeyHub; | ||
var $backgroundApiProxy: IBackgroundApi; | ||
var $backgroundApi: IBackgroundApi; | ||
|
||
var $$navigationShortcuts: any; | ||
var $$simpleDb: any; | ||
var $$appEventBus: any; | ||
var $$appUIEventBus: any; | ||
var $$appStore: EnhancedStore; | ||
var $$appDispatch: any; | ||
var $$appSelector: any; | ||
var $$appStorage: any; | ||
var $$platformEnv: any; | ||
var $$debugLogger: any; | ||
var $$localforage: any; | ||
var $$navigationActions: any; | ||
var $$wcTransports: any; | ||
var $$onekeyDisabledSetTimeout: boolean | undefined; | ||
var $$onekeyDisabledSetInterval: boolean | undefined; | ||
var $$onekeyPerfTrace: | ||
| { | ||
log: (options: { name: string; payload?: any }) => void; | ||
timeline: Array<{ | ||
time: string; | ||
elapsed: number; | ||
lag: number; | ||
name: string; | ||
payload?: any; | ||
}>; | ||
} | ||
| undefined; | ||
|
||
var chrome: typeof chrome; // chrome api | ||
var browser: typeof chrome; // firefox api | ||
|
||
interface Window { | ||
// All website | ||
ethereum: any; | ||
web3: any; | ||
$onekey: IWindowOneKeyHub; | ||
|
||
// Native App webview content | ||
ReactNativeWebView: WebView; | ||
|
||
// Desktop internal (main,renderer) | ||
// ONEKEY_DESKTOP_GLOBALS: Record<any, any>; | ||
|
||
// Ext internal (ui,background,contentScript) | ||
extJsBridgeUiToBg: JsBridgeBase; | ||
extJsBridgeOffscreenToBg: JsBridgeBase; | ||
ONEKEY_DESKTOP_DEEP_LINKS: any[]; | ||
} | ||
} | ||
|
||
declare global { | ||
namespace FormatjsIntl { | ||
interface Message { | ||
ids: LocaleIds; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '@onekeyfe/cross-inpage-provider-types'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
/* eslint-disable @typescript-eslint/no-unused-vars, import/first, import/order */ | ||
import '@onekeyhq/shared/src/polyfills'; | ||
|
||
console.log('polyfills----') | ||
console.log('polyfills----'); | ||
import { KitProvider } from '@onekeyhq/kit'; | ||
|
||
console.log('KitProvider', KitProvider) | ||
console.log('KitProvider', KitProvider); | ||
|
||
export default KitProvider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.