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

@stylable/language-service

Package Overview
Dependencies
Maintainers
5
Versions
165
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stylable/language-service - npm Package Compare versions

Comparing version 3.1.2 to 3.1.3

30

cjs/lib/completion-providers.js

@@ -118,3 +118,3 @@ "use strict";

if (parentSelector.nodes.every((n) => (postcss_ast_utils_1.isDeclaration(n) && completion_types_1.importDirectives[name] !== n.prop) || postcss_ast_utils_1.isComment(n)) &&
completion_types_1.importDirectives[name].indexOf(fullLineText.trim()) === 0) {
completion_types_1.importDirectives[name].startsWith(fullLineText.trim())) {
res.push(completion_types_1.importInternalDirective(name, createDirectiveRange(position, fullLineText, lineChunkAtCursor)));

@@ -139,3 +139,3 @@ }

if (parentSelector.nodes.every((n) => (postcss_ast_utils_1.isDeclaration(n) && completion_types_1.rulesetDirectives.mixin !== n.prop) || postcss_ast_utils_1.isComment(n)) &&
completion_types_1.rulesetDirectives.mixin.indexOf(fullLineText.trim()) === 0) {
completion_types_1.rulesetDirectives.mixin.startsWith(fullLineText.trim())) {
res.push(completion_types_1.rulesetInternalDirective('mixin', createDirectiveRange(position, fullLineText, lineChunkAtCursor)));

@@ -149,3 +149,3 @@ }

postcss_ast_utils_1.isComment(n)) &&
completion_types_1.rulesetDirectives[name].indexOf(fullLineText.trim()) === 0) {
completion_types_1.rulesetDirectives[name].startsWith(fullLineText.trim())) {
res.push(completion_types_1.rulesetInternalDirective(name, createDirectiveRange(position, fullLineText, lineChunkAtCursor)));

@@ -172,5 +172,5 @@ }

return topLevelDeclarations
.filter(d => !/@namespace/.test(meta.ast.source.input.css) ||
.filter(d => !meta.ast.source.input.css.includes('@namespace') ||
d !== 'namespace')
.filter(d => completion_types_1.topLevelDirectives[d].indexOf(fullLineText.trim()) === 0)
.filter(d => completion_types_1.topLevelDirectives[d].startsWith(fullLineText.trim()))
.map(d => completion_types_1.topLevelDirective(d, createDirectiveRange(position, fullLineText, lineChunkAtCursor)));

@@ -198,3 +198,3 @@ }

!this.isInsideValueDirective(fullLineText, position.character) &&
fullLineText.indexOf(':') !== -1) {
fullLineText.includes(':')) {
const parsed = pvp(fullLineText.slice(fullLineText.indexOf(':') + 1)).nodes;

@@ -221,3 +221,3 @@ const node = parsed[parsed.length - 1];

isInsideValueDirective(wholeLine, pos) {
if (!/value\(/.test(wholeLine)) {
if (!wholeLine.includes('value(')) {
return false;

@@ -343,3 +343,3 @@ }

.filter(ms => ms.startsWith(lastName))
.filter(ms => names.indexOf(ms) === -1)
.filter(ms => !names.includes(ms))
.map(ms => {

@@ -500,3 +500,3 @@ return completion_types_1.cssMixinCompletion(ms, new ProviderRange(new ProviderPosition(position.line, position.character - lastName.length), position), meta.mappedSymbols[ms]._kind === 'import'

if (lastNode.type === 'pseudo-element' &&
core_1.nativePseudoElements.indexOf(lastNode.name) !== -1) {
core_1.nativePseudoElements.includes(lastNode.name)) {
lastNode = resolvedElements[0][resolvedElements[0].length - 2];

@@ -514,3 +514,3 @@ }

let filter = lastNode.resolved.length
? states.indexOf(lastSelectoid.replace(':', '')) !== -1
? states.includes(lastSelectoid.replace(':', ''))
? ''

@@ -521,3 +521,3 @@ : lastSelectoid.replace(':', '')

? resolvedElements[0][resolvedElements[0].length - 2].type === 'pseudo-element' &&
core_1.nativePseudoElements.indexOf(resolvedElements[0][resolvedElements[0].length - 2].name) !== -1
core_1.nativePseudoElements.includes(resolvedElements[0][resolvedElements[0].length - 2].name)
? resolvedElements[0][resolvedElements[0].length - 3]

@@ -647,3 +647,3 @@ : resolvedElements[0][resolvedElements[0].length - 2]

if (lastNode.type === 'pseudo-element' &&
core_1.nativePseudoElements.indexOf(lastNode.name) !== -1) {
core_1.nativePseudoElements.includes(lastNode.name)) {
lastNode = resolvedElements[0][resolvedElements[0].length - 2];

@@ -670,4 +670,3 @@ }

// selectoid is a CSS native pseudo-sclass
core_1.nativePseudoClasses.indexOf(lastSelectoid.replace(':', '')) !==
-1 ||
core_1.nativePseudoClasses.includes(lastSelectoid.replace(':', '')) ||
allStates.hasOwnProperty(lastSelectoid.replace(':', ''))) &&

@@ -698,4 +697,3 @@ chunkyStates.every(cs => cs !== k)) {

const lastState = lastSelectoid.replace(':', '');
const realState = allStates.hasOwnProperty(lastState) ||
core_1.nativePseudoClasses.indexOf(lastState) !== -1;
const realState = allStates.hasOwnProperty(lastState) || core_1.nativePseudoClasses.includes(lastState);
return states.reduce((acc, st) => {

@@ -702,0 +700,0 @@ acc.push(completion_types_1.stateCompletion(st.name, st.state.path, new ProviderRange(new ProviderPosition(position.line, lastState

@@ -45,3 +45,3 @@ "use strict";

const wordIndex = lines[i].indexOf(report.options.word);
if (!!~wordIndex) {
if (~wordIndex) {
start.line = i;

@@ -48,0 +48,0 @@ start.character = wordIndex;

@@ -73,3 +73,3 @@ "use strict";

const lineIndex = lines.findIndex(l => reg.test(l));
if (lineIndex > -1 && lines[lineIndex].indexOf(v.name) > -1) {
if (lineIndex > -1 && lines[lineIndex].includes(v.name)) {
let extraLines = 0;

@@ -76,0 +76,0 @@ let extraChars = 0;

@@ -129,3 +129,3 @@ "use strict";

if (name === k.name ||
(name.charAt(0) !== name.charAt(0).toLowerCase() && k.name === 'root')) {
(!name.startsWith(name.charAt(0).toLowerCase()) && k.name === 'root')) {
temp = k;

@@ -138,3 +138,3 @@ stateMeta = meta;

const res = this.findMyState(callingMeta, name, word);
if (!!res) {
if (res) {
temp = k;

@@ -154,3 +154,3 @@ stateMeta = res.meta;

}
else if (word.charAt(0) !== word.charAt(0).toLowerCase()) {
else if (!word.startsWith(word.charAt(0).toLowerCase())) {
// Default import, link to top of imported stylesheet

@@ -169,3 +169,3 @@ defs.push(new ProviderLocation(meta.source, completion_providers_1.createRange(0, 0, 0, 0)));

res._kind === 'css' &&
Object.keys(res.symbol[core_1.valueMapping.states]).indexOf(state) !== -1) {
Object.keys(res.symbol[core_1.valueMapping.states]).includes(state)) {
return res;

@@ -232,3 +232,3 @@ }

}
if (/value\(\s*[^\)]*$/.test(value)) {
if (/value\(\s*[^)]*$/.test(value)) {
return null;

@@ -296,3 +296,3 @@ }

escapeRegExp(re) {
return re.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, '\\$1');
return re.replace(/([.*+?^=!:${}()|[\]/\\])/g, '\\$1');
}

@@ -573,3 +573,3 @@ getSignatureForTsModifier(mixin, activeParam, filePath, isDefault, paramInfo) {

function isIllegalLine(line) {
return /^\s*[-\.:]+\s*$/.test(line);
return /^\s*[-.:]+\s*$/.test(line);
}

@@ -648,3 +648,3 @@ const lineEndsRegexp = /({|}|;)/;

if (rs.resolved.some(inner => inner.meta.source === defMeta.source &&
Object.keys(inner.symbol[core_1.valueMapping.states]).indexOf(word) !== -1) &&
Object.keys(inner.symbol[core_1.valueMapping.states]).includes(word)) &&
rs.resolved[rs.resolved.length - 1].symbol.name ===

@@ -873,3 +873,3 @@ lastResolvedSelector.symbol.name) {

}
if (!defMeta.mappedSymbols[word] && word.charAt(0) !== word.charAt(0).toLowerCase()) {
if (!defMeta.mappedSymbols[word] && !word.startsWith(word.charAt(0).toLowerCase())) {
// Default import

@@ -999,6 +999,5 @@ stylesheetsPath.forEach(stylesheetPath => {

const elem = parsed.selector[parsed.target.index].type === '*' ||
parsed.selector[parsed.target.index].type.charAt(0) !==
parsed.selector[parsed.target.index].type
.charAt(0)
.toLowerCase()
!parsed.selector[parsed.target.index].type.startsWith(parsed.selector[parsed.target.index].type
.charAt(0)
.toLowerCase())
? findLast(parsed.selector[parsed.target.index].text, (str) => !str.startsWith(':') || str.startsWith('::')).replace('.', '')

@@ -1014,3 +1013,3 @@ : parsed.selector[parsed.target.index].name;

inner.meta.source === defMeta.source &&
Object.keys(symbolStates).indexOf(word) !== -1);
Object.keys(symbolStates).includes(word));
}

@@ -1206,7 +1205,7 @@ return false;

function isNamedDirective(line) {
return line.indexOf(core_1.valueMapping.named) !== -1;
return line.includes(core_1.valueMapping.named);
}
function isInValue(lineText, position) {
let isInValue = false;
if (/value\(/.test(lineText)) {
if (lineText.includes('value(')) {
const line = lineText.slice(0, position.character);

@@ -1334,3 +1333,3 @@ let stack = 0;

else if (meta.mappedSymbols[word]._kind === 'class') {
if (!!meta.mappedSymbols[word].alias) {
if (meta.mappedSymbols[word].alias) {
meta = stylable.resolver.resolveImport(meta.mappedSymbols[word].alias).meta;

@@ -1382,3 +1381,3 @@ }

let reso;
if (word.charAt(0) !== word.charAt(0).toLowerCase()) {
if (!word.startsWith(word.charAt(0).toLowerCase())) {
reso = resolvedElements[0][resolvedElements[0].length - 1].resolved.find(res => !!res.symbol['-st-root']);

@@ -1385,0 +1384,0 @@ }

@@ -36,3 +36,3 @@ import { IFileSystem } from '@file-services/types';

provideCompletionItemsFromSrc(src: string, pos: Position, fileName: string): Completion[];
getDefinitionLocation(src: string, position: ProviderPosition, filePath: string): Promise<Location[]>;
getDefinitionLocation(src: string, position: ProviderPosition, filePath: string): Location[];
getSignatureHelp(src: string, pos: Position, filePath: string, paramInfo: typeof ParameterInformation): SignatureHelp | null;

@@ -39,0 +39,0 @@ getRefs(filePath: string, position: ProviderPosition): Location[];

@@ -142,4 +142,4 @@ "use strict";

}
async getDefinitionLocation(src, position, filePath) {
const defs = await this.provider.getDefinitionLocation(src, position, vscode_uri_1.URI.file(filePath).fsPath, this.fs);
getDefinitionLocation(src, position, filePath) {
const defs = this.provider.getDefinitionLocation(src, position, vscode_uri_1.URI.file(filePath).fsPath, this.fs);
return defs.map(loc => vscode_languageserver_types_1.Location.create(vscode_uri_1.URI.file(loc.uri).fsPath, loc.range));

@@ -146,0 +146,0 @@ }

@@ -13,4 +13,3 @@ "use strict";

}
if (node.source.start.line === position.line &&
node.source.start.column > position.character) {
if (node.source.start.line === position.line && node.source.start.column > position.character) {
return false;

@@ -42,3 +41,3 @@ }

.slice(node.source.start.line - 1, node.source.end ? node.source.end.line : undefined);
if (part.findIndex(s => s.indexOf('{') !== -1) + node.source.start.line > position.line) {
if (part.findIndex(s => s.includes('{')) + node.source.start.line > position.line) {
return true;

@@ -56,6 +55,6 @@ }

.slice(node.source.start.line - 1, node.source.end.line);
if (part.findIndex(s => s.indexOf('}') !== -1) + node.source.start.line < position.line) {
if (part.findIndex(s => s.includes('}')) + node.source.start.line < position.line) {
return true;
}
if (part[position.line - node.source.start.line].indexOf('}') > -1 &&
if (part[position.line - node.source.start.line].includes('}') &&
part[position.line - node.source.start.line].indexOf('}') < position.character) {

@@ -62,0 +61,0 @@ return true;

{
"name": "@stylable/language-service",
"version": "3.1.2",
"version": "3.1.3",
"description": "Stylable Language Services - syntax highlighting, completions, hinting and more for the Stylable CSS preprocessor.",

@@ -17,9 +17,9 @@ "main": "./cjs/index.js",

"@file-services/typescript": "^2.1.2",
"@stylable/core": "^3.1.1",
"@stylable/core": "^3.1.3",
"css-selector-tokenizer": "^0.7.1",
"postcss": "^7.0.26",
"postcss-value-parser": "^4.0.2",
"typescript": "~3.7.4",
"typescript": "~3.7.5",
"vscode-css-languageservice": "^4.0.2",
"vscode-languageserver": "^6.0.0",
"vscode-languageserver": "^6.1.0",
"vscode-uri": "^2.1.1"

@@ -41,3 +41,3 @@ },

"license": "BSD-3-Clause",
"gitHead": "90e2d628f9557f1d5a0a4d5ce1928828044e5361"
"gitHead": "ebe8f0a6a6472621e671b3333ed410660325b73a"
}

@@ -207,7 +207,7 @@ import path from 'path';

if (
parentSelector!.nodes!.every(
parentSelector.nodes!.every(
(n: any) =>
(isDeclaration(n) && importDirectives[name] !== n.prop) || isComment(n)
) &&
importDirectives[name].indexOf(fullLineText.trim()) === 0
importDirectives[name].startsWith(fullLineText.trim())
) {

@@ -252,3 +252,3 @@ res.push(

) &&
rulesetDirectives.mixin.indexOf(fullLineText.trim()) === 0
rulesetDirectives.mixin.startsWith(fullLineText.trim())
) {

@@ -267,3 +267,3 @@ res.push(

if (
parentSelector!.nodes!.every(
parentSelector.nodes!.every(
(n: any) =>

@@ -273,3 +273,3 @@ (isDeclaration(n) && rulesetDirectives[name] !== n.prop) ||

) &&
rulesetDirectives[name].indexOf(fullLineText.trim()) === 0
rulesetDirectives[name].startsWith(fullLineText.trim())
) {

@@ -311,6 +311,6 @@ res.push(

d =>
!/@namespace/.test((meta.ast.source!.input as any).css) ||
!(meta.ast.source!.input as any).css.includes('@namespace') ||
d !== 'namespace'
)
.filter(d => topLevelDirectives[d].indexOf(fullLineText.trim()) === 0)
.filter(d => topLevelDirectives[d].startsWith(fullLineText.trim()))
.map(d =>

@@ -348,3 +348,3 @@ topLevelDirective(

!this.isInsideValueDirective(fullLineText, position.character) &&
fullLineText.indexOf(':') !== -1
fullLineText.includes(':')
) {

@@ -381,3 +381,3 @@ const parsed = pvp(fullLineText.slice(fullLineText.indexOf(':') + 1)).nodes;

isInsideValueDirective(wholeLine: string, pos: number) {
if (!/value\(/.test(wholeLine)) {
if (!wholeLine.includes('value(')) {
return false;

@@ -582,3 +582,3 @@ }

.filter(ms => ms.startsWith(lastName))
.filter(ms => names.indexOf(ms) === -1)
.filter(ms => !names.includes(ms))
.map(ms => {

@@ -714,3 +714,3 @@ return cssMixinCompletion(

if (isNamedValueLine) {
let importName: string = '';
let importName = '';
if (

@@ -849,3 +849,3 @@ parentSelector &&

lastNode.type === 'pseudo-element' &&
nativePseudoElements.indexOf(lastNode.name) !== -1
nativePseudoElements.includes(lastNode.name)
) {

@@ -865,3 +865,3 @@ lastNode = resolvedElements[0][resolvedElements[0].length - 2];

let filter = lastNode.resolved.length
? states.indexOf(lastSelectoid.replace(':', '')) !== -1
? states.includes(lastSelectoid.replace(':', ''))
? ''

@@ -873,5 +873,5 @@ : lastSelectoid.replace(':', '')

? resolvedElements[0][resolvedElements[0].length - 2].type === 'pseudo-element' &&
nativePseudoElements.indexOf(
nativePseudoElements.includes(
resolvedElements[0][resolvedElements[0].length - 2].name
) !== -1
)
? resolvedElements[0][resolvedElements[0].length - 3]

@@ -1098,3 +1098,3 @@ : resolvedElements[0][resolvedElements[0].length - 2]

lastNode.type === 'pseudo-element' &&
nativePseudoElements.indexOf(lastNode.name) !== -1
nativePseudoElements.includes(lastNode.name)
) {

@@ -1127,4 +1127,3 @@ lastNode = resolvedElements[0][resolvedElements[0].length - 2];

// selectoid is a CSS native pseudo-sclass
nativePseudoClasses.indexOf(lastSelectoid.replace(':', '')) !==
-1 ||
nativePseudoClasses.includes(lastSelectoid.replace(':', '')) ||
allStates.hasOwnProperty(lastSelectoid.replace(':', ''))) &&

@@ -1162,4 +1161,3 @@ chunkyStates.every(cs => cs !== k)

const realState =
allStates.hasOwnProperty(lastState) ||
nativePseudoClasses.indexOf(lastState) !== -1;
allStates.hasOwnProperty(lastState) || nativePseudoClasses.includes(lastState);

@@ -1166,0 +1164,0 @@ return states.reduce((acc: Completion[], st) => {

@@ -178,3 +178,3 @@ import { valueMapping } from '@stylable/core';

// semantic
export function classCompletion(className: string, rng: ProviderRange, removeDot: boolean = false) {
export function classCompletion(className: string, rng: ProviderRange, removeDot = false) {
return new Completion(

@@ -181,0 +181,0 @@ (removeDot ? '' : '.') + className,

@@ -52,8 +52,8 @@ import { Diagnostic as StylableDiagnostic, process, safeParse, Stylable } from '@stylable/core';

for (let i = searchStart; i <= searchEnd; ++i) {
const wordIndex = lines[i].indexOf(report.options.word!);
if (!!~wordIndex) {
const wordIndex = lines[i].indexOf(report.options.word);
if (~wordIndex) {
start.line = i;
start.character = wordIndex;
end.line = i;
end.character = wordIndex + report.options.word!.length;
end.character = wordIndex + report.options.word.length;
break;

@@ -60,0 +60,0 @@ }

@@ -118,3 +118,3 @@ import { IFileSystem } from '@file-services/types';

const lineIndex = lines.findIndex(l => reg.test(l));
if (lineIndex > -1 && lines[lineIndex].indexOf(v.name) > -1) {
if (lineIndex > -1 && lines[lineIndex].includes(v.name)) {
let extraLines = 0;

@@ -121,0 +121,0 @@ let extraChars = 0;

@@ -22,3 +22,3 @@ import { ParsedValue, StateParsedValue, systemValidators } from '@stylable/core';

const stateParts: ParsedValue[] = pvp(value).nodes;
let requiredHinting: boolean = false;
let requiredHinting = false;
const validator = { length: 0, requiredHinting: false };

@@ -25,0 +25,0 @@ let stateTypeValidatorToHint: string | null = null;

@@ -286,4 +286,4 @@ import { IFileSystem, IFileSystemStats } from '@file-services/types';

public async getDefinitionLocation(src: string, position: ProviderPosition, filePath: string) {
const defs = await this.provider.getDefinitionLocation(
public getDefinitionLocation(src: string, position: ProviderPosition, filePath: string) {
const defs = this.provider.getDefinitionLocation(
src,

@@ -290,0 +290,0 @@ position,

@@ -12,15 +12,12 @@ import postcss from 'postcss';

}
if (!node.source!.start) {
if (!node.source.start) {
return false;
}
if (node.source!.start!.line > position.line) {
if (node.source.start.line > position.line) {
return false;
}
if (
node.source!.start!.line === position.line &&
node.source!.start!.column > position.character
) {
if (node.source.start.line === position.line && node.source.start.column > position.character) {
return false;
}
if (!node.source!.end) {
if (!node.source.end) {
return (

@@ -32,6 +29,6 @@ !isBeforeRuleset(position, node) ||

}
if (node.source!.end!.line < position.line) {
if (node.source.end.line < position.line) {
return false;
}
if (node.source!.end!.line === position.line && node.source!.end!.column < position.character) {
if (node.source.end.line === position.line && node.source.end.column < position.character) {
return false;

@@ -51,4 +48,4 @@ }

.split('\n')
.slice(node.source!.start!.line - 1, node.source!.end ? node.source!.end!.line : undefined);
if (part.findIndex(s => s.indexOf('{') !== -1) + node.source!.start!.line > position.line) {
.slice(node.source!.start!.line - 1, node.source!.end ? node.source!.end.line : undefined);
if (part.findIndex(s => s.includes('{')) + node.source!.start!.line > position.line) {
return true;

@@ -66,7 +63,7 @@ }

.slice(node.source!.start!.line - 1, node.source!.end!.line);
if (part.findIndex(s => s.indexOf('}') !== -1) + node.source!.start!.line < position.line) {
if (part.findIndex(s => s.includes('}')) + node.source!.start!.line < position.line) {
return true;
}
if (
part[position.line - node.source!.start!.line].indexOf('}') > -1 &&
part[position.line - node.source!.start!.line].includes('}') &&
part[position.line - node.source!.start!.line].indexOf('}') < position.character

@@ -107,3 +104,3 @@ ) {

res: postcss.NodeBase[] = [],
includeSelector: boolean = false
includeSelector = false
): postcss.NodeBase[] {

@@ -110,0 +107,0 @@ res.push(ast);

@@ -57,3 +57,3 @@ const selectorTokenizer = require('css-selector-tokenizer');

inputSelector: string,
cursorIndex: number = 0
cursorIndex = 0
): { selector: SelectorQuery[]; target: CursorPosition; lastSelector: string } {

@@ -73,4 +73,4 @@ const res: SelectorQuery[] = [];

let currentPosition = (spaceBeforeSelector && spaceBeforeSelector[0].length) || 0;
let currentSourceQuery: string = '';
let lastSelector: string = '';
let currentSourceQuery = '';
let lastSelector = '';
let chunkInternalPos = 0;

@@ -77,0 +77,0 @@ res.push(createSelectorChunk());

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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