Search code examples
javascripteslinteslintrcprettier-eslint

ESLint: Disable "Invalid number literal casing" rule


I'm using NuxtJS CLI, which comes together with Prettier and ESLint.

I have problems with hexadecimal numbers:

0xffffff

ESLint doesn't like it and throws this error:

Invalid number literal casing unicorn/number-literal-case

I found this 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:

'prefer-numeric-literals': 'off',

That solved 50% of errors, but some ESLint "unicorn" is still causing the error. 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?

  • Prettier version: 2.4.0
  • ESLint version: 7.3.2

Solution

  • The purpose of the rule is to have consistent casing, it wants you to write 0xFFFFFF (so all uppercase with lowercase x). If you don't want that you can disable it in the config with

    'unicorn/number-literal-case': 'off',