Socket
Socket
Sign inDemoInstall

@volar/language-core

Package Overview
Dependencies
Maintainers
0
Versions
227
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@volar/language-core


Version published
Weekly downloads
2M
decreased by-3.54%
Maintainers
0
Weekly downloads
 
Created

Package description

What is @volar/language-core?

@volar/language-core is a core library for the Volar language server, which provides enhanced language support for Vue.js. It offers features like type checking, code completion, and diagnostics for Vue components.

What are @volar/language-core's main functionalities?

Type Checking

This feature allows you to perform type checking on Vue components. The code sample demonstrates how to create a language service and get semantic diagnostics for a Vue file.

const { createLanguageService } = require('@volar/language-core');
const service = createLanguageService({
  getScriptFileNames: () => ['example.vue'],
  getScriptVersion: () => '1',
  getScriptSnapshot: (fileName) => {
    if (fileName === 'example.vue') {
      return {
        getText: (start, end) => '<template><div>{{ message }}</div></template><script>export default { data() { return { message: 123 }; } };</script>',
        getLength: () => 100,
        getChangeRange: () => undefined
      };
    }
  },
  getCurrentDirectory: () => '/',
  getCompilationSettings: () => ({}),
  getDefaultLibFileName: () => 'lib.d.ts'
});
const diagnostics = service.getSemanticDiagnostics('example.vue');
console.log(diagnostics);

Code Completion

This feature provides code completion suggestions for Vue components. The code sample shows how to create a language service and get code completions at a specific position in a Vue file.

const { createLanguageService } = require('@volar/language-core');
const service = createLanguageService({
  getScriptFileNames: () => ['example.vue'],
  getScriptVersion: () => '1',
  getScriptSnapshot: (fileName) => {
    if (fileName === 'example.vue') {
      return {
        getText: (start, end) => '<template><div>{{ message }}</div></template><script>export default { data() { return { message: 123 }; } };</script>',
        getLength: () => 100,
        getChangeRange: () => undefined
      };
    }
  },
  getCurrentDirectory: () => '/',
  getCompilationSettings: () => ({}),
  getDefaultLibFileName: () => 'lib.d.ts'
});
const completions = service.getCompletionsAtPosition('example.vue', 10, {});
console.log(completions);

Diagnostics

This feature provides diagnostics for Vue components, helping to identify syntax errors. The code sample demonstrates how to create a language service and get syntactic diagnostics for a Vue file.

const { createLanguageService } = require('@volar/language-core');
const service = createLanguageService({
  getScriptFileNames: () => ['example.vue'],
  getScriptVersion: () => '1',
  getScriptSnapshot: (fileName) => {
    if (fileName === 'example.vue') {
      return {
        getText: (start, end) => '<template><div>{{ message }}</div></template><script>export default { data() { return { message: 123 }; } };</script>',
        getLength: () => 100,
        getChangeRange: () => undefined
      };
    }
  },
  getCurrentDirectory: () => '/',
  getCompilationSettings: () => ({}),
  getDefaultLibFileName: () => 'lib.d.ts'
});
const diagnostics = service.getSyntacticDiagnostics('example.vue');
console.log(diagnostics);

Other packages similar to @volar/language-core

Changelog

Source

2.3.4 (2024-06-25)

Bug Fixes

  • language-service: EmbeddedCodeFormattingOptions.level value incorrect

FAQs

Package last updated on 24 Jun 2024

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc