npm i -D eslint-plugin-react-refresh 在eslint.config.js 文件增加 import reactRefresh from "eslint-plugin-react-refresh"; export default [ /* Main config */ reactRefresh.configs.vite, ]; 最终的文件内容大概长这样: import globals from "globals"; import pluginJs from "@eslint/js";...
npm i -D eslint-plugin-react-refresh Usage This plugin provides a single rule,react-refresh/only-export-components. There are multiple ways to enable it. Recommended config importreactRefreshfrom"eslint-plugin-react-refresh";exportdefault[/* Main config */reactRefresh.configs.recommended,]; ...
"react/jsx-no-target-blank": "off", "react-refresh/only-export-components": [ "warn", {allowConstantExport: true} ] } } ] 希望可以不用没有都写import { useState } from "react"这种引入 在使用 Vite 的unplugin-auto-import插件时,虽然它可以帮助你自动引入 React 相关的函数和组件,但 ESLint...
22 22 'react-refresh/only-export-components': [ 23 - 'warn', 24 - { allowConstantExport: true }, 25 - ], 26 - }, 27 - }, 23 + 'off', 24 + { allowConstantExport: true } 25 + ] 26 + } 27 + } 28 28 ) 0 commit comments Comments0 (0) Please sign ...
import reactRefresh from 'eslint-plugin-react-refresh' import tseslint from 'typescript-eslint' export default tseslint.config( { ignores: ['dist'] }, { extends: [js.configs.recommended, ...tseslint.configs.recommended], files: ['**/*.{ts,tsx}'], ...
Validate that your components can safely be updated with Fast Refresh - eslint-plugin-react-refresh/src/only-export-components.test.ts at main · ArnaudBarre/eslint-plugin-react-refresh
settings: { react: { version: "18.2" } }, plugins: ["react-refresh", "testing-library"], rules: { "react/jsx-no-target-blank": "off", "react-refresh/only-export-components": [ "warn", { allowConstantExport: true }, ],
eslint flat config double quotes + semi react, react-hooks & react-refresh, OH MY! no vue (I don't use vue (as of 2023-10-12) don't want/need the vue plugins/parsers/etc) assumes you're using prettier Based on: My old, very long, and very messy (non-flat) eslint config (...
import js from '@eslint/js' import globals from 'globals' import reactHooks from 'eslint-plugin-react-hooks' import reactRefresh from 'eslint-plugin-react-refresh' import tseslint from 'typescript-eslint' export default tseslint.config( { ignores: ['dist'] }, { extends: [js.configs....
},sourceType:'module',// 使用模块化方式,支持 ES6 模块导入/导出},plugins: {// 启用 React 插件react: pluginReact,// 启用 React Hooks 插件'react-hooks': hooksPlugin,// 启用 React Refresh 插件(用于热更新)'react-refresh': reactRefresh,// 启用 TypeScript ESLint 插件'@typescript-eslint': ty...