ESLint Code Format in Vue

I created a project with npm and vuejs / vue-cli.

I imported the ESLint extension.

I have eslint entries in my file package.json.

Now when I format my code (right click, Format Code), it completely distorts my code.

What do I need to do to get the vscode format in accordance with ESLint rules?

enter image description here

enter image description here

enter image description here

But on the ESLint website, it complains that everything is not formatted correctly, and therefore it is explicitly installed and works in a sense:

enter image description here

+4
source share
2 answers

1) First you need to install the ESLint extension in VS code.

ESLint. ESLint , ,

npm install eslint //For a local install
 or 
npm install -g eslint //For a global install.

2) Setting.json VS.  - > - > .

3) .

 {
    "eslint.enable": true,
    "eslint.autoFixOnSave": true,
    "eslint.run": "onType",
    "eslint.options": {
        "extensions": [".js",".vue"]
    },
    "eslint.validate": [
        { "language": "vue", "autoFix": true }
    ]
}

4) vue.It linting error.If , VS-.

+3

. , eslint, npm ( ), "eslint --init", vscode. , .

0

Source: https://habr.com/ru/post/1684343/


All Articles