I'm new to Node and JS. I'm following a course and trying to use ESLint and stuffs but ran into problems that i couldn't fix.
ESLint not working at all even i set up and config all the things just like my mentor showed me.
My eslintrc:
{
"extends": ["eslint:recommended", "airbnb", "prettier", "plugin:node/recommended"],
"plugins": ["prettier"],
"rules": {
"prettier/prettier": "error",
"spaced-comment": "off",
"no-console": "warn",
"consistent-return": "off",
"func-names": "off",
"object-shorthand": "off",
"no-process-exit": "off",
"no-param-reassign": "off",
"no-return-await": "off",
"no-underscore-dangle": "off",
"class-methods-use-this": "off",
"prefer-destructuring": ["error", { "object": true, "array": false }],
"no-unused-vars": ["error", { "argsIgnorePattern": "req|res|next|val" }]
}
}
My packet.json:
{
"name": "natours",
"version": "1.0.0",
"description": "Learning node, express and mongoDB",
"main": "app.js",
"scripts": {
"start:dev": "nodemon server.js",
"start:prod": "NODE_ENV=production nodemon server.js"
},
"author": "Bac Son",
"license": "ISC",
"dependencies": {
"dotenv": "^8.1.0",
"express": "^4.17.1",
"morgan": "^1.9.1"
},
"devDependencies": {
"eslint": "^6.5.1",
"eslint-config-airbnb": "^18.0.1",
"eslint-config-prettier": "^6.3.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-node": "^10.0.0",
"eslint-plugin-prettier": "^3.1.1",
"eslint-plugin-react": "^7.15.1",
"prettier": "^1.18.2"
}
}
And I also get this error while I'm trying to fix the problems by myself:
"Failed to load plugin 'node' declared in 'starter.eslintrc.json': Cannot find module 'eslint-plugin-node'"
Very appreciate any help
Does eslint work for you in a terminal. If not this is not a problem with the vscode-eslint extension so you are better of asking this question on Stack Overflow. If it works for you in a terminal can you please provide me with a GitHub repository I can clone that demos what you are seeing.
My ESLint works fine in terminal, so i think problems come from VSCode
Here my repo: https://github.com/bacsonvv/eslintissue
I tried to run ESLint in terminal with my index.js and it warned me all the rules i config, but when i try it with VSCode nothing happens
I can reproduce the same issue.
Tests
npx eslint ...Prerequisites
What did I witness when the bug occurred?
Workarounds
Downgrade to latest 5.X eslint
@jsamr you want to have a look at https://github.com/microsoft/vscode-eslint/issues/696#issuecomment-537445913
@bacsonvv I can't reproduce this using the provided repository. I get
[Info - 11:53:35 AM] ESLint server running in node v12.4.0
[Info - 11:53:35 AM] ESLint server is running.
[Info - 11:53:40 AM] ESLint library loaded from: c:\Users\dirkb\Projects\mseng\VSCode\Playgrounds\bugs\eslint\eslintissue\starter\node_modules\eslint\lib\api.js
[Warn - 11:53:40 AM]
No ESLint configuration (e.g .eslintrc) found for file: c:\Users\dirkb\Projects\mseng\VSCode\Playgrounds\bugs\eslint\eslintissue\starter\server.js
File will not be validated. Consider running 'eslint --init' in the workspace folder eslintissue
Alternatively you can disable ESLint by executing the 'Disable ESLint' command.
Can you please make the example self contained.
This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.
Happy Coding!