nextjs检查报错 @typescript-eslint/no-unused-vars?

.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

阅读 1.5k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题