vscode-css-languageservice 6.1.1 → 6.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +4 -3
- package/lib/esm/beautify/beautify-css.js +1 -1
- package/lib/esm/cssLanguageService.d.ts +2 -1
- package/lib/esm/cssLanguageService.js +1 -0
- package/lib/esm/cssLanguageTypes.d.ts +2 -2
- package/lib/esm/data/webCustomData.js +3502 -310
- package/lib/esm/languageFacts/colors.js +6 -7
- package/lib/esm/parser/cssErrors.js +34 -35
- package/lib/esm/parser/cssNodes.js +4 -4
- package/lib/esm/parser/cssParser.js +16 -16
- package/lib/esm/parser/scssErrors.js +4 -5
- package/lib/esm/parser/scssParser.js +3 -0
- package/lib/esm/services/cssCodeActions.js +2 -3
- package/lib/esm/services/cssCompletion.js +13 -4
- package/lib/esm/services/cssNavigation.js +19 -7
- package/lib/esm/services/lessCompletion.js +58 -59
- package/lib/esm/services/lint.js +64 -18
- package/lib/esm/services/lintRules.js +21 -22
- package/lib/esm/services/scssCompletion.js +107 -107
- package/lib/esm/services/selectorPrinting.js +2 -3
- package/lib/umd/beautify/beautify-css.js +1 -1
- package/lib/umd/cssLanguageService.d.ts +2 -1
- package/lib/umd/cssLanguageService.js +1 -0
- package/lib/umd/cssLanguageTypes.d.ts +2 -2
- package/lib/umd/data/webCustomData.js +3502 -310
- package/lib/umd/languageFacts/colors.js +7 -8
- package/lib/umd/parser/cssErrors.js +35 -36
- package/lib/umd/parser/cssNodes.js +4 -4
- package/lib/umd/parser/cssParser.js +16 -16
- package/lib/umd/parser/scssErrors.js +5 -6
- package/lib/umd/parser/scssParser.js +3 -0
- package/lib/umd/services/cssCodeActions.js +3 -4
- package/lib/umd/services/cssCompletion.js +14 -5
- package/lib/umd/services/cssNavigation.js +20 -8
- package/lib/umd/services/lessCompletion.js +59 -60
- package/lib/umd/services/lint.js +65 -19
- package/lib/umd/services/lintRules.js +22 -23
- package/lib/umd/services/scssCompletion.js +108 -108
- package/lib/umd/services/selectorPrinting.js +3 -4
- package/package.json +13 -16
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "./cssCompletion", "../cssLanguageTypes", "vscode
|
|
7
|
+
define(["require", "exports", "./cssCompletion", "../cssLanguageTypes", "@vscode/l10n"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
/*---------------------------------------------------------------------------------------------
|
|
@@ -16,8 +16,7 @@
|
|
|
16
16
|
exports.LESSCompletion = void 0;
|
|
17
17
|
const cssCompletion_1 = require("./cssCompletion");
|
|
18
18
|
const cssLanguageTypes_1 = require("../cssLanguageTypes");
|
|
19
|
-
const
|
|
20
|
-
const localize = nls.loadMessageBundle();
|
|
19
|
+
const l10n = require("@vscode/l10n");
|
|
21
20
|
class LESSCompletion extends cssCompletion_1.CSSCompletion {
|
|
22
21
|
constructor(lsOptions, cssDataManager) {
|
|
23
22
|
super('@', lsOptions, cssDataManager);
|
|
@@ -62,156 +61,156 @@
|
|
|
62
61
|
{
|
|
63
62
|
'name': 'if',
|
|
64
63
|
'example': 'if(condition, trueValue [, falseValue]);',
|
|
65
|
-
'description':
|
|
64
|
+
'description': l10n.t('returns one of two values depending on a condition.')
|
|
66
65
|
},
|
|
67
66
|
{
|
|
68
67
|
'name': 'boolean',
|
|
69
68
|
'example': 'boolean(condition);',
|
|
70
|
-
'description':
|
|
69
|
+
'description': l10n.t('"store" a boolean test for later evaluation in a guard or if().')
|
|
71
70
|
},
|
|
72
71
|
// List functions
|
|
73
72
|
{
|
|
74
73
|
'name': 'length',
|
|
75
74
|
'example': 'length(@list);',
|
|
76
|
-
'description':
|
|
75
|
+
'description': l10n.t('returns the number of elements in a value list')
|
|
77
76
|
},
|
|
78
77
|
{
|
|
79
78
|
'name': 'extract',
|
|
80
79
|
'example': 'extract(@list, index);',
|
|
81
|
-
'description':
|
|
80
|
+
'description': l10n.t('returns a value at the specified position in the list')
|
|
82
81
|
},
|
|
83
82
|
{
|
|
84
83
|
'name': 'range',
|
|
85
84
|
'example': 'range([start, ] end [, step]);',
|
|
86
|
-
'description':
|
|
85
|
+
'description': l10n.t('generate a list spanning a range of values')
|
|
87
86
|
},
|
|
88
87
|
{
|
|
89
88
|
'name': 'each',
|
|
90
89
|
'example': 'each(@list, ruleset);',
|
|
91
|
-
'description':
|
|
90
|
+
'description': l10n.t('bind the evaluation of a ruleset to each member of a list.')
|
|
92
91
|
},
|
|
93
92
|
// Other built-ins
|
|
94
93
|
{
|
|
95
94
|
'name': 'escape',
|
|
96
95
|
'example': 'escape(@string);',
|
|
97
|
-
'description':
|
|
96
|
+
'description': l10n.t('URL encodes a string')
|
|
98
97
|
},
|
|
99
98
|
{
|
|
100
99
|
'name': 'e',
|
|
101
100
|
'example': 'e(@string);',
|
|
102
|
-
'description':
|
|
101
|
+
'description': l10n.t('escape string content')
|
|
103
102
|
},
|
|
104
103
|
{
|
|
105
104
|
'name': 'replace',
|
|
106
105
|
'example': 'replace(@string, @pattern, @replacement[, @flags]);',
|
|
107
|
-
'description':
|
|
106
|
+
'description': l10n.t('string replace')
|
|
108
107
|
},
|
|
109
108
|
{
|
|
110
109
|
'name': 'unit',
|
|
111
110
|
'example': 'unit(@dimension, [@unit: \'\']);',
|
|
112
|
-
'description':
|
|
111
|
+
'description': l10n.t('remove or change the unit of a dimension')
|
|
113
112
|
},
|
|
114
113
|
{
|
|
115
114
|
'name': 'color',
|
|
116
115
|
'example': 'color(@string);',
|
|
117
|
-
'description':
|
|
116
|
+
'description': l10n.t('parses a string to a color'),
|
|
118
117
|
'type': 'color'
|
|
119
118
|
},
|
|
120
119
|
{
|
|
121
120
|
'name': 'convert',
|
|
122
121
|
'example': 'convert(@value, unit);',
|
|
123
|
-
'description':
|
|
122
|
+
'description': l10n.t('converts numbers from one type into another')
|
|
124
123
|
},
|
|
125
124
|
{
|
|
126
125
|
'name': 'data-uri',
|
|
127
126
|
'example': 'data-uri([mimetype,] url);',
|
|
128
|
-
'description':
|
|
127
|
+
'description': l10n.t('inlines a resource and falls back to `url()`'),
|
|
129
128
|
'type': 'url'
|
|
130
129
|
},
|
|
131
130
|
{
|
|
132
131
|
'name': 'abs',
|
|
133
|
-
'description':
|
|
132
|
+
'description': l10n.t('absolute value of a number'),
|
|
134
133
|
'example': 'abs(number);'
|
|
135
134
|
},
|
|
136
135
|
{
|
|
137
136
|
'name': 'acos',
|
|
138
|
-
'description':
|
|
137
|
+
'description': l10n.t('arccosine - inverse of cosine function'),
|
|
139
138
|
'example': 'acos(number);'
|
|
140
139
|
},
|
|
141
140
|
{
|
|
142
141
|
'name': 'asin',
|
|
143
|
-
'description':
|
|
142
|
+
'description': l10n.t('arcsine - inverse of sine function'),
|
|
144
143
|
'example': 'asin(number);'
|
|
145
144
|
},
|
|
146
145
|
{
|
|
147
146
|
'name': 'ceil',
|
|
148
147
|
'example': 'ceil(@number);',
|
|
149
|
-
'description':
|
|
148
|
+
'description': l10n.t('rounds up to an integer')
|
|
150
149
|
},
|
|
151
150
|
{
|
|
152
151
|
'name': 'cos',
|
|
153
|
-
'description':
|
|
152
|
+
'description': l10n.t('cosine function'),
|
|
154
153
|
'example': 'cos(number);'
|
|
155
154
|
},
|
|
156
155
|
{
|
|
157
156
|
'name': 'floor',
|
|
158
|
-
'description':
|
|
157
|
+
'description': l10n.t('rounds down to an integer'),
|
|
159
158
|
'example': 'floor(@number);'
|
|
160
159
|
},
|
|
161
160
|
{
|
|
162
161
|
'name': 'percentage',
|
|
163
|
-
'description':
|
|
162
|
+
'description': l10n.t('converts to a %, e.g. 0.5 > 50%'),
|
|
164
163
|
'example': 'percentage(@number);',
|
|
165
164
|
'type': 'percentage'
|
|
166
165
|
},
|
|
167
166
|
{
|
|
168
167
|
'name': 'round',
|
|
169
|
-
'description':
|
|
168
|
+
'description': l10n.t('rounds a number to a number of places'),
|
|
170
169
|
'example': 'round(number, [places: 0]);'
|
|
171
170
|
},
|
|
172
171
|
{
|
|
173
172
|
'name': 'sqrt',
|
|
174
|
-
'description':
|
|
173
|
+
'description': l10n.t('calculates square root of a number'),
|
|
175
174
|
'example': 'sqrt(number);'
|
|
176
175
|
},
|
|
177
176
|
{
|
|
178
177
|
'name': 'sin',
|
|
179
|
-
'description':
|
|
178
|
+
'description': l10n.t('sine function'),
|
|
180
179
|
'example': 'sin(number);'
|
|
181
180
|
},
|
|
182
181
|
{
|
|
183
182
|
'name': 'tan',
|
|
184
|
-
'description':
|
|
183
|
+
'description': l10n.t('tangent function'),
|
|
185
184
|
'example': 'tan(number);'
|
|
186
185
|
},
|
|
187
186
|
{
|
|
188
187
|
'name': 'atan',
|
|
189
|
-
'description':
|
|
188
|
+
'description': l10n.t('arctangent - inverse of tangent function'),
|
|
190
189
|
'example': 'atan(number);'
|
|
191
190
|
},
|
|
192
191
|
{
|
|
193
192
|
'name': 'pi',
|
|
194
|
-
'description':
|
|
193
|
+
'description': l10n.t('returns pi'),
|
|
195
194
|
'example': 'pi();'
|
|
196
195
|
},
|
|
197
196
|
{
|
|
198
197
|
'name': 'pow',
|
|
199
|
-
'description':
|
|
198
|
+
'description': l10n.t('first argument raised to the power of the second argument'),
|
|
200
199
|
'example': 'pow(@base, @exponent);'
|
|
201
200
|
},
|
|
202
201
|
{
|
|
203
202
|
'name': 'mod',
|
|
204
|
-
'description':
|
|
203
|
+
'description': l10n.t('first argument modulus second argument'),
|
|
205
204
|
'example': 'mod(number, number);'
|
|
206
205
|
},
|
|
207
206
|
{
|
|
208
207
|
'name': 'min',
|
|
209
|
-
'description':
|
|
208
|
+
'description': l10n.t('returns the lowest of one or more values'),
|
|
210
209
|
'example': 'min(@x, @y);'
|
|
211
210
|
},
|
|
212
211
|
{
|
|
213
212
|
'name': 'max',
|
|
214
|
-
'description':
|
|
213
|
+
'description': l10n.t('returns the lowest of one or more values'),
|
|
215
214
|
'example': 'max(@x, @y);'
|
|
216
215
|
}
|
|
217
216
|
];
|
|
@@ -219,137 +218,137 @@
|
|
|
219
218
|
{
|
|
220
219
|
'name': 'argb',
|
|
221
220
|
'example': 'argb(@color);',
|
|
222
|
-
'description':
|
|
221
|
+
'description': l10n.t('creates a #AARRGGBB')
|
|
223
222
|
},
|
|
224
223
|
{
|
|
225
224
|
'name': 'hsl',
|
|
226
225
|
'example': 'hsl(@hue, @saturation, @lightness);',
|
|
227
|
-
'description':
|
|
226
|
+
'description': l10n.t('creates a color')
|
|
228
227
|
},
|
|
229
228
|
{
|
|
230
229
|
'name': 'hsla',
|
|
231
230
|
'example': 'hsla(@hue, @saturation, @lightness, @alpha);',
|
|
232
|
-
'description':
|
|
231
|
+
'description': l10n.t('creates a color')
|
|
233
232
|
},
|
|
234
233
|
{
|
|
235
234
|
'name': 'hsv',
|
|
236
235
|
'example': 'hsv(@hue, @saturation, @value);',
|
|
237
|
-
'description':
|
|
236
|
+
'description': l10n.t('creates a color')
|
|
238
237
|
},
|
|
239
238
|
{
|
|
240
239
|
'name': 'hsva',
|
|
241
240
|
'example': 'hsva(@hue, @saturation, @value, @alpha);',
|
|
242
|
-
'description':
|
|
241
|
+
'description': l10n.t('creates a color')
|
|
243
242
|
},
|
|
244
243
|
{
|
|
245
244
|
'name': 'hue',
|
|
246
245
|
'example': 'hue(@color);',
|
|
247
|
-
'description':
|
|
246
|
+
'description': l10n.t('returns the `hue` channel of `@color` in the HSL space')
|
|
248
247
|
},
|
|
249
248
|
{
|
|
250
249
|
'name': 'saturation',
|
|
251
250
|
'example': 'saturation(@color);',
|
|
252
|
-
'description':
|
|
251
|
+
'description': l10n.t('returns the `saturation` channel of `@color` in the HSL space')
|
|
253
252
|
},
|
|
254
253
|
{
|
|
255
254
|
'name': 'lightness',
|
|
256
255
|
'example': 'lightness(@color);',
|
|
257
|
-
'description':
|
|
256
|
+
'description': l10n.t('returns the `lightness` channel of `@color` in the HSL space')
|
|
258
257
|
},
|
|
259
258
|
{
|
|
260
259
|
'name': 'hsvhue',
|
|
261
260
|
'example': 'hsvhue(@color);',
|
|
262
|
-
'description':
|
|
261
|
+
'description': l10n.t('returns the `hue` channel of `@color` in the HSV space')
|
|
263
262
|
},
|
|
264
263
|
{
|
|
265
264
|
'name': 'hsvsaturation',
|
|
266
265
|
'example': 'hsvsaturation(@color);',
|
|
267
|
-
'description':
|
|
266
|
+
'description': l10n.t('returns the `saturation` channel of `@color` in the HSV space')
|
|
268
267
|
},
|
|
269
268
|
{
|
|
270
269
|
'name': 'hsvvalue',
|
|
271
270
|
'example': 'hsvvalue(@color);',
|
|
272
|
-
'description':
|
|
271
|
+
'description': l10n.t('returns the `value` channel of `@color` in the HSV space')
|
|
273
272
|
},
|
|
274
273
|
{
|
|
275
274
|
'name': 'red',
|
|
276
275
|
'example': 'red(@color);',
|
|
277
|
-
'description':
|
|
276
|
+
'description': l10n.t('returns the `red` channel of `@color`')
|
|
278
277
|
},
|
|
279
278
|
{
|
|
280
279
|
'name': 'green',
|
|
281
280
|
'example': 'green(@color);',
|
|
282
|
-
'description':
|
|
281
|
+
'description': l10n.t('returns the `green` channel of `@color`')
|
|
283
282
|
},
|
|
284
283
|
{
|
|
285
284
|
'name': 'blue',
|
|
286
285
|
'example': 'blue(@color);',
|
|
287
|
-
'description':
|
|
286
|
+
'description': l10n.t('returns the `blue` channel of `@color`')
|
|
288
287
|
},
|
|
289
288
|
{
|
|
290
289
|
'name': 'alpha',
|
|
291
290
|
'example': 'alpha(@color);',
|
|
292
|
-
'description':
|
|
291
|
+
'description': l10n.t('returns the `alpha` channel of `@color`')
|
|
293
292
|
},
|
|
294
293
|
{
|
|
295
294
|
'name': 'luma',
|
|
296
295
|
'example': 'luma(@color);',
|
|
297
|
-
'description':
|
|
296
|
+
'description': l10n.t('returns the `luma` value (perceptual brightness) of `@color`')
|
|
298
297
|
},
|
|
299
298
|
{
|
|
300
299
|
'name': 'saturate',
|
|
301
300
|
'example': 'saturate(@color, 10%);',
|
|
302
|
-
'description':
|
|
301
|
+
'description': l10n.t('return `@color` 10% points more saturated')
|
|
303
302
|
},
|
|
304
303
|
{
|
|
305
304
|
'name': 'desaturate',
|
|
306
305
|
'example': 'desaturate(@color, 10%);',
|
|
307
|
-
'description':
|
|
306
|
+
'description': l10n.t('return `@color` 10% points less saturated')
|
|
308
307
|
},
|
|
309
308
|
{
|
|
310
309
|
'name': 'lighten',
|
|
311
310
|
'example': 'lighten(@color, 10%);',
|
|
312
|
-
'description':
|
|
311
|
+
'description': l10n.t('return `@color` 10% points lighter')
|
|
313
312
|
},
|
|
314
313
|
{
|
|
315
314
|
'name': 'darken',
|
|
316
315
|
'example': 'darken(@color, 10%);',
|
|
317
|
-
'description':
|
|
316
|
+
'description': l10n.t('return `@color` 10% points darker')
|
|
318
317
|
},
|
|
319
318
|
{
|
|
320
319
|
'name': 'fadein',
|
|
321
320
|
'example': 'fadein(@color, 10%);',
|
|
322
|
-
'description':
|
|
321
|
+
'description': l10n.t('return `@color` 10% points less transparent')
|
|
323
322
|
},
|
|
324
323
|
{
|
|
325
324
|
'name': 'fadeout',
|
|
326
325
|
'example': 'fadeout(@color, 10%);',
|
|
327
|
-
'description':
|
|
326
|
+
'description': l10n.t('return `@color` 10% points more transparent')
|
|
328
327
|
},
|
|
329
328
|
{
|
|
330
329
|
'name': 'fade',
|
|
331
330
|
'example': 'fade(@color, 50%);',
|
|
332
|
-
'description':
|
|
331
|
+
'description': l10n.t('return `@color` with 50% transparency')
|
|
333
332
|
},
|
|
334
333
|
{
|
|
335
334
|
'name': 'spin',
|
|
336
335
|
'example': 'spin(@color, 10);',
|
|
337
|
-
'description':
|
|
336
|
+
'description': l10n.t('return `@color` with a 10 degree larger in hue')
|
|
338
337
|
},
|
|
339
338
|
{
|
|
340
339
|
'name': 'mix',
|
|
341
340
|
'example': 'mix(@color1, @color2, [@weight: 50%]);',
|
|
342
|
-
'description':
|
|
341
|
+
'description': l10n.t('return a mix of `@color1` and `@color2`')
|
|
343
342
|
},
|
|
344
343
|
{
|
|
345
344
|
'name': 'greyscale',
|
|
346
345
|
'example': 'greyscale(@color);',
|
|
347
|
-
'description':
|
|
346
|
+
'description': l10n.t('returns a grey, 100% desaturated color'),
|
|
348
347
|
},
|
|
349
348
|
{
|
|
350
349
|
'name': 'contrast',
|
|
351
350
|
'example': 'contrast(@color1, [@darkcolor: black], [@lightcolor: white], [@threshold: 43%]);',
|
|
352
|
-
'description':
|
|
351
|
+
'description': l10n.t('return `@darkcolor` if `@color1 is> 43% luma` otherwise return `@lightcolor`, see notes')
|
|
353
352
|
},
|
|
354
353
|
{
|
|
355
354
|
'name': 'multiply',
|
package/lib/umd/services/lint.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "vscode
|
|
7
|
+
define(["require", "exports", "@vscode/l10n", "../languageFacts/facts", "../parser/cssNodes", "../utils/arrays", "./lintRules", "./lintUtil"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
/*---------------------------------------------------------------------------------------------
|
|
@@ -14,13 +14,12 @@
|
|
|
14
14
|
'use strict';
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.LintVisitor = void 0;
|
|
17
|
-
const
|
|
17
|
+
const l10n = require("@vscode/l10n");
|
|
18
18
|
const languageFacts = require("../languageFacts/facts");
|
|
19
19
|
const nodes = require("../parser/cssNodes");
|
|
20
20
|
const arrays_1 = require("../utils/arrays");
|
|
21
21
|
const lintRules_1 = require("./lintRules");
|
|
22
22
|
const lintUtil_1 = require("./lintUtil");
|
|
23
|
-
const localize = nls.loadMessageBundle();
|
|
24
23
|
class NodesByRootMap {
|
|
25
24
|
constructor() {
|
|
26
25
|
this.data = {};
|
|
@@ -38,6 +37,12 @@
|
|
|
38
37
|
}
|
|
39
38
|
}
|
|
40
39
|
class LintVisitor {
|
|
40
|
+
static entries(node, document, settings, cssDataManager, entryFilter) {
|
|
41
|
+
const visitor = new LintVisitor(document, settings, cssDataManager);
|
|
42
|
+
node.acceptVisitor(visitor);
|
|
43
|
+
visitor.completeValidations();
|
|
44
|
+
return visitor.getEntries(entryFilter);
|
|
45
|
+
}
|
|
41
46
|
constructor(document, settings, cssDataManager) {
|
|
42
47
|
this.cssDataManager = cssDataManager;
|
|
43
48
|
this.warnings = [];
|
|
@@ -57,12 +62,6 @@
|
|
|
57
62
|
});
|
|
58
63
|
}
|
|
59
64
|
}
|
|
60
|
-
static entries(node, document, settings, cssDataManager, entryFilter) {
|
|
61
|
-
const visitor = new LintVisitor(document, settings, cssDataManager);
|
|
62
|
-
node.acceptVisitor(visitor);
|
|
63
|
-
visitor.completeValidations();
|
|
64
|
-
return visitor.getEntries(entryFilter);
|
|
65
|
-
}
|
|
66
65
|
isValidPropertyDeclaration(element) {
|
|
67
66
|
const propertyName = element.fullPropertyName;
|
|
68
67
|
return this.validProperties[propertyName];
|
|
@@ -120,10 +119,10 @@
|
|
|
120
119
|
const curr = expectedClone[i];
|
|
121
120
|
if (curr) {
|
|
122
121
|
if (result === null) {
|
|
123
|
-
result =
|
|
122
|
+
result = l10n.t("'{0}'", curr);
|
|
124
123
|
}
|
|
125
124
|
else {
|
|
126
|
-
result =
|
|
125
|
+
result = l10n.t("{0}, '{1}'", result, curr);
|
|
127
126
|
}
|
|
128
127
|
}
|
|
129
128
|
}
|
|
@@ -194,11 +193,11 @@
|
|
|
194
193
|
if (missingVendorSpecific || needsStandard) {
|
|
195
194
|
for (const node of this.keyframes.data[name].nodes) {
|
|
196
195
|
if (needsStandard) {
|
|
197
|
-
const message =
|
|
196
|
+
const message = l10n.t("Always define standard rule '@keyframes' when defining keyframes.");
|
|
198
197
|
this.addEntry(node, lintRules_1.Rules.IncludeStandardPropertyWhenUsingVendorPrefix, message);
|
|
199
198
|
}
|
|
200
199
|
if (missingVendorSpecific) {
|
|
201
|
-
const message =
|
|
200
|
+
const message = l10n.t("Always include all vendor specific rules: Missing: {0}", missingVendorSpecific);
|
|
202
201
|
this.addEntry(node, lintRules_1.Rules.AllVendorPrefixes, message);
|
|
203
202
|
}
|
|
204
203
|
}
|
|
@@ -297,7 +296,7 @@
|
|
|
297
296
|
const node = elem[index].node;
|
|
298
297
|
const value = node.getValue();
|
|
299
298
|
if (value && !value.matches('none')) {
|
|
300
|
-
this.addEntry(node, lintRules_1.Rules.PropertyIgnoredDueToDisplay,
|
|
299
|
+
this.addEntry(node, lintRules_1.Rules.PropertyIgnoredDueToDisplay, l10n.t("inline-block is ignored due to the float. If 'float' has a value other than 'none', the box is floated and 'display' is treated as 'block'"));
|
|
301
300
|
}
|
|
302
301
|
}
|
|
303
302
|
}
|
|
@@ -306,7 +305,7 @@
|
|
|
306
305
|
if (displayElems.length > 0) {
|
|
307
306
|
const elem = this.fetch(propertyTable, 'vertical-align');
|
|
308
307
|
for (let index = 0; index < elem.length; index++) {
|
|
309
|
-
this.addEntry(elem[index].node, lintRules_1.Rules.PropertyIgnoredDueToDisplay,
|
|
308
|
+
this.addEntry(elem[index].node, lintRules_1.Rules.PropertyIgnoredDueToDisplay, l10n.t("Property is ignored due to the display. With 'display: block', vertical-align should not be used."));
|
|
310
309
|
}
|
|
311
310
|
}
|
|
312
311
|
/////////////////////////////////////////////////////////////
|
|
@@ -369,7 +368,7 @@
|
|
|
369
368
|
// _property and *property might be contributed via custom data
|
|
370
369
|
if (!this.cssDataManager.isKnownProperty(fullName) && !this.cssDataManager.isKnownProperty(name)) {
|
|
371
370
|
if (!this.validProperties[name]) {
|
|
372
|
-
this.addEntry(decl.getProperty(), lintRules_1.Rules.UnknownProperty,
|
|
371
|
+
this.addEntry(decl.getProperty(), lintRules_1.Rules.UnknownProperty, l10n.t("Unknown property: '{0}'", decl.getFullPropertyName()));
|
|
373
372
|
}
|
|
374
373
|
}
|
|
375
374
|
propertiesBySuffix.add(name, name, null); // don't pass the node as we don't show errors on the standard
|
|
@@ -387,6 +386,23 @@
|
|
|
387
386
|
if (!needsStandard && actual.length === 1) {
|
|
388
387
|
continue; // only the non-vendor specific rule is used, that's fine, no warning
|
|
389
388
|
}
|
|
389
|
+
/**
|
|
390
|
+
* We should ignore missing standard properties, if there's an explicit contextual reference to a
|
|
391
|
+
* vendor specific pseudo-element selector with the same vendor (prefix)
|
|
392
|
+
*
|
|
393
|
+
* (See https://github.com/microsoft/vscode/issues/164350)
|
|
394
|
+
*/
|
|
395
|
+
const entriesThatNeedStandard = new Set(needsStandard ? entry.nodes : []);
|
|
396
|
+
if (needsStandard) {
|
|
397
|
+
const pseudoElements = this.getContextualVendorSpecificPseudoElements(node);
|
|
398
|
+
for (const node of entry.nodes) {
|
|
399
|
+
const propertyName = node.getName();
|
|
400
|
+
const prefix = propertyName.substring(0, propertyName.length - suffix.length);
|
|
401
|
+
if (pseudoElements.some(x => x.startsWith(prefix))) {
|
|
402
|
+
entriesThatNeedStandard.delete(node);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}
|
|
390
406
|
const expected = [];
|
|
391
407
|
for (let i = 0, len = LintVisitor.prefixes.length; i < len; i++) {
|
|
392
408
|
const prefix = LintVisitor.prefixes[i];
|
|
@@ -397,12 +413,12 @@
|
|
|
397
413
|
const missingVendorSpecific = this.getMissingNames(expected, actual);
|
|
398
414
|
if (missingVendorSpecific || needsStandard) {
|
|
399
415
|
for (const node of entry.nodes) {
|
|
400
|
-
if (needsStandard) {
|
|
401
|
-
const message =
|
|
416
|
+
if (needsStandard && entriesThatNeedStandard.has(node)) {
|
|
417
|
+
const message = l10n.t("Also define the standard property '{0}' for compatibility", suffix);
|
|
402
418
|
this.addEntry(node, lintRules_1.Rules.IncludeStandardPropertyWhenUsingVendorPrefix, message);
|
|
403
419
|
}
|
|
404
420
|
if (missingVendorSpecific) {
|
|
405
|
-
const message =
|
|
421
|
+
const message = l10n.t("Always include all vendor specific properties: Missing: {0}", missingVendorSpecific);
|
|
406
422
|
this.addEntry(node, lintRules_1.Rules.AllVendorPrefixes, message);
|
|
407
423
|
}
|
|
408
424
|
}
|
|
@@ -412,6 +428,36 @@
|
|
|
412
428
|
}
|
|
413
429
|
return true;
|
|
414
430
|
}
|
|
431
|
+
/**
|
|
432
|
+
* Walks up the syntax tree (starting from given `node`) and captures vendor
|
|
433
|
+
* specific pseudo-element selectors.
|
|
434
|
+
* @returns An array of vendor specific pseudo-elements; or empty if none
|
|
435
|
+
* was found.
|
|
436
|
+
*/
|
|
437
|
+
getContextualVendorSpecificPseudoElements(node) {
|
|
438
|
+
function walkDown(s, n) {
|
|
439
|
+
for (const child of n.getChildren()) {
|
|
440
|
+
if (child.type === nodes.NodeType.PseudoSelector) {
|
|
441
|
+
const pseudoElement = child.getChildren()[0]?.getText();
|
|
442
|
+
if (pseudoElement) {
|
|
443
|
+
s.add(pseudoElement);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
walkDown(s, child);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
function walkUp(s, n) {
|
|
450
|
+
if (n.type === nodes.NodeType.Ruleset) {
|
|
451
|
+
for (const selector of n.getSelectors().getChildren()) {
|
|
452
|
+
walkDown(s, selector);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
return n.parent ? walkUp(s, n.parent) : undefined;
|
|
456
|
+
}
|
|
457
|
+
const result = new Set();
|
|
458
|
+
walkUp(result, node);
|
|
459
|
+
return Array.from(result);
|
|
460
|
+
}
|
|
415
461
|
visitPrio(node) {
|
|
416
462
|
/////////////////////////////////////////////////////////////
|
|
417
463
|
// Don't use !important
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "../parser/cssNodes", "vscode
|
|
7
|
+
define(["require", "exports", "../parser/cssNodes", "@vscode/l10n"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
/*---------------------------------------------------------------------------------------------
|
|
@@ -15,8 +15,7 @@
|
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.LintConfigurationSettings = exports.Settings = exports.Rules = exports.Setting = exports.Rule = void 0;
|
|
17
17
|
const nodes = require("../parser/cssNodes");
|
|
18
|
-
const
|
|
19
|
-
const localize = nls.loadMessageBundle();
|
|
18
|
+
const l10n = require("@vscode/l10n");
|
|
20
19
|
const Warning = nodes.Level.Warning;
|
|
21
20
|
const Error = nodes.Level.Error;
|
|
22
21
|
const Ignore = nodes.Level.Ignore;
|
|
@@ -39,28 +38,28 @@
|
|
|
39
38
|
}
|
|
40
39
|
exports.Setting = Setting;
|
|
41
40
|
exports.Rules = {
|
|
42
|
-
AllVendorPrefixes: new Rule('compatibleVendorPrefixes',
|
|
43
|
-
IncludeStandardPropertyWhenUsingVendorPrefix: new Rule('vendorPrefix',
|
|
44
|
-
DuplicateDeclarations: new Rule('duplicateProperties',
|
|
45
|
-
EmptyRuleSet: new Rule('emptyRules',
|
|
46
|
-
ImportStatemement: new Rule('importStatement',
|
|
47
|
-
BewareOfBoxModelSize: new Rule('boxModel',
|
|
48
|
-
UniversalSelector: new Rule('universalSelector',
|
|
49
|
-
ZeroWithUnit: new Rule('zeroUnits',
|
|
50
|
-
RequiredPropertiesForFontFace: new Rule('fontFaceProperties',
|
|
51
|
-
HexColorLength: new Rule('hexColorLength',
|
|
52
|
-
ArgsInColorFunction: new Rule('argumentsInColorFunction',
|
|
53
|
-
UnknownProperty: new Rule('unknownProperties',
|
|
54
|
-
UnknownAtRules: new Rule('unknownAtRules',
|
|
55
|
-
IEStarHack: new Rule('ieHack',
|
|
56
|
-
UnknownVendorSpecificProperty: new Rule('unknownVendorSpecificProperties',
|
|
57
|
-
PropertyIgnoredDueToDisplay: new Rule('propertyIgnoredDueToDisplay',
|
|
58
|
-
AvoidImportant: new Rule('important',
|
|
59
|
-
AvoidFloat: new Rule('float',
|
|
60
|
-
AvoidIdSelector: new Rule('idSelector',
|
|
41
|
+
AllVendorPrefixes: new Rule('compatibleVendorPrefixes', l10n.t("When using a vendor-specific prefix make sure to also include all other vendor-specific properties"), Ignore),
|
|
42
|
+
IncludeStandardPropertyWhenUsingVendorPrefix: new Rule('vendorPrefix', l10n.t("When using a vendor-specific prefix also include the standard property"), Warning),
|
|
43
|
+
DuplicateDeclarations: new Rule('duplicateProperties', l10n.t("Do not use duplicate style definitions"), Ignore),
|
|
44
|
+
EmptyRuleSet: new Rule('emptyRules', l10n.t("Do not use empty rulesets"), Warning),
|
|
45
|
+
ImportStatemement: new Rule('importStatement', l10n.t("Import statements do not load in parallel"), Ignore),
|
|
46
|
+
BewareOfBoxModelSize: new Rule('boxModel', l10n.t("Do not use width or height when using padding or border"), Ignore),
|
|
47
|
+
UniversalSelector: new Rule('universalSelector', l10n.t("The universal selector (*) is known to be slow"), Ignore),
|
|
48
|
+
ZeroWithUnit: new Rule('zeroUnits', l10n.t("No unit for zero needed"), Ignore),
|
|
49
|
+
RequiredPropertiesForFontFace: new Rule('fontFaceProperties', l10n.t("@font-face rule must define 'src' and 'font-family' properties"), Warning),
|
|
50
|
+
HexColorLength: new Rule('hexColorLength', l10n.t("Hex colors must consist of three, four, six or eight hex numbers"), Error),
|
|
51
|
+
ArgsInColorFunction: new Rule('argumentsInColorFunction', l10n.t("Invalid number of parameters"), Error),
|
|
52
|
+
UnknownProperty: new Rule('unknownProperties', l10n.t("Unknown property."), Warning),
|
|
53
|
+
UnknownAtRules: new Rule('unknownAtRules', l10n.t("Unknown at-rule."), Warning),
|
|
54
|
+
IEStarHack: new Rule('ieHack', l10n.t("IE hacks are only necessary when supporting IE7 and older"), Ignore),
|
|
55
|
+
UnknownVendorSpecificProperty: new Rule('unknownVendorSpecificProperties', l10n.t("Unknown vendor specific property."), Ignore),
|
|
56
|
+
PropertyIgnoredDueToDisplay: new Rule('propertyIgnoredDueToDisplay', l10n.t("Property is ignored due to the display."), Warning),
|
|
57
|
+
AvoidImportant: new Rule('important', l10n.t("Avoid using !important. It is an indication that the specificity of the entire CSS has gotten out of control and needs to be refactored."), Ignore),
|
|
58
|
+
AvoidFloat: new Rule('float', l10n.t("Avoid using 'float'. Floats lead to fragile CSS that is easy to break if one aspect of the layout changes."), Ignore),
|
|
59
|
+
AvoidIdSelector: new Rule('idSelector', l10n.t("Selectors should not contain IDs because these rules are too tightly coupled with the HTML."), Ignore),
|
|
61
60
|
};
|
|
62
61
|
exports.Settings = {
|
|
63
|
-
ValidProperties: new Setting('validProperties',
|
|
62
|
+
ValidProperties: new Setting('validProperties', l10n.t("A list of properties that are not validated against the `unknownProperties` rule."), [])
|
|
64
63
|
};
|
|
65
64
|
class LintConfigurationSettings {
|
|
66
65
|
constructor(conf = {}) {
|