From d41534a647f36e913d7f3b227423f96559dba878 Mon Sep 17 00:00:00 2001 From: barshathakuri Date: Mon, 18 Mar 2024 16:33:14 +0545 Subject: [PATCH 1/4] Project set up --- .unimportedrc.json | 5 +- docker-compose.yml | 4 +- eslint.config.js | 48 +++++- index.html | 40 ++++- package.json | 76 ++++---- public/pineapple.svg | 86 ---------- src/App/PageError/index.tsx | 4 +- src/App/routes.tsx | 12 +- src/assets/react.svg | 1 - src/index.css | 295 +++++++++++++++++++++++++++----- src/index.tsx | 3 +- src/utils/routes.test.tsx | 11 +- src/utils/routes.tsx | 10 +- src/views/Home/index.module.css | 7 - src/views/Home/index.tsx | 40 +---- src/views/Root/index.module.css | 25 --- src/views/Root/index.tsx | 31 +--- tsconfig.json | 14 +- tsconfig.node.json | 2 +- 19 files changed, 418 insertions(+), 296 deletions(-) delete mode 100644 public/pineapple.svg delete mode 100644 src/assets/react.svg delete mode 100644 src/views/Home/index.module.css delete mode 100644 src/views/Root/index.module.css diff --git a/.unimportedrc.json b/.unimportedrc.json index 14a2d972..84b413d8 100644 --- a/.unimportedrc.json +++ b/.unimportedrc.json @@ -4,8 +4,5 @@ "ignoreUnimported": ["**/*.d.ts"], "ignoreUnused": [], "extensions": [".ts", ".js", ".tsx", ".jsx"], - "aliases": { - "#views/*": ["./src/views/*"], - "#utils/*": ["./src/utils/*"] - } + "aliases": {} } diff --git a/docker-compose.yml b/docker-compose.yml index 3f19cad0..0ff5e2f8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,9 +2,7 @@ version: '3.8' services: react: build: . - command: sh -c 'yarn install && yarn dev --host' - environment: - APP_TITLE: ${APP_TITLE:-React Base App} + command: sh -c 'yarn install && yarn start --host' volumes: - .:/code ports: diff --git a/eslint.config.js b/eslint.config.js index 7c802424..891f8a8a 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,10 +1,8 @@ import { FlatCompat } from '@eslint/eslintrc'; import js from '@eslint/js'; -import path from 'path'; -import { fileURLToPath } from 'url'; +import process from 'process'; -const filename = fileURLToPath(import.meta.url); -const dirname = path.dirname(filename); +const dirname = process.cwd(); const compat = new FlatCompat({ baseDirectory: dirname, @@ -13,9 +11,11 @@ const compat = new FlatCompat({ const appConfigs = compat.config({ env: { + node: true, browser: true, es2020: true, }, + root: true, extends: [ 'airbnb', 'airbnb/hooks', @@ -30,14 +30,18 @@ const appConfigs = compat.config({ plugins: [ '@typescript-eslint', 'react-refresh', + 'simple-import-sort', + 'import-newlines' ], settings: { 'import/parsers': { - '@typescript-eslint/parser': ['.ts', '.tsx'] + '@typescript-eslint/parser': ['.ts', '.tsx'] }, 'import/resolver': { - typescript: { - project: './tsconfig.json', + typescript: { + project: [ + './tsconfig.json', + ], }, }, }, @@ -72,6 +76,7 @@ const appConfigs = compat.config({ 'import/no-cycle': ['error', { allowUnsafeDynamicCyclicDependency: true }], 'react/react-in-jsx-scope': 'off', + 'camelcase': 'off', 'react/jsx-indent': ['error', 4], 'react/jsx-indent-props': ['error', 4], @@ -83,10 +88,39 @@ const appConfigs = compat.config({ 'react-hooks/exhaustive-deps': 'warn', 'react/require-default-props': ['warn', { ignoreFunctionalComponents: true }], + 'simple-import-sort/imports': 'warn', + 'simple-import-sort/exports': 'warn', + 'import-newlines/enforce': ['warn', 1] }, + overrides: [ + { + files: ['*.js', '*.jsx', '*.ts', '*.tsx'], + rules: { + 'simple-import-sort/imports': [ + 'error', + { + 'groups': [ + // side effect imports + ['^\\u0000'], + // packages `react` related packages come first + ['^react', '^@?\\w'], + // internal packages + ['^#.+$'], + // parent imports. Put `..` last + // other relative imports. Put same-folder imports and `.` last + ['^\\.\\.(?!/?$)', '^\\.\\./?$', '^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'], + // style imports + ['^.+\\.json$', '^.+\\.module.css$'], + ] + } + ] + } + } + ] }).map((conf) => ({ ...conf, files: ['src/**/*.tsx', 'src/**/*.jsx', 'src/**/*.ts', 'src/**/*.js'], + ignores: ['src/generated/types.ts'], })); const otherConfig = { diff --git a/index.html b/index.html index e0322f2c..3db286e5 100644 --- a/index.html +++ b/index.html @@ -8,7 +8,7 @@ %APP_TITLE% - + + + + + + -
+
+
+ %APP_TITLE% loading... +
+