Skip to content

Commit

Permalink
fix portal eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
wow-sven authored Apr 28, 2024
1 parent 5c04f75 commit 14a357e
Show file tree
Hide file tree
Showing 108 changed files with 347 additions and 266 deletions.
335 changes: 108 additions & 227 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ module.exports = {
ignoreRestSiblings: true,
},
],
'padding-line-between-statements': [
'error',
{ blankLine: 'always', prev: 'directive', next: '*' },
],
},
overrides: [
{
Expand Down Expand Up @@ -107,242 +111,119 @@ module.exports = {
'@typescript-eslint/no-var-requires': 'off',
},
},
],
}

// overrides: [
// {
// files: ['sdk/typescript/src/**/*'],
// rules: {
// 'require-extensions/require-extensions': 'error',
// 'require-extensions/require-index': 'error',
// '@typescript-eslint/consistent-type-imports': ['error'],
// 'import/consistent-type-specifier-style': ['error', 'prefer-top-level'],
// 'import/no-cycle': ['error'],
// },
// },
// {
// files: ['apps/explorer/**/*'],
// rules: {
// 'import/order': [
// 'warn',
// {
// groups: [['builtin', 'external'], ['internal', 'parent', 'sibling', 'index'], 'type'],
// pathGroups: [
// {
// pattern: '{.,..}/**/*.css',
// group: 'type',
// position: 'after',
// },
// {
// pattern: '~/**',
// group: 'internal',
// },
// ],
// 'newlines-between': 'always',
// alphabetize: { order: 'asc' },
// warnOnUnassignedImports: true,
// },
// ],
// 'import/no-duplicates': ['error'],
// 'import/no-anonymous-default-export': 'off',
// '@typescript-eslint/consistent-type-imports': [
// 'error',
// {
// prefer: 'type-imports',
// disallowTypeAnnotations: true,
// fixStyle: 'inline-type-imports',
// },
// ],
// '@typescript-eslint/unified-signatures': 'error',
// '@typescript-eslint/parameter-properties': 'error',
// 'react/jsx-key': ['error', {}],

// 'react/boolean-prop-naming': 'off',
// 'react/jsx-boolean-value': ['error', 'never'],
{
files: ['rooch-portal-v1'],
rules: {
'import/no-duplicates': ['error'],
'import/no-anonymous-default-export': 'off',
'@typescript-eslint/consistent-type-imports': [
'error',
{
prefer: 'type-imports',
disallowTypeAnnotations: true,
fixStyle: 'inline-type-imports',
},
],
'@typescript-eslint/unified-signatures': 'error',
'@typescript-eslint/parameter-properties': 'error',
'react/jsx-key': ['error', {}],

// // Always use function declarations for components
// 'react/function-component-definition': [
// 'error',
// {
// namedComponents: 'function-declaration',
// unnamedComponents: 'arrow-function',
// },
// ],
// 'react/prefer-stateless-function': 'error',
// 'react/jsx-pascal-case': ['error', { allowAllCaps: true, allowNamespace: true }],
'react/boolean-prop-naming': 'off',
'react/jsx-boolean-value': ['error', 'never'],

// // Always self-close when applicable
// 'react/self-closing-comp': [
// 'error',
// {
// component: true,
// html: true,
// },
// ],
// 'react/void-dom-elements-no-children': 'error',
// Always use function declarations for components
'react/function-component-definition': [
'error',
{
namedComponents: 'function-declaration',
unnamedComponents: 'arrow-function',
},
],
'react/prefer-stateless-function': 'error',
'react/jsx-pascal-case': ['error', { allowAllCaps: true, allowNamespace: true }],

// // Use alternatives instead of danger
// 'react/no-danger': 'error',
// 'react/no-danger-with-children': 'error',
// Always self-close when applicable
'react/self-closing-comp': [
'error',
{
component: true,
html: true,
},
],
'react/void-dom-elements-no-children': 'error',

// // Accessibility requirements
// 'react/button-has-type': 'error',
// 'react/no-invalid-html-attribute': 'error',
// Use alternatives instead of danger
'react/no-danger': 'error',
'react/no-danger-with-children': 'error',

// // Security requirements
// 'react/jsx-no-script-url': 'error',
// 'react/jsx-no-target-blank': 'error',
// Accessibility requirements
'react/button-has-type': 'error',
'react/no-invalid-html-attribute': 'error',

// // Enforce consistent JSX spacing and syntax
// 'react/jsx-no-comment-textnodes': 'error',
// 'react/jsx-no-duplicate-props': 'error',
// 'react/jsx-no-undef': 'error',
// 'react/jsx-space-before-closing': 'off',
// Security requirements
'react/jsx-no-script-url': 'error',
'react/jsx-no-target-blank': 'error',

// // Avoid interpolation as much as possible
// 'react/jsx-curly-brace-presence': ['error', { props: 'never', children: 'never' }],
// Enforce consistent JSX spacing and syntax
'react/jsx-no-comment-textnodes': 'error',
'react/jsx-no-duplicate-props': 'error',
'react/jsx-no-undef': 'error',
'react/jsx-space-before-closing': 'off',

// // Always use shorthand fragments when applicable
// 'react/jsx-fragments': ['error', 'syntax'],
// 'react/jsx-no-useless-fragment': ['error', { allowExpressions: true }],
// 'react/jsx-handler-names': [
// 'error',
// {
// eventHandlerPropPrefix: 'on',
// },
// ],
// Avoid interpolation as much as possible
'react/jsx-curly-brace-presence': ['error', { props: 'never', children: 'never' }],

// // Avoid bad or problematic patterns
// 'react/jsx-uses-vars': 'error',
// 'react/no-access-state-in-setstate': 'error',
// 'react/no-arrow-function-lifecycle': 'error',
// 'react/no-children-prop': 'error',
// 'react/no-did-mount-set-state': 'error',
// 'react/no-did-update-set-state': 'error',
// 'react/no-direct-mutation-state': 'error',
// 'react/no-namespace': 'error',
// 'react/no-redundant-should-component-update': 'error',
// 'react/no-render-return-value': 'error',
// 'react/no-string-refs': 'error',
// 'react/no-this-in-sfc': 'error',
// 'react/no-typos': 'error',
// 'react/no-unescaped-entities': 'error',
// 'react/no-unknown-property': 'error',
// 'react/no-unused-class-component-methods': 'error',
// 'react/no-will-update-set-state': 'error',
// 'react/require-optimization': 'off',
// 'react/style-prop-object': 'error',
// 'react/no-unstable-nested-components': 'error',
// Always use shorthand fragments when applicable
'react/jsx-fragments': ['error', 'syntax'],
'react/jsx-no-useless-fragment': ['error', { allowExpressions: true }],
'react/jsx-handler-names': [
'error',
{
eventHandlerPropPrefix: 'on',
},
],

// // We may eventually want to turn this on but it requires migration:
// 'react/no-array-index-key': 'off',
// Avoid bad or problematic patterns
'react/jsx-uses-vars': 'error',
'react/no-access-state-in-setstate': 'error',
'react/no-arrow-function-lifecycle': 'error',
'react/no-children-prop': 'error',
'react/no-did-mount-set-state': 'error',
'react/no-did-update-set-state': 'error',
'react/no-direct-mutation-state': 'error',
'react/no-namespace': 'error',
'react/no-redundant-should-component-update': 'error',
'react/no-render-return-value': 'error',
'react/no-string-refs': 'error',
'react/no-this-in-sfc': 'error',
'react/no-typos': 'error',
'react/no-unescaped-entities': 'error',
'react/no-unknown-property': 'error',
'react/no-unused-class-component-methods': 'error',
'react/no-will-update-set-state': 'error',
'react/require-optimization': 'off',
'react/style-prop-object': 'error',
'react/no-unstable-nested-components': 'error',

// // Require usage of the custom Link component:
// 'no-restricted-imports': [
// 'error',
// {
// paths: [
// {
// name: 'react-router-dom',
// importNames: ['Link', 'useNavigate', 'useSearchParams'],
// message:
// 'Please use `LinkWithQuery`, `useSearchParamsMerged`, and `useNavigateWithQuery` from "~/ui/utils/LinkWithQuery" instead.',
// },
// ],
// },
// ],
// 'arrow-body-style': ['error', 'as-needed'],
// },
// },
// {
// files: ['apps/wallet/**/*'],
// rules: {
// 'react/display-name': 'off',
// 'import/order': [
// 'warn',
// {
// groups: [['builtin', 'external'], ['internal', 'parent', 'sibling', 'index'], 'type'],
// pathGroups: [
// {
// pattern: '{.,..,_*,*}/**/*.?(s)css',
// group: 'type',
// position: 'after',
// },
// {
// pattern: '_*',
// group: 'internal',
// },
// {
// pattern: '_*/**',
// group: 'internal',
// },
// ],
// pathGroupsExcludedImportTypes: ['builtin', 'object', 'type'],
// alphabetize: { order: 'asc' },
// warnOnUnassignedImports: true,
// },
// ],
// 'import/no-duplicates': ['error'],
// '@typescript-eslint/consistent-type-imports': [
// 'error',
// {
// prefer: 'type-imports',
// disallowTypeAnnotations: true,
// fixStyle: 'inline-type-imports',
// },
// ],
// '@typescript-eslint/unified-signatures': 'error',
// '@typescript-eslint/parameter-properties': 'error',
// 'no-console': ['warn'],
// '@typescript-eslint/no-non-null-assertion': 'off',
// },
// },
// {
// files: ['apps/wallet/src/**/*.test.*', 'apps/wallet/src/**/*.spec.*'],
// We may eventually want to turn this on but it requires migration:
'react/no-array-index-key': 'off',

// rules: {
// // Allow any casting in tests:
// '@typescript-eslint/no-explicit-any': 'off',
// },
// },
// {
// files: ['dapps/kiosk/**/*'],
// rules: {
// 'no-unused-vars': 'off', // or "@typescript-eslint/no-unused-vars": "off",
// 'unused-imports/no-unused-imports': 'error',
// 'unused-imports/no-unused-vars': [
// 'warn',
// {
// vars: 'all',
// varsIgnorePattern: '^_',
// args: 'after-used',
// argsIgnorePattern: '^_',
// },
// ],
// },
// },
// {
// files: ['sdk/ledgerjs-hw-app-sui/**/*', 'apps/wallet/**/*'],
// rules: {
// // ledgerjs-hw-app-sui and wallet use Buffer
// 'no-restricted-globals': ['off'],
// '@typescript-eslint/ban-types': ['off'],
// },
// },
// {
// files: ['*.test.*', '*.spec.*'],
// rules: {
// // Reset to defaults to allow `Buffer` usage in tests (given they run in Node and do not impact bundle):
// 'no-restricted-globals': ['off'],
// '@typescript-eslint/ban-types': ['error'],
// },
// },
// {
// files: ['*.stories.*'],
// rules: {
// // Story files have render functions that this rule incorrectly warns on:
// 'react-hooks/rules-of-hooks': 'off',
// },
// },
// ],
// Require usage of the custom Link component:
'no-restricted-imports': [
'error',
{
paths: [
{
name: 'react-router-dom',
importNames: ['Link', 'useNavigate', 'useSearchParams'],
message:
'Please use `LinkWithQuery`, `useSearchParamsMerged`, and `useNavigateWithQuery` from "~/ui/utils/LinkWithQuery" instead.',
},
],
},
],
'arrow-body-style': ['error', 'as-needed'],
},
},
],
}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,4 @@ crates/rooch-indexer/.env
sdk/typescript/dist/
sdk/typescript/example/
sdk/typescript/src/generated/
rooch-portal-v1/script/nohup.out
*.out
16 changes: 0 additions & 16 deletions rooch-portal-v1/.eslintrc.cjs

This file was deleted.

13 changes: 13 additions & 0 deletions rooch-portal-v1/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (c) RoochNetwork
// SPDX-License-Identifier: Apache-2.0

///<reference types="vite/client" />

interface ImportMetaEnv extends Readonly<Record<string, string>> {
readonly VITE_ROOCH_OPERATING_ADDRESS: string
// more env variables...
}

interface ImportMeta {
readonly env: ImportMetaEnv
}
Loading

0 comments on commit 14a357e

Please sign in to comment.