.eslintrc.js
module.exports = {
extends: [
'plugin:react/recommended',
"plugin:@typescript-eslint/recommended",
],
parserOptions: {
project: './tsconfig.eslint.json',
"sourceType": "module",
"ecmaVersion": 2018
},
plugins: ['@typescript-eslint', "react-hooks", "import"],
env: {
browser: false,
es6: true,
node: true,
commonjs: true
},
rules: {
camelCase: 'off',
"no-unused-vars": "off",
'@typescript-eslint/no-unused-vars': [2, { "args": "none" }],
bracketSameLine: 0,
'@typescript-eslint/no-var-requires': 0,
"@typescript-eslint/no-explicit-any": "off",
"no-nested-ternary": 0,
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-inferrable-types': 'off',
"@typescript-eslint/ban-ts-ignore": "off",
"react/prop-types": "off",
"react/jsx-no-target-blank": "off",
"react/display-name": "off",
"react/react-in-jsx-scope": "off",
"react/no-unescaped-entities": 0,
"react/jsx-uses-react": 0,
"react/jsx-uses-vars": 0,
"react/no-children-prop": "off"
}
}
_app.tsx
import App from 'next/app'
let appLng = ''
class myApp extends App<Props & State> {
static async getInitialProps(appContext: { ctx: any; Component: any; pageProps: any }) {
const lng = appLng || 'zh'
return {
lng
}
}
async componentDidMount() {
const { lng } = this.props
if (typeof window === 'object') {
appLng = lng
}
}
}
eslint检查报错:error 'appLng' is assigned a value but never used @typescript-eslint/no-unused-vars