Skip to content

False positive for await-async-utils #715

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

Closed
matheusmb opened this issue Jan 4, 2023 · 5 comments · Fixed by #722
Closed

False positive for await-async-utils #715

matheusmb opened this issue Jan 4, 2023 · 5 comments · Fixed by #722
Labels

Comments

@matheusmb
Copy link

matheusmb commented Jan 4, 2023

Have you read the Troubleshooting section?

Yes

Plugin version

v5.9.1

ESLint version

v7.32.0

Node.js version

v14.18.1

package manager and version

6.14.17

Operating system

WSL2

Bug description

On creating a wrapper around a testing-library async util, eslint triggers the false positive rule await-async-utils.

Steps to reproduce

I created the following helper in my setup function:

function setup() {
  mockedGetCurrentUserProfile.mockResolvedValue(INITIAL_VALUES);
  const utils = render(<ProfileSettingsPanel open onClose={jest.fn()} />);

  const waitForLoadComplete = () => {
    return waitForElementToBeRemoved(screen.queryByRole('progressbar'));
  };

  return { waitForLoadComplete, ...utils };
}

When I try to use it inside a test:

it('example', () => {
    const { user, waitForLoadComplete } = setup();
               // ^^^^^^^^^^^^^ -> Promise returned from waitForLoadComplete wrapper over async util must be handled
    await waitForLoadComplete();
// ...
});

Error output/screenshots

No response

ESLint configuration

const path = require('path');
const { printSchema } = require('graphql');
const { loadSchemaSync } = require('@graphql-tools/load');
const { GraphQLFileLoader } = require('@graphql-tools/graphql-file-loader');
const hq = require('alias-hq');

const webpackMap = hq.get('webpack');
const aliasMap = Object.keys(webpackMap).map((k) => [k, webpackMap[k]]);

const schemaPath = path.join(__dirname, './client/apollo/schema.graphql');
const schema = loadSchemaSync(schemaPath, {
  loaders: [new GraphQLFileLoader()],
});
const schemaString = printSchema(schema);

/** @type {eslint/ESLint.ConfigData} */
const config = {
  ignorePatterns: [
    'client/apollo/autogenTypes.ts',
    'client/apollo/schema.graphql',
    'server/index.ts',
  ],
  extends: ['@private-company', 'plugin:@next/next/recommended'],
  plugins: ['graphql', 'import'],
  settings: {
    /**
     * Path aliasing needs specific configuration.
     * This depends on
     * https://www.npmjs.com/package/eslint-import-resolver-alias
     */
    'import/resolver': {
      alias: {
        map: aliasMap,
        extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
      },
    },
  },
  rules: {
    // From eslint-plugin-graphql
    'react/jsx-no-target-blank': 0,
    'no-console': 'error',
    '@typescript-eslint/no-unused-vars': 'error',
    'graphql/template-strings': [
      'error',
      {
        env: 'apollo',
        schemaString,
      },
      {
        env: 'literal',
        schemaString,
      },
    ],
  },
  overrides: [
    {
      files: ['*.ts', '*.tsx'],
      rules: {
        '@typescript-eslint/explicit-module-boundary-types': 'warn',
      },
    },
    {
      files: ['.eslintrc.js', 'jest.config.js'],
      rules: {
        'import/no-extraneous-dependencies': 'off',
      },
    },
  ],
};

module.exports = config;

Rule(s) affected

await-async-utils

Anything else?

No response

Do you want to submit a pull request to fix this bug?

No

@matheusmb matheusmb added bug Something isn't working triage Pending to be triaged by a maintainer labels Jan 4, 2023
@Belco90 Belco90 removed the triage Pending to be triaged by a maintainer label Jan 10, 2023
@Belco90
Copy link
Member

Belco90 commented Jan 10, 2023

Thanks for reporting this @matheusmb! We probably need to skip reporting nodes when destructuring.

@patriscus
Copy link
Contributor

@Belco90 can I contribute to this issue? I cannot promise that I'll be able to solve this without help, but I'd like to try it nonetheless. If I see it's too much, I would let you know accordingly.

@Belco90
Copy link
Member

Belco90 commented Jan 26, 2023

@patriscus By all means! Let us know if you need help.

@github-actions
Copy link

github-actions bot commented Feb 8, 2023

🎉 This issue has been resolved in version 5.10.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
Copy link

github-actions bot commented Aug 5, 2023

🎉 This issue has been resolved in version 6.0.0-alpha.15 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants