ESLint, prettier, and VS Code

After installing the npm packages, install eslint-config-prettier eslint-plugin-prettier prettier lint-staged husky --save-dev. Creating the corresponding .eslintrc and .prettierrc configuration files in the project root when running the npm run eslint command and installing plugins from the VS code market. Error in the terminal

:npm ERR! missing script: eslint

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Евгений\AppData\Roaming\npm-cache\_logs\2019-12-16T14_07_00_742Z-debug.log

And when you run this command, node_modules/.bin/eslint src / the terminal outputs that 'node_modules' is not recognized as an internal or external command, operable program or batch file. (this folder is also in the root of the project )

.prettierrc

{ "userTabs": false, "printWidth": 80, "tabWidth":2, "singleQuote":true, "trailingComma":"es5", "parcer":"flow", "semi":false }

.eslintrc

{
"extends": [
    "react-app",
    "prettir"
],

"rules" : {

    "jsx-quotes": [
        1,
        "prefer-double"
    ]

    },
    "plugins":[
        "prettier"
    ]
}

In short, the linter does not start.. because I'm crooked) help)..Screen of pacage.json I attached enter a description of the image here

Author: Qwertiy, 2019-12-16

1 answers

For eslint-plugin-prettier to work, you still need to set ESLint: npm i -D eslint separately. This is written in the readme on github:

Eslint-plugin-prettier does not install Prettier or ESLint for you. You must install these yourself.

You also have a typo in the configuration file .eslintrc.json: prettir -> prettier.

npm run eslint. This command runs the scripts that were described in the package file.json, if it is not there, it will throw an error missing script: eslint. I.e. you need to add something similar:

"scripts": {
  "eslint": "eslint --format codeframe ./"
},

In general, it would be useful to review the plugin documentation, there is a description and examples of how to configure and use it.

 2
Author: Exploding Kitten, 2019-12-16 20:39:20