1

I installed eslint globally using npm install -g eslint --save-dev and it create eslint.config.mjs in my WSL2 project directory.

I installed the jquery plugin globally using npm install -g eslint-plugin-jquery --save-dev but I cannot find where it was placed.

I tried to modify eslint.config.mjs for jquery.

import globals from "globals";
import pluginJs from "@eslint/js";

export default [
  {files: ["**/*.js"], languageOptions: {sourceType: "script"}},
  {languageOptions: { globals: globals.browser }},
  pluginJs.configs.recommended,
  {"plugins": ["jquery"],"extends": ["plugin:jquery/deprecated"]},
];

From my project directory I ran npx eslint build/may08/js/merged.min.js and got the error response:

Oops! Something went wrong! :(
ESLint: 9.2.0
A config object has a "plugins" key defined as an array of strings.
Flat config requires "plugins" to be an object in this form:

    {
        plugins: {
            jquery: pluginObject
        }
    }

I modified the last line to {plugins: jquery} but received the error:

Oops! Something went wrong! :(
ESLint: 9.2.0
ReferenceError: jquery is not defined
    at file:///home/jabrown/develop/jqproject/eslint.config.mjs?mtime=1715366321831:9:13
    at ModuleJob.run (node:internal/modules/esm/module_job:235:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:461:24)
    at async loadFlatConfigFile (/home/jabrown/node_modules/eslint/lib/eslint/eslint.js:317:21)
    at async calculateConfigArray (/home/jabrown/node_modules/eslint/lib/eslint/eslint.js:396:28)
    at async ESLint.lintFiles (/home/jabrown/node_modules/eslint/lib/eslint/eslint.js:815:25)
    at async Object.execute (/home/jabrown/node_modules/eslint/lib/cli.js:500:23)
    at async main (/home/jabrown/node_modules/eslint/bin/eslint.js:153:22)

Most of the configuration examples that I found still used eslintrc.js. Running ESLint on jquery source files should be in very common use. So how is it configured?

1 Answer 1

-1

I installed the jquery plugin globally using npm install -g eslint-plugin-jquery --save-dev but I cannot find where it was placed.

To list where global node_modules exist:

npm -g list

To see the user-level installed:

npm list

To list the full configuration:

npm config ls -l

eslint would require dependencies, including eslint plugins to be installed in the current directory of the project, also known as the build directory, where node_modules will be. eslint will look only locally (within the folder) for eslint plugins. I presume that's why they can't be found.

duplicate: How to list npm user-installed packages

Sign up to request clarification or add additional context in comments.

5 Comments

I found it under .npm-global/lib and listed in my home directory but not in the project directory.
npm install should install all dependencies in current directory (your project directory, where packages.json is).
I found package.json and package-lock.json in my home directory but only eslint.config.mjs in my jqproject directory.
depends how your project is setup. Based on your feedback, you may have also yarn and a configuration to reference jqproject.
Did not use yarn. I did run npx eslint --init. There is no package.json anywhere. We use a script to merge ~25 *.js files into one. I put /* global $ */ at the top and run npx eslint <file> from the command line. That works well enough.

Your Answer

Draft saved
Draft discarded

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.