diff --git a/.eslintignore b/.eslintignore index 73f09d8..5c434c7 100644 --- a/.eslintignore +++ b/.eslintignore @@ -3,4 +3,4 @@ node_modules/* .DS_Store dist .eslintrc.js -vite.config.js \ No newline at end of file +vite.config.ts \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js index df19239..e0b837a 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -3,35 +3,38 @@ module.exports = { env: { browser: true, node: true, - amd: true, es6: true, }, - extends: ['plugin:react/recommended', 'airbnb-base', 'prettier'], + parser: '@typescript-eslint/parser', parserOptions: { - ecmaVersion: 'latest', sourceType: 'module', + ecmaVersion: 'latest', + tsconfigRootDir: __dirname, + project: ['./tsconfig.json'], }, + extends: [ + 'eslint:recommended', + 'plugin:react/recommended', + 'airbnb/hooks', + 'airbnb-typescript', + 'plugin:react/recommended', + 'plugin:react/jsx-runtime', + 'plugin:@typescript-eslint/recommended', + 'plugin:@typescript-eslint/recommended-requiring-type-checking', + 'plugin:import/recommended', + ], settings: { react: { version: 'detect', }, 'import/resolver': { - node: { - paths: ['src'], - extensions: ['.js', '.jsx', '.ts', '.tsx'], + typescript: { + project: './tsconfig.json', }, }, }, - plugins: ['react', 'simple-import-sort', 'import'], + plugins: ['react', '@typescript-eslint'], rules: { - 'react/react-in-jsx-scope': 'off', - 'react/display-name': 'off', - 'jsx-a11y/accessible-emoji': 'off', - 'simple-import-sort/imports': 'error', - 'simple-import-sort/exports': 'error', - 'import/first': 'error', - 'import/newline-after-import': 'error', - 'import/no-duplicates': 'error', 'no-console': 'warn', 'no-plusplus': 'off', 'no-else-return': 'off', @@ -63,7 +66,7 @@ module.exports = { ], 'import/prefer-default-export': 'off', 'class-methods-use-this': 'off', - 'nonblock-statement-body-position': ['error', 'beside'], + 'nonblock-statement-body-position': ['error', 'below'], camelcase: [ 'error', { @@ -73,5 +76,69 @@ module.exports = { ], 'no-prototype-builtins': 'off', 'no-await-in-loop': 'off', + 'react/display-name': 'off', + 'no-underscore-dangle': [ + 'error', + { + allow: [], + allowAfterThis: true, + allowAfterSuper: false, + enforceInMethodNames: true, + }, + ], + 'no-console': 'off', + 'no-nested-ternary': 'off', + 'nonblock-statement-body-position': ['error', 'beside'], + 'newline-after-var': 'error', + 'jsx-quotes': ['error', 'prefer-double'], + 'max-len': 'off', + 'import/no-unresolved': 'warn', + 'import/no-cycle': 'off', + 'react/display-name': 'off', + 'react/react-in-jsx-scope': 'off', + 'react/jsx-wrap-multilines': [ + 'error', + { + declaration: 'parens-new-line', + assignment: 'parens-new-line', + return: 'parens-new-line', + arrow: 'parens-new-line', + condition: 'parens-new-line', + logical: 'parens-new-line', + prop: 'parens-new-line', + }, + ], + '@typescript-eslint/no-shadow': 'off', + '@typescript-eslint/indent': [ + 'error', + 4, + { + SwitchCase: 1, + /** + * Need to ignore rule on class files with decorator to avoid over-indented attribute + * https://github.com/typescript-eslint/typescript-eslint/issues/1824 + */ + ignoredNodes: [ + 'ClassBody.body > PropertyDefinition[decorators.length > 0] > .key', + ], + }, + ], + '@typescript-eslint/explicit-member-accessibility': [ + 'error', + { + accessibility: 'no-public', + }, + ], + '@typescript-eslint/lines-between-class-members': [ + 'error', + 'always', + { + exceptAfterSingleLine: true, + }, + ], + '@typescript-eslint/no-use-before-define': ['error'], + '@typescript-eslint/no-shadow': 'error', + '@typescript-eslint/space-before-function-paren': ['error', 'always'], + '@typescript-eslint/type-annotation-spacing': 'error', }, }; diff --git a/.husky/pre-commit b/.husky/pre-commit index d24fdfc..e9884e8 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,4 @@ #!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh" -npx lint-staged +pnpm run lint diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index 50245a7..0000000 --- a/.prettierignore +++ /dev/null @@ -1,5 +0,0 @@ -node_modules -node_modules/* -.DS_Store -dist -build diff --git a/.prettierrc.js b/.prettierrc.js deleted file mode 100644 index e75f797..0000000 --- a/.prettierrc.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - semi: true, - trailingComma: 'all', - singleQuote: true, - printWidth: 90, - tabWidth: 4, - endOfLine: 'auto', -}; diff --git a/index.html b/index.html index d376e67..cbdd6e0 100644 --- a/index.html +++ b/index.html @@ -7,6 +7,6 @@
- +