Skip to content
Liquan Yang edited this page May 9, 2024 · 65 revisions

You may also want to check file https://github.com/iamcco/coc-diagnostic/blob/master/src/config.ts for more linter config.

Don't forget to map the linter to a filetype, as described here.

"cpplint": {
  "command": "cpplint",
  "args": ["%file"],
  "debounce": 100,
  "isStderr": true,
  "isStdout": false,
  "sourceName": "cpplint",
  "offsetLine": 0,
  "offsetColumn": 0,
  "formatPattern": [
    "^[^:]+:(\\d+):(\\d+)?\\s+([^:]+?)\\s\\[(\\d)\\]$",
    {
      "line": 1,
      "column": 2,
      "message": 3,
      "security": 4
    }
  ],
  "securities": {
    "1": "info",
    "2": "warning",
    "3": "warning",
    "4": "error",
    "5": "error"
  }
}

Only tested with globally installed elm-review and native nvim lsp.

"elm-review": {
  "command": "elm-review",
  "rootPatterns": [".git", "elm-stuff"],
  "debounce": 100,
  "args": [],
  "sourceName": "elm-review",
  "formatLines": 3,
  "formatPattern": [
    "^[-─\\s]+(?:ELM-REVIEW ERROR)?[-─\\s]+([^:]+):(\\d+):(\\d+)\n\n([^\\n]+)$",
    {
      "sourceName": 1,
      "sourceNameFilter": true,
      "line": 2,
      "column": 3,
      "message": 4
    }
  ]
}
"eslint": {
  "command": "./node_modules/.bin/eslint",  // this will find local eslint first, if local eslint not found, it
  "rootPatterns": [
    ".git"
  ],
  "debounce": 100,
  "args": [
    "--stdin",
    "--stdin-filename",
    "%filepath",
    "--format",
    "json"
  ],
  "sourceName": "eslint",
  "parseJson": {
    "errorsRoot": "[0].messages",
    "line": "line",
    "column": "column",
    "endLine": "endLine",
    "endColumn": "endColumn",
    "message": "${message} [${ruleId}]",
    "security": "severity"
  },
  "securities": {
    "2": "error",
    "1": "warning"
  }
}
  "fish": {
    "command": "fish",
    "args": ["-n", "%file"],
    "isStdout": false,
    "isStderr": true,
    "sourceName": "fish",
    "formatLines": 1,
    "formatPattern": [
      "^.*\\(line (\\d+)\\): (.*)$",
      {
        "line": 1,
        "message": 2
      }
    ]
  }
"flake8": {
  "command": "flake8",
  "debounce": 100,
  "args": [ "--format=%(row)d,%(col)d,%(code).1s,%(code)s: %(text)s", "-" ],
  "offsetLine": 0,
  "offsetColumn": 0,
  "sourceName": "flake8",
  "formatLines": 1,
  "formatPattern": [
    "(\\d+),(\\d+),([A-Z]),(.*)(\\r|\\n)*$",
    {
      "line": 1,
      "column": 2,
      "security": 3,
      "message": 4
    }
  ],
  "securities": {
    "W": "warning",
    "E": "error",
    "F": "error",
    "C": "error",
    "N": "error"
  }
}
"golangci-lint": {
  "command": "golangci-lint",
  "rootPatterns": [ ".git", "go.mod" ],
  "debounce": 100,
  "args": [ "run", "--out-format", "json" ],
  "sourceName": "golangci-lint",
  "parseJson": {
    "sourceName": "Pos.Filename",
    "sourceNameFilter": true,
    "errorsRoot": "Issues",
    "line": "Pos.Line",
    "column": "Pos.Column",
    "message": "${Text} [${FromLinter}]",
  }
}
"hadolint": {
  "command": "hadolint",
  "sourceName": "hadolint",
  "args": [
    "-f",
    "json",
    "-"
  ],
  "rootPatterns": [".hadolint.yaml"],
  "parseJson": {
    "line": "line",
    "column": "column",
    "security": "level",
    "message": "${message} [${code}]"
  },
  "securities": {
    "error": "error",
    "warning": "warning",
    "info": "info",
    "style": "hint"
  }
}
"hlint": {
  "command": "hlint",
  "debounce": 100,
  "args": ["--json", "-"],
  "sourceName": "hlint",
  "parseJson": {
    "line": "startLine",
    "column": "startColumn",
    "endLine": "endLine",
    "endColumn": "endColumn",
    "message": "${hint}",
    "security": "severity"
  },
  "securities": {
    "Error": "error",
    "Warning": "warning",
    "Suggestion": "info"
  }
}
"languagetool": {
  "command": "languagetool",
  "debounce": 200,
  "args": ["-"],
  "offsetLine": 0,
  "offsetColumn": 0,
  "sourceName": "languagetool",
  "formatLines": 2,
  "formatPattern": [
    "^\\d+?\\.\\)\\s+Line\\s+(\\d+),\\s+column\\s+(\\d+),\\s+([^\\n]+)\nMessage:\\s+(.*)(\\r|\\n)*$",
    {
      "line": 1,
      "column": 2,
      "message": [4, 3]
    }
  ],
}
"lslint": {
  "command": "lslint",
  "isStdout": false,
  "isStderr": true,
  "debounce": 100,
  "formatPattern": [
    "^(.+):: \\( *(\\d+), *(\\d+)\\): (.+)(\\r|\\n)*$",
    { "column": 3, "line": 2, "message": [4], "security": 1 }
  ],
  "securities": { "ERROR": "error", "WARN": "warning" },
  "sourceName": "lslint"
}
"markdownlint": {
  "command": "markdownlint",
  "isStderr": true,
  "debounce": 100,
  "args": [ "--stdin" ],
  "offsetLine": 0,
  "offsetColumn": 0,
  "sourceName": "markdownlint",
  "formatLines": 1,
  "formatPattern": [
    "^.*?:\\s?(\\d+)(:(\\d+)?)?\\s(MD\\d{3}\\/[A-Za-z0-9-/]+)\\s(.*)$",
    {
      "line": 1,
      "column": 3,
      "message": [4]
    }
  ]
}
"mix_credo": {
  "command": "mix",
  "debounce": 100,
  "rootPatterns": ["mix.exs"],
  "args": ["credo", "suggest", "--format", "flycheck", "--read-from-stdin"],
  "offsetLine": 0,
  "offsetColumn": 0,
  "sourceName": "mix_credo",
  "formatLines": 1,
  "formatPattern": [
    "^[^ ]+?:([0-9]+)(:([0-9]+))?:\\s+([^ ]+):\\s+(.*)(\\r|\\n)*$",
    {
    "line": 1,
    "column": 3,
    "message": 5,
    "security": 4
    }
  ],
  "securities": {
    "F": "warning",
    "C": "warning",
    "D": "info",
    "R": "info"
  }
}

compile error. this only works when file on save. you can use both ['mix_credo', 'mix_credo_compile'] for filetype.

"mix_credo_compile": {
  "command": "mix",
  "debounce": 100,
  "rootPatterns": ["mix.exs"],
  "args": ["credo", "suggest", "--format", "flycheck", "--read-from-stdin"],
  "offsetLine": -1,
  "offsetColumn": 0,
  "sourceName": "mix_credo",
  "formatLines": 1,
  "formatPattern": [
    "^([^ ]+)\\s+\\(([^)]+)\\)\\s+([^ ]+?):([0-9]+):\\s+(.*)(\\r|\\n)*$",
    {
    "line": -1,
    "column": -1,
    "message": ["[", 2, "]: ", 3, ": ", 5],
    "security": 1
    }
  ],
  "securities": {
    "**": "error"
  }
}
"mypy": {
  "sourceName": "mypy",
  "command": "mypy",
  "args": [
    "--no-color-output",
    "--no-error-summary",
    "--show-column-numbers",
    "--follow-imports=silent",
    "%file"
  ],
  "formatPattern": [
    "^.*:(\\d+?):(\\d+?): ([a-z]+?): (.*)$",
    {
      "line": 1,
      "column": 2,
      "security": 3,
      "message": 4
    }
  ],
  "securities": {
    "error": "error"
  }
}
 "phpcs": {
    "command": "./vendor/bin/phpcs",
    "debounce": 100,
    "rootPatterns": [ "composer.json", "composer.lock", "vendor", ".git" ],
    "args": [ "--standard=PSR2", "--report=emacs", "-s", "-" ],
    "offsetLine": 0,
    "offsetColumn": 0,
    "sourceName": "phpcs",
    "formatLines": 1,
    "formatPattern": [
      "^.*:(\\d+):(\\d+):\\s+(.*)\\s+-\\s+(.*)(\\r|\\n)*$",
      {
        "line": 1,
        "column": 2,
        "message": 4,
        "security": 3
      }
    ],
    "securities": {
      "error": "error",
      "warning": "warning"
    }
  }
}
"phpstan": {
  "command": "./vendor/bin/phpstan",
  "debounce": 100,
  "rootPatterns": [ "composer.json", "composer.lock", "vendor", ".git" ],
  "args": [ "analyze", "--error-format", "raw", "--no-progress", "%file" ],
  "offsetLine": 0,
  "offsetColumn": 0,
  "sourceName": "phpstan",
  "formatLines": 1,
  "formatPattern": [
    "^[^:]+:(\\d+):(.*)(\\r|\\n)*$",
    {
      "line": 1,
      "message": 2
    }
  ]
}

If you need to change the --level setting etc., put the phpstan.neon configuration file in the project

e.g. phpstan.neon

parameters:
  level: 5
  # more config...
"psalm": {
  "command": "./vendor/bin/psalm",
  "debounce": 100,
  "rootPatterns": ["composer.json", "composer.lock", "vendor", ".git"],
  "args": ["--output-format=emacs", "--no-progress"],
  "offsetLine": 0,
  "offsetColumn": 0,
  "sourceName": "psalm",
  "formatLines": 1,
  "formatPattern": [
    "^[^:]+:(\\d+):(\\d+):(.*)\\s-\\s(.*)(\\r|\\n)*$",
    {
      "line": 1,
      "column": 2,
      "message": 4,
      "security": 3
    }
  ],
  "securities": {
    "error": "error",
    "warning": "warning"
  },
  "requiredFiles": ["psalm.xml"]
}

psalm.xml configuration file is required to run psalm.

Add a psalm.xml config:

./vendor/bin/psalm --init
"pylint": {
  "sourceName": "pylint",
  "command": "pylint",
  "args": [
    "--output-format",
    "text",
    "--score",
    "no",
    "--msg-template",
    "'{line}:{column}:{category}:{msg} ({msg_id}:{symbol})'",
    "%file"
  ],
  "formatPattern": [
    "^(\\d+?):(\\d+?):([a-z]+?):(.*)$",
    {
      "line": 1,
      "column": 2,
      "security": 3,
      "message": 4
    }
  ],
  "rootPatterns": [".git", "pyproject.toml", "setup.py"],
  "securities": {
    "informational": "hint",
    "refactor": "info",
    "convention": "info",
    "warning": "warning",
    "error": "error",
    "fatal": "error"
  },
  "offsetColumn": 1,
  "formatLines": 1
}
"reek": {
  "command": "bundle",
  "sourceName": "reek",
  "debounce": 100,
  "args": [
    "exec",
    "reek",
    "--format",
    "json",
    "--force-exclusion",
    "--stdin-filename",
    "%filepath"
  ],
  "parseJson": {
    "line": "lines[0]",
    "endLine": "lines[1]",
    "message": "[${smell_type}] ${message}"
  },
  "securities": {
    "undefined": "info"
  }
},
"revive": {
    "command": "revive",
    "rootPatterns": [ ".git", "go.mod" ],
    "debounce": 100,
    "args": [ "%file" ],
    "sourceName": "revive",
    "formatPattern": [
      "^[^:]+:(\\d+):(\\d+):\\s+(.*)$",
      {
        "line": 1,
        "column": 2,
        "message": [3]
      }
    ]
 }
"rubocop": {
  "command": "bundle",
  "sourceName": "rubocop",
  "debounce": 100,
  "args": [
    "exec",
    "rubocop",
    "--format",
    "json",
    "--force-exclusion",
    "--stdin",
    "%filepath"
  ],
  "parseJson": {
    "errorsRoot": "files[0].offenses",
    "line": "location.start_line",
    "endLine": "location.last_line",
    "column": "location.start_column",
    "endColumn": "location.end_column",
    "message": "[${cop_name}] ${message}",
    "security": "severity"
  },
  "securities": {
    "fatal": "error",
    "error": "error",
    "warning": "warning",
    "convention": "info",
    "refactor": "info",
    "info": "info"
  }
}
"ruff": {
  "command": "ruff",
  "debounce": 500,
  "args": [ "check", "--output-format", "json", "%filepath" ],
  "rootPatterns": [ "pyproject.toml", "ruff.toml" ],
  "sourceName": "ruff",
  "parseJson": {
    "line": "location.row",
    "column": "location.column",
    "endLine": "end_location.row",
    "endColumn": "end_location.column",
    "message": "${message} [${code}]",
    "security": "fix.applicability"
  },
  "securities": {
    "safe": "warning",
    "unsafe": "error"
  }
}
"shellcheck": {
  "command": "shellcheck",
  "debounce": 100,
  "args": [
    "--format",
    "json",
    "-"
  ],
  "sourceName": "shellcheck",
  "parseJson": {
    "line": "line",
    "column": "column",
    "endLine": "endLine",
    "endColumn": "endColumn",
    "message": "${message} [${code}]",
    "security": "level"
  },
  "securities": {
    "error": "error",
    "warning": "warning",
    "info": "info",
    "style": "hint"
  }
}
"slim-lint": {
  "command": "bundle",
  "sourceName": "slim-lint",
  "debounce": 100,
  "args": [
    "exec",
    "slim-lint",
    "--reporter", "json",
    "--stdin-file-path", "%filepath"
  ],
  "parseJson": {
    "errorsRoot": "files[0].offenses",
    "line": "location.line",
    "message": "${message}",
    "security": "severity"
  },
  "securities": {
    "error": "error",
    "warning": "warning"
  }
}
"solhint": {
  "command": "./node_modules/.bin/solhint",
  "rootPatterns": [".solhint.json"],
  "debounce": 100,
  "args": ["--formatter", "unix", "%filepath"],
  "sourceName": "solhint",
  "offsetLine": 0,
  "offsetColumn": 0,
  "formatLines": 1,
  "formatPattern": [
    "^[^:]+:(\\d+):(\\d+):\\s+([^\\[]+)\\[([A-z]+)\\/?[a-z-]*\\]$",
    {
      "line": 1,
      "column": 2,
      "security": 4,
      "message": 3
    }
  ],
  "securities": {
    "Error": "error",
    "Warning": "warning"
  }
}
"standard": {
  "command": "./node_modules/.bin/standard",
  "isStderr": false,
  "isStdout": true,
  "args": ["--stdin", "--verbose"],
  "rootPatterns": [".git"],
  "debounce": 100,
  "offsetLine": 0,
  "offsetColumn": 0,
  "sourceName": "standard",
  "formatLines": 1,
  "formatPattern": [
    "^\\s*<\\w+>:(\\d+):(\\d+):\\s+(.*)(\\r|\\n)*$",
    {
      "line": 1,
      "column": 2,
      "message": 3
    }
  ]
}
"stylelint": {
  "command": "./node_modules/.bin/stylelint",
  "rootPatterns": [
    ".git"
  ],
  "debounce": 100,
  "args": [
    "--formatter",
    "json",
    "--stdin-filename",
    "%filepath"
  ],
  "sourceName": "stylelint",
  "parseJson": {
    "errorsRoot": "[0].warnings",
    "line": "line",
    "column": "column",
    "message": "${text}",
    "security": "severity"
  },
  "securities": {
    "error": "error",
    "warning": "warning"
  }
}

"--type", "tex" can be changed to "--type", "md" for Markdown

"textidote": {
  "command": "textidote",
  "debounce": 500,
  "args": ["--type", "tex", "--check", "en", "--output", "singleline", "--no-color"],
  "offsetLine": 0,
  "offsetColumn": 0,
  "sourceName": "textidote",
  "formatLines": 1,
  "formatPattern": [
    "\\(L(\\d+)C(\\d+)-L(\\d+)C(\\d+)\\):(.+)\".+\"$",
    {
      "line": 1,
      "column": 2,
      "endLine": 3,
      "endColumn": 4,
      "message": 5
    }
  ],
}
"tidy": {
  "command": "tidy",
  "args": ["-e", "-q"],
  "rootPatterns": [".git/"],
  "isStderr": true,
  "debounce": 100,
  "offsetLine": 0,
  "offsetColumn": 0,
  "sourceName": "tidy",
  "formatLines": 1,
  "formatPattern": [
    "^.*?(\\d+).*?(\\d+)\\s+-\\s+([^:]+):\\s+(.*)(\\r|\\n)*$",
    {
      "line": 1,
      "column": 2,
      "endLine": 1,
      "endColumn": 2,
      "message": [4],
      "security": 3
    }
  ],
  "securities": {
    "Error": "error",
    "Warning": "warning"
  }
}
"vale": {
  "command": "vale",
  "debounce": 100,
  "args": ["--no-exit", "--output", "JSON", "--ext", ".md"],
  "sourceName": "vale",
  "parseJson": {
    "errorsRoot": "stdin.md",
    "line": "Line",
    "column": "Span[0]",
    "endLine": "Line",
    "endColumn": "Span[1]",
    "message": "${Message}\n${Link}",
    "security": "Severity"
  },
  "securities": {
    "error": "error",
    "warning": "warning",
    "suggestion": "info"
  }
}
"vint": {
  "command": "vint",
  "debounce": 100,
  "args": [ "--enable-neovim", "-"],
  "offsetLine": 0,
  "offsetColumn": 0,
  "sourceName": "vint",
  "formatLines": 1,
  "formatPattern": [
    "[^:]+:(\\d+):(\\d+):\\s*(.*)(\\r|\\n)*$",
    {
      "line": 1,
      "column": 2,
      "message": 3
    }
  ]
}
"write-good": {
  "command": "write-good",
  "debounce": 100,
  "args": [ "--text=%text" ],
  "offsetLine": 0,
  "offsetColumn": 1,
  "sourceName": "write-good",
  "formatLines": 1,
  "formatPattern": [
    "(.*)\\s+on\\s+line\\s+(\\d+)\\s+at\\s+column\\s+(\\d+)\\s*$",
    {
      "line": 2,
      "column": 3,
      "message": 1
    }
  ]
}
"xo": {
  "command": "xo",  // or use "./node_modules/.bin/xo" if installed in a project-level directory
  "rootPatterns": [
    "package.json",
    ".git"
  ],
  "debounce": 100,
  "args": [
    "--reporter",
    "json",
    "--stdin",
    "--stdin-filename",
    "%filepath"
  ],
  "sourceName": "xo",
  "parseJson": {
    "errorsRoot": "[0].messages",
    "line": "line",
    "column": "column",
    "endLine": "endLine",
    "endColumn": "endColumn",
    "message": "[xo] ${message} [${ruleId}]",
    "security": "severity"
  },
  "securities": {
    "2": "error",
    "1": "warning"
  }
}
  "zsh": {
    "command": "zsh",
    "args": ["-n", "%file"],
    "isStdout": false,
    "isStderr": true,
    "sourceName": "zsh",
    "formatLines": 1,
    "formatPattern": [
      "^[^:]+:(\\d+):\\s+(.*)$",
      {
        "line": 1,
        "message": 2
      }
    ]
  }