소스 검색

configure eslint, @ path alias

Aneurin Barker Snook 1 년 전
부모
커밋
9749e2bd41
7개의 변경된 파일151개의 추가작업 그리고 5개의 파일을 삭제
  1. 117 0
      web/.eslintrc.cjs
  2. 16 0
      web/package-lock.json
  3. 1 0
      web/package.json
  4. 2 2
      web/src/App.tsx
  5. 2 2
      web/src/main.tsx
  6. 7 1
      web/tsconfig.json
  7. 6 0
      web/vite.config.ts

+ 117 - 0
web/.eslintrc.cjs

@@ -14,5 +14,122 @@ module.exports = {
       'warn',
       { allowConstantExport: true },
     ],
+    '@typescript-eslint/consistent-type-imports': 'error',
+    '@typescript-eslint/member-delimiter-style': [
+      'error',
+      {
+        'multiline': {
+          'delimiter': 'none',
+          'requireLast': true
+        },
+        'singleline': {
+          'delimiter': 'comma',
+          'requireLast': false
+        }
+      }
+    ],
+    '@typescript-eslint/type-annotation-spacing': [
+      'error',
+      {
+        'before': false,
+        'after': true,
+        'overrides': {
+          'arrow': {
+            'before': true,
+            'after': true
+          }
+        }
+      }
+    ],
+    'arrow-body-style': [
+      'error',
+      'as-needed'
+    ],
+    'arrow-spacing': 'error',
+    'brace-style': [
+      'error',
+      '1tbs'
+    ],
+    'comma-dangle': [
+      'error',
+      'always-multiline'
+    ],
+    'curly': [
+      'off'
+    ],
+    'eol-last': [
+      'error',
+      'always'
+    ],
+    'indent': [
+      'error',
+      2
+    ],
+    'jsx-quotes': [
+      'error',
+      'prefer-double'
+    ],
+    'line-comment-position': [
+      'error',
+      'above'
+    ],
+    'linebreak-style': [
+      'error',
+      'unix'
+    ],
+    'max-len': [
+      'warn',
+      {
+        'code': 160
+      }
+    ],
+    'no-array-constructor': 'error',
+    'no-eval': 'error',
+    'no-lonely-if': 'error',
+    'no-multi-assign': 'error',
+    'no-new-object': 'error',
+    'no-tabs': 'error',
+    'no-trailing-spaces': 'warn',
+    'no-unreachable': 'error',
+    'no-var': 'error',
+    'nonblock-statement-body-position': 'error',
+    'one-var': [
+      'error',
+      'never'
+    ],
+    'prefer-arrow-callback': 'error',
+    'prefer-const': 'warn',
+    'quotes': [
+      'error',
+      'single'
+    ],
+    'semi': [
+      'error',
+      'never'
+    ],
+    'sort-imports': [
+      'warn',
+      {
+        'memberSyntaxSortOrder': [
+          'none',
+          'all',
+          'single',
+          'multiple'
+        ]
+      }
+    ],
+    'sort-vars': 'error'
   },
+  'overrides': [
+    {
+      'files': [
+        '*.tsx'
+      ],
+      'rules': {
+        'max-len': [
+          'off'
+        ]
+      }
+    }
+  ]
 }

+ 16 - 0
web/package-lock.json

@@ -12,6 +12,7 @@
         "react-dom": "^18.2.0"
       },
       "devDependencies": {
+        "@types/node": "^20.10.3",
         "@types/react": "^18.2.37",
         "@types/react-dom": "^18.2.15",
         "@typescript-eslint/eslint-plugin": "^6.10.0",
@@ -1133,6 +1134,15 @@
       "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==",
       "dev": true
     },
+    "node_modules/@types/node": {
+      "version": "20.10.3",
+      "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.3.tgz",
+      "integrity": "sha512-XJavIpZqiXID5Yxnxv3RUDKTN5b81ddNC3ecsA0SoFXz/QU8OGBwZGMomiq0zw+uuqbL/krztv/DINAQ/EV4gg==",
+      "dev": true,
+      "dependencies": {
+        "undici-types": "~5.26.4"
+      }
+    },
     "node_modules/@types/prop-types": {
       "version": "15.7.11",
       "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.11.tgz",
@@ -2980,6 +2990,12 @@
         "node": ">=14.17"
       }
     },
+    "node_modules/undici-types": {
+      "version": "5.26.5",
+      "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
+      "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==",
+      "dev": true
+    },
     "node_modules/update-browserslist-db": {
       "version": "1.0.13",
       "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz",

+ 1 - 0
web/package.json

@@ -14,6 +14,7 @@
     "react-dom": "^18.2.0"
   },
   "devDependencies": {
+    "@types/node": "^20.10.3",
     "@types/react": "^18.2.37",
     "@types/react-dom": "^18.2.15",
     "@typescript-eslint/eslint-plugin": "^6.10.0",

+ 2 - 2
web/src/App.tsx

@@ -1,7 +1,7 @@
-import { useState } from 'react'
+import './App.css'
 import reactLogo from './assets/react.svg'
+import { useState } from 'react'
 import viteLogo from '/vite.svg'
-import './App.css'
 
 function App() {
   const [count, setCount] = useState(0)

+ 2 - 2
web/src/main.tsx

@@ -1,7 +1,7 @@
+import './index.css'
+import App from './App.tsx'
 import React from 'react'
 import ReactDOM from 'react-dom/client'
-import App from './App.tsx'
-import './index.css'
 
 ReactDOM.createRoot(document.getElementById('root')!).render(
   <React.StrictMode>

+ 7 - 1
web/tsconfig.json

@@ -18,7 +18,13 @@
     "strict": true,
     "noUnusedLocals": true,
     "noUnusedParameters": true,
-    "noFallthroughCasesInSwitch": true
+    "noFallthroughCasesInSwitch": true,
+
+    /* Path resolver */
+    "baseUrl": ".",
+    "paths": {
+      "@/*": ["./src/*"]
+    }
   },
   "include": ["src"],
   "references": [{ "path": "./tsconfig.node.json" }]

+ 6 - 0
web/vite.config.ts

@@ -1,7 +1,13 @@
 import { defineConfig } from 'vite'
 import react from '@vitejs/plugin-react'
+import { URL, fileURLToPath } from 'url'
 
 // https://vitejs.dev/config/
 export default defineConfig({
   plugins: [react()],
+  resolve: {
+    alias: {
+      '@': fileURLToPath(new URL('./src', import.meta.url)),
+    },
+  },
 })