Git Product home page Git Product logo

coc-eslint's Introduction

coc-eslint

Eslint language server extension for coc.nvim.

Forked from vscode-eslint.

Note buffers need save to disk to make this extension work as expected.

Install

In your vim/neovim run the following command:

:CocInstall coc-eslint

Features

  • Lint javascript files using eslint.
  • Provide codeActions for fixing lint issues.
  • Provide eslint commands:
    • eslint.executeAutofix Fix all auto-fixable Problems.
    • eslint.createConfig Create ESLint configuration.
    • eslint.showOutputChannel Show Output Channel.
    • eslint.restart Restart ESLint Server.
    • eslint.lintProject Run eslint for current project, add errors to quickfix list.

Note: eslint may not work with files just created, invoke :CocCommand eslint.restart on that case.

Configuration options

Notice these configuration settings allow you to configure the behaviour of the coc-eslint extension. They should be set in your coc-settings.json file, which can be opened with the :CocConfig command.

  • eslint.enable: Controls whether eslint is enabled or not. Default: true
  • eslint.packageManager: The package manager you use to install node modules. Default: "npm" Valid options: ["npm","yarn","pnpm"]
  • eslint.alwaysShowStatus: Always show the ESlint status bar item. Default: false
  • eslint.fixOnSaveTimeout: Timeout in miliseconds when run auto fix on save. Default: 1000
  • eslint.nodeEnv: The value of NODE_ENV to use when running eslint tasks. Default: null
  • eslint.nodePath: A path added to NODE_PATH when resolving the eslint module. Default: null
  • eslint.options: The eslint options object to provide args normally passed to eslint when executed from a command line (see https://eslint.org/docs/developer-guide/nodejs-api#eslint-class). Default: {}
  • eslint.trace.server: Traces the communication between VSCode and the eslint linter service. Default: "off"
  • eslint.run: Run the linter on save (onSave) or on type (onType) Default: "onType" Valid options: ["onSave","onType"]
  • eslint.autoFixOnSave: Turns auto fix on save on or off. Default: false
  • eslint.quiet: Turns on quiet mode, which ignores warnings. Default: false
  • eslint.onIgnoredFiles: Whether ESLint should issue a warning on ignored files. Default: "off" Valid options: ["warn","off"]
  • eslint.useESLintClass: Since version 7 ESLint offers a new API call ESLint. Use it even if the old CLIEngine is available. From version 8 on forward on ESLint class is available. Default: false
  • eslint.experimental.useFlatConfig: Enables support of experimental Flat Config (aka eslint.config.js, supported by ESLint version 8.21 or later). Default: false
  • eslint.workingDirectories: Specifies how the working directories ESLint is using are computed. ESLint resolves configuration files (e.g. eslintrc, .eslintignore) relative to a working directory so it is important to configure this correctly.
  • eslint.validate: An array of language ids which should be validated by ESLint. If not installed ESLint will show an error.
  • eslint.probe: An array of language ids for which the extension should probe if support is installed. Default: ["javascript","javascriptreact","typescript","typescriptreact","html","vue","markdown"]
  • eslint.runtime: The location of the node binary to run ESLint under. Default: null
  • eslint.debug: Enables ESLint debug mode (same as --debug on the command line) Default: false
  • eslint.execArgv: Additional exec argv argument passed to the runtime. This can for example be used to control the maximum heap space using --max_old_space_size Default: null
  • eslint.codeAction.disableRuleComment: Show disable lint rule in the quick fix menu. Default: {"enable":true,"location":"separateLine"}
  • eslint.codeAction.showDocumentation: Show open lint rule documentation web page in the quick fix menu. Default: {"enable":true}
  • eslint.codeActionsOnSave.mode: Specifies the code action mode. Possible values are 'all' and 'problems'. Default: "all" Valid options: ["all","problems"]
  • eslint.codeActionsOnSave.rules: The rules that should be executed when computing the code actions on save or formatting a file. Defaults to the rules configured via the ESLint configuration Default: null
  • eslint.format.enable: Enables ESLint as a formatter. Default: false
  • eslint.rules.customizations: Override the severity of one or more rules reported by this extension, regardless of the project's ESLint config. Use globs to apply default severities for multiple rules.
  • eslint.lintTask.options: Command line options applied when running the task for linting the whole workspace (see https://eslint.org/docs/user-guide/command-line-interface). Default: ["."]

Auto-fixing

The extension supports automatic fixing of warnings to the extent that it is supported by eslint. For warnings which support an auto-fix. You can apply the quick fix by either:

  • Set eslint.autoFixOnSave to true and save your file (recommended).
  • Trigger <Plug>(coc-codeaction) with mapped keys, and select a fix action in the input list.
  • Run command :CocCommand eslint.executeAutofix.
  • Trigger command eslint.executeAutofix from :CocCommand.

Supporting

If you like my extension, consider supporting me on Patreon or PayPal:

Patreon donate button PayPal donate button

License

MIT

coc-eslint's People

Contributors

benoitzugmeyer avatar brunoparga avatar chemzqm avatar christopher-francisco avatar ckipp01 avatar fannheyward avatar iamcco avatar jpoppe avatar maienm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coc-eslint's Issues

Error when opening .eslintrc.js

When I open my .eslintrc.js or similar file with coc-tsserver, coc-prettier & coc-eslint I receive a continuous error in my statusline:

[coc.nvim] error: UnhandledRejection: Range#create called with invalid arguments[null, -1, null, 0]

It appears this error is being caused by DiagnosticBuffer.fixRange, but I am unable to figure out what the source of the problem is or how to resolve it. I have tried various things to no avail.

All that I have been able to figure out is that the error is likely coming from coc-eslint, since removing this makes the error disappear.

Any suggestions?

Thanks

Modifies file

with these settings

  "eslint.enable": true,
  "eslint.autoFix": false,
  "eslint.autoFixOnSave": false,
  "eslint.run": "onType",
  "eslint.packageManager": "npm",

coc-eslint still modifies the file, so when you try to write using :w vim throws error.

Error on willSaveWaitUntil: Error: Request textDocument/willSaveWaitUntil failed with message: Cannot read property 'CLIEngine' of undefined

Result from CocInfo

[coc.nvim] Error on willSaveWaitUntil: Error: Request textDocument/willSaveWaitUntil failed with message: Cannot read property 'CLIEngine' of undefined "pages/index.js" 86L, 2343C written

Describe the bug

Every time I save a file in my standard next.js project folder I get the error above. I don't get this when I use a create-react-app project.

Reproduce the bug

create a next.js project with...

mkdir project && cd project
npm i --save react react-redux next
mkdir pages && touch pages/index.js
nvim pages/index.js

now try to save the file

my coc.vim vim config:

  set updatetime=300
  call coc#add_extension(
    \ 'coc-tsserver',
    \ 'coc-json',
    \ 'coc-pairs',
    \ 'coc-snippets',
    \ 'coc-vimlsp',
    \ 'coc-lists',
    \ 'coc-yank',
    \ 'coc-emmet',
    \ 'coc-word',
    \ 'coc-dictionary',
    \ 'coc-eslint',
    \ 'coc-prettier',
    \ 'coc-tslint-plugin',
    \)
  set signcolumn=yes
  nmap <silent> [[ <Plug>(coc-diagnostic-prev)
  nmap <silent> ]] <Plug>(coc-diagnostic-next)]"

  autocmd CursorHold * silent call CocActionAsync('highlight')

  set cmdheight=2

  " only coc-prettier & only coc-eslint & or both
  map <leader>fs :CocCommand eslint.executeAutofix<CR>
  map <leader>ff :CocCommand prettier.formatFile<CR>
  map <leader>fa <leader>xs<leader>xf

  " coc-snippet
  inoremap <silent><expr> <TAB>
    \ pumvisible() ? coc#_select_confirm() :
    \ coc#expandableOrJumpable() ? "\<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\<CR>" :
    \ <SID>check_back_space() ? "\<TAB>" :
    \ coc#refresh()

  function! s:check_back_space() abort
    let col = col('.') - 1
    return !col || getline('.')[col - 1]  =~# '\s'
  endfunction

  " Use <c-n> to trigger completion.
  inoremap <silent><expr> <c-n> coc#refresh()

  " coc-pair extended by \n on enter
  inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm() : "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"

  " Remap keys for gotos
  nmap <silent> gd <Plug>(coc-definition)
  nmap <silent> gy <Plug>(coc-type-definition)
  nmap <silent> gi <Plug>(coc-implementation)
  nmap <silent> gr <Plug>(coc-references)

  " Use K to show documentation in preview window
  nnoremap <silent> K :call <SID>show_documentation()<CR>

  function! s:show_documentation()
    if (index(['vim','help'], &filetype) >= 0)
      execute 'h '.expand('<cword>')
    else
      call CocAction('doHover')
    endif
  endfunction

Screenshots (optional)

image

How to use local eslint?

Is it possible to make coc-eslint use the copy of eslint at ./node_modules/.bin/eslint?

It may be a different version to the one installed globally, with different behaviour.

Related: I've experienced some strange autofixes with this plug-in enabled. Can I confirm it reads each project or directory's local .eslintrc?

Many thanks.

Broken path generation (on macvim)

This plugin works fine on commandline vim. However, it seems like when run it inside MacVim it seems like the file:/// uri is missing the home directory prefix. It results in a crash when trying to open a nonexistent file.

Disable particular lint rules

There doesn't appear to be a way to disable particular lint rules. I don't want to disable the rule in eslint itself, as I want eslint to still check for / flag the rule at commit time, I just want it to be quiet about a particular rule in my editor.

Unable to find global node modules

Hi, first of all, thank you for all your work!

I cannot use local node_modules as I run my app inside a docker container and the modules are not shared with the host, and I've run into a problem where coc-eslint is unable to find the global node modules, even though I think it is properly configured.

Output of :version:

:version
NVIM v0.4.0-902-gb65a7b7f6
Build type: RelWithDebInfo
LuaJIT 2.0.5
Compilation: /usr/bin/gcc-5 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -DMIN_LOG_LEVEL=3 -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wvla -fstack-protector-strong -fdiagnostics-color=auto -Wno-array
-bounds -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/home/travis/build/neovim/bot-ci/build/neovim/build/config -I/home/travis/build/neovim/bot-ci/build/neovim/src -I/home/travis/build/neovim/bot-ci/build/neovim/.deps/usr/inclu
de -I/usr/include -I/home/travis/build/neovim/bot-ci/build/neovim/build/src/nvim/auto -I/home/travis/build/neovim/bot-ci/build/neovim/build/include
Compiled by travis@travis-job-aaa3286b-17a0-4354-95d2-447d580a1864

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/home/travis/build/neovim/bot-ci/build/neovim/build/nvim.AppDir/usr/share/nvim"

Run :checkhealth for more info

The output of npm root -g is:

/home/myUser/.npm-global/lib/node_modules

My coc-settings.json:

{
    "tsserver.npm":  "/home/myUser/.npm-global/lib/node_modules",
    "tsserver.trace.server":  "verbose",
    "coc.preferences.hoverTarget": "float",
    "coc.preferences.enableFloatHighlight": true,
    "coc.preferences.useQuickfixForLocations": true,
    "suggest.enablePreview": true,
    "tsserver.enable": true,
    "typescript.suggestionActions.enabled": false,
    "javascript.suggestionActions.enabled": false,
    "eslint.nodePath": "/home/myUser/.npm-global/lib/node_modules",
    "eslint.autoFixOnSave" : true,
    "eslint.packageManager" : "npm"
}

The first error I see when opening Neovim on javascript/jsx files:

Consider running eslint --debug /home/myUser/Projects/myDir/mySubDir/app/components/builder/QuestionHorizontalNav.jsx from a terminal to obtain a trace about the configuration files used.

Running the above suggestion from the terminal runs fine and returns no errors.

Running :CocCommand workspace.showOutput for eslint shows:

[Info  - 2:49:19 PM] ESLint server running in node v11.15.0
[Info  - 2:49:19 PM] ESLint library loaded from: /home/myUser/Projects/someProject/someSubDir/node_modules/eslint/lib/api.js
[Error  - 2:49:19 PM] 
Failed to load plugin react-hooks: Cannot find module 'eslint-plugin-react-hooks'
Happened while validating /home/myUser/Projects/someProject/someSubDir/app/components/builder/QuestionHorizontalNav.jsx
This can happen for a couple of reasons:
1. The plugin name is spelled incorrectly in an ESLint configuration file (e.g. .eslintrc).
2. If ESLint is installed globally, then make sure 'eslint-plugin-react-hooks' is installed globally as well.
3. If ESLint is installed locally, then 'eslint-plugin-react-hooks' isn't installed correctly.

Consider running eslint --debug /home/myUser/Projects/someProject/someSubDir/app/components/builder/QuestionHorizontalNav.jsx from a terminal to obtain a trace about the configuration files used.

Here's the output of ls /home/myUser/.npm-global/lib/node_modules:

babel-eslint
eslint
eslint-plugin-immutable
eslint-plugin-react
eslint-plugin-react-hooks
jscodeshift
livedown
node-gyp
npx
prettier
@types
webpack-bundle-analyzer

I do have the right modules installed globally, but for some reason coc-eslint is ignoring the global directory /home/myUser/.npm-global/lib/node_modules.

Am I missing something from the configuration?

Any help is appreciated, thank you!

Linting messages as Virtualtext.

Is it possible to have this functionality with this plugin? Something similar to the option in coc-git: git.addGBlameToVirtualText.

Thanks.

Extremely slow execution and timeout errors

Every time that I save a file I get this message:

[coc.nvim] eslint will save operation timeout after 0.5s

If I save and quit, then I see this printed out in the terminal:

Error detected while processing function <lambda>27[1]..<SNR>187_onExit:
line    3:
E684: list index out of range: -1
E15: Invalid expression: a:out[len(a:out) - 1]

This is reproducible in even trivial files in empty projects, so I don't think the timeout is due to the complexity of the file being analyzed. Running :CocCommand eslint.executeAutofix manually works, but it can take 10-30 seconds on files with less than ten lines of code and no imports. Eslint works fine from the command-line without the same lag.

I'm using version 1.1.2 of the plugin and eslint v5.16.0 on Linux. My coc-eslint config is completely vanilla, I haven't done anything except install the plugin. Please let me know if there's additional information that I can provide which would be helpful.

Action "Disable rule for current line/entire file"

vscode-eslint provides the following actions:

  1. Disable [rule] for this line: Adds // eslint-disable-next-line [rule] to the line above
  2. Disable [rule] for the entire file: Adds /* eslint-disable [rule] */ on the first line of the current file.
    image

I was wondering if there is already a way to do that, and if not, if it would be possible to implement that...

eslint signs not disappearing

In vim8, when I get eslint errors the signs appear, I fix them, save and the error highlight is still visible on the words. I need to reload the file for the error to disappear, any ideas?

config:

{
  "coc.preferences.colorSupport": true,
  "eslint.enable": true,
  "eslint.filetypes": ["javascript", "javascriptreact", "typescript", "typescript.tsx", "typescriptreact.tsx", "typescript.jsx", "typescriptreact.tsx", "typescriptreact"],
  "eslint.autoFix": false,
  "eslint.autoFixOnSave": false,
  "tsserver.log": "verbose",
  "tsserver.trace.server": "verbose",
  "eslint.trace.server": "verbose",
  "diagnostic.refreshOnInsertMode": false,
  "list.source.outline.defaultOptions": ["--auto-preview"],
  "typescript.format.insertSpaceAfterCommaDelimiter": true,
  "typescript.format.insertSpaceAfterConstructor": true,
  "typescript.format.insertSpaceAfterSemicolonInForStatements": true,
  "typescript.format.insertSpaceBeforeAndAfterBinaryOperators": true,
  "typescript.format.insertSpaceAfterKeywordsInControlFlowStatements": true,
  "typescript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": true,
  "typescript.format.insertSpaceBeforeFunctionParenthesis": true,
  "typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": true,
  "typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": true,
  "typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": true,
  "typescript.format.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": true,
  "typescript.format.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": true,
  "typescript.format.insertSpaceAfterTypeAssertion": true
}

.eslintignore doesn't work

CocInfo:

## versions

vim version: NVIM v0.4.0-dev
node version: v8.9.0
coc.nvim version: 0.0.55
term: xterm-256color
platform: linux

## Error messages

## Output channel: prettier

## Output channel: snippets
[Info 2019-2-18] Loaded 41 snippets from /home/cjnucette/.config/coc/extensions/node_modules/JavaScriptSnippets/snippets/snippets.json
[Info 2019-2-18] Loaded 28 snippets from /home/cjnucette/.config/coc/extensions/node_modules/coc-tsserver/snippets/typescript.json
[Info 2019-2-18] Loaded 57 snippets from /home/cjnucette/.config/coc/extensions/node_modules/jest-snippets/snippets/snippets.json
[Info 10:07:10] Loaded 15 snippets from: /home/cjnucette/.config/nvim/plugged/yats.vim/UltiSnips/typescript.snippets

## Output channel: tsserver
[Info  - 10:07:09] Forking TSServer
PATH: /home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:/home/cjnucette/.local/share/umake/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/cjnucette/.local/bin:/home/cjnucette/.local/share/npm/bin:./node_modules/.bin:/home/cjnucette/go/bin:/home/cjnucette/.fzf/bin 
[Info  - 10:07:10] Started TSServer
{
  "path": "/home/cjnucette/code/hapi-tutorial/node_modules/typescript/lib",
  "_api": {
    "versionString": "3.3.3",
    "version": "3.3.3"
  }
}

## Output channel: eslint
[Info  - 10:07:10] ESLint server running in node v8.9.0
[Info  - 10:07:10] ESLint library loaded from: /home/cjnucette/code/hapi-tutorial/node_modules/eslint/lib/api.js

## Output channel: highlight
[Info  - 10:07:10] Highlight server running in node v8.9.0

.eslintignore:

node_modules/
dist/

I can't get coc-prettier to read .prettierignore either, btw.

eslint-react-hooks - code action is missing

Hi,
I miss code action from eslint-react-hooks.
There is action in vs code named 'Fix this react-hooks/exhaustive-deps problem' that fix (add/remove) dependencies (like testProp in useMemo hook).

Minimal test code:

import * as React from "react";
import { useMemo } from "react";

export const FComponent: React.FC<{}> = ({ testProp }) => {
    const test = useMemo(() => {
        if (testProp) return "test";
        return "-";
    }, [testProp]);

    return <div>{test}</div>;
};

Is this some kind of bug or just missing functionality?
Thanks

Possible to resolve node modules from opened file path, not `cwd`?

First off thank you for everything you do with coc.nvim, has completely changed how I use neovim! ❤️

On to the question: is it possible to resolve node modules from the opened file path?

I work in a monorepo with the following layout (simplified for example here):

image

If I'm in the specific-package directory and open file.ts (nvim ./file.ts) everything works beautifully. It picks up on my .eslintrc.json, loads the expected node_modules and autofixes correctly.

If I try to open file.ts from packages (nvim ./specific-package/file.ts) it no longer lints or autofixes. CocList folders shows /packages and workspace.showOutput for eslint shows errors loading the eslint modules I'm using:

[Info  - 5:09:14 PM] ESLint server running in node v10.15.3
[Info  - 5:09:15 PM] ESLint library loaded from: /Users/nathanshelly/projects/go/src/github.com/opendoor-labs/code/js/packages/trade-in-dashboard-fe/node_modules/eslint/lib/api.js
[Error  - 5:09:15 PM] 
Failed to load plugin '@typescript-eslint' declared in 'js/packages/trade-in-dashboard-fe/.eslintrc.json': Cannot find module '@typescript-eslint/eslint-plugin'
Require stack:
- /Users/nathanshelly/projects/go/src/github.com/opendoor-labs/code/__placeholder__.js
Referenced from: /Users/nathanshelly/projects/go/src/github.com/opendoor-labs/code/js/packages/trade-in-dashboard-fe/.eslintrc.json
Happened while validating /Users/nathanshelly/projects/go/src/github.com/opendoor-labs/code/js/packages/trade-in-dashboard-fe/src/routes/SellPage/OfferClosed.tsx
This can happen for a couple of reasons:
1. The plugin name is spelled incorrectly in an ESLint configuration file (e.g. .eslintrc).
2. If ESLint is installed globally, then make sure '@typescript-eslint/eslint-plugin' is installed globally as well.
3. If ESLint is installed locally, then '@typescript-eslint/eslint-plugin' isn't installed correctly.

Consider running eslint --debug /Users/nathanshelly/projects/go/src/github.com/opendoor-labs/code/js/packages/trade-in-dashboard-fe/src/routes/SellPage/OfferClosed.tsx from a terminal to obtain a trace about the configuration files used.

I understand that this extension resolves node modules upwards from the workspace folder so it makes sense that it fails here. I'm hoping there's a way I can trigger resolution to occur from the file and not my current working directory. This seems possibly related to #23.

Thanks again for all the amazing work you've done!

Additional diagnostics

Full :CocInfo

## versions

vim version: NVIM v0.5.0-dev
node version: v10.15.3
coc.nvim version: 0.0.74-a84f813105
term: tmux-256color
platform: darwin

## Messages

## Output channel: prettier


## Output channel: watchman

[Info  - 6:10:05 PM] watchman watching project: /Users/nathanshelly/projects/go/src/github.com/opendoor-labs/code
[Info  - 6:10:05 PM] subscribing "**/[tj]sconfig.json" in /Users/nathanshelly/projects/go/src/github.com/opendoor-labs/code
[Info  - 6:10:05 PM] subscribing "**/package.json" in /Users/nathanshelly/projects/go/src/github.com/opendoor-labs/code
[Info  - 6:10:05 PM] subscribing "**/.eslintr{c.js,c.yaml,c.yml,c,c.json}" in /Users/nathanshelly/projects/go/src/github.com/opendoor-labs/code
[Info  - 6:10:05 PM] subscribing "**/.eslintignore" in /Users/nathanshelly/projects/go/src/github.com/opendoor-labs/code
[Info  - 6:10:05 PM] subscribing "**/package.json" in /Users/nathanshelly/projects/go/src/github.com/opendoor-labs/code
[Info  - 6:10:05 PM] subscribing "**/{.prettierrc,.prettierrc.json,.prettierrc.yaml,.prettierrc.yml,.prettierrc.js,package.json,prettier.config.js}" in /Users/nathanshelly/projects/go/src/github.com/opendoor-labs/code
[Info  - 6:10:05 PM] subscribing "**/*.{ts,tsx}" in /Users/nathanshelly/projects/go/src/github.com/opendoor-labs/code

## Output channel: tsserver

[Info  - 6:10:05 PM] Forking TSServer
PATH: /Users/nathanshelly/.asdf/installs/nodejs/10.15.3/bin:/Users/nathanshelly/.asdf/installs/nodejs/10.15.3/.npm/bin:/Users/nathanshelly/.asdf/shims:/usr/local/opt/asdf/bin:/usr/local/opt/fzf/bin:/Users/nathanshelly/.cargo/bin:/Users/nathanshelly/.poetry/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/usr/local/opt/asdf/bin 
[Info  - 6:10:05 PM] Started TSServer
{
  "path": "/Users/nathanshelly/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib",
  "_pathLabel": "",
  "_api": {
    "versionString": "3.6.2",
    "version": "3.6.2"
  }
}

## Output channel: eslint

[Info  - 6:10:05 PM] ESLint server running in node v10.15.3
[Info  - 6:10:05 PM] ESLint library loaded from: /Users/nathanshelly/projects/go/src/github.com/opendoor-labs/code/js/packages/trade-in-dashboard-fe/node_modules/eslint/lib/api.js
[Error  - 6:10:05 PM] 
Failed to load plugin '@typescript-eslint' declared in 'js/packages/trade-in-dashboard-fe/.eslintrc.json': Cannot find module '@typescript-eslint/eslint-plugin'
Require stack:
- /Users/nathanshelly/projects/go/src/github.com/opendoor-labs/code/__placeholder__.js
Referenced from: /Users/nathanshelly/projects/go/src/github.com/opendoor-labs/code/js/packages/trade-in-dashboard-fe/.eslintrc.json
Happened while validating /Users/nathanshelly/projects/go/src/github.com/opendoor-labs/code/js/packages/trade-in-dashboard-fe/src/routes/SellPage/OfferClosed.tsx
This can happen for a couple of reasons:
1. The plugin name is spelled incorrectly in an ESLint configuration file (e.g. .eslintrc).
2. If ESLint is installed globally, then make sure '@typescript-eslint/eslint-plugin' is installed globally as well.
3. If ESLint is installed locally, then '@typescript-eslint/eslint-plugin' isn't installed correctly.

Consider running eslint --debug /Users/nathanshelly/projects/go/src/github.com/opendoor-labs/code/js/packages/trade-in-dashboard-fe/src/routes/SellPage/OfferClosed.tsx from a terminal to obtain a trace about the configuration files used.

Relevant section of CocConfig

{
  "eslint.autoFix": true,
  "eslint.autoFixOnSave": true,
  "eslint.filetypes": ["javascript","javascriptreact", "typescript", "typescriptreact"]
}

Here's my full config.

How to use coc-eslint with yarn2 project?

coc-eslint already support yarn2 project, but you need do following setup:

  1. yarn add @yarnpkg/pnpify in your project, this will add pnpify to your project.
  2. yarn pnpify --sdk, this will generate directory .vscode/pnpify that contains eslint

Now coc-eslint can load ESLint automatically.

langserver failure

Hi, since yesterday I've been getting the following error:

[coc.nvim] server eslint langserver failed to start: undefined

no changes to configs, just did :CocUpdate I've tried un/re installing
Any ideas?

Jump to error

I just moved from ALE to using coc-eslint, and I wonder is there any way I can jump directly to offending position as I had with ALE?

Current master complains about frozen lockfile, then fails to compile

When I try to install the current master, first yarn complains, that it needs to modify the lockfile:

>>> yarn install --frozen-lockfile                                                                                                                                                                                                
yarn install v1.15.2
[1/5] Validating package.json...
warning [email protected]: The engine "coc" appears to be invalid.
[2/5] Resolving packages...
error Your lockfile needs to be updated, but yarn was run with `--frozen-lockfile`.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

When then running it without the --frozen-lockfile option, it fails to compile:

>>> yarn install                                                                                                                                                                                                              
yarn install v1.15.2
[1/5] Validating package.json...
warning [email protected]: The engine "coc" appears to be invalid.
[2/5] Resolving packages...
[3/5] Fetching packages...
[4/5] Linking dependencies...
[5/5] Building fresh packages...
success Saved lockfile.
$ npx npm-run-all clean build
[#######################################################################################################################################################################################################################################################################] 355/355[npx: installed 58 in 1.714s
yarn run v1.15.2
$ rimraf lib
Done in 0.10s.
yarn run v1.15.2
$ tsc -p tsconfig.json
src/index.ts:260:11 - error TS2345: Argument of type 'NotificationType<DidCloseTextDocumentParams, TextDocumentRegistrationOptions>' is not assignable to parameter of type 'string'.

260           DidCloseTextDocumentNotification.type,
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/index.ts:268:11 - error TS2345: Argument of type 'NotificationType<DidOpenTextDocumentParams, TextDocumentRegistrationOptions>' is not assignable to parameter of type 'string'.

268           DidOpenTextDocumentNotification.type,
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/index.ts:294:24 - error TS2345: Argument of type 'RequestType<ExecuteCommandParams, any, void, ExecuteCommandRegistrationOptions>' is not assignable to parameter of type 'string'.

294     client.sendRequest(ExecuteCommandRequest.type, params)
                           ~~~~~~~~~~~~~~~~~~~~~~~~~~

src/index.ts:301:27 - error TS2345: Argument of type 'NotificationType<[number, string], void>' is not assignable to parameter of type 'string'.

301     client.onNotification(exitCalled, params => {
                              ~~~~~~~~~~

src/index.ts:307:22 - error TS2345: Argument of type 'RequestType<NoConfigParams, NoConfigResult, void, void>' is not assignable to parameter of type 'string'.

307     client.onRequest(NoConfigRequest.type, params => {
                         ~~~~~~~~~~~~~~~~~~~~

src/index.ts:313:22 - error TS2345: Argument of type 'RequestType<NoESLintLibraryParams, NoESLintLibraryResult, void, void>' is not assignable to parameter of type 'string'.

313     client.onRequest(NoESLintLibraryRequest.type, params => {
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/index.ts:318:22 - error TS2345: Argument of type 'RequestType<OpenESLintDocParams, OpenESLintDocResult, void, void>' is not assignable to parameter of type 'string'.

318     client.onRequest(OpenESLintDocRequest.type, async params => {
                         ~~~~~~~~~~~~~~~~~~~~~~~~~


Found 7 errors.

error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ERROR: "build" exited with 2.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

Could not find a declaration file for module - how to get rid of it?

My project is not in ts but in js. Seems that tsserver reports this as a lint error

Could not find a declaration file for module 'redux-notifications'. '/Users/adam/projects/ad/node_modules/redux-notifications/lib/index.js' implicitly has an 'any' type. Try npm install @types/redux-notificationsif it exists or add a new declaration (.d.ts) file containingdeclare module 'redux-notifications';``

This message also comes in vscode, but is almost invisible - it comes when hovered three dots (...)

But in vim it shows as a lint warning

Which means that across entire codebase I get warnings. I'd like to be able to turn them off somehow. Installing typings removes the error, but I don't want to add typings to a js project.
I also tried setting noImplicitAny in jsconfig, but the warning still shows.

Have you got any suggestions on how to suppress them?

Thank you!

Unable to resolve plugins

I'm finally making the jump over to nvim and i'm having some issues getting set up. I ran :healthcheck and everything is green checkmarked, however I can't get coc-eslint to work.

For example if I open up ./App/src/file.js I get the following error inside the coc-eslint :CocList output -> eslint output:

[Info  - 7:42:13 AM] ESLint server running in node v12.12.0
[Info  - 7:42:13 AM] ESLint library loaded from: /App/node_modules/eslint/lib/api.js
[Error  - 7:42:13 AM] Failed to load plugin 'jsx-a11y' declared in 'homepage/.eslintrc': Cannot find module 'eslint-plugin-jsx-a11y'
Require stack: /App/__placeholder__.js
Happened while validating /App/src/file.js
This can happen for a couple of reasons:
  1. The plugin name is spelled incorrectly in an ESLint configuration file (e.g. .eslintrc).
  2. If ESLint is installed globally, then make sure 'eslint-plugin-jsx-a11y' is installed globally as well.
  3. If ESLint is installed locally, then 'eslint-plugin-jsx-a11y' isn't installed correctly.

Consider running eslint --debug /App/src/file.js from
a terminal to obtain a trace about the configuration files used.

However I know there is no issue with the plugin missing because I ran npm install, and if I open the same file in VSCode from the same root directory it works just fine and is able to lint.

I'm also able to successfully lint by running:

eslint --debug /App/src/file.js

Anyone have any ideas why it would not be able to load plugins?

Not respecting "onSave" setting

What I did:

{
  "eslint.run": "onSave"
}

What I expected to happen

I expected no new lint warnings until I save the file.

What actually happened

Instead of waiting until I save, the file is linted the second I leave INSERT mode.

My project as a lint rule for ensuring you run prettier. The rule has the unfortunate habit of making the entire file an error. This would usually not be an issue, since I have format on save enabled, in addition to only running ESLint on save (see above rule). But I'm finding that instead, when I write something in insert mode that's not formatted correctly, the file is linted when I exit insert mode, even though the file has not been saved.

eslint errors not mapped to diagnostics

I'm having eslint errors not listed in the diagnostics, so I cannot jump to them with my ]g and [g bindings

Here's an error reported by eslint-plugin-graphql

When moving the cursor in another line, and pressing [g, I get

Looking at #39, it seems that navigating eslint errors via coc-diagnostic-{next,prev} is the expected behavior.
Any idea why it doesn't work in my setup?

:CocLocalConfig

{
  "coc.preferences.formatOnSaveFiletypes": [
    "css",
    "javascript",
    "javascriptreact",
    "typescript",
    "typescriptreact"
  ],
  "tsserver.formatOnType": true,
  "coc.preferences.formatOnType": true,
  "eslint.autoFixOnSave": false,
  "eslint.filetypes": ["javascript", "javascriptreact", "typescript", "typescriptreact"],
  "prettier.disableSuccessMessage": true,
  "prettier.eslintIntegration": true
}

vimrc diagnostic related config

nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)
nnoremap <silent> <space>d  :<C-u>CocList diagnostics<cr>
autocmd User CocStatusChange,CocDiagnosticChange call lightline#update()

coc.nvim version

silent! let g:plugs['coc.nvim'].commit = '688776c'

:CocUpdate

:CocInfo

## versions

vim version: NVIM v0.4.3
node version: v14.3.0
coc.nvim version: 0.0.78-0c973a7a47
coc.nivm directory: /home/dori/.vim/plugged/coc.nvim
term: screen-256color
platform: linux

## Output channel: prettier


## Output channel: snippets

[Info 1:43:25 PM] Using ultisnips directories: UltiSnips /home/dori/.config/coc/ultisnips
[Info 1:43:26 PM] Using ultisnips python command: pyx

## Output channel: tsserver

[Info  - 1:43:26 PM] Forking TSServer
PATH: /home/dori/.local/bin:/home/dori/.gem/ruby/2.7.0/bin:/home/dori/.virtualenvs/project/bin:/home/dori/.cache/antibody/https-COLON--SLASH--SLASH-github.com-SLASH-caarlos0-SLASH-zsh-open-pr:/opt/google-cloud-sdk/bin:/usr/local/bin:/usr/bin:/home/dori/.local/bin/:/usr/local/sbin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/dori/.local/bin:/home/dori/.fzf/bin:/home/dori/.krew/bin 
[Info  - 1:43:27 PM] Started TSServer
{
  "path": "/home/dori/Projects/Work/project-v3/client/node_modules/typescript/lib",
  "_api": {
    "versionString": "3.9.3",
    "version": "3.9.3"
  }
}

## Output channel: eslint

[Info  - 1:43:27 PM] ESLint server running in node v14.3.0
[Info  - 1:43:27 PM] ESLint library loaded from: /usr/lib/node_modules/eslint/lib/api.js
[Error  - 1:43:28 PM] .eslintrc.yml » eslint-config-airbnb-typescript » /home/dori/Projects/Work/project-v3/client/node_modules/eslint-config-airbnb-typescript/lib/shared.js: 	Configuration for rule "@typescript-eslint/indent" is invalid: 	Value {"SwitchCase":1,"VariableDeclarator":1,"outerIIFEBody":1,"FunctionDeclaration":{"parameters":1,"body":1},"FunctionExpression":{"parameters":1,"body":1},"CallExpression":{"arguments":1},"ArrayExpression":1,"ObjectExpression":1,"ImportDeclaration":1,"flatTernaryExpressions":false,"ignoredNodes":["JSXElement","JSXElement > *","JSXAttribute","JSXIdentifier","JSXNamespacedName","JSXMemberExpression","JSXSpreadAttribute","JSXExpressionContainer","JSXOpeningElement","JSXClosingElement","JSXFragment","JSXOpeningFragment","JSXClosingFragment","JSXText","JSXEmptyExpression","JSXSpreadChild"],"ignoreComments":false,"offsetTernaryExpressions":false} should NOT have additional properties. 

Wondering if that has anything to do with neoclide/coc-prettier#62

[Question] Eslint config on project level

I am using the plugin and it is awesome! Thank you!

I have a question though - How can I provide a per project config?

for example in one project I'd like to use
"eslint.nodePath": "~/projects/xx/frontend/node_modules"
but for the other one
"eslint.nodePath": "~/projects/yy/node_modules",

Is there a way to do this please? I am not sure if this is on plugin or coc level.

Thank you

Missing semicolon cannot be fixed with code action

I'm using eslint-plugin-prettier, with "semi": true in my .prettierrc.
coc-eslint correctly marks lines with a missing semicolon as erroneous in the gutter, but no visible part of the line actually gets associated with the error, and as such, both coc-codeaction and coc-codeaction-selected don't show an option to fix it.
Instead, I have to trigger the autofix via :CocCommand eslint.executeAutofix.
image
image

I assumed this was related to the error column being past the end of the line, so I tried adding an extra space at the end of the line.
The space gets marked as an error and can hence be fixed via code action.
image

Disable eslint on project basis

I've projects using eslint and others using tslint. For the project that isn't using tslint there is a warning that eslint can't be started and after installing it globally it says "no eslint configuration found". But it shouldn't be executed for this projects.

Would it be an option to disable the plugin for projects that have no configuration instead?

coc-eslint doesn't start for TS files in some cases

I would like to enable coc-eslint for TS files on a project-by-project basis. If I add the TS filetypes to eslint.filetypes in the global coc config, coc-eslint is always started when I edit a TS file. However, if I only add the TS types to eslint.filetypes in a project-local coc config, eslint is only started if I start vim with a file. For example, if I start vim with just vi and then edit a JS file with :e src/file.js, coc-eslint isn't started. However, if I open vim with vi src/file.js, coc-eslint is started.

How can I get eslint to start for TS files, but only for certain projects?

Cannot find module error after updating to 1.2.5

This worked fine in 1.2.4, but fails after I update to 1.2.5. I get the following error:

[coc.nvim] Cannot find module 'eslint-plugin-console' Referenced from: /Users/sam/work/console/frontend/packages/.eslintrc.js

#43 is the only change I see in the release.

The project I'm working on is https://github.com/openshift/console, which uses yarn workspaces. eslint works fine outside of vim.

## versions

vim version: NVIM v0.4.3
node version: v10.19.0
coc.nvim version: 0.0.74-15f685206a
term: iTerm.app
platform: darwin

LanguageClient not starting for vue files

Hello,

I have been trying to run eslint for .vue files with vue filetype. Works perfectly fine for coc-vetur, coc-prettier however not for coc-eslint. It wont start even though I have added vue into the eslint.filetypes array. I can switch to filetype javascript or typescript to actually test it out (it starts and lints) but that breaks my other plugins as expected.

Is vue supported?

Errors not showing up

I got the coc-nvim plugin installed, as well as coc-eslint installed and pointed at the correct node_modules directory.

Coc logs suggest that eslint started just fine.

But Whatever I do, I cannot get coc to highlight an error. It works well for other languages. I have tried writing the file, closing it and reopening it, switching modes, etc.

But if I deliberately type gibberish it will not highlight as an error. Am I missing something in my config?

coc-eslint doesn't work

I've installed coc-eslint but I'm not receiving any output from it. I am using the latest nvim built with homebrew, and I have .elintrc.js in the root of the project I'm working on and eslint is installed as a dependency of the project. the root of the projects is also the cwd, so I have put these lines in my ~/.config/nvim/coc-settings.json

  "eslint.enable": true,
  "eslint.trace.server": "verbose",
  "eslint.nodePath": "./node_modules/",
  "eslint.options": {
    "configFile": "./.eslintrc.js"
  }

and this is part of the output of CocCommand workspace.showOutput:

[Trace - 08:59:50] NODE_PATH value is: /Users/matteo/dev/html5-exercises-player/node_modules/
[Trace - 08:59:50] NODE_PATH value is: /Users/matteo/.nvf/installed/node-8.12.0/lib/node_modules
Uncaught exception recevied.
Error: spawn /Users/matteo/.config/nvim/plugged/coc.nvim/build/coc-macos ENOENT
    at _errnoException (util.js:992:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
    at onErrorNT (internal/child_process.js:372:16)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
module.js:547
    throw err;
    ^

Error: Cannot find module '-e'
    at Function.Module._resolveFilename (module.js:545:15)
    at Function.Module._resolveFilename (pkg/prelude/bootstrap.js:1278:46)
    at Function.Module._load (module.js:472:25)
    at Function.Module.runMain (pkg/prelude/bootstrap.js:1307:12)
    at startup (bootstrap_node.js:227:16)
    at bootstrap_node.js:648:3

the NODE_PATH are correct, and the coc-macos file exists:

 ~ ls -l /Users/matteo/.config/nvim/plugged/coc.nvim/build/coc-macos
-rwxr-xr-x  1 matteo  staff  47223252 28 Ott 23:28 /Users/matteo/.config/nvim/plugged/coc.nvim/build/coc-macos

Eslint failed to load in every script file

Result from CocInfo

versions

vim version: NVIM v0.4.3
node version: v14.1.0
coc.nvim version: 0.0.78-57637bb44c
term: alacritty
platform: Linux

Output channel: snippets

[Info 2:30:23 AM] Using ultisnips directories: UltiSnips /home/mdsp9070/.config/coc/ultisnips
[Info 2:30:24 AM] Using ultisnips python command: pyx

Output channel: tsserver

[Info - 2:30:23 AM] Forking TSServer
PATH: /home/mdsp9070/.zinit/polaris/bin:/usr/local/bin/latexmk:/root/.gem/ruby/2.7.0/bin:/home/mdsp9070/.gem/ruby/2.7.0/bin:/home/mdsp9070/.local/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/var/lib/snapd/snap/bin:/home/mdsp9070/.rvm/bin:/bin:/home/mdsp9070/.config/yarn/global/node_modules/typescript/bin
[Info - 2:30:24 AM] Started TSServer
{
"path": "/home/mdsp9070/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib",
"_pathLabel": "",
"_api": {
"versionString": "3.8.3",
"version": "3.8.3"
}
}

Output channel: eslint

[Info - 2:30:24 AM] ESLint server running in node v14.1.0

Describe the bug

Eslint fails to load every time on any script file. I searched to similar issues but none found on the grounds that ":CocInfo" don't provide any error...

Eslint is properly installed globally and I'm not using Yarn 2.

Reproduce the bug

Here's my coc.vim: https://github.com/Mdsp9070/nvim/blob/master/partials/coc.vim

Screenshots (optional)

Screenshot from 2020-05-09 02-40-42

Does not resolve eslint library for yarn2 projects

When using yarn2 for a project I am getting an error saying Failed to load the ESLint library for the document .... With yarn2 pnp is enabled so there is not a node_modules folder and thus eslint cannot be resolved from the workspace.

Info Output Below:


vim version: NVIM v0.4.3
node version: v12.15.0
coc.nvim version: 0.0.74-6700e7468d
term: xterm-256color
platform: linux

## Messages
[coc.nvim] Failed to load the ESLint library for the document /home/arlen/workspace/node/marianos_clipper/index.js
## Output channel: prettier


## Output channel: tsserver

[Info  - 3:45:46 PM] Forking TSServer
PATH: /home/arlen/.nvm/versions/node/v12.15.0/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/arlen/Dotfiles/functions:/home/arlen/.gem/ruby/2.7.0/bin:/home/arlen/Applications:/home/arlen/Dotfiles/functions:/home/arlen/.gem/ruby/2.7.0/bin:/home/arlen/Applications 
[Info  - 3:45:46 PM] Started TSServer
{
  "path": "/home/arlen/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib",
  "_pathLabel": "",
  "_api": {
    "versionString": "3.7.3",
    "version": "3.7.3"
  }
}

## Output channel: eslint

[Info  - 3:45:46 PM] ESLint server running in node v12.15.0```

possible release?

Hello!

thanks for the plugin and all your work!

Was wondering if it's possible to get an npm release so that I can make use of #31

thanks!

how make it work with .ts files?

Do not work with local and global installed eslint.
[coc.nvim
cocOpenLog:

2019-04-08T15:05:17.150 ERROR (pid:27447) [commands] - Error: Language client is not ready yet
    at LanguageClient.sendRequest (/home/user/.vim/plugged/coc.nvim/build/index.js:65643:19)
    at Object.<anonymous> (/home/user/.config/coc/extensions/node_modules/coc-eslint/lib/index.js:206:20)
    at Generator.next (<anonymous>)
    at fulfilled (/home/user/.config/coc/extensions/node_modules/tslib/tslib.js:104:62)
    at process._tickCallback (internal/process/next_tick.js:68:7)

editing file before full load breaks eslint

If I open a js file and start editing right away, I won't have any eslint error as long as my file is open.
I have to wait like 3 seconds and only then I can edit my file and eslint errors are visible.

Can this be fixed?

I would also like to know if it's possible to use eslint_d in coc_eslint?

[coc.nvim] Failed to load the ESLint library for the document test.js

I'm just now getting more "serious" about using Coc in my development machine - and I'm trying to use this extension as a replacement for ALE by suggestion from this article but unfortunately I'm getting some pretty buggy behavior.

When I load a javascript file (any file) I see warnings that are legit warnings (like the neovim "sign" / gutter indicator is there) but I see the error in this issue summary at the bottom
image

However, if I play around enough (not sure what triggers it, but spamming $ and 0 in normal mode on a line where a sign exists eventually triggers the expected warning (and btw this one in particular I'd love to turn off but I realize its an existing annoyance for others):
image

I did try `:CocUpdateSync and got this output:

:!yarnpkg upgrade --latest --ignore-engines
[No write since last change]

yarn upgrade v1.13.0
warning package.json: No license field
warning No license field
warning No license field
warning No license field
[1/4] Resolving packages...
warning coc-prettier > prettier-eslint > eslint > file-entry-cache > flat-cache > [email protected]: CircularJSON is in maintenance only, flatted is its successor.
warning coc-prettier > prettier-stylelint > stylelint > autoprefixer > [email protected]: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning "coc-prettier > [email protected]" has unmet peer dependency "typescript@^2.5.3 || ^3.0.0".
warning "coc-prettier > prettier-tslint > [email protected]" has unmet peer dependency "typescript@>=2.1.0 || >=2.1.0-dev || >=2.2.0-dev || >=2.3.0-dev || >=2.4.0-dev || >=2.5.0-dev
|| >=2.6.0-dev || >=2.7.0-dev || >=2.8.0-dev || >=2.9.0-dev || >=3.0.0-dev || >= 3.1.0-dev || >= 3.2.0-dev".
warning "coc-prettier > prettier-tslint > tslint > [email protected]" has unmet peer dependency "typescript@>=2.1.0 || >=2.1.0-dev || >=2.2.0-dev || >=2.3.0-dev || >=2.4.0-dev || >=
2.5.0-dev || >=2.6.0-dev || >=2.7.0-dev || >=2.8.0-dev || >=2.9.0-dev || >= 3.0.0-dev || >= 3.1.0-dev".
[4/4] Rebuilding all packages...
success Saved lockfile.
warning No license field
success Saved 365 new dependencies.

Is that warning anything special?

I'd greatly appreciate any help here :)

:CocInfo Output

## versions

vim version: NVIM v0.3.2-dev
node version: v10.15.3
coc.nvim version: 0.0.65-5effa64974
term: iTerm.app
platform: darwin

## Error messages

## Output channel: prettier


[Trace - 4/26/2019, 1:34:45 PM:] Formatted file: file:///Users/foobar/temp/test.js


[Trace - 4/26/2019, 1:34:45 PM:] Prettier format edits: [
  {
    "range": {
      "start": {
        "character": 0,
        "line": 0
      },
      "end": {
        "character": 0,
        "line": 16
      }
    },
    "newText": "var debug = require(\"debug\");\n\n// A comment\n\nfunction sayHi() {\n  console.log(\"hi\");\n}\n\naksayHi();\n\nasdfl;\nj: w;\n"
  }
]


## Output channel: tsserver

[Info  - 1:34:32 PM] Forking TSServer
PATH: /Users/foobar/.yarn/bin:/Users/foobar/.config/yarn/global/node_modules/.bin:/var/folders/nl/ry78xgy13djdd9ntz2vfkq240000gn/T/fnm-shell-299137/bin:/Users/foobar/.fnm:/opt/local/bin:/opt/local/sbin:/Users/foobar/.pyenv/plugins/pyenv-virtualenv/shims:/Users/foobar/.pyenv/shims:/Users/foobar/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/Users/foobar/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/sbin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Wireshark.app/Contents/MacOS:/Users/foobar/.yarn/bin:/Users/foobar/.config/yarn/global/node_modules/.bin:/var/folders/nl/ry78xgy13djdd9ntz2vfkq240000gn/T/fnm-shell-3942512/bin:/Users/foobar/.fnm:/opt/local/bin:/opt/local/sbin:/Users/foobar/.pyenv/plugins/pyenv-virtualenv/shims:/Users/foobar/.pyenv/shims:/Users/foobar/.pyenv/bin:/Users/foobar/.cargo/bin 
[Info  - 1:34:32 PM] Started TSServer
{
  "path": "/Users/foobar/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib",
  "_pathLabel": "",
  "_api": {
    "versionString": "3.3.4000",
    "version": "3.3.4000"
  }
}

## Output channel: eslint

[Info  - 1:34:32 PM] ESLint server running in node v10.15.3

:CocConfig

{
  "suggest.echodocSupport": true,
  "suggest.maxCompleteItemCount": 20,
  "coc.preferences.formatOnSaveFiletypes": ["javascript", "typescript", "typescriptreact", "json", "javascriptreact"],
  "eslint.filetypes": ["javascript", "typescript", "typescriptreact", "javascriptreact"],
  "eslint.options": {
    "configFile": "~/.eslintrc"
  },
  "diagnostic.errorSign": "",
  "diagnostic.warningSign": "",
  "diagnostic.infoSign": ""
}

Errors don't update on file change

Hello,

I have a problem with the package. When I open a jsx (or js) file for the first time, it shows me errors (even when I hover on them, the message at the bottom shows me what is the problem). As soon as I edit the file in any way, the errors stop refreshing and the new errors are not shown anymore. What's more, when I hover over the previous problems, I don't see the message in the message line (the problem looks like on the screen).

I've tried to install purely only coc-vim and then coc-eslint. I've tried to run without any plugins and configuration except for coc-vim and the problem is still there. I've tried to run it on ubuntu and on macos, tried different nvim versions, tried different node versions, tried different projects and the problem doesn't disappear.
It works fine with ALE.

I've also tried to debug it and see if :CocInfo or any other command I could think of returns any error, but there is nothing there.

Interestingly enough, if the file I open has wrong syntax (ex. declared the variable twice), after I remove the variable it refreshes the linting. Also when I do :CocRestart, it refreshes the errors.

(On screenshot: it's an error that the variable is unused, I've just added the 'xxxx' variable that doesn't get linted)
I'm using the latest available version of coc-eslint

Screenshot 2019-08-29 at 08 57 26

Output from :CocInfo after going into file, adding the line and saving it:
ksnip_20190829-091751

Link to my configs:
https://gitlab.com/Dammic/dotfiles

Could you point me to an issue that could be there (or point me to any diagnostics that could help me debug the problem)? Thanks in advance!

Parsing error: The keyword 'const' is reserved

Hello. I'm trying to use eslint for linting javascript files via coc.nvim.

Here is my plugin settings for coc.nvim:

Plug 'neoclide/coc.nvim', {'do': { -> coc#util#install()}}
let g:coc_global_extensions = [
      \ 'coc-word',
      \ 'coc-tsserver',
      \ 'coc-tslint-plugin',
      \ 'coc-json',
      \ 'coc-eslint',
      \ 'coc-prettier',
      \ 'coc-python',
      \ 'coc-java',
      \ 'coc-solargraph',
      \ 'coc-yaml',
      \ 'coc-vimlsp',
      \ 'coc-yank',
      \ 'coc-diagnostic',
      \ 'coc-lists'
      \]

Here is my coc-settings.json:

{
  "diagnostic-languageserver.filetypes": {
    "markdown": [ "write-good", "markdownlint" ],
    "javascript": [ "prettier", "eslint" ],
    "sh": "shellcheck"
  },

  "tsserver.enableJavascript": false,

  "prettier.eslintIntegration": true,

  "eslint.filetypes": [
    "javascript",
    "javascript.jsx",
    "javascriptreact"
  ],
  "eslint.autoFix": true,
  "eslint.autoFixOnSave": true,

  "solargraph.diagnostics": true
}

Javascript file I'm opening in neovim:

/* global require describe it */

const fs = require('fs'); // ERROR IS HERE
const assert = require('assert');
const pgp = require('pg-promise')(/*options*/);
const cn = {
  user: 'nobody',
  host: '/var/run/postgresql',
};

describe('rows', () => {
  it('should be updated', (done) => {
const db = pgp(cn);
const solution = fs.readFileSync('./solution.sql', 'utf8');

      const actualQuery = db.query(solution);
    const expectedQuery = db.query('select solution() AS name;');

    Promise.all([expectedQuery, actualQuery]).then(([expected, actual]) => {
      assert.equal(JSON.stringify(expected), JSON.stringify(actual));
    }).then(done, done);
  });
});

What do I want to achieve:

  • get rid of error
  • integrate eslint with prettier, since i have an $HOME/.editorconfig file and I want to apply its rules to all projects inside $HOME (which were not overwritten with their own .editorconfig)

Improve local module resolution

It's recommended that eslint installations are local to a project, that is, that eslint and all it's plugins are installed dependencies of the project. This is even more important after the release of eslint 7.0.

Right now, it's very difficult for coc-eslint to find local packages, let me explain why.

The readme shows that if the local package cannot be found, the settings nodePath or packageManager can be set to resolve packages globally. But there is no mention of settings for local packages.

And resolution of local packages is bound to fail. Coc-eslint uses the function resolveSettings to search for the eslint package.

Let's say the user is in a workspace, and he has not configured nodePath nor packageManager. The module will be searched like this:

directory = settings.workspaceFolder ? URI.parse(settings.workspaceFolder.uri).fsPath : undefined
promise = resolveModule('./eslint', directory, nodePath).catch(() => {
  return resolveModule('eslint', directory, nodePath)
})

The variable directory will resolve to /home/user/project. The function call resolveModule('./eslint', '/home/user/project', undefined) will try to read the non-existing directory '/home/user/project/eslint', which will fail.

A workaround is to use "eslint.nodePath": "./node_modules", but this is not intuitive and not documented.

Proposed alternatives

  1. Try to resolve first ./node_modules/eslint. I don't know any project that doesn't use <project_path>/node_modules for storing modules.
promise = resolveModule('./node_modules/eslint', directory, nodePath).catch(() => {
  return resolveModule('./eslint', directory, nodePath).catch(() => {
    return resolveModule('eslint', directory, nodePath)
  });
});
  1. Append the configuration variable "eslint.localNodePath", which should use node_modules as the default value.
      let directory: string
      if (uri.scheme === 'file') {
        directory = path.dirname(uri.fsPath)
      } else {
        directory = settings.workspaceFolder ? URI.parse(settings.workspaceFolder.uri).fsPath : undefined
      }
      if (directory && settings.localNodePath) {
        directory = path.resolve(directory, settings.localNodePath);
      }

Default Config Exception on startup

I've been unable to get coc-eslint to report linting errors/warnings. Here is my workstation.showOutput output. Any ideas?

 [Trace - 10:29:10] Sending response 'workspace/configuration - (2)'. Processing request took 1ms
  Result: [
      {
          "packageManager": "npm",
          "validate": true,
          "autoFix": true,
          "autoFixOnSave": false,
          "options": {},
          "run": "onType",
          "workspaceFolder": {
              "uri": "file:///home/cawalch/foo",
              "name": "foo"
          }
      }
  ]


  [Trace - 10:29:10] Received notification 'window/logMessage'.
  Params: {
      "type": 3,
      "message": "Registering request handler for workspace/didChangeWorkspaceFolders failed."
  }


  [1  - 10:29:10] Registering request handler for workspace/didChangeWorkspaceFolders failed.
  (node:55260) UnhandledPromiseRejectionWarning: Error: Request client/registerCapability failed with message: No feature implementation for workspace/didChangeWorkspaceFolders found. Registration failed.
      at handleResponse (/home/cawalch/.config/coc/extensions/node_modules/vscode-jsonrpc/lib/main.js:436:48)
      at processMessageQueue (/home/cawalch/.config/coc/extensions/node_modules/vscode-jsonrpc/lib/main.js:263:17)
      at Immediate.setImmediate [as _onImmediate] (/home/cawalch/.config/coc/extensions/node_modules/vscode-jsonrpc/lib/main.js:247:13)
      at runCallback (timers.js:810:20)
      at tryOnImmediate (timers.js:768:5)
      at processImmediate [as _immediateCallback] (timers.js:745:5)
  (node:55260) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
  (node:55260) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
  [Trace - 10:29:11] 'npm config get prefix' value is: /home/cawalch/.nvm/versions/node/v8.10.0
  [Trace - 10:29:11] NODE_PATH value is: /home/cawalch/.nvm/versions/node/v8.10.0/lib/node_modules
  module.js:547
      throw err;
      ^

  Error: Cannot find module '-e'
      at Function.Module._resolveFilename (module.js:545:15)
      at Function.Module._resolveFilename (pkg/prelude/bootstrap.js:1278:46)
      at Function.Module._load (module.js:472:25)
      at Function.Module.runMain (pkg/prelude/bootstrap.js:1307:12)
      at startup (bootstrap_node.js:227:16)
      at bootstrap_node.js:648:3

Eslint not running for typescript.tsx files, even though eslint.filetypes is set

Hello,

Eslint isn't running for my .tsx-files, the output from :set filetype is filetype=typescript.tsx,

and my CocConfig is:

{
  "eslint.autoFixOnSave": true,
	"eslint.filetypes": ["javascript", "javascriptreact", "typescript", "typescript.tsx", "typescriptreact.tsx", "typescript.jsx", "typescriptreact.tsx"]
}

it works for js and ts files.

Any idea what might be wrong? thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.