Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.
This repository was archived by the owner on Oct 23, 2024. It is now read-only.

Compatibility with Prettier #2

@tvharris

Description

@tvharris

When using Prettier, most ESLint formatting rules are redundant or may conflict.

Prettier recommends installing eslint-config-prettier to turn off most ESLint formatting rules.

I have attached ESLint and Prettier configurations based on Rooster's (without their project specific rules, at Peter's recommendation), and I have removed ESLint rules that overlap with Prettier. I tested the removed rules to make sure Prettier could handle them. I let the redundant rule linebreak-style": ["error", "unix"] remain because the vsCode Prettier plugin can't autofix the linebreak style.

Discussion of printWidth/max-len and ecmaVersion will be in separate issues.

Note that when using prettier it's also important to have a .prettierignore file.

.prettierrc.json:

{  
  "printWidth": 100,
  "singleQuote": true,
  "quoteProps": "consistent",
  "bracketSpacing": false,
  "endOfLine": "lf"
}

.eslintrc.json:

{
  "env": {"node": true, "es2021": true},
  "parserOptions": {"ecmaVersion": 2021},
  "extends": ["eslint:recommended", "prettier", "plugin:json/recommended"],
  "rules": {
    "max-len": ["error", {"code": 120}],
    "no-undef": "off",
    "no-redeclare": "off",
    "no-inner-declarations": "off",
    "no-unused-vars": ["warn", {"args": "none"}],
    "no-restricted-properties": [
      "error",
      {
        "object": "_",
        "property": "reduce",
        "message": "Please update a variable referenced via closure instead of using _.reduce()"
      },
      {
        "object": "it",
        "property": "only"
      },
      {
        "object": "describe",
        "property": "only"
      },
      {
        "object": "path",
        "property": "join",
        "message": "Please use forward slashes as a cross-platform path delimiter"
      }
    ],
    "no-implicit-globals": "error",
    "no-lonely-if": "error",
    "new-cap": ["error", {"newIsCap": true, "capIsNew": false, "properties": false}],
    "no-extend-native": "error",
    "no-use-before-define": ["error", {"functions": false}],
    "linebreak-style": ["error", "unix"],
    "no-empty": ["error", {"allowEmptyCatch": true}],

    "no-restricted-syntax": [
      "error",
      "BinaryExpression[operator='!==']",
      "BinaryExpression[operator='===']",
      "DebuggerStatement",
      "MetaProperty",
      "LabeledStatement"
    ]
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions