Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1:1 Error: Replace ⏎import·{getIsomorphicEnhancedResolver with import·{·getIsomorphicEnhancedResolver· prettier/prettier #81

Closed
karimsx opened this issue Jun 19, 2021 · 5 comments

Comments

@karimsx
Copy link

karimsx commented Jun 19, 2021

What is the problem?

After updating blitz from 0.35 to 0.38
i started getting these error when running blitz build

npm run lint do not show these errors at att

./app/modules/user/queries/getIsFriend.ts
1:1  Error: Replace `⏎import·{getIsomorphicEnhancedResolver` with `import·{·getIsomorphicEnhancedResolver·`  prettier/prettier
12:28  Error: Insert `,`  prettier/prettier
13:4  Error: Insert `,`  prettier/prettier

Paste all your error logs here:

./app/modules/user/queries/getIsFriend.client.ts
1:1  Error: Replace `⏎import·{getIsomorphicEnhancedResolver` with `import·{·getIsomorphicEnhancedResolver·`  prettier/prettier
11:28  Error: Insert `,`  prettier/prettier
12:4  Error: Insert `,`  prettier/prettier



./app/modules/user/queries/getUser.client.ts
1:1  Error: Replace `⏎import·{getIsomorphicEnhancedResolver` with `import·{·getIsomorphicEnhancedResolver·`  prettier/prettier
11:28  Error: Insert `,`  prettier/prettier
12:4  Error: Insert `,`  prettier/prettier

./app/modules/user/queries/getUser.ts
1:1  Error: Replace `⏎import·{getIsomorphicEnhancedResolver` with `import·{·getIsomorphicEnhancedResolver·`  prettier/prettier
12:28  Error: Insert `,`  prettier/prettier
13:4  Error: Insert `,`  prettier/prettier

Paste all relevant code snippets here:

import { resolver } from 'blitz'
import db, { Prisma } from 'db'
import { UserUpdateGeneralType, UserUpdateGeneralZod } from 'app/modules/user/validations'
import fs from 'fs'

export type getUserInput = Pick<
  Prisma.UserFindManyArgs,
  'take' | 'skip' | 'where' | 'select' | 'include'
>

export default resolver.pipe(
  resolver.authorize(),
  async ({ take, skip, where, select }: getUserInput, ctx) => {
    // This throws an error if credentials are invalid

    const users = await db.user.findMany({
      where,
      take,
      skip,
    })

    const count = await db.user.count()
    const hasMore = skip! + take! < count

    return { users, hasMore }
  },
)

eslint.rc

module.exports = {
  root: true,
  extends: ['blitz', 'plugin:prettier/recommended'],
  ignorePatterns: 'blitz/**',

  rules: {
    'jsx-a11y/no-autofocus': 'off',
    'jsx-a11y/click-events-have-key-events': 'off',
    'jsx-a11y/no-static-element-interactions': 'off',

    // to be removed
    'no-unused-vars': 'off',

    'prettier/prettier': [
      'error',
      {
        singleQuote: true,
        arrowParens: 'always',
        trailingComma: 'all',
        endOfLine: 'auto',
      },
    ],
  },

  overrides: [
    {
      files: ['**/*.ts', '**/*.tsx'],
      extends: ['plugin:@typescript-eslint/recommended', 'plugin:typescript-sort-keys/recommended'],
      rules: {
        // to be removed
        '@typescript-eslint/explicit-module-boundary-types': 'off',
        '@typescript-eslint/no-explicit-any': 'off',
        '@typescript-eslint/ban-types': 'off',
        '@typescript-eslint/no-var-requires': 'off',
        '@typescript-eslint/no-unused-vars': 'off',
        '@typescript-eslint/ban-ts-comment': 'off',
        '@typescript-eslint/no-non-null-assertion': 'off',
        '@typescript-eslint/no-empty-function': 'off',
        '@typescript-eslint/no-shadow': 'off',

        // valid
        'no-shadow': 'off',
        'react/require-default-props': 'off',
        '@typescript-eslint/no-unused-expressions': ['error'],
        'no-unused-expressions': 'off',
        '@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
        'react/jsx-filename-extension': ['error', { extensions: ['.jsx', '.tsx'] }],
      },

      settings: {
        'import/resolver': {
          alias: {
            extensions: ['.ts', '.tsx', '.js', '.jsx'],
          },
        },
      },
    },
  ],
}

What are detailed steps to reproduce this?

updated from 0.35 to 0.38

Run blitz -v and paste the output here:

  Package manager: yarn 
  System:
    OS: Linux 5.10 Manjaro Linux
    CPU: (12) x64 AMD Ryzen 5 2600 Six-Core Processor
    Memory: 3.79 GB / 15.62 GB
    Shell: 5.1.8 - /bin/bash
  Binaries:
    Node: 14.17.0 - ~/.nvm/versions/node/v14.17.0/bin/node
    Yarn: 1.22.10 - /usr/bin/yarn
    npm: 6.14.13 - ~/.nvm/versions/node/v14.17.0/bin/npm
    Watchman: Not Found
  npmPackages:
    @prisma/client: ~2.21 => 2.21.2 
    blitz: 0.38.0 => 0.38.0 
    prisma: 2.21 => 2.21.2 
    react: 0.0.0-experimental-6a589ad71 => 0.0.0-experimental-6a589ad71 
    react-dom: 0.0.0-experimental-6a589ad71 => 0.0.0-experimental-6a589ad71 
    typescript: 4.3.2 => 4.3.2 

Please include below any other applicable logs and screenshots that show your problem:

No response

@deini
Copy link

deini commented Jun 19, 2021

Hey @karimsx, Next 11 (which blitz uses in v0.38) now runs eslint during builds.

Those look like regular prettier errors which are enabled in your eslint config.

Everything else looks good to me. By any chance have you modified the lint script? Can you share the scripts section on your package.json?

@acornellier
Copy link
Contributor

I'm also getting eslint errors on my queries and mutation files, only during build. I think there's something wrong on blitz's end.

@acornellier
Copy link
Contributor

Reproduction instructions for my similar bug:

  1. blitz new test && cd test
  2. yarn add @typescript-eslint/eslint-plugin
  3. replace .eslintrc.js contents with
module.exports = {
  root: true,
  extends: [
    "blitz"
  ],
  plugins: [
    "@typescript-eslint"
  ],
  rules: {
    "jsx-a11y/alt-text": "off",
    "jsx-a11y/no-autofocus": "off",
    "no-console": ["warn", { allow: ["info"] }],
    "require-await": "error",
    "react/jsx-key": "error",
    "react/no-unescaped-entities": "off",
    "react/self-closing-comp": "error",
    "@typescript-eslint/quotes": [2, "double", { avoidEscape: true }
    ]
  }
}
  1. yarn build

You'll see errors like

./pages/api/auth/mutations/changePassword.ts
3:30  Error: Strings must use doublequote.  @typescript-eslint/quotes
4:41  Error: Strings must use doublequote.  @typescript-eslint/quotes
5:29  Error: Strings must use doublequote.  @typescript-eslint/quotes
11:14  Error: Strings must use doublequote.  @typescript-eslint/quotes
12:13  Error: Strings must use doublequote.  @typescript-eslint/quotes
13:21  Error: Strings must use doublequote.  @typescript-eslint/quotes

@flybayer
Copy link
Member

This issue will go away with blitz-js/blitz#2516

For now you can add an eslint override rule that disables your eslint prettier for pages/api/**/queries/** and pages/api/**/mutations/** paths.

Is it ok to go ahead and close this?

@karimsx
Copy link
Author

karimsx commented Jun 21, 2021

@deini @flybayer Thanks of course.

@karimsx karimsx closed this as completed Jun 21, 2021
@itsdillon itsdillon transferred this issue from blitz-js/blitz Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants