eslint-config icon indicating copy to clipboard operation
eslint-config copied to clipboard

How do I keep only the indent rules of prettier or set them to the same effect of prettier using style/indent

Open laterdayi opened this issue 1 year ago • 10 comments

Clear and concise description of the problem

How do I keep only the indent rules of prettier or set them to the same effect of prettier using style/indent

Suggested solution

How do I keep only the indent rules of prettier or set them to the same effect of prettier using style/indent

Alternative

How do I keep only the indent rules of prettier or set them to the same effect of prettier using style/indent

Additional context

How do I keep only the indent rules of prettier or set them to the same effect of prettier using style/indent

Validations

  • [X] Follow our Code of Conduct
  • [X] Read the Contributing Guide.
  • [X] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

laterdayi avatar Jan 05 '24 09:01 laterdayi

    onUpdateValue: (value: (string | number | null)[]) => {
        if (formData.value) formData.value.eqpIds = [];
        value?.length
          ? executeGetEquipmentNumberChildList(__, {
              params: { LayoutId: value, check: '1' }
            })
          : handleQueryEquipmentNumberList();
      }
    onUpdateValue: (value: (string | number | null)[]) => {
        if (formData.value) formData.value.eqpIds = [];
        value?.length
          ? executeGetEquipmentNumberChildList(__, {
            params: { LayoutId: value, check: '1' }
          })
          : handleQueryEquipmentNumberList();
      }

I wanted to keep the top style, but now it's the bottom style

laterdayi avatar Jan 05 '24 09:01 laterdayi

For best results, you should use either prettier or eslint stylistic rules (style/*), not both.

For even better results, don't use prettier at all and configure your indent rules like this.

thenbe avatar Jan 05 '24 13:01 thenbe

this whole linting and styling business with all it's plethora of config/plugin packages, is at times more complicated than programming itself.

This is exactly why I'm using this project (antfu/eslint-config) :)


All those things you mentioned, you can just get rid of them:

rm -f .prettierrc .prettierignore
npm rm eslint-config-prettier eslint-plugin-prettier prettier
# npm rm prettier-plugin-whatever

For vscode, just turn off anything prettier and only leave eslint. I don't use vscode so I'm not sure how exactly, but you can probably take inspiration from here (search for prettier, eslint in that file for the relevant settings).

thenbe avatar Jan 05 '24 14:01 thenbe

@thenbe But using style/* does not indent the first effect image

laterdayi avatar Jan 05 '24 14:01 laterdayi

@laterdayi try https://eslint.style/rules/js/indent#flatternaryexpressions and https://eslint.style/rules/js/indent#offsetternaryexpressions One of them should do this

Dimava avatar Jan 05 '24 14:01 Dimava

@Dimava Still can't achieve this effect, can you help me

laterdayi avatar Jan 05 '24 15:01 laterdayi

value?.length
          ? executeGetEquipmentNumberChildList(__, {
            params: { LayoutId: value, check: '1' }
          })
          : handleQueryEquipmentNumberList();

'style/indent': ['error', 2, { 'flatTernaryExpressions': false, offsetTernaryExpressions: true }],

laterdayi avatar Jan 05 '24 15:01 laterdayi

        value?.length
          ? executeGetEquipmentNumberChildList(__, {
              params: { LayoutId: value, check: '1' }
            })
          : **handleQueryEquipmentNumberList();

image I expected that, but it prompted an error

laterdayi avatar Jan 05 '24 15:01 laterdayi

@laterdayi it should autofix the error on save Is there a rule conflict? I.e. does it reformat back to the code you don't want? Check what rule is that, you may need to disable it, or you may be using the wrong indent rule (you may need style/ts/indent or whatever)

Dimava avatar Jan 05 '24 15:01 Dimava

It fixes itself, but it fixes the wrong thing It can't be fixed like this

value?.length
          ? executeGetEquipmentNumberChildList(__, {
              params: { LayoutId: value, check: '1' }
            })
          : **handleQueryEquipmentNumberList();

laterdayi avatar Jan 06 '24 01:01 laterdayi