bmatcuk / stylelint-lsp

A stylelint Language Server
MIT License
46 stars 4 forks source link

Fix catching stylelint linting failures #21

Closed Gelio closed 3 years ago

Gelio commented 3 years ago

With v1.2.3, we seem to have regressed with #18 😟

Stylelint linting failures (e.g. non-existing configuration) result in a rejected promise, not an error being thrown synchronously. Thus, the failure needs to be caught asynchronously.

Without this fix, there were unhandled promise rejections inside neovim's LSP log:

[ ERROR ] 2021-05-08T08:54:49+0200 ] ...nt_nvimnOFBMw/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:457 ] "rpc" "stylelint-lsp" "stderr" "(node:70348) UnhandledPromiseRejectionWarning: Error: No configuration provided for /home/voreny/projects/personal/supreme-trobot/src/popup.ts\n at module.exports (/home/voreny/.nvm/versions/node/v14.15.0/lib/node_modules/stylelint-lsp/node_modules/stylelint/lib/utils/configurationError.js:10:14)\n at /home/voreny/.nvm/versions/node/v14.15.0/lib/node_modules/stylelint-lsp/node_modules/stylelint/lib/getConfigForFile.js:56:11\n at async validate (/home/voreny/.nvm/versions/node/v14.15.0/lib/node_modules/stylelint-lsp/dist/validate.js:37:36)\n at async /home/voreny/.nvm/versions/node/v14.15.0/lib/node_modules/stylelint-lsp/dist/validate.js:116:13\n" [ ERROR ] 2021-05-08T08:54:49+0200 ] ...nt_nvimnOFBMw/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:457 ] "rpc" "stylelint-lsp" "stderr" "(node:70348) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 43)\n"

With this PR, the fix for #19 is working great and the error about the configuration not being provided does not repeat πŸ˜„

codecov[bot] commented 3 years ago

Codecov Report

Merging #21 (1650ff3) into master (c8df19a) will not change coverage. The diff coverage is 33.33%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #21   +/-   ##
=======================================
  Coverage   63.53%   63.53%           
=======================================
  Files           6        6           
  Lines         362      362           
  Branches       58       58           
=======================================
  Hits          230      230           
  Misses        113      113           
  Partials       19       19           
Impacted Files Coverage Ξ”
src/settings.ts 57.14% <33.33%> (ΓΈ)

Continue to review full report at Codecov.

Legend - Click here to learn more Ξ” = absolute <relative> (impact), ΓΈ = not affected, ? = missing data Powered by Codecov. Last update c8df19a...1650ff3. Read the comment docs.

bmatcuk commented 3 years ago

Oh ya! That makes sense. Thanks =)

bmatcuk commented 3 years ago

I cut v1.2.4 with this fix.

Gelio commented 3 years ago

Np πŸ™‚ Thanks for merging