创建Tauri项目
npm create tauri-app
选项如下
✔ Project name · bible-study-tool-app ✔ Choose which language to use for your frontend · TypeScript / JavaScript - (pnpm, yarn, npm) ✔ Choose your package manager · npm ✔ Choose your UI template · React - (https://reactjs.org/) ✔ Choose your UI flavor · TypeScript
安装npm 依赖
cd bible-study-tool-app npm install npm run tauri dev
安装配置eslint
npm i -D eslint
创建eslint配置
npx eslint --init
选项如下
✔ How would you like to use ESLint? · problems ✔ What type of modules does your project use? · esm ✔ Which framework does your project use? · react ✔ Does your project use TypeScript? · No / Yes ✔ Where does your code run? · browser ✔ What format do you want your config file to be in? · JavaScript eslint-plugin-react@latest @typescript-eslint/eslint-plugin@latest @typescript-eslint/parser@latest ✔ Would you like to install them now? · No / Yes ✔ Which package manager do you want to use? · npm
安装airbnb配置
https://www.npmjs.com/package/eslint-config-airbnb
https://www.npmjs.com/package/eslint-config-airbnb-typescript
npx install-peerdeps --dev eslint-config-airbnb npm i -D eslint-config-airbnb-typescript
添加配置 .eslintrc.cjs
extends: [ // 删掉eslint-recommanded项 'airbnb', 'airbnb-typescript', 'airbnb/hooks', // 添加以上三行 'plugin:react/recommended', 'plugin:@typescript-eslint/recommended', ], ..., parserOptions: { ecmaVersion: 'latest', sourceType: 'module', // 添加以下这行 project: './tsconfig.json', }, ..., rules: { // 禁止以下规则,我不喜欢语句加分号 seme colon 'react/react-in-jsx-scope': 0, '@typescript-eslint/semi': 0, },
tsconfig.json
中加入:
"include": [".eslintrc.cjs", "src"],