eslint报错error Identifier xxx is not in camel case解决方法

栏目: eslint 发布时间:2023-03-01

eslint 报错 error Identifier xxx is not in camel case ,如何解决呢?

报错示例:

You may use special comments to disable some warnings.
Use // eslint-disable-next-line to ignore the next line.
Use /* eslint-disable */ to ignore all warnings in a file.
ERROR in [eslint]
/Users/teng/code/src/hooks/table.ts
  13:14  error  Identifier 'current_page' is not in camel case  camelcase

✖ 1 problem (1 error, 0 warnings)


webpack compiled with 1 error

eslint 报错 error Identifier xxx is not in camel case 解决方法

方法1: 使用 eslint-disable-next-line 或 eslint-disable

以上述报错为例:

// eslint-disable-next-line
const { current: current_page } = pagination
/* eslint-disable */
const { current: current_page } = pagination

方法二:使用驼峰写法

以上述报错为例:

const { current: currentPage } = pagination

方法三:配置 eslint ,忽略驼峰命名检查

// .eslintrc
module.exports = {
  rules: {
    camelcase: 0
  }
}

以上就是 eslint 报错 error Identifier xxx is not in camel case 的解决方法,大家可以根据项目的代码规范,选择合适的解决方法。

本文地址:https://www.tides.cn/p_eslint-error-dentifier-xxx-is-not-in-camel-case