pinterest / arcanist-linters

A collection of custom Arcanist linters
Apache License 2.0
63 stars 45 forks source link

ESLintLinter: Pass name as code #32

Closed mrcljx closed 4 years ago

mrcljx commented 4 years ago

The code isn't supposed to be the violating source code, but some "identifier" for the violation. Some examples are:

final class ArcanistTextLinter extends ArcanistLinter {
  const LINT_DOS_NEWLINE          = 1;
  const LINT_TAB_LITERAL          = 2;
  const LINT_LINE_WRAP            = 3;
  const LINT_EOF_NEWLINE          = 4;
  const LINT_BAD_CHARSET          = 5;
  const LINT_TRAILING_WHITESPACE  = 6;
  const LINT_BOF_WHITESPACE       = 8;
  const LINT_EOF_WHITESPACE       = 9;
  const LINT_EMPTY_FILE           = 10;

A common pattern seems to be to just pass $this->getLinterName() there's just no real code. Also done in the PrettierLinter in this repo.

mrcljx commented 4 years ago

I stumbled over this because of my long project path prefix:

[2020-01-06 12:35:50] EXCEPTION: (PhutilAggregateException) Some linters failed:
    - Exception: Parameter ("[REDACTED]/SomeFile.js") passed to "setCode()" when constructing a lint message must be a scalar with a maximum string length of 128 bytes, but is 134 bytes in length. at [<arcanist>/src/lint/engine/ArcanistLintEngine.php:274]