diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 9f3ecb2a..00000000 --- a/.eslintignore +++ /dev/null @@ -1,8 +0,0 @@ -node_modules/* -dist/* -web-dev-server.config.js -tsup.config.ts -**/test/** -vite.config.ts -scripts/prepare-packages.ts -tests/e2e diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 28944eec..00000000 --- a/.eslintrc.js +++ /dev/null @@ -1,3 +0,0 @@ -const Config = require('@vechain/repo-config'); - -module.exports = Config.EslintLibrary; diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 00000000..c9e3ec07 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,17 @@ +import tseslint from 'typescript-eslint'; + +export default tseslint.config({ + ignores: ['**/*.config.ts', 'dist/**'], + extends: [...tseslint.configs.recommended], + files: ['**/*.{ts,tsx}'], + rules: { + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/ban-ts-comment': 'off', + 'no-console': ['error', { allow: ['error'] }], + 'eslint-comments/no-unused-disable': 'off', + '@typescript-eslint/no-unused-vars': [ + 'error', + { argsIgnorePattern: '^_' }, + ], + }, +}); diff --git a/examples/sample-angular-app/.eslintrc.js b/examples/sample-angular-app/.eslintrc.js deleted file mode 100644 index 4185cb4f..00000000 --- a/examples/sample-angular-app/.eslintrc.js +++ /dev/null @@ -1,9 +0,0 @@ -const Config = require('@vechain/repo-config'); - -module.exports = { - ...Config.EslintLibrary, - rules: { - 'no-constant-binary-expression': 'off', - 'eslint-comments/disable-enable-pair': 'off', - }, -}; diff --git a/examples/sample-angular-app/package.json b/examples/sample-angular-app/package.json index de6368ce..0180d63c 100644 --- a/examples/sample-angular-app/package.json +++ b/examples/sample-angular-app/package.json @@ -8,7 +8,6 @@ "clean": "rm -rf dist .turbo .angular", "dev": "ng serve --port 5004", "gh-pages-build": "ng build --configuration development --base-href '/vechain-dapp-kit/angular/'", - "lint": "eslint src --ext .js,.jsx,.ts,.tsx", "preview": "ng serve --port 5004", "purge": "yarn clean; rm -rf node_modules", "watch": "ng build --watch --configuration development" @@ -51,7 +50,6 @@ "@angular/compiler-cli": "^16.1.0", "@types/jasmine": "~3.10.0", "@types/node": "^12.11.1", - "@vechain/repo-config": "https://github.com/vechain/repo-config#v0.0.1", "jasmine-core": "~4.0.0", "karma": "~6.3.0", "karma-chrome-launcher": "~3.1.0", diff --git a/examples/sample-angular-app/src/app/app.component.ts b/examples/sample-angular-app/src/app/app.component.ts index 46a68bb1..86b9c38f 100644 --- a/examples/sample-angular-app/src/app/app.component.ts +++ b/examples/sample-angular-app/src/app/app.component.ts @@ -26,7 +26,6 @@ export class AppComponent implements OnInit { const vechainDAppKitOptions = { nodeUrl: 'https://testnet.vechain.org/', - genesis: 'test', walletConnectOptions, usePersistence: true, }; diff --git a/examples/sample-angular-app/src/environments/environment.prod.ts b/examples/sample-angular-app/src/environments/environment.prod.ts index b931095f..3938526c 100644 --- a/examples/sample-angular-app/src/environments/environment.prod.ts +++ b/examples/sample-angular-app/src/environments/environment.prod.ts @@ -1,5 +1,4 @@ // eslint-disable @typescript-eslint/no-unsafe-assignment -// eslint-disable @typescript-eslint/no-unsafe-member-access // Packages import packageInfo from '../../package.json'; @@ -12,7 +11,6 @@ const baseUrl = scheme + host + port + path; export const environment = { production: true, - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access version: packageInfo.version, appName: 'EasyAngular', envName: 'prod', diff --git a/examples/sample-angular-app/src/environments/environment.ts b/examples/sample-angular-app/src/environments/environment.ts index 5244976c..1158e730 100644 --- a/examples/sample-angular-app/src/environments/environment.ts +++ b/examples/sample-angular-app/src/environments/environment.ts @@ -1,5 +1,4 @@ // eslint-disable @typescript-eslint/no-unsafe-assignment -// eslint-disable @typescript-eslint/no-unsafe-member-access // This file can be replaced during build by using the `fileReplacements` array. // `ng build` replaces `environment.ts` with `environment.prod.ts`. // The list of file replacements can be found in `angular.json`. @@ -18,7 +17,6 @@ const baseUrl = scheme + host + port + path; export const environment = { production: false, - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access version: packageInfo.version, appName: 'EasyAngular', envName: 'local', diff --git a/examples/sample-angular-app/src/main.ts b/examples/sample-angular-app/src/main.ts index 5d15c9f8..ae94c856 100644 --- a/examples/sample-angular-app/src/main.ts +++ b/examples/sample-angular-app/src/main.ts @@ -3,5 +3,4 @@ import { AppComponent } from './app/app.component'; bootstrapApplication(AppComponent, { providers: [], - // eslint-disable-next-line no-console }).catch((err) => console.error(err)); diff --git a/examples/sample-angular-app/src/polyfills.ts b/examples/sample-angular-app/src/polyfills.ts index 3db6b9bd..730b959b 100644 --- a/examples/sample-angular-app/src/polyfills.ts +++ b/examples/sample-angular-app/src/polyfills.ts @@ -1,5 +1,3 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -/* eslint-disable @typescript-eslint/no-unsafe-member-access */ /** * This file includes polyfills needed by Angular and is loaded before the app. * You can add your own extra polyfills to this file. @@ -55,6 +53,7 @@ import 'zone.js'; // Included with Angular CLI. import '@angular/localize/init'; (window as any).global = window; +// eslint-disable-next-line @typescript-eslint/no-require-imports global.Buffer = global.Buffer || require('buffer').Buffer; (window as any).process = { env: { DEBUG: undefined }, diff --git a/examples/sample-next-app/.eslintignore b/examples/sample-next-app/.eslintignore deleted file mode 100644 index 35e54460..00000000 --- a/examples/sample-next-app/.eslintignore +++ /dev/null @@ -1,2 +0,0 @@ -.eslintrc.js -tsconfig.json \ No newline at end of file diff --git a/examples/sample-next-app/package.json b/examples/sample-next-app/package.json index 3eb5fb0b..9a6baecf 100644 --- a/examples/sample-next-app/package.json +++ b/examples/sample-next-app/package.json @@ -23,7 +23,7 @@ "@types/node": "^20", "@types/react": "^18", "@types/react-dom": "^18", - "eslint": "^8", + "eslint": "^9.12.0", "eslint-config-next": "14.1.4", "typescript": "5.3.3" } diff --git a/examples/sample-react-app/.eslintrc.cjs b/examples/sample-react-app/.eslintrc.cjs deleted file mode 100644 index 74080493..00000000 --- a/examples/sample-react-app/.eslintrc.cjs +++ /dev/null @@ -1,18 +0,0 @@ -module.exports = { - root: true, - env: { browser: true, es2020: true }, - extends: [ - 'eslint:recommended', - 'plugin:@typescript-eslint/recommended', - 'plugin:react-hooks/recommended', - ], - ignorePatterns: ['dist', '.eslintrc.cjs'], - parser: '@typescript-eslint/parser', - plugins: ['react-refresh'], - rules: { - 'react-refresh/only-export-components': [ - 'warn', - { allowConstantExport: true }, - ], - }, -}; diff --git a/examples/sample-react-app/eslint.config.mjs b/examples/sample-react-app/eslint.config.mjs new file mode 100644 index 00000000..c9e3ec07 --- /dev/null +++ b/examples/sample-react-app/eslint.config.mjs @@ -0,0 +1,17 @@ +import tseslint from 'typescript-eslint'; + +export default tseslint.config({ + ignores: ['**/*.config.ts', 'dist/**'], + extends: [...tseslint.configs.recommended], + files: ['**/*.{ts,tsx}'], + rules: { + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/ban-ts-comment': 'off', + 'no-console': ['error', { allow: ['error'] }], + 'eslint-comments/no-unused-disable': 'off', + '@typescript-eslint/no-unused-vars': [ + 'error', + { argsIgnorePattern: '^_' }, + ], + }, +}); diff --git a/examples/sample-react-app/package.json b/examples/sample-react-app/package.json index 07469189..c1dd77c9 100644 --- a/examples/sample-react-app/package.json +++ b/examples/sample-react-app/package.json @@ -8,7 +8,7 @@ "clean": "rm -rf dist .turbo", "dev": "vite", "gh-pages-build": "tsc && vite build", - "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", + "lint": "eslint", "preview": "vite preview --mode=development", "purge": "yarn clean; rm -rf node_modules", "test": "vitest" @@ -29,7 +29,7 @@ "@typescript-eslint/eslint-plugin": "^6.10.0", "@typescript-eslint/parser": "^6.10.0", "@vitejs/plugin-react": "^4.2.0", - "eslint": "^8.53.0", + "eslint": "^9.12.0", "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-refresh": "^0.4.4", "react-test-renderer": "^18.2.0", diff --git a/examples/sample-react-app/src/App.tsx b/examples/sample-react-app/src/App.tsx index 752817e5..c7529a3a 100644 --- a/examples/sample-react-app/src/App.tsx +++ b/examples/sample-react-app/src/App.tsx @@ -3,30 +3,26 @@ import { useWallet, useWalletModal, } from '@vechain/dapp-kit-react'; +import { friendlyAddress } from '@vechain/dapp-kit-ui'; import { useEffect, useState } from 'react'; function App() { - const { account } = useWallet(); - const { open, onConnectionStatusChange } = useWalletModal(); + const { account, accountDomain, isAccountDomainLoading } = useWallet(); + + const { open } = useWalletModal(); const [buttonText, setButtonText] = useState('Connect Custom Button'); useEffect(() => { - const handleConnected = (address: string | null) => { - if (address) { - const formattedAddress = `${address.slice( - 0, - 6, - )}...${address.slice(-4)}`; - setButtonText(`Disconnect from ${formattedAddress}`); - } else { - setButtonText('Connect Custom Button'); - } - }; - - handleConnected(account); - - onConnectionStatusChange(handleConnected); - }, [account, onConnectionStatusChange]); + if (account) { + const addressOrDomain = + accountDomain && !isAccountDomainLoading + ? accountDomain + : friendlyAddress(account || ''); + setButtonText(`Disconnect from ${addressOrDomain}`); + } else { + setButtonText('Connect Custom Button'); + } + }, [account, accountDomain, isAccountDomainLoading]); return (