gpt-3.5-turbo-0301· openai
Suzhen/CodeChat
пример файла конфигурации .eslintrc.js и файл конфигурации tsconfig.json с airbnb для…
- User
пример файла конфигурации .eslintrc.js и файл конфигурации tsconfig.json с airbnb для использования с файлами react js, ts, jsx, tsx,
- Assistant
Файл конфигурации .eslintrc.js:
module.exports = { extends: [ "airbnb", "plugin:@typescript-eslint/recommended", "prettier/@typescript-eslint", "plugin:prettier/recommended", ], env: { browser: true, es6: true, }, parser: "@typescript-eslint/parser", parserOptions: { ecmaFeatures: { jsx: true, tsx: true, }, ecmaVersion: 2018, sourceType: "module", }, plugins: ["@typescript-eslint", "react-hooks"], rules: { "react/jsx-filename-extension": [1, { extensions: [".js", ".jsx", ".ts", ".tsx"] }], "import/extensions": [ "error", "ignorePackages", { js: "never", jsx: "never", ts: "never", tsx: "never", }, ], "@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }], "react-hooks/rules-of-hooks": "error", "react-hooks/exhaustive-deps": "warn", }, };Файл конфигурации tsconfig.json:
{ "compilerOptions": { "lib": ["dom", "dom.iterable", "esnext"], "target": "es5", "module": "esnext", "moduleResolution": "node", "esModuleInterop": true, "strict": true, "jsx": "react", "sourceMap": true, "outDir": "dist", "baseUrl": ".", "paths": { "@components/*": ["src/components/*"], "@constants/*": ["src/constants/*"], "@utils/*": ["src/utils/*"] } }, "include": ["src/**/*"], "exclude": ["node_modules", "dist"] } - User
какие пакеты нужно для этого установить
- Assistant
Для использования конфигурации .eslintrc.js и tsconfig.json с airbnb для файлов React JS, TS, JSX, TSX, необходимо установить следующие пакеты:
- eslint
- @typescript-eslint/parser
- @typescript-eslint/eslint-plugin
- eslint-config-airbnb
- eslint-config-prettier
- eslint-plugin-import
- eslint-plugin-jsx-a11y
- eslint-plugin-react
- eslint-plugin-react-hooks
- prettier
- typescript
Вы можете установить пакеты отдельно один за другим, либо использовать команду:
npm install eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-config-airbnb eslint-config-prettier eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-react eslint-plugin-react-hooks prettier typescript --save-devили
yarn add eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-config-airbnb eslint-config-prettier eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-react eslint-plugin-react-hooks prettier typescript -D