Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TODO: local node_modules linter support like eslint or textlint #45

Closed
terrortylor opened this issue Jan 28, 2021 · 2 comments
Closed

Comments

@terrortylor
Copy link

There is a TODO item on the repository home page to add/documet local mode_modules linter support.
I've got an example i my config I'd like to add to the wiki

@terrortylor
Copy link
Author

I use the following configuration to lint with eslint that is installed as a project dependency in node_modules:

require'lspconfig'.diagnosticls.setup{
    filetypes = {"javascript", "typescript"},
    root_dir = function(fname)
      return util.root_pattern("tsconfig.json")(fname) or
      util.root_pattern(".eslintrc.js", ".git")(fname);
    end,
    init_options = {
      linters = {
        eslint = {
          command = "./node_modules/.bin/eslint",
          rootPatterns = {".eslintrc.js", ".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 = "[eslint] ${message} [${ruleId}]",
            security = "severity"
          },
          securities = {
            [2] = "error",
            [1] = "warning"
          }
        },
      },
      filetypes = {
        javascript = "eslint",
        typescript = "eslint"
      }
    }
  }

This uses eslint v7.12.1
and NodeJS v12.20.1

The root_dir option is set to pick up the root directory based on the .eslintrc.js file or .git directory.

@iamcco
Copy link
Owner

iamcco commented Feb 18, 2021

The todo item local node_modules linter support is done. you can use the local node_modules linters.

@iamcco iamcco closed this as completed May 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants