webpack-contrib / eslint-webpack-plugin

A ESLint plugin for webpack
MIT License
255 stars 49 forks source link

Cannot use with webpack ERROR in Cannot read property 'tapPromise' of undefined #113

Closed adityak368 closed 3 years ago

adityak368 commented 3 years ago

I get the following error:

ERROR in Cannot read property 'tapPromise' of undefined

ERROR in Cannot read property 'tapPromise' of undefined

ERROR in Cannot read property 'tapPromise' of undefined

ERROR in Cannot read property 'tapPromise' of undefined

webpack 5.47.0 compiled with 12 errors in 167 ms i 「wdm」: Failed to compile.

Expected Behavior

Weback should load the eslint rules

Actual Behavior

Does not compile

Code


const ESLintPlugin = require('eslint-webpack-plugin');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');

// webpack.config.js
    resolve: {
        extensions: ['.ts', '.tsx', '.js', '.json'],
        plugins: [
            new TsconfigPathsPlugin({ configFile: path.join(__dirname, 'tsconfig.json') }),
            new ESLintPlugin({
                extensions: ['js', 'jsx', 'ts', 'tsx'],
            }),
        ],
    },

If i remove

new ESLintPlugin({
     extensions: ['js', 'jsx', 'ts', 'tsx'],
}),

it works

.eslintrc

{
    "parser": "@typescript-eslint/parser",
    "parserOptions": {
        "ecmaFeatures": {
            "jsx": true
        },
        "useJSXTextNode": true,
        "sourceType": "module"
    },
    "extends": [
        "plugin:promise/recommended",
        "plugin:jsx-a11y/recommended",
        "plugin:prettier/recommended",
        "plugin:import/recommended",
        "plugin:react/recommended",
        "plugin:react-hooks/recommended",
        "eslint:recommended",
        "plugin:@typescript-eslint/recommended"
    ],
    "plugins": ["promise", "jsx-a11y", "prettier", "import", "react", "react-hooks", "@typescript-eslint"],
    "env": {
        "browser": true,
        "node": true
    },
    "rules": {
        "import/no-extraneous-dependencies": 1,
        "import/order": [
            "error",
            {
                "groups": ["builtin", "external", "internal"],
                "pathGroups": [
                    {
                        "pattern": "react",
                        "group": "external",
                        "position": "before"
                    }
                ],
                "pathGroupsExcludedImportTypes": ["react"],
                "newlines-between": "always-and-inside-groups",
                "alphabetize": {
                    "order": "asc",
                    "caseInsensitive": true
                },
                "warnOnUnassignedImports": true
            }
        ]
    }
}

How Do We Reproduce?

Just with the above config create new react app

adityak368 commented 3 years ago

the problem was that plugin should not have been inside resolve

mread1208 commented 3 years ago

@adityak368, Thank you for posting your solution.... I made the same mistake!

shmuel-torii commented 1 year ago

@adityak368 Thank you for posting your solution.... I made the same mistake :)