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

Including eslint-plugin-import cause lint postpone #1961

Closed
ogonkov opened this issue Dec 8, 2020 · 9 comments
Closed

Including eslint-plugin-import cause lint postpone #1961

ogonkov opened this issue Dec 8, 2020 · 9 comments

Comments

@ogonkov
Copy link
Contributor

ogonkov commented Dec 8, 2020

When including eslint-plugin-import (even without any rules) cause tests to "stuck" after showing lint results.

Lint shows results, and then waits for some time before shell receives exit code.

Installed eslint dependencies:

Reduced eslint config

{
    plugins: [
        'react',
        'react-hooks',
        'jsx-a11y',
        // 'import'
    ],
    parser: '@babel/eslint-parser',
    parserOptions: {
        ecmaVersion: 10,
        sourceType: 'module',
        impliedStrict: true,
        ecmaFeatures: {
            jsx: true
        }
    },
    env: {
        browser: true,
        amd: true,
        es6: true
    },
    'extends': [
        'eslint:recommended',
        'plugin:react/recommended',
        'plugin:jsx-a11y/recommended'
    ],
    settings: {
        'import/resolver': {
            webpack: {
                config: path.resolve(__dirname, 'app/webpack.config.js')
            }
        },
    }
}

When un-commenting import line, i see this strange behaviour, like something happens in background after lint finished.

✖ 23 problems (6 errors, 17 warnings)
  3 errors and 4 warnings potentially fixable with the `--fix` option.

// <-- Stuck happens here, before showing log bellow

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] lint:js-staged: `CI_MERGE_REQUEST_TARGET_BRANCH_NAME=master ./contrib/ci/gitlab-lint-changed-js.sh`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] lint:js-staged script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
@ljharb
Copy link
Member

ljharb commented Dec 8, 2020

That’s very strange; with no rules enabled, i wouldn’t expect the plugin to do anything. If you remove all the other things from your config, do you still see this behavior?

@ogonkov
Copy link
Contributor Author

ogonkov commented Dec 8, 2020

You mean other plugins? When config is run without import plugin everything happen smooth. That make me guess that problem is in import plugin

@ogonkov
Copy link
Contributor Author

ogonkov commented Dec 8, 2020

Seems like without settings.import/resolver problem is gone.

@ljharb
Copy link
Member

ljharb commented Dec 8, 2020

What’s in your webpack config? Perhaps the contents of that are contributing?

@ogonkov
Copy link
Contributor Author

ogonkov commented Dec 8, 2020

Oh. Wow. Thank you, @ljharb!

My webpack config returns promise, and looks like it was the reason of that stuck.

Even more, this seems was a reason of memory leak, that was the initial reason of debugging eslint config. Looks like that eslint-plugin-import/eslint-import-resolver-webpack is not working well with webpack configs, that returns promise.

Should i file another bug?

@ljharb
Copy link
Member

ljharb commented Dec 8, 2020

Since eslint runs synchronously, I don't think it's possible for an async webpack config to integrate with eslint.

@ljharb
Copy link
Member

ljharb commented Dec 8, 2020

Closing in favor of #883.

@ljharb ljharb closed this as completed Dec 8, 2020
@ogonkov
Copy link
Contributor Author

ogonkov commented Dec 9, 2020

That should be added to readme, to avoid further mistakes.

@ljharb
Copy link
Member

ljharb commented Dec 10, 2020

Sure, a PR to do so would be appreciated.

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

No branches or pull requests

2 participants