Skip to content

Commit daf6052

Browse files
authored
lint - report layer issues in CSS (microsoft#269671)
1 parent b9e0612 commit daf6052

5 files changed

Lines changed: 41 additions & 14 deletions

File tree

build/hygiene.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ const copyrightHeaderLines = [
2323

2424
/**
2525
* @param {string[] | NodeJS.ReadWriteStream} some
26-
* @param {boolean} linting
26+
* @param {boolean} runEslint
2727
*/
28-
function hygiene(some, linting = true) {
28+
function hygiene(some, runEslint = true) {
2929
const eslint = require('./gulp-eslint');
3030
const gulpstylelint = require('./stylelint');
3131
const formatter = require('./lib/formatter');
@@ -156,7 +156,7 @@ function hygiene(some, linting = true) {
156156
const unicodeFilterStream = filter(unicodeFilter, { restore: true });
157157

158158
const result = input
159-
.pipe(filter((f) => !f.stat.isDirectory()))
159+
.pipe(filter((f) => Boolean(f.stat && !f.stat.isDirectory())))
160160
.pipe(snapshotFilter)
161161
.pipe(yarnLockFilter)
162162
.pipe(productJsonFilter)
@@ -175,7 +175,7 @@ function hygiene(some, linting = true) {
175175
result.pipe(filter(tsFormattingFilter)).pipe(formatting)
176176
];
177177

178-
if (linting) {
178+
if (runEslint) {
179179
streams.push(
180180
result
181181
.pipe(filter(eslintFilter))
@@ -186,18 +186,19 @@ function hygiene(some, linting = true) {
186186
})
187187
)
188188
);
189-
streams.push(
190-
result.pipe(filter(stylelintFilter)).pipe(gulpstylelint(((message, isError) => {
191-
if (isError) {
192-
console.error(message);
193-
errorCount++;
194-
} else {
195-
console.warn(message);
196-
}
197-
})))
198-
);
199189
}
200190

191+
streams.push(
192+
result.pipe(filter(stylelintFilter)).pipe(gulpstylelint(((message, isError) => {
193+
if (isError) {
194+
console.error(message);
195+
errorCount++;
196+
} else {
197+
console.warn(message);
198+
}
199+
})))
200+
);
201+
201202
let count = 0;
202203
return es.merge(...streams).pipe(
203204
es.through(

build/lib/stylelint/vscode-known-variables.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@
5454
"--vscode-chat-avatarForeground",
5555
"--vscode-chat-checkpointSeparator",
5656
"--vscode-chat-editedFileForeground",
57+
"--vscode-chat-font-family",
58+
"--vscode-chat-font-size-body-l",
59+
"--vscode-chat-font-size-body-m",
60+
"--vscode-chat-font-size-body-s",
61+
"--vscode-chat-font-size-body-xl",
62+
"--vscode-chat-font-size-body-xs",
63+
"--vscode-chat-font-size-body-xxl",
5764
"--vscode-chat-linesAddedForeground",
5865
"--vscode-chat-linesRemovedForeground",
5966
"--vscode-chat-requestBackground",
@@ -376,6 +383,7 @@
376383
"--vscode-inlineChat-background",
377384
"--vscode-inlineChat-border",
378385
"--vscode-inlineChat-foreground",
386+
"--vscode-inlineChat-regionHighlight",
379387
"--vscode-inlineChat-shadow",
380388
"--vscode-inlineChatDiff-inserted",
381389
"--vscode-inlineChatDiff-removed",

build/stylelint.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,30 @@ module.exports = gulpstylelint;
1919
function gulpstylelint(reporter) {
2020
const variableValidator = getVariableNameValidator();
2121
let errorCount = 0;
22+
const monacoWorkbenchPattern = /\.monaco-workbench/;
23+
const restrictedPathPattern = /^src[\/\\]vs[\/\\](base|platform|editor)[\/\\]/;
24+
const layerCheckerDisablePattern = /\/\*\s*stylelint-disable\s+layer-checker\s*\*\//;
25+
2226
return es.through(function (file) {
2327
/** @type {string[]} */
2428
const lines = file.__lines || file.contents.toString('utf8').split(/\r\n|\r|\n/);
2529
file.__lines = lines;
2630

31+
const isRestrictedPath = restrictedPathPattern.test(file.relative);
32+
33+
// Check if layer-checker is disabled for the entire file
34+
const isLayerCheckerDisabled = lines.some(line => layerCheckerDisablePattern.test(line));
35+
2736
lines.forEach((line, i) => {
2837
variableValidator(line, unknownVariable => {
2938
reporter(file.relative + '(' + (i + 1) + ',1): Unknown variable: ' + unknownVariable, true);
3039
errorCount++;
3140
});
41+
42+
if (isRestrictedPath && !isLayerCheckerDisabled && monacoWorkbenchPattern.test(line)) {
43+
reporter(file.relative + '(' + (i + 1) + ',1): The class .monaco-workbench cannot be used in files under src/vs/{base,platform,editor} because only src/vs/workbench applies it', true);
44+
errorCount++;
45+
}
3246
});
3347

3448
this.emit('data', file);

src/vs/editor/browser/services/hoverService/hover.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6+
/* stylelint-disable layer-checker */
7+
68
.monaco-workbench .workbench-hover {
79
position: relative;
810
font-size: 13px;

src/vs/editor/contrib/symbolIcons/browser/symbolIcons.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6+
/* stylelint-disable layer-checker */
7+
68
.monaco-editor .codicon.codicon-symbol-array,
79
.monaco-workbench .codicon.codicon-symbol-array { color: var(--vscode-symbolIcon-arrayForeground); }
810
.monaco-editor .codicon.codicon-symbol-boolean,

0 commit comments

Comments
 (0)