Reputation: 1437
I installed the ESLint extension in VS Code and it appears to be working in .js files. I can see references to ESLint when I hover over words with a squiggly red line under them.
ESLint only works when I am in a certain directory called Public (or directories inside it) which is not a problem. Inside that directory there is a package.json file with this in it:
{
"type": "module",
"devDependencies": {
"eslint": "^8.27.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "^6.6.1",
"eslint-plugin-react": "^7.31.10",
"eslint-plugin-react-hooks": "^4.6.0"
}
}
there is also a node_modules directory with an eslint directory and a @eslint directory as well as 11 other directories starting with eslint-... such as eslint-utils.
I thought that, given the above, if I was inside the Public directory I would be able to issue commands such aseslint -v
. However, when I run that I get:
~/Public$ eslint -v
Command 'eslint' not found, but can be installed with:
sudo apt install eslint
~/Public$
I wanted to run the command eslint --print-config file.js
in order to see all the ESLint rules that apply to a given file.
It would be great to know why the eslint command is not working in this directory. I would also be interested to know other methods to find out what set of ESLint rules are being applied to a given file either by using the command line or from within VS Code.
Upvotes: 0
Views: 493
Reputation: 1324
Most users use npx to run ESLint on the command line like this:
npx eslint [options] [file|dir|glob]*
Such as:
# Run on two files
npx eslint file1.js file2.js
# Run on multiple files
npx eslint lib/**
Source: https://eslint.org/docs/latest/user-guide/command-line-interface
hope it helps
Upvotes: 1