0

I'm experiencing the same problem as the poser of this question:

Why is ESLint not working properly for Lightning Web Components in VS Code and how to make it work?

One of the steps is to run npm init which asks a bunch of questions. What values should be provided in response?

I was unable to ask this as a comment on the original answer due to low rep.

1
  • From the wealth of info sfdxfox provided, the following steps got me where I wanted to be npm install followed by ctrl-shift-p : ESLint:Manage Library Execution : Allow Everywhere
    – 123
    Mar 11 at 21:08
0

You don't need npm init if you use force:project:create. I just did a test to verify, and the diff between what force:project:create and all npm init does is:

@@ -39,5 +39,8 @@
     "**/{aura|lwc}/**": [
       "eslint"
     ]
-  }
+  },
+  "main": "index.js",
+  "author": "",
+  "license": "ISC"
 }

In other words, it adds a little extra info that you don't need (because you're not making an npm package, you're using it to save your dependencies and scripts).

If you insist on doing npm init anyways, just press Enter/Return to accept all defaults (unless you want to provide any extra details). There's no need to do anything here.

It's worth noting that apparently, babel-eslint is already present when you force:project:create (maybe it was accidentally removed in a previous release?)

What you do want to do is run npm install, as this actually installs a number of dependencies, and almost everything else you need to get things up and running.

The default force:package:create and subsequent installation of the Salesforce Extension Pack won't fully fix a myriad of small problems you'll encounter until you run npm install.

Finally, the install steps seem to be incorrect; some of the referenced packages are deprecated. Instead, run:

npm install eslint@6.x typescript @lwc/eslint-plugin-lwc @salesforce/eslint-config-lwc --save-dev

NOTE TO FUTURE VISITORS

At some point, you may get warnings about things being deprecated or other unmet peer dependencies. If you see this, you need to select a new version of plugins until you run out of deprecated messages (if possible), and unmet peer dependencies.

For example:

npm WARN eslint-plugin-compat@3.3.0 requires a peer of eslint@^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 but none is installed. You must install peer dependencies yourself.

This means you've installed the wrong version of eslint.

You may need to adjust the above installation command to fix this problem.

You may get some "npm WARN deprecated" messages, too. In that case, nothing you can do until the package maintainers for LWC plugins updates their manifest to use new projects (which also typically means altering code, so be patient).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.