ESLint is not working?

Viewed 8186

I Wanted to use ESLint to make my code better. I have installed it using the comand :

$ npm install -g eslint

later I ran the following command to generate a config file . A file '.eslintrc.json' is created in my project's root directory

$ eslint --init

later i ran the following command :

$ eslint yourfile.js

but it didn't output any result.

later I have installed airbnb .

npm info "eslint-config-airbnb@latest" peerDependencies

also executed :

(
  export PKG=eslint-config-airbnb;
  npm info "$PKG@latest" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm install --save-dev "$PKG@latest"
)

this created a folder 'eslint-config-airbnb' in /usr/lib/node_modules .

in '.eslintrc.json' file I placed "extends": "airbnb" .

then ran the command 'eslint filename.js'. It still doesn't output anything.Where did I go wrong ? Why am I unable to get the result ?

output screen shot : eslint output

config file screen shot :.eslintrc.json

2 Answers

Solution:

STEP 1

Project Directory: node node_modules\eslint\bin\eslint.js --init


STEP 2

I added the following scripts in package.json:

"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "set DEBUG=* & node app.js",
    "lint": "./node_modules/.bin/eslint app.js"
 }

Run the command npm run lint in terminal and it should start working.

Related