New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

vscode-json-languageservice

Package Overview
Dependencies
Maintainers
7
Versions
163
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vscode-json-languageservice - npm Package Compare versions

Comparing version 4.0.2 to 4.1.0

4

CHANGELOG.md

@@ -0,1 +1,5 @@

4.1.0 / 2021-04-24
================
* `SchemaConfiguration.fileMatch` now supports glob patterns (e.g. /foo/**/bar.json')
4.0.0 / 2020-12-14

@@ -2,0 +6,0 @@ ================

7

lib/esm/jsonLanguageTypes.d.ts

@@ -117,5 +117,6 @@ import { JSONWorkerContribution, JSONPath, Segment, CompletionsCollector } from './jsonContributions';

/**
* A list of file path patterns that are associated to the schema. The '*' wildcard can be used. Exclusion patterns starting with '!'.
* For example '*.schema.json', 'package.json', '!foo*.schema.json'.
* A match succeeds when there is at least one pattern matching and last matching pattern does not start with '!'.
* A list of file path glob patterns that are associated to the schema. The '*' and '**' wildcards can be used.
* Exclusion patterns starting with '!'.
* For example: '*.schema.json', 'package.json', '!foo*.schema.json', 'foo/**\/BADRESP.json'.
* A match succeeds when there is at least one pattern matching and last matching patter`n does not start with '!'.
*/

@@ -122,0 +123,0 @@ fileMatch?: string[];

@@ -13,2 +13,4 @@ /*---------------------------------------------------------------------------------------------

return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);

@@ -21,2 +23,3 @@ function __() { this.constructor = d; }

import { isNumber, equals, isBoolean, isString, isDefined } from '../utils/objects';
import { extendedRegExp } from '../utils/strings';
import { ErrorCode, Diagnostic, DiagnosticSeverity, Range } from '../jsonLanguageTypes';

@@ -618,3 +621,3 @@ import * as nls from 'vscode-nls';

if (isString(schema.pattern)) {
var regex = new RegExp(schema.pattern);
var regex = extendedRegExp(schema.pattern);
if (!regex.test(node.value)) {

@@ -811,3 +814,3 @@ validationResult.problems.push({

var propertyPattern = _g[_f];
var regex = new RegExp(propertyPattern);
var regex = extendedRegExp(propertyPattern);
for (var _h = 0, _j = unprocessedProperties.slice(0); _h < _j.length; _h++) {

@@ -814,0 +817,0 @@ var propertyName = _j[_h];

@@ -8,3 +8,3 @@ /*---------------------------------------------------------------------------------------------

import { stringifyObject } from '../utils/json';
import { endsWith } from '../utils/strings';
import { endsWith, extendedRegExp } from '../utils/strings';
import { isDefined } from '../utils/objects';

@@ -443,3 +443,3 @@ import { CompletionItem, CompletionItemKind, Range, TextEdit, InsertTextFormat, MarkupKind } from '../jsonLanguageTypes';

var pattern = _b[_a];
var regex = new RegExp(pattern);
var regex = extendedRegExp(pattern);
if (regex.test(parentKey)) {

@@ -446,0 +446,0 @@ propertyMatched = true;

@@ -9,24 +9,32 @@ /*---------------------------------------------------------------------------------------------

import * as Parser from '../parser/jsonParser';
import { Minimatch } from 'minimatch';
import * as nls from 'vscode-nls';
var localize = nls.loadMessageBundle();
var BANG = '!';
var PATH_SEP = '/';
var FilePatternAssociation = /** @class */ (function () {
function FilePatternAssociation(pattern, uris) {
this.patternRegExps = [];
this.isInclude = [];
this.minimatchWrappers = [];
try {
for (var _i = 0, pattern_1 = pattern; _i < pattern_1.length; _i++) {
var p = pattern_1[_i];
var include = p[0] !== '!';
var patternString = pattern_1[_i];
var include = patternString[0] !== BANG;
if (!include) {
p = p.substring(1);
patternString = patternString.substring(1);
}
this.patternRegExps.push(new RegExp(Strings.convertSimple2RegExpPattern(p) + '$'));
this.isInclude.push(include);
if (patternString.length > 0) {
if (patternString[0] === PATH_SEP) {
patternString = patternString.substring(1);
}
this.minimatchWrappers.push({
minimatch: new Minimatch("**/" + patternString),
include: include,
});
}
}
;
this.uris = uris;
}
catch (e) {
// invalid pattern
this.patternRegExps.length = 0;
this.isInclude.length = 0;
this.minimatchWrappers.length = 0;
this.uris = [];

@@ -37,6 +45,6 @@ }

var match = false;
for (var i = 0; i < this.patternRegExps.length; i++) {
var regExp = this.patternRegExps[i];
if (regExp.test(fileName)) {
match = this.isInclude[i];
for (var _i = 0, _a = this.minimatchWrappers; _i < _a.length; _i++) {
var _b = _a[_i], minimatch = _b.minimatch, include = _b.include;
if (minimatch.match(fileName)) {
match = include;
}

@@ -115,3 +123,3 @@ }

var pattern = _a[_i];
var regex = new RegExp(pattern);
var regex = Strings.extendedRegExp(pattern);
if (regex.test(next)) {

@@ -306,2 +314,3 @@ return this.getSectionRecursive(path, schema.patternProperties[pattern]);

path.split('/').some(function (part) {
part = part.replace(/~1/g, '/').replace(/~0/g, '~');
current = current[part];

@@ -509,3 +518,3 @@ return !current;

function normalizeResourceForMatching(resource) {
// remove querues and fragments, normalize drive capitalization
// remove queries and fragments, normalize drive capitalization
try {

@@ -512,0 +521,0 @@ return URI.parse(resource).with({ fragment: null, query: null }).toString();

@@ -45,1 +45,9 @@ /*---------------------------------------------------------------------------------------------

}
export function extendedRegExp(pattern) {
if (startsWith(pattern, '(?i)')) {
return new RegExp(pattern.substring(4), 'i');
}
else {
return new RegExp(pattern);
}
}

@@ -117,5 +117,6 @@ import { JSONWorkerContribution, JSONPath, Segment, CompletionsCollector } from './jsonContributions';

/**
* A list of file path patterns that are associated to the schema. The '*' wildcard can be used. Exclusion patterns starting with '!'.
* For example '*.schema.json', 'package.json', '!foo*.schema.json'.
* A match succeeds when there is at least one pattern matching and last matching pattern does not start with '!'.
* A list of file path glob patterns that are associated to the schema. The '*' and '**' wildcards can be used.
* Exclusion patterns starting with '!'.
* For example: '*.schema.json', 'package.json', '!foo*.schema.json', 'foo/**\/BADRESP.json'.
* A match succeeds when there is at least one pattern matching and last matching patter`n does not start with '!'.
*/

@@ -122,0 +123,0 @@ fileMatch?: string[];

@@ -454,3 +454,3 @@ /*---------------------------------------------------------------------------------------------

var pattern = _b[_a];
var regex = new RegExp(pattern);
var regex = strings_1.extendedRegExp(pattern);
if (regex.test(parentKey)) {

@@ -457,0 +457,0 @@ propertyMatched = true;

@@ -11,3 +11,3 @@ /*---------------------------------------------------------------------------------------------

else if (typeof define === "function" && define.amd) {
define(["require", "exports", "jsonc-parser", "vscode-uri", "../utils/strings", "../parser/jsonParser", "vscode-nls"], factory);
define(["require", "exports", "jsonc-parser", "vscode-uri", "../utils/strings", "../parser/jsonParser", "minimatch", "vscode-nls"], factory);
}

@@ -22,24 +22,32 @@ })(function (require, exports) {

var Parser = require("../parser/jsonParser");
var minimatch_1 = require("minimatch");
var nls = require("vscode-nls");
var localize = nls.loadMessageBundle();
var BANG = '!';
var PATH_SEP = '/';
var FilePatternAssociation = /** @class */ (function () {
function FilePatternAssociation(pattern, uris) {
this.patternRegExps = [];
this.isInclude = [];
this.minimatchWrappers = [];
try {
for (var _i = 0, pattern_1 = pattern; _i < pattern_1.length; _i++) {
var p = pattern_1[_i];
var include = p[0] !== '!';
var patternString = pattern_1[_i];
var include = patternString[0] !== BANG;
if (!include) {
p = p.substring(1);
patternString = patternString.substring(1);
}
this.patternRegExps.push(new RegExp(Strings.convertSimple2RegExpPattern(p) + '$'));
this.isInclude.push(include);
if (patternString.length > 0) {
if (patternString[0] === PATH_SEP) {
patternString = patternString.substring(1);
}
this.minimatchWrappers.push({
minimatch: new minimatch_1.Minimatch("**/" + patternString),
include: include,
});
}
}
;
this.uris = uris;
}
catch (e) {
// invalid pattern
this.patternRegExps.length = 0;
this.isInclude.length = 0;
this.minimatchWrappers.length = 0;
this.uris = [];

@@ -50,6 +58,6 @@ }

var match = false;
for (var i = 0; i < this.patternRegExps.length; i++) {
var regExp = this.patternRegExps[i];
if (regExp.test(fileName)) {
match = this.isInclude[i];
for (var _i = 0, _a = this.minimatchWrappers; _i < _a.length; _i++) {
var _b = _a[_i], minimatch = _b.minimatch, include = _b.include;
if (minimatch.match(fileName)) {
match = include;
}

@@ -128,3 +136,3 @@ }

var pattern = _a[_i];
var regex = new RegExp(pattern);
var regex = Strings.extendedRegExp(pattern);
if (regex.test(next)) {

@@ -319,2 +327,3 @@ return this.getSectionRecursive(path, schema.patternProperties[pattern]);

path.split('/').some(function (part) {
part = part.replace(/~1/g, '/').replace(/~0/g, '~');
current = current[part];

@@ -522,3 +531,3 @@ return !current;

function normalizeResourceForMatching(resource) {
// remove querues and fragments, normalize drive capitalization
// remove queries and fragments, normalize drive capitalization
try {

@@ -525,0 +534,0 @@ return vscode_uri_1.URI.parse(resource).with({ fragment: null, query: null }).toString();

@@ -16,3 +16,3 @@ /*---------------------------------------------------------------------------------------------

Object.defineProperty(exports, "__esModule", { value: true });
exports.repeat = exports.convertSimple2RegExpPattern = exports.endsWith = exports.startsWith = void 0;
exports.extendedRegExp = exports.repeat = exports.convertSimple2RegExpPattern = exports.endsWith = exports.startsWith = void 0;
function startsWith(haystack, needle) {

@@ -62,2 +62,11 @@ if (haystack.length < needle.length) {

exports.repeat = repeat;
function extendedRegExp(pattern) {
if (startsWith(pattern, '(?i)')) {
return new RegExp(pattern.substring(4), 'i');
}
else {
return new RegExp(pattern);
}
}
exports.extendedRegExp = extendedRegExp;
});
{
"name": "vscode-json-languageservice",
"version": "4.0.2",
"version": "4.1.0",
"description": "Language service for JSON",

@@ -17,3 +17,7 @@ "main": "./lib/umd/jsonLanguageService.js",

},
"engines": {
"npm": ">=7.0.0"
},
"devDependencies": {
"@types/minimatch": "^3.0.3",
"@types/mocha": "^8.2.0",

@@ -30,2 +34,3 @@ "@types/node": "^10.12.21",

"jsonc-parser": "^3.0.0",
"minimatch": "^3.0.4",
"vscode-languageserver-textdocument": "^1.0.1",

@@ -32,0 +37,0 @@ "vscode-languageserver-types": "^3.16.0",

Sorry, the diff of this file is too big to display

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