Skip to content

--prettier overrides {"prettier/prettier": "off"} in rules #512

Closed as not planned

Description

@jonahsnider
"xo": {
	"prettier": true,
	"rules": {
		"prettier/prettier": "off"
	}
}

This should turn off the prettier/prettier rule while still enabling Prettier mode in XO, but instead the rule remains enabled.

Activity

  1. changed the title [-]--prettier overrides "prettier/prettier": "off" in rules[/-] [+]--prettier overrides {"prettier/prettier": "off"} in rules[/+] on Dec 25, 2020
  2. sindresorhus commented on Dec 25, 2020

    @sindresorhus
    Member

    What's the purpose of turning off prettier/prettier while leaving the prettier option to true? I don't personally use Prettier or the prettier option.

  3. jonahsnider commented on Dec 25, 2020

    @jonahsnider
    ContributorAuthor

    I use the Prettier CLI to check all the files Prettier supports in my project. I don't want both the check-format and lint jobs in CI to fail.

  4. fregante commented on Aug 16, 2021

    @fregante
    Member

    I don't get it, that doesn't seem to answer Sindre's question. What's the point of setting it to true if you disable it afterwards? What's even the intended outcome for XO?

    In projects where I have both the Prettier CLI and XO, I just use prettier/prettier: "off" without needing to enable it in XO itself.

  5. jonahsnider commented on Aug 16, 2021

    @jonahsnider
    ContributorAuthor

    There is more to the Prettier integration than just the prettier/prettier rule. When possible, I want to use Prettier exclusively to check code style and to avoid both the Prettier CLI and XO erroring from a formatting error.

  6. fregante commented on Aug 17, 2021

    @fregante
    Member

    There is more to the Prettier integration than just the prettier/prettier rule.

    What would that be?

    What's even the intended outcome for XO?

  7. jonahsnider commented on Aug 17, 2021

    @jonahsnider
    ContributorAuthor

    Using eslint-config-prettier to disable other formatting issues that should be handled by Prettier.

  8. fregante commented on Aug 6, 2022

    @fregante
    Member

    xo/lib/options-manager.js

    Lines 412 to 421 in 3a4c9c9

    if (options.prettier) {
    // The prettier plugin uses Prettier to format the code with `--fix`
    config.baseConfig.plugins.push('prettier');
    // The prettier plugin overrides ESLint stylistic rules that are handled by Prettier
    config.baseConfig.extends.push('plugin:prettier/recommended');
    // The `prettier/prettier` rule reports errors if the code is not formatted in accordance to Prettier
    config.baseConfig.rules['prettier/prettier'] = ['error', mergeWithPrettierConfig(options, prettierConfig)];
    }

    If you're going to set --prettier and prettier/prettier: "off" in your config, you might as well just set prettier/recommended once instead, it's less config and your intent is much clearer:

    {
    	"extends": "plugin:prettier/recommended"
    }

    Asking XO to first run --prettier and then apparently disabling it later looks super confusing.

    Feel free to reopen if this is considered a bug though.

  9. lachieh commented on Mar 21, 2024

    @lachieh

    I wouldn't consider this a bug, but I'd love a way to disable conflicting prettier rules (which is the role of eslint-config-prettier) but not surface the warnings or run prettier --fix through eslint/xo (which is the role of eslint-plugin-prettier).

    Personally, I find it much nicer to just let prettier format on save silently than showing an error/warning in the IDE. Formatting should be just handled but surfacing a warning means I have to pay attention to something.

    I've tried to solve this by just enabling the eslint-config-prettier rule:

    {
        "extends": "prettier"
    }
    

    However, because the typescript rules are applied after, this causes fights between @typescript-eslint/indent because it is applied over the top of the user config:

    xo/lib/options-manager.js

    Lines 356 to 359 in 1245088

    if (options.space && !options.prettier) {
    if (options.ts) {
    config.baseConfig.rules['@typescript-eslint/indent'] = ['error', spaces, {SwitchCase: 1}];
    } else {

    I'm happy to file this as a separate issue, but figured the original discussion was relevant. I'm also happy to contribute a PR once the direction is nailed down.

  10. fregante commented on Sep 21, 2026

    @fregante
    Member

    Using eslint-config-prettier to disable other formatting issues that should be handled by Prettier.

    This was finally implemented as --prettier compat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions