1

В VS Code settings.json для Prettier указал следующие настройки

"prettier.useTabs": false,
"prettier.printWidth": 80,
"prettier.tabWidth": 4,
"prettier.singleQuote": false,
"prettier.semi": true,
"prettier.trailingComma": "es5",

Во Vue проекте есть .eslint.js со следующими настройками

module.exports = {
root: true,
env: {
    node: true,
},
extends: ["plugin:vue/essential", "eslint:recommended", "@vue/prettier"],
parserOptions: {
    parser: "babel-eslint",
},
rules: {
    "no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
    "no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
    indent: ["error", 4], // не работает
    "vue/script-indent": ["error", 4, { "baseIndent": 1 }], // не работает
},

};

В VSCode Prettier настройки работают, но в ".eslint.js" не реагирует ни на какие правила "rules", ESLint выдает ошибки на пробелы, необходимо 2, когда в ".eslint.js" задал 4. Как сделать так, чтоб ESLint был настроен:

  1. На 4 пробела
  2. На 2 таба
0

1 ответ 1

0

Файл конфига в формате JS должен быть .eslintrc.js:

Configuration File Formats

ESLint supports configuration files in several formats:

    JavaScript - use .eslintrc.js and export an object containing your configuration.
    JavaScript (ESM) - use .eslintrc.cjs when running ESLint in JavaScript packages that specify "type":"module" in their package.json. Note that ESLint does not support ESM configuration at this time.
    YAML - use .eslintrc.yaml or .eslintrc.yml to define the configuration structure.
    JSON - use .eslintrc.json to define the configuration structure. ESLint's JSON files also allow JavaScript-style comments.
    Deprecated - use .eslintrc, which can be either JSON or YAML.
    package.json - create an eslintConfig property in your package.json file and define your configuration there.

If there are multiple configuration files in the same directory, ESLint will only use one. The priority order is:

    .eslintrc.js
    .eslintrc.cjs
    .eslintrc.yaml
    .eslintrc.yml
    .eslintrc.json
    .eslintrc
    package.json

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.