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

@codemirror/lang-javascript

Package Overview
Dependencies
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codemirror/lang-javascript - npm Package Compare versions

Comparing version 0.18.0 to 0.19.0

6

CHANGELOG.md

@@ -0,1 +1,7 @@

## 0.19.0 (2021-08-11)
### Breaking changes
Update dependencies to 0.19.0
## 0.18.0 (2021-03-03)

@@ -2,0 +8,0 @@

46

dist/index.d.ts

@@ -1,2 +0,2 @@

import { LezerLanguage, LanguageSupport } from '@codemirror/language';
import { LRLanguage, LanguageSupport } from '@codemirror/language';
import { Completion } from '@codemirror/autocomplete';

@@ -6,6 +6,24 @@ import { Diagnostic } from '@codemirror/lint';

declare const javascriptLanguage: LezerLanguage;
declare const typescriptLanguage: LezerLanguage;
declare const jsxLanguage: LezerLanguage;
declare const tsxLanguage: LezerLanguage;
/**
A language provider based on the [Lezer JavaScript
parser](https://github.com/lezer-parser/javascript), extended with
highlighting and indentation information.
*/
declare const javascriptLanguage: LRLanguage;
/**
A language provider for TypeScript.
*/
declare const typescriptLanguage: LRLanguage;
/**
Language provider for JSX.
*/
declare const jsxLanguage: LRLanguage;
/**
Language provider for JSX + TypeScript.
*/
declare const tsxLanguage: LRLanguage;
/**
JavaScript support. Includes [snippet](https://codemirror.net/6/docs/ref/#lang-javascript.snippets)
completion.
*/
declare function javascript(config?: {

@@ -16,6 +34,24 @@ jsx?: boolean;

/**
A collection of JavaScript-related
[snippets](https://codemirror.net/6/docs/ref/#autocomplete.snippet).
*/
declare const snippets: readonly Completion[];
/**
Connects an [ESLint](https://eslint.org/) linter to CodeMirror's
[lint](https://codemirror.net/6/docs/ref/#lint) integration. `eslint` should be an instance of the
[`Linter`](https://eslint.org/docs/developer-guide/nodejs-api#linter)
class, and `config` an optional ESLint configuration. The return
value of this function can be passed to [`linter`](https://codemirror.net/6/docs/ref/#lint.linter)
to create a JavaScript linting extension.
Note that ESLint targets node, and is tricky to run in the
browser. The [eslint4b](https://github.com/mysticatea/eslint4b)
and
[eslint4b-prebuilt](https://github.com/marijnh/eslint4b-prebuilt/)
packages may help with that.
*/
declare function esLint(eslint: any, config?: any): (view: EditorView) => Diagnostic[];
export { esLint, javascript, javascriptLanguage, jsxLanguage, snippets, tsxLanguage, typescriptLanguage };

120

dist/index.js

@@ -1,10 +0,12 @@

import { parser } from 'lezer-javascript';
import { LezerLanguage, indentNodeProp, continuedIndent, flatIndent, delimitedIndent, foldNodeProp, foldInside, LanguageSupport } from '@codemirror/language';
import { parser } from '@lezer/javascript';
import { LRLanguage, indentNodeProp, continuedIndent, flatIndent, delimitedIndent, foldNodeProp, foldInside, LanguageSupport } from '@codemirror/language';
import { styleTags, tags } from '@codemirror/highlight';
import { snippetCompletion, ifNotIn, completeFromList } from '@codemirror/autocomplete';
/// A collection of JavaScript-related
/// [snippets](#autocomplete.snippet).
/**
A collection of JavaScript-related
[snippets](https://codemirror.net/6/docs/ref/#autocomplete.snippet).
*/
const snippets = [
snippetCompletion("function ${name}(${params}) {\n\t${}\n}", {
/*@__PURE__*/snippetCompletion("function ${name}(${params}) {\n\t${}\n}", {
label: "function",

@@ -14,3 +16,3 @@ detail: "definition",

}),
snippetCompletion("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n\t${}\n}", {
/*@__PURE__*/snippetCompletion("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n\t${}\n}", {
label: "for",

@@ -20,3 +22,3 @@ detail: "loop",

}),
snippetCompletion("for (let ${name} of ${collection}) {\n\t${}\n}", {
/*@__PURE__*/snippetCompletion("for (let ${name} of ${collection}) {\n\t${}\n}", {
label: "for",

@@ -26,3 +28,3 @@ detail: "of loop",

}),
snippetCompletion("try {\n\t${}\n} catch (${error}) {\n\t${}\n}", {
/*@__PURE__*/snippetCompletion("try {\n\t${}\n} catch (${error}) {\n\t${}\n}", {
label: "try",

@@ -32,3 +34,3 @@ detail: "block",

}),
snippetCompletion("class ${name} {\n\tconstructor(${params}) {\n\t\t${}\n\t}\n}", {
/*@__PURE__*/snippetCompletion("class ${name} {\n\tconstructor(${params}) {\n\t\t${}\n\t}\n}", {
label: "class",

@@ -38,3 +40,3 @@ detail: "definition",

}),
snippetCompletion("import {${names}} from \"${module}\"\n${}", {
/*@__PURE__*/snippetCompletion("import {${names}} from \"${module}\"\n${}", {
label: "import",

@@ -44,3 +46,3 @@ detail: "named",

}),
snippetCompletion("import ${name} from \"${module}\"\n${}", {
/*@__PURE__*/snippetCompletion("import ${name} from \"${module}\"\n${}", {
label: "import",

@@ -52,11 +54,13 @@ detail: "default",

/// A language provider based on the [Lezer JavaScript
/// parser](https://github.com/lezer-parser/javascript), extended with
/// highlighting and indentation information.
const javascriptLanguage = LezerLanguage.define({
parser: parser.configure({
/**
A language provider based on the [Lezer JavaScript
parser](https://github.com/lezer-parser/javascript), extended with
highlighting and indentation information.
*/
const javascriptLanguage = /*@__PURE__*/LRLanguage.define({
parser: /*@__PURE__*/parser.configure({
props: [
indentNodeProp.add({
IfStatement: continuedIndent({ except: /^\s*({|else\b)/ }),
TryStatement: continuedIndent({ except: /^\s*({|catch|finally)\b/ }),
/*@__PURE__*/indentNodeProp.add({
IfStatement: /*@__PURE__*/continuedIndent({ except: /^\s*({|else\b)/ }),
TryStatement: /*@__PURE__*/continuedIndent({ except: /^\s*({|catch|finally)\b/ }),
LabeledStatement: flatIndent,

@@ -67,13 +71,13 @@ SwitchBody: context => {

},
Block: delimitedIndent({ closing: "}" }),
Block: /*@__PURE__*/delimitedIndent({ closing: "}" }),
ArrowFunction: cx => cx.baseIndent + cx.unit,
"TemplateString BlockComment": () => -1,
"Statement Property": continuedIndent({ except: /^{/ }),
"Statement Property": /*@__PURE__*/continuedIndent({ except: /^{/ }),
JSXElement(context) {
let closed = /^\s*<\//.test(context.textAfter);
return context.lineIndent(context.state.doc.lineAt(context.node.from)) + (closed ? 0 : context.unit);
return context.lineIndent(context.node.from) + (closed ? 0 : context.unit);
},
JSXEscape(context) {
let closed = /\s*\}/.test(context.textAfter);
return context.lineIndent(context.state.doc.lineAt(context.node.from)) + (closed ? 0 : context.unit);
return context.lineIndent(context.node.from) + (closed ? 0 : context.unit);
},

@@ -84,7 +88,7 @@ "JSXOpenTag JSXSelfClosingTag"(context) {

}),
foldNodeProp.add({
/*@__PURE__*/foldNodeProp.add({
"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression": foldInside,
BlockComment(tree) { return { from: tree.from + 2, to: tree.to - 2 }; }
}),
styleTags({
/*@__PURE__*/styleTags({
"get set async static": tags.modifier,

@@ -95,3 +99,3 @@ "for while do if else switch try catch finally return throw break continue default case": tags.controlKeyword,

"with debugger from as new": tags.keyword,
TemplateString: tags.special(tags.string),
TemplateString: /*@__PURE__*/tags.special(tags.string),
Super: tags.atom,

@@ -103,10 +107,10 @@ BooleanLiteral: tags.bool,

VariableName: tags.variableName,
"CallExpression/VariableName": tags.function(tags.variableName),
VariableDefinition: tags.definition(tags.variableName),
"CallExpression/VariableName": /*@__PURE__*/tags.function(tags.variableName),
VariableDefinition: /*@__PURE__*/tags.definition(tags.variableName),
Label: tags.labelName,
PropertyName: tags.propertyName,
"CallExpression/MemberExpression/PropertyName": tags.function(tags.propertyName),
"FunctionDeclaration/VariableDefinition": tags.function(tags.definition(tags.variableName)),
"ClassDeclaration/VariableDefinition": tags.definition(tags.className),
PropertyNameDefinition: tags.definition(tags.propertyName),
"CallExpression/MemberExpression/PropertyName": /*@__PURE__*/tags.function(tags.propertyName),
"FunctionDeclaration/VariableDefinition": /*@__PURE__*/tags.function(/*@__PURE__*/tags.definition(tags.variableName)),
"ClassDeclaration/VariableDefinition": /*@__PURE__*/tags.definition(tags.className),
PropertyNameDefinition: /*@__PURE__*/tags.definition(tags.propertyName),
UpdateOp: tags.updateOperator,

@@ -130,3 +134,3 @@ LineComment: tags.lineComment,

TypeName: tags.typeName,
TypeDefinition: tags.definition(tags.typeName),
TypeDefinition: /*@__PURE__*/tags.definition(tags.typeName),
"type enum interface implements namespace module declare": tags.definitionKeyword,

@@ -150,10 +154,18 @@ "abstract global privacy readonly": tags.modifier,

});
/// A language provider for TypeScript.
const typescriptLanguage = javascriptLanguage.configure({ dialect: "ts" });
/// Language provider for JSX.
const jsxLanguage = javascriptLanguage.configure({ dialect: "jsx" });
/// Language provider for JSX + TypeScript.
const tsxLanguage = javascriptLanguage.configure({ dialect: "jsx ts" });
/// JavaScript support. Includes [snippet](#lang-javascript.snippets)
/// completion.
/**
A language provider for TypeScript.
*/
const typescriptLanguage = /*@__PURE__*/javascriptLanguage.configure({ dialect: "ts" });
/**
Language provider for JSX.
*/
const jsxLanguage = /*@__PURE__*/javascriptLanguage.configure({ dialect: "jsx" });
/**
Language provider for JSX + TypeScript.
*/
const tsxLanguage = /*@__PURE__*/javascriptLanguage.configure({ dialect: "jsx ts" });
/**
JavaScript support. Includes [snippet](https://codemirror.net/6/docs/ref/#lang-javascript.snippets)
completion.
*/
function javascript(config = {}) {

@@ -167,14 +179,16 @@ let lang = config.jsx ? (config.typescript ? tsxLanguage : jsxLanguage)

/// Connects an [ESLint](https://eslint.org/) linter to CodeMirror's
/// [lint](#lint) integration. `eslint` should be an instance of the
/// [`Linter`](https://eslint.org/docs/developer-guide/nodejs-api#linter)
/// class, and `config` an optional ESLint configuration. The return
/// value of this function can be passed to [`linter`](#lint.linter)
/// to create a JavaScript linting extension.
///
/// Note that ESLint targets node, and is tricky to run in the
/// browser. The [eslint4b](https://github.com/mysticatea/eslint4b)
/// and
/// [eslint4b-prebuilt](https://github.com/marijnh/eslint4b-prebuilt/)
/// packages may help with that.
/**
Connects an [ESLint](https://eslint.org/) linter to CodeMirror's
[lint](https://codemirror.net/6/docs/ref/#lint) integration. `eslint` should be an instance of the
[`Linter`](https://eslint.org/docs/developer-guide/nodejs-api#linter)
class, and `config` an optional ESLint configuration. The return
value of this function can be passed to [`linter`](https://codemirror.net/6/docs/ref/#lint.linter)
to create a JavaScript linting extension.
Note that ESLint targets node, and is tricky to run in the
browser. The [eslint4b](https://github.com/mysticatea/eslint4b)
and
[eslint4b-prebuilt](https://github.com/marijnh/eslint4b-prebuilt/)
packages may help with that.
*/
function esLint(eslint, config) {

@@ -181,0 +195,0 @@ if (!config) {

{
"name": "@codemirror/lang-javascript",
"version": "0.18.0",
"version": "0.19.0",
"description": "JavaScript language support for the CodeMirror code editor",
"scripts": {
"test": "mocha test/test-*.js",
"prepare": "tsc -p tsconfig.local.json && rollup -c"
"test": "cm-runtests",
"prepare": "cm-buildhelper src/index.ts"
},

@@ -29,18 +29,13 @@ "keywords": [

"dependencies": {
"@codemirror/autocomplete": "^0.18.0",
"@codemirror/highlight": "^0.18.0",
"@codemirror/language": "^0.18.0",
"@codemirror/lint": "^0.18.0",
"@codemirror/state": "^0.18.0",
"@codemirror/view": "^0.18.0",
"lezer-javascript": "^0.13.0"
"@codemirror/autocomplete": "^0.19.0",
"@codemirror/highlight": "^0.19.0",
"@codemirror/language": "^0.19.0",
"@codemirror/lint": "^0.19.0",
"@codemirror/state": "^0.19.0",
"@codemirror/view": "^0.19.0",
"@lezer/javascript": "^0.14.0"
},
"devDependencies": {
"rollup": "^2.35.1",
"rollup-plugin-dts": "^2.0.1",
"typescript": "^4.1.3",
"@types/mocha": "^5.2.0",
"ist": "^1.1.6",
"lezer": "^0.13.0",
"mocha": "^7.1.1"
"@codemirror/buildhelper": "^0.1.5",
"@lezer/lr": "^0.14.0"
},

@@ -47,0 +42,0 @@ "repository": {

Sorry, the diff of this file is not supported yet

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