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

@volar/language-core

Package Overview
Dependencies
Maintainers
1
Versions
234
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@volar/language-core

  • 2.2.0-alpha.11
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.3M
increased by2.65%
Maintainers
1
Weekly downloads
 
Created

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

FAQs

Package last updated on 30 Apr 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

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc