• Resolved Daniel

    (@junglized)


    Helo all,

    I’m trying to replace deprecated npm package eslint-config-wordpress, which works great without a hassle. The recommenrded package now is @wordpress/eslint-plugin, which doesn’t seem to work well with VSCode (on Linux Mint) or I don’t know how to install it.

    1 step: I went to a WordPress main local installation (I’m using Local by Flywheel – works great) and opened a terminal there. In the terminal I typed what I’ve found on NPM’s website: npm install @wordpress/eslint-plugin –save-dev

    2 step: I created .eslintrc file and added

    {
        "extends": [ "plugin:@wordpress/eslint-plugin/recommended" ]
    }

    Now going to VSCode and opening any js file from any theme or plugin gives me ‘Failed to load plugin ‘@wordpress/eslint-plugin’ declared in ‘../../../../../../../.eslintrc’: Cannot find module ‘@wordpress/eslint-plugin’ Require stack: – /home/user/www/__placeholder__.js Referenced from: /home/user/www/.eslintrc’ error.

    I think I don’t understand how this should work and how to install it properly. With mentioned deprecated plugin it was really straightforward and worked great.

    I appreciate some help in this regard.

    Best regards, Dan.

    • This topic was modified 3 years, 12 months ago by Daniel.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi Dan!

    Hmm. Can you verify that the package.json file in the same folder as the .eslintrc includes the @wordpress/eslint-plugin package?

    Thread Starter Daniel

    (@junglized)

    Hi Steve,

    Thanks for pointing that out. No, it didn’t include it. Now I have two files: package.json and .eslintrc together along with node_modules folder in which @wordpress folder resides. And all of that located in main WordPress installation folder.

    Now changing recommended to, let’s say, es5 inside of .eslintrc changes eslint’s warnings when linting .js files inside themes folder.

    Now I can place .eslintrc anywhere on the path in between node_modules and file being linted. That way I can use different setups for different projects.

    So I assume that works well now.

    Right on!

    I’ll mark this as resolved. If you run into any other issues let the forum know!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to install @wordpress/eslint-plugin to make it work?’ is closed to new replies.