Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
vscode-css-languageservice
Advanced tools
The vscode-css-languageservice package provides a set of tools and services for working with CSS in a way that integrates seamlessly with Visual Studio Code. It offers features like CSS validation, completion, hover information, and more, making it easier for developers to write and maintain CSS code.
CSS Validation
This feature allows you to validate CSS code and get diagnostics information. The code sample demonstrates how to create a CSS language service, parse a stylesheet, and perform validation to get diagnostics.
const cssService = require('vscode-css-languageservice').getCSSLanguageService();
const document = { uri: 'test.css', languageId: 'css', version: 1, getText: () => 'body { color: red; }' };
const stylesheet = cssService.parseStylesheet(document);
const diagnostics = cssService.doValidation(document, stylesheet);
console.log(diagnostics);
CSS Completion
This feature provides code completion suggestions for CSS. The code sample shows how to get completion items for a given position in a CSS document.
const cssService = require('vscode-css-languageservice').getCSSLanguageService();
const document = { uri: 'test.css', languageId: 'css', version: 1, getText: () => 'body { col' } };
const position = { line: 0, character: 10 };
const stylesheet = cssService.parseStylesheet(document);
const completions = cssService.doComplete(document, position, stylesheet);
console.log(completions);
CSS Hover Information
This feature provides hover information for CSS code. The code sample demonstrates how to get hover information for a specific position in a CSS document.
const cssService = require('vscode-css-languageservice').getCSSLanguageService();
const document = { uri: 'test.css', languageId: 'css', version: 1, getText: () => 'body { color: red; }' };
const position = { line: 0, character: 7 };
const stylesheet = cssService.parseStylesheet(document);
const hover = cssService.doHover(document, position, stylesheet);
console.log(hover);
PostCSS is a tool for transforming CSS with JavaScript plugins. It offers a wide range of functionalities including linting, autoprefixing, and more. Unlike vscode-css-languageservice, which is focused on providing language services for CSS in an editor environment, PostCSS is more about transforming and processing CSS code.
Stylelint is a modern linter that helps you avoid errors and enforce conventions in your styles. It is highly configurable and can be integrated into various build systems. While vscode-css-languageservice provides validation and other language services within an editor, Stylelint is more focused on linting and enforcing coding standards.
CSS-tree is a tool for working with CSS, including parsing, generating, and analyzing CSS code. It provides a low-level API for manipulating CSS. Compared to vscode-css-languageservice, which offers high-level language services, CSS-tree provides more granular control over CSS parsing and manipulation.
Language services for CSS, LESS and SCSS
The vscode-css-languageservice contains the language smarts behind the CSS, LESS and SCSS editing experience of Visual Studio Code and the Monaco editor.
npm install --save vscode-css-languageservice
For the complete API see cssLanguageService.ts and cssLanguageTypes.ts
yarn test
to compile and run testsHow can I run and debug the service?
cssCompletion.ts
How can I run and debug the service inside an instance of VSCode?
yarn link vscode-css-languageservice
in vscode/extensions/css-language-features/server
to run VSCode with the latest changes from vscode-css-languageservice
vscode/scripts/code.sh|bat
) and open a .css
filevscode-css-languageservice
sources, run command Debug: Attach to Node process
and pick the code-oss
process with the css-language-features
path
cssCompletion.ts
.css
fileNote: All CSS entities (properties, at-rules, etc) are sourced from https://github.com/microsoft/vscode-custom-data/tree/master/web-data and transpiled here. For adding new property or fixing existing properties' completion/hover description, please open PR there).
(MIT License)
Copyright 2016, 20 Microsoft
With the exceptions of build/mdn-documentation.js
, which is built upon content from Mozilla Developer Network
and distributed under CC BY-SA 2.5.
FAQs
Language service for CSS, LESS and SCSS
The npm package vscode-css-languageservice receives a total of 481,322 weekly downloads. As such, vscode-css-languageservice popularity was classified as popular.
We found that vscode-css-languageservice demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
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.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.