Skip to content

Commit 1ded897

Browse files
authored
prepare 6.2.7 (#361)
* prepare 6.2.7 * run ci on node 16.x and 18.x
1 parent c2abf4f commit 1ded897

7 files changed

Lines changed: 1162 additions & 651 deletions

File tree

.github/workflows/node.js.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
strategy:
1515
matrix:
16-
node-version: [14.x, 16.x]
16+
node-version: [16.x, 18.x]
1717
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
1818

1919
steps:

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vscode-css-languageservice",
3-
"version": "6.2.6",
3+
"version": "6.2.7",
44
"description": "Language service for CSS, LESS and SCSS",
55
"main": "./lib/umd/cssLanguageService.js",
66
"typings": "./lib/umd/cssLanguageService",
@@ -17,18 +17,18 @@
1717
"devDependencies": {
1818
"@types/mocha": "^10.0.1",
1919
"@types/node": "16.x",
20-
"@typescript-eslint/eslint-plugin": "^5.59.7",
21-
"@typescript-eslint/parser": "^5.59.7",
22-
"@vscode/web-custom-data": "^0.4.6",
23-
"eslint": "^8.41.0",
24-
"js-beautify": "^1.14.7",
20+
"@typescript-eslint/eslint-plugin": "^6.5.0",
21+
"@typescript-eslint/parser": "^6.5.0",
22+
"@vscode/web-custom-data": "^0.4.7",
23+
"eslint": "^8.48.0",
24+
"js-beautify": "^1.14.9",
2525
"mocha": "^10.2.0",
2626
"rimraf": "^5.0.1",
2727
"source-map-support": "^0.5.21",
28-
"typescript": "^5.0.4"
28+
"typescript": "^5.2.2"
2929
},
3030
"dependencies": {
31-
"@vscode/l10n": "^0.0.14",
31+
"@vscode/l10n": "^0.0.16",
3232
"vscode-languageserver-textdocument": "^1.0.8",
3333
"vscode-languageserver-types": "^3.17.3",
3434
"vscode-uri": "^3.0.7"

src/beautify/beautify-css.js

Lines changed: 53 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// copied from js-beautify/js/lib/beautify-css.js
2-
// version: 1.14.7
2+
// version: 1.14.9
33
/* AUTO-GENERATED. DO NOT MODIFY. */
44
/*
55
@@ -1079,18 +1079,18 @@ function Beautifier(source_text, options) {
10791079

10801080
// https://developer.mozilla.org/en-US/docs/Web/CSS/At-rule
10811081
this.NESTED_AT_RULE = {
1082-
"@page": true,
1083-
"@font-face": true,
1084-
"@keyframes": true,
1082+
"page": true,
1083+
"font-face": true,
1084+
"keyframes": true,
10851085
// also in CONDITIONAL_GROUP_RULE below
1086-
"@media": true,
1087-
"@supports": true,
1088-
"@document": true
1086+
"media": true,
1087+
"supports": true,
1088+
"document": true
10891089
};
10901090
this.CONDITIONAL_GROUP_RULE = {
1091-
"@media": true,
1092-
"@supports": true,
1093-
"@document": true
1091+
"media": true,
1092+
"supports": true,
1093+
"document": true
10941094
};
10951095
this.NON_SEMICOLON_NEWLINE_PROPERTY = [
10961096
"grid-template-areas",
@@ -1218,8 +1218,7 @@ Beautifier.prototype.beautify = function() {
12181218
// label { content: blue }
12191219
var insidePropertyValue = false;
12201220
var enteringConditionalGroup = false;
1221-
var insideAtExtend = false;
1222-
var insideAtImport = false;
1221+
var insideNonNestedAtRule = false;
12231222
var insideScssMap = false;
12241223
var topCharacter = this._ch;
12251224
var insideNonSemiColonValues = false;
@@ -1274,10 +1273,32 @@ Beautifier.prototype.beautify = function() {
12741273

12751274
// Ensures any new lines following the comment are preserved
12761275
this.eatWhitespace(true);
1277-
} else if (this._ch === '@' || this._ch === '$') {
1276+
} else if (this._ch === '$') {
12781277
this.preserveSingleSpace(isAfterSpace);
12791278

1280-
// deal with less propery mixins @{...}
1279+
this.print_string(this._ch);
1280+
1281+
// strip trailing space, if present, for hash property checks
1282+
var variable = this._input.peekUntilAfter(/[: ,;{}()[\]\/='"]/g);
1283+
1284+
if (variable.match(/[ :]$/)) {
1285+
// we have a variable or pseudo-class, add it and insert one space before continuing
1286+
variable = this.eatString(": ").replace(/\s$/, '');
1287+
this.print_string(variable);
1288+
this._output.space_before_token = true;
1289+
}
1290+
1291+
variable = variable.replace(/\s$/, '');
1292+
1293+
// might be sass variable
1294+
if (parenLevel === 0 && variable.indexOf(':') !== -1) {
1295+
insidePropertyValue = true;
1296+
this.indent();
1297+
}
1298+
} else if (this._ch === '@') {
1299+
this.preserveSingleSpace(isAfterSpace);
1300+
1301+
// deal with less property mixins @{...}
12811302
if (this._input.peek() === '{') {
12821303
this.print_string(this._ch + this.eatString('}'));
12831304
} else {
@@ -1295,22 +1316,21 @@ Beautifier.prototype.beautify = function() {
12951316

12961317
variableOrRule = variableOrRule.replace(/\s$/, '');
12971318

1298-
if (variableOrRule === 'extend') {
1299-
insideAtExtend = true;
1300-
} else if (variableOrRule === 'import') {
1301-
insideAtImport = true;
1302-
}
1319+
// might be less variable
1320+
if (parenLevel === 0 && variableOrRule.indexOf(':') !== -1) {
1321+
insidePropertyValue = true;
1322+
this.indent();
13031323

1304-
// might be a nesting at-rule
1305-
if (variableOrRule in this.NESTED_AT_RULE) {
1324+
// might be a nesting at-rule
1325+
} else if (variableOrRule in this.NESTED_AT_RULE) {
13061326
this._nestedLevel += 1;
13071327
if (variableOrRule in this.CONDITIONAL_GROUP_RULE) {
13081328
enteringConditionalGroup = true;
13091329
}
1310-
// might be less variable
1311-
} else if (!insideRule && parenLevel === 0 && variableOrRule.indexOf(':') !== -1) {
1312-
insidePropertyValue = true;
1313-
this.indent();
1330+
1331+
// might be a non-nested at-rule
1332+
} else if (parenLevel === 0 && !insidePropertyValue) {
1333+
insideNonNestedAtRule = true;
13141334
}
13151335
}
13161336
} else if (this._ch === '#' && this._input.peek() === '{') {
@@ -1322,6 +1342,9 @@ Beautifier.prototype.beautify = function() {
13221342
this.outdent();
13231343
}
13241344

1345+
// non nested at rule becomes nested
1346+
insideNonNestedAtRule = false;
1347+
13251348
// when entering conditional groups, only rulesets are allowed
13261349
if (enteringConditionalGroup) {
13271350
enteringConditionalGroup = false;
@@ -1362,8 +1385,7 @@ Beautifier.prototype.beautify = function() {
13621385
if (previous_ch === '{') {
13631386
this._output.trim(true);
13641387
}
1365-
insideAtImport = false;
1366-
insideAtExtend = false;
1388+
13671389
if (insidePropertyValue) {
13681390
this.outdent();
13691391
insidePropertyValue = false;
@@ -1397,9 +1419,10 @@ Beautifier.prototype.beautify = function() {
13971419
}
13981420
}
13991421

1400-
if ((insideRule || enteringConditionalGroup) && !(this._input.lookBack("&") || this.foundNestedPseudoClass()) && !this._input.lookBack("(") && !insideAtExtend && parenLevel === 0) {
1422+
if ((insideRule || enteringConditionalGroup) && !(this._input.lookBack("&") || this.foundNestedPseudoClass()) && !this._input.lookBack("(") && !insideNonNestedAtRule && parenLevel === 0) {
14011423
// 'property: value' delimiter
14021424
// which could be in a conditional group query
1425+
14031426
this.print_string(':');
14041427
if (!insidePropertyValue) {
14051428
insidePropertyValue = true;
@@ -1436,8 +1459,7 @@ Beautifier.prototype.beautify = function() {
14361459
this.outdent();
14371460
insidePropertyValue = false;
14381461
}
1439-
insideAtExtend = false;
1440-
insideAtImport = false;
1462+
insideNonNestedAtRule = false;
14411463
this.print_string(this._ch);
14421464
this.eatWhitespace(true);
14431465

@@ -1502,7 +1524,7 @@ Beautifier.prototype.beautify = function() {
15021524
} else if (this._ch === ',') {
15031525
this.print_string(this._ch);
15041526
this.eatWhitespace(true);
1505-
if (this._options.selector_separator_newline && (!insidePropertyValue || insideScssMap) && parenLevel === 0 && !insideAtImport && !insideAtExtend) {
1527+
if (this._options.selector_separator_newline && (!insidePropertyValue || insideScssMap) && parenLevel === 0 && !insideNonNestedAtRule) {
15061528
this._output.add_new_line();
15071529
} else {
15081530
this._output.space_before_token = true;

src/beautify/esm/beautify-css.js

Lines changed: 53 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// copied from js-beautify/js/lib/beautify-css.js
2-
// version: 1.14.7
2+
// version: 1.14.9
33
/* AUTO-GENERATED. DO NOT MODIFY. */
44
/*
55
@@ -1076,18 +1076,18 @@ function Beautifier(source_text, options) {
10761076

10771077
// https://developer.mozilla.org/en-US/docs/Web/CSS/At-rule
10781078
this.NESTED_AT_RULE = {
1079-
"@page": true,
1080-
"@font-face": true,
1081-
"@keyframes": true,
1079+
"page": true,
1080+
"font-face": true,
1081+
"keyframes": true,
10821082
// also in CONDITIONAL_GROUP_RULE below
1083-
"@media": true,
1084-
"@supports": true,
1085-
"@document": true
1083+
"media": true,
1084+
"supports": true,
1085+
"document": true
10861086
};
10871087
this.CONDITIONAL_GROUP_RULE = {
1088-
"@media": true,
1089-
"@supports": true,
1090-
"@document": true
1088+
"media": true,
1089+
"supports": true,
1090+
"document": true
10911091
};
10921092
this.NON_SEMICOLON_NEWLINE_PROPERTY = [
10931093
"grid-template-areas",
@@ -1215,8 +1215,7 @@ Beautifier.prototype.beautify = function() {
12151215
// label { content: blue }
12161216
var insidePropertyValue = false;
12171217
var enteringConditionalGroup = false;
1218-
var insideAtExtend = false;
1219-
var insideAtImport = false;
1218+
var insideNonNestedAtRule = false;
12201219
var insideScssMap = false;
12211220
var topCharacter = this._ch;
12221221
var insideNonSemiColonValues = false;
@@ -1271,10 +1270,32 @@ Beautifier.prototype.beautify = function() {
12711270

12721271
// Ensures any new lines following the comment are preserved
12731272
this.eatWhitespace(true);
1274-
} else if (this._ch === '@' || this._ch === '$') {
1273+
} else if (this._ch === '$') {
12751274
this.preserveSingleSpace(isAfterSpace);
12761275

1277-
// deal with less propery mixins @{...}
1276+
this.print_string(this._ch);
1277+
1278+
// strip trailing space, if present, for hash property checks
1279+
var variable = this._input.peekUntilAfter(/[: ,;{}()[\]\/='"]/g);
1280+
1281+
if (variable.match(/[ :]$/)) {
1282+
// we have a variable or pseudo-class, add it and insert one space before continuing
1283+
variable = this.eatString(": ").replace(/\s$/, '');
1284+
this.print_string(variable);
1285+
this._output.space_before_token = true;
1286+
}
1287+
1288+
variable = variable.replace(/\s$/, '');
1289+
1290+
// might be sass variable
1291+
if (parenLevel === 0 && variable.indexOf(':') !== -1) {
1292+
insidePropertyValue = true;
1293+
this.indent();
1294+
}
1295+
} else if (this._ch === '@') {
1296+
this.preserveSingleSpace(isAfterSpace);
1297+
1298+
// deal with less property mixins @{...}
12781299
if (this._input.peek() === '{') {
12791300
this.print_string(this._ch + this.eatString('}'));
12801301
} else {
@@ -1292,22 +1313,21 @@ Beautifier.prototype.beautify = function() {
12921313

12931314
variableOrRule = variableOrRule.replace(/\s$/, '');
12941315

1295-
if (variableOrRule === 'extend') {
1296-
insideAtExtend = true;
1297-
} else if (variableOrRule === 'import') {
1298-
insideAtImport = true;
1299-
}
1316+
// might be less variable
1317+
if (parenLevel === 0 && variableOrRule.indexOf(':') !== -1) {
1318+
insidePropertyValue = true;
1319+
this.indent();
13001320

1301-
// might be a nesting at-rule
1302-
if (variableOrRule in this.NESTED_AT_RULE) {
1321+
// might be a nesting at-rule
1322+
} else if (variableOrRule in this.NESTED_AT_RULE) {
13031323
this._nestedLevel += 1;
13041324
if (variableOrRule in this.CONDITIONAL_GROUP_RULE) {
13051325
enteringConditionalGroup = true;
13061326
}
1307-
// might be less variable
1308-
} else if (!insideRule && parenLevel === 0 && variableOrRule.indexOf(':') !== -1) {
1309-
insidePropertyValue = true;
1310-
this.indent();
1327+
1328+
// might be a non-nested at-rule
1329+
} else if (parenLevel === 0 && !insidePropertyValue) {
1330+
insideNonNestedAtRule = true;
13111331
}
13121332
}
13131333
} else if (this._ch === '#' && this._input.peek() === '{') {
@@ -1319,6 +1339,9 @@ Beautifier.prototype.beautify = function() {
13191339
this.outdent();
13201340
}
13211341

1342+
// non nested at rule becomes nested
1343+
insideNonNestedAtRule = false;
1344+
13221345
// when entering conditional groups, only rulesets are allowed
13231346
if (enteringConditionalGroup) {
13241347
enteringConditionalGroup = false;
@@ -1359,8 +1382,7 @@ Beautifier.prototype.beautify = function() {
13591382
if (previous_ch === '{') {
13601383
this._output.trim(true);
13611384
}
1362-
insideAtImport = false;
1363-
insideAtExtend = false;
1385+
13641386
if (insidePropertyValue) {
13651387
this.outdent();
13661388
insidePropertyValue = false;
@@ -1394,9 +1416,10 @@ Beautifier.prototype.beautify = function() {
13941416
}
13951417
}
13961418

1397-
if ((insideRule || enteringConditionalGroup) && !(this._input.lookBack("&") || this.foundNestedPseudoClass()) && !this._input.lookBack("(") && !insideAtExtend && parenLevel === 0) {
1419+
if ((insideRule || enteringConditionalGroup) && !(this._input.lookBack("&") || this.foundNestedPseudoClass()) && !this._input.lookBack("(") && !insideNonNestedAtRule && parenLevel === 0) {
13981420
// 'property: value' delimiter
13991421
// which could be in a conditional group query
1422+
14001423
this.print_string(':');
14011424
if (!insidePropertyValue) {
14021425
insidePropertyValue = true;
@@ -1433,8 +1456,7 @@ Beautifier.prototype.beautify = function() {
14331456
this.outdent();
14341457
insidePropertyValue = false;
14351458
}
1436-
insideAtExtend = false;
1437-
insideAtImport = false;
1459+
insideNonNestedAtRule = false;
14381460
this.print_string(this._ch);
14391461
this.eatWhitespace(true);
14401462

@@ -1499,7 +1521,7 @@ Beautifier.prototype.beautify = function() {
14991521
} else if (this._ch === ',') {
15001522
this.print_string(this._ch);
15011523
this.eatWhitespace(true);
1502-
if (this._options.selector_separator_newline && (!insidePropertyValue || insideScssMap) && parenLevel === 0 && !insideAtImport && !insideAtExtend) {
1524+
if (this._options.selector_separator_newline && (!insidePropertyValue || insideScssMap) && parenLevel === 0 && !insideNonNestedAtRule) {
15031525
this._output.add_new_line();
15041526
} else {
15051527
this._output.space_before_token = true;

src/cssLanguageTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ export interface IPropertyData {
191191
values?: IValueData[];
192192
references?: IReference[];
193193
relevance?: number;
194+
atRule?: string;
194195
}
195196
export interface IAtDirectiveData {
196197
name: string;

0 commit comments

Comments
 (0)