[英]ESLint: Disable "Invalid number literal casing" rule
I'm using NuxtJS CLI, which comes together with Prettier and ESLint.我正在使用 NuxtJS CLI,它与 Prettier 和 ESLint 一起使用。
I have problems with hexadecimal numbers:我对十六进制数字有疑问:
0xffffff
ESLint doesn't like it and throws this error: ESLint 不喜欢它并抛出这个错误:
Invalid number literal casing unicorn/number-literal-case
I foundthis solution , but it didn't work for some reason.我找到了这个解决方案,但由于某种原因它不起作用。
Now I want to disable this rule at all to move forward with my project.现在我想完全禁用此规则以继续我的项目。
I tried this rule into .eslintsrc.js:我在 .eslintsrc.js 中尝试了这条规则:
'prefer-numeric-literals': 'off',
That solved 50% of errors, but some ESLint "unicorn" is still causing the error.这解决了 50% 的错误,但一些 ESLint “独角兽”仍然导致错误。 I tried to uninstall this dependency - but it won't go away.
我试图卸载这个依赖 - 但它不会消失。
I also tried to write hexadecimal numbers in uppercase, but prettier transforms it to lowercase on save.我还尝试以大写形式编写十六进制数字,但在保存时更漂亮地将其转换为小写。
The single option is to write code in this way:唯一的选择是以这种方式编写代码:
/* eslint-disable */
object.material.color.set(Math.random() * 0xffffff)
/* eslint-enable */
But this is not convenient...但这不方便...
Is there a way to fix it?有没有办法解决它?
The purpose of the rule is to have consistent casing, it wants you to write 0xFFFFFF
(so all uppercase with lowercase x
).该规则的目的是保持大小写一致,它希望你写
0xFFFFFF
(所以所有大写字母都带有小写x
)。 If you don't want that you can disable it in the config with如果你不想这样,你可以在配置中禁用它
'unicorn/number-literal-case': 'off',
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.