Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shinnn/stylelint-warning-to-vscode-diagnostic
Convert a stylelint warning into a Visual Studio Code diagnostic
https://github.com/shinnn/stylelint-warning-to-vscode-diagnostic
convert diagnostics javascript language-server-protocol nodejs stylelint visual-studio-code vscode warning
Last synced: about 1 month ago
JSON representation
Convert a stylelint warning into a Visual Studio Code diagnostic
- Host: GitHub
- URL: https://github.com/shinnn/stylelint-warning-to-vscode-diagnostic
- Owner: shinnn
- License: isc
- Created: 2017-02-16T10:48:38.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-11-24T22:59:05.000Z (about 6 years ago)
- Last Synced: 2024-10-18T20:12:45.534Z (3 months ago)
- Topics: convert, diagnostics, javascript, language-server-protocol, nodejs, stylelint, visual-studio-code, vscode, warning
- Language: JavaScript
- Size: 74.2 KB
- Stars: 0
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# stylelint-warning-to-vscode-diagnostic
[![npm version](https://img.shields.io/npm/v/stylelint-warning-to-vscode-diagnostic.svg)](https://www.npmjs.com/package/stylelint-warning-to-vscode-diagnostic)
[![Build Status](https://travis-ci.org/shinnn/stylelint-warning-to-vscode-diagnostic.svg?branch=master)](https://travis-ci.org/shinnn/stylelint-warning-to-vscode-diagnostic)
[![Coverage Status](https://img.shields.io/coveralls/shinnn/stylelint-warning-to-vscode-diagnostic.svg)](https://coveralls.io/github/shinnn/stylelint-warning-to-vscode-diagnostic?branch=master)Convert a [stylelint](https://github.com/stylelint/stylelint) warning into a [Visual Studio Code diagnostic](https://code.visualstudio.com/Docs/extensionAPI/vscode-api#Diagnostic)
```javascript
const {lint} = require('stylelint');
const stylelintWarningToVscodeDiagnostic = require('stylelint-warning-to-vscode-diagnostic');(async () => {
const [result] = await lint({
code: 'a { color: red; }',
config: {
rules: {
'color-named': 'never'
}
}
});const [warning] = result.warnings;
/* {
rule: 'color-named',
text: 'Unexpected named color "red" (color-named)',
severity: 'error',
line: 1,
column: 12
} */stylelintWarningToVscodeDiagnostic(warnings);
/* {
message: 'Unexpected named color "red" (color-named)',
severity: 1,
source: 'stylelint',
range: {
start: {
line: 0,
character: 11
},
end: {
line: 0,
character: 11
}
}
} */
})();
```## Installation
[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/getting-started/what-is-npm).
```
npm install stylelint-warning-to-vscode-diagnostic
```## API
```javascript
const stylelintWarningToVscodeDiagnostic = require('stylelint-warning-to-vscode-diagnostic');
```### stylelintWarningToVscodeDiagnostic(*warning*)
*warning*: `Object` (stylelint [warning](https://github.com/stylelint/stylelint/blob/9.1.1/lib/createStylelintResult.js#L127-L131))
Return: `Object` (VS Code [diagnostic](https://github.com/Microsoft/vscode-languageserver-node/blob/release/3.5.0/types/src/main.ts#L165-L192))## License
[ISC License](./LICENSE) © 2018 Shinnosuke Watanabe