sindresorhus / eslint-plugin-unicorn

More than 100 powerful ESLint rules

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`unicorn/number-literal-case` conflicts with `prettier/prettier`

nbouvrette opened this issue · comments

When using the recommended rules from Unicorn, the unicorn/number-literal-case rule fails and attempts to reformat hexadecimal literals to uppercase (e.g., 0xFFFFFFFF). However, prettier/prettier (with its recommended configurations) prefers lowercase hexadecimal literals and, to my knowledge, does not provide a way to disable this specific rule. Consequently, when both sets of rules are applied, they conflict with each other, leading to a situation where they effectively cancel each other out.

Please include eslint-config-prettier, when use togethor with prettier.
Or use plugin:prettier/recommended, this already includes eslint-config-prettier https://github.com/prettier/eslint-plugin-prettier/blob/master/recommended.js

I'm not sure I understand your comment @fisker ? I am using a ESLint's flatconfig and already have prettier/recommended and unicorn/recommended:

import prettierRecommendedConfig from 'eslint-plugin-prettier/recommended'
import unicornPlugin from 'eslint-plugin-unicorn'

export default [
  // Prettier recommended configs.
  // @see https://github.com/prettier/eslint-plugin-prettier
  prettierRecommendedConfig,
  // Unicorn recommended configs.
  // @see https://github.com/sindresorhus/eslint-plugin-unicorn
  unicornPlugin.configs['flat/recommended']
]

Move prettierRecommendedConfig to last.

Oh ok this basically lets prettier override the rule so I don't have to disable Unicorn's?