refactor: upgrade ESLint 9→10 and simplify React lint toolchain
- Upgrade eslint and @eslint/js to v10 - Replace eslint-plugin-react-x + eslint-plugin-react-dom + eslint-plugin-react-hooks with unified @eslint-react/eslint-plugin - Raise dev Node.js requirement to ^22.13.0 || >=24 (runtime packages unaffected) - Add .npmrc with engine-strict=true - Move all @eslint-react rule overrides to eslint.config.js, eliminating plugin-specific inline eslint-disable comments - Fix real issues caught by new rules: useless assignments, leaked setTimeout, ref naming, useState setter naming
This commit is contained in:
@@ -9,19 +9,19 @@ const LanguageContext = createContext<{
|
||||
} | null>(null)
|
||||
|
||||
export function LanguageProvider({ children }: { children: ReactNode }) {
|
||||
const [language, setLang] = useState<Lang>(() => {
|
||||
const [language, setLanguage] = useState<Lang>(() => {
|
||||
const stored = localStorage.getItem('language') as Lang
|
||||
if (stored === 'zh-CN' || stored === 'en-US') return stored
|
||||
return navigator.language.startsWith('zh') ? 'zh-CN' : 'en-US'
|
||||
})
|
||||
|
||||
const setLanguage = (lang: Lang) => {
|
||||
setLang(lang)
|
||||
const switchLanguage = (lang: Lang) => {
|
||||
setLanguage(lang)
|
||||
localStorage.setItem('language', lang)
|
||||
}
|
||||
|
||||
return (
|
||||
<LanguageContext value={{ language, isZh: language === 'zh-CN', setLanguage }}>
|
||||
<LanguageContext value={{ language, isZh: language === 'zh-CN', setLanguage: switchLanguage }}>
|
||||
{children}
|
||||
</LanguageContext>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user