Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

monaco-css-linter

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

monaco-css-linter

Simple CSS Linter for the Monaco Editor.

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Monaco CSS Linter

Monaco CSS Linter is a simple CSS Linter plugin for the Monaco Editor. It uses the W3C CSS Validator under the hood to verify CSS Code.

Installation

npm i monaco-css-linter

Usage

import monaco, { editor } from 'monaco-editor';
import CSSMonacoLinter from 'monaco-css-linter';

// The Monaco Editor can be easily created, given an
// empty container and an options literal.
// Two members of the literal are "value" and "language".
// The editor takes the full size of its container.

const editor = monaco.editor.create(document.getElementById('container'), {
    value: 'css code here ...',
    language: 'css',
});

const linter = new CSSMonacoLinter(editor, monaco);
linter.watch();

You can get the linter response in this way :

import { CSSMonacoMarks } from 'monaco-css-linter';

//...

const cssCode = editor.getValue();
const report = new CSSMonacoMarks(cssCode);
const response = report.getLinterResponse();

API

Class: CSSMonacoLinter(editor: editor.IStandaloneCodeEditor, monaco: Monaco, options?: OptionsWithoutWarnings)

Attributes
  • editor: editor.IStandaloneCodeEditor The object returned when you create an editor.
  • monaco: typeof monaco The monaco variable.
  • options?: OptionsWithoutWarnings w3c validator options.
Methods
  • lint () => void: Lint one time the editor.
  • watch () => void: Lint the editor each time the onChange event is triggered.

Class: CSSMonacoMarks(css: string, options?: OptionsWithoutWarnings, model?: editor.ITextModel)

Attributes
  • css: string The codoe to verify.
  • options?: OptionsWithoutWarnings w3c validator options.
  • model?: editor.ITextModel the model of the editor.
  • linterResponse?: ValidateTextResultWithoutWarnings Value returned by the W3C CSS Validator.
Methods
  • async getEditorMarks(monaco: Monaco): Promise<editor.IMarkerData[]> Return the monaco markers.
  • getLinterResponse(): ValidateTextResultWithoutWarnings | undefined
  • async requestLint(): Promise<ValidateTextResultWithoutWarnings> Start the CSS linter asynchronously.

License

MIT, see the LICENSE file for detail.

Keywords

FAQs

Package last updated on 10 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc