Miss any of our Open RFC calls?Watch the recordings here! »

stylelint-processor-name-to-vscode-language-ids

0.0.0 • Public • Published

stylelint-warning-to-vscode-diagnostic

NPM version Build Status Coverage Status

Convert a stylelint warning into a Visual Studio Code diagnostic

const {lint} = require('stylelint');
const stylelintWarningToVscodeDiagnostic = require('stylelint-warning-to-vscode-diagnostic');
 
async () => {
  const {results: [{warnings}]} = await lint({
    code: 'a { color: red; }',
    config: {
      rules: {
        'color-named': 'never'
      }
    }
  });
 
  warnings[0];
  /* {
    rule: 'color-named',
    text: 'Unexpected named color "red" (color-named)',
    severity: 'error',
    line: 1,
    column: 12
  } */
 
  stylelintWarningToVscodeDiagnostic(warnings[0]);
  /* {
    message: 'Unexpected named color "red" (color-named)',
    severity: 1,
    source: 'stylelint',
    range: {
      start: {
        line: 0,
        character: 11
      },
      end: {
        line: 0,
        character: 11
      }
    }
  } */
};

Installation

Use npm.

npm install stylelint-warning-to-vscode-diagnostic

API

const stylelintWarningToVscodeDiagnostic = require('stylelint-warning-to-vscode-diagnostic');

stylelintWarningToVscodeDiagnostic(warning)

warning: Object (stylelint warning)
Return: Object (VS Code diagnostic)

License

Copyright (c) 2017 Shinnosuke Watanabe

Licensed under the MIT License.

Install

npm i stylelint-processor-name-to-vscode-language-ids

DownloadsWeekly Downloads

2

Version

0.0.0

License

MIT

Last publish

Collaborators

  • avatar