prettier / eslint-config-prettier

Turns off all rules that are unnecessary or might conflict with Prettier.
MIT License
5.39k stars 255 forks source link

issues with typescript + eslint #233

Closed lifeiscontent closed 1 year ago

lifeiscontent commented 1 year ago

Hi there, I've been trying to figure out what's going on here,

I have the following code:

const validateContext =
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
    <S extends Yup.ObjectSchema<any>, C>(schema: S, context: C) =>
    <V extends object>(values: V) => {
      return schema
        .validate(values, { abortEarly: true, context })
        .then(() => undefined)
        .catch(yupToFormErrors);
    };

and no matter what I do, prettier always adds a new line between the comment and <S extends Yup.ObjectSchema> which disables the eslint comment

I'm working within a monorepo, which has a .prettierrc at the root of the monorepo, and an eslint config that looks like this

extends: [
  'eslint:recommended',
  'plugin:react/recommended',
  'plugin:react/jsx-runtime',
  'plugin:react-hooks/recommended',
  'plugin:@typescript-eslint/recommended',
  'plugin:prettier/recommended',
],
lydell commented 1 year ago

Hi!

That has nothing to do with eslint-config-prettier, which is simply a file that turns a bunch of ESLint rules off. No more, no less.

As a workaround, this might work:

const validateContext =
  <S extends Yup.ObjectSchema<any>, C>( // eslint-disable-line @typescript-eslint/no-explicit-any
    schema: S,
    context: C 
  ) =>
  <V extends object>(values: V) => {
    return schema
      .validate(values, { abortEarly: true, context })
      .then(() => undefined)
      .catch(yupToFormErrors);
  };