Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
bd1042c1
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bd1042c1
编写于
1月 06, 2020
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
lint - use single quotes
上级
68474b90
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
83 addition
and
83 deletion
+83
-83
build/lib/globalsLinter.js
build/lib/globalsLinter.js
+40
-40
build/lib/globalsLinter.ts
build/lib/globalsLinter.ts
+43
-43
未找到文件。
build/lib/globalsLinter.js
浏览文件 @
bd1042c1
...
...
@@ -21,69 +21,69 @@ const minimatch_1 = require("minimatch");
// #############################################################################################
//
const
RULES
=
{
"
no-nodejs-globals
"
:
[
'
no-nodejs-globals
'
:
[
{
"
target
"
:
"
**/vs/**/test/{common,browser}/**
"
,
"
allowed
"
:
[
"
process
"
,
"
Buffer
"
,
"
__filename
"
,
"
__dirname
"
'
target
'
:
'
**/vs/**/test/{common,browser}/**
'
,
'
allowed
'
:
[
'
process
'
,
'
Buffer
'
,
'
__filename
'
,
'
__dirname
'
]
},
{
"
target
"
:
"
**/vs/workbench/api/common/extHostExtensionService.ts
"
,
"
allowed
"
:
[
"
global
"
// -> safe access to 'global'
'
target
'
:
'
**/vs/workbench/api/common/extHostExtensionService.ts
'
,
'
allowed
'
:
[
'
global
'
// -> safe access to 'global'
]
},
{
"
target
"
:
"
**/vs/**/{common,browser}/**
"
,
"
allowed
"
:
[
/* none */
]
'
target
'
:
'
**/vs/**/{common,browser}/**
'
,
'
allowed
'
:
[
/* none */
]
}
],
"
no-dom-globals
"
:
[
'
no-dom-globals
'
:
[
{
"
target
"
:
"
**/vs/base/parts/quickopen/common/quickOpen.ts
"
,
"
allowed
"
:
[
"
HTMLElement
"
// quick open will be replaced with a different widget soon
'
target
'
:
'
**/vs/base/parts/quickopen/common/quickOpen.ts
'
,
'
allowed
'
:
[
'
HTMLElement
'
// quick open will be replaced with a different widget soon
]
},
{
"
target
"
:
"
**/vs/**/test/{common,node,electron-main}/**
"
,
"
allowed
"
:
[
"
document
"
,
"
HTMLElement
"
,
"
createElement
"
'
target
'
:
'
**/vs/**/test/{common,node,electron-main}/**
'
,
'
allowed
'
:
[
'
document
'
,
'
HTMLElement
'
,
'
createElement
'
]
},
{
"
target
"
:
"
**/vs/**/{common,node,electron-main}/**
"
,
"
allowed
"
:
[
/* none */
]
'
target
'
:
'
**/vs/**/{common,node,electron-main}/**
'
,
'
allowed
'
:
[
/* none */
]
}
]
};
const
TS_CONFIG_PATH
=
path_1
.
join
(
__dirname
,
'
../../
'
,
'
src
'
,
'
tsconfig.json
'
);
const
DOM_GLOBALS_DEFINITION
=
'
lib.dom.d.ts
'
;
const
DISALLOWED_DOM_GLOBALS
=
[
"
window
"
,
"
document
"
,
"
HTMLElement
"
,
"
createElement
"
'
window
'
,
'
document
'
,
'
HTMLElement
'
,
'
createElement
'
];
const
NODE_GLOBALS_DEFINITION
=
'
@types/node
'
;
const
DISALLOWED_NODE_GLOBALS
=
[
// https://nodejs.org/api/globals.html#globals_global_objects
"
NodeJS
"
,
"
Buffer
"
,
"
__dirname
"
,
"
__filename
"
,
"
clearImmediate
"
,
"
exports
"
,
"
global
"
,
"
module
"
,
"
process
"
,
"
setImmediate
"
'
NodeJS
'
,
'
Buffer
'
,
'
__dirname
'
,
'
__filename
'
,
'
clearImmediate
'
,
'
exports
'
,
'
global
'
,
'
module
'
,
'
process
'
,
'
setImmediate
'
];
let
hasErrors
=
false
;
function
checkFile
(
program
,
sourceFile
,
rule
)
{
...
...
@@ -127,7 +127,7 @@ function checkFile(program, sourceFile, rule) {
}
function
createProgram
(
tsconfigPath
)
{
const
tsConfig
=
ts
.
readConfigFile
(
tsconfigPath
,
ts
.
sys
.
readFile
);
const
configHostParser
=
{
fileExists
:
fs_1
.
existsSync
,
readDirectory
:
ts
.
sys
.
readDirectory
,
readFile
:
file
=>
fs_1
.
readFileSync
(
file
,
"
utf8
"
),
useCaseSensitiveFileNames
:
process
.
platform
===
'
linux
'
};
const
configHostParser
=
{
fileExists
:
fs_1
.
existsSync
,
readDirectory
:
ts
.
sys
.
readDirectory
,
readFile
:
file
=>
fs_1
.
readFileSync
(
file
,
'
utf8
'
),
useCaseSensitiveFileNames
:
process
.
platform
===
'
linux
'
};
const
tsConfigParsed
=
ts
.
parseJsonConfigFileContent
(
tsConfig
.
config
,
configHostParser
,
path_1
.
resolve
(
path_1
.
dirname
(
tsconfigPath
)),
{
noEmit
:
true
});
const
compilerHost
=
ts
.
createCompilerHost
(
tsConfigParsed
.
options
,
true
);
return
ts
.
createProgram
(
tsConfigParsed
.
fileNames
,
tsConfigParsed
.
options
,
compilerHost
);
...
...
@@ -139,13 +139,13 @@ const program = createProgram(TS_CONFIG_PATH);
for
(
const
sourceFile
of
program
.
getSourceFiles
())
{
let
noDomGlobalsLinter
=
undefined
;
let
noNodeJSGlobalsLinter
=
undefined
;
for
(
const
rules
of
RULES
[
"
no-dom-globals
"
])
{
for
(
const
rules
of
RULES
[
'
no-dom-globals
'
])
{
if
(
minimatch_1
.
match
([
sourceFile
.
fileName
],
rules
.
target
).
length
>
0
)
{
noDomGlobalsLinter
=
{
allowed
:
rules
.
allowed
};
break
;
}
}
for
(
const
rules
of
RULES
[
"
no-nodejs-globals
"
])
{
for
(
const
rules
of
RULES
[
'
no-nodejs-globals
'
])
{
if
(
minimatch_1
.
match
([
sourceFile
.
fileName
],
rules
.
target
).
length
>
0
)
{
noNodeJSGlobalsLinter
=
{
allowed
:
rules
.
allowed
};
break
;
...
...
build/lib/globalsLinter.ts
浏览文件 @
bd1042c1
...
...
@@ -3,9 +3,9 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
*
as
ts
from
"
typescript
"
;
import
{
readFileSync
,
existsSync
}
from
"
fs
"
;
import
{
resolve
,
dirname
,
join
}
from
"
path
"
;
import
*
as
ts
from
'
typescript
'
;
import
{
readFileSync
,
existsSync
}
from
'
fs
'
;
import
{
resolve
,
dirname
,
join
}
from
'
path
'
;
import
{
match
}
from
'
minimatch
'
;
//
...
...
@@ -22,45 +22,45 @@ import { match } from 'minimatch';
//
const
RULES
=
{
"
no-nodejs-globals
"
:
[
'
no-nodejs-globals
'
:
[
{
"
target
"
:
"
**/vs/**/test/{common,browser}/**
"
,
"
allowed
"
:
[
// -> less strict for test files
"
process
"
,
"
Buffer
"
,
"
__filename
"
,
"
__dirname
"
'
target
'
:
'
**/vs/**/test/{common,browser}/**
'
,
'
allowed
'
:
[
// -> less strict for test files
'
process
'
,
'
Buffer
'
,
'
__filename
'
,
'
__dirname
'
]
},
{
"
target
"
:
"
**/vs/workbench/api/common/extHostExtensionService.ts
"
,
"
allowed
"
:
[
"
global
"
// -> safe access to 'global'
'
target
'
:
'
**/vs/workbench/api/common/extHostExtensionService.ts
'
,
'
allowed
'
:
[
'
global
'
// -> safe access to 'global'
]
},
{
"
target
"
:
"
**/vs/**/{common,browser}/**
"
,
"
allowed
"
:
[
/* none */
]
'
target
'
:
'
**/vs/**/{common,browser}/**
'
,
'
allowed
'
:
[
/* none */
]
}
],
"
no-dom-globals
"
:
[
'
no-dom-globals
'
:
[
{
"
target
"
:
"
**/vs/base/parts/quickopen/common/quickOpen.ts
"
,
"
allowed
"
:
[
"
HTMLElement
"
// quick open will be replaced with a different widget soon
'
target
'
:
'
**/vs/base/parts/quickopen/common/quickOpen.ts
'
,
'
allowed
'
:
[
'
HTMLElement
'
// quick open will be replaced with a different widget soon
]
},
{
"
target
"
:
"
**/vs/**/test/{common,node,electron-main}/**
"
,
"
allowed
"
:
[
// -> less strict for test files
"
document
"
,
"
HTMLElement
"
,
"
createElement
"
'
target
'
:
'
**/vs/**/test/{common,node,electron-main}/**
'
,
'
allowed
'
:
[
// -> less strict for test files
'
document
'
,
'
HTMLElement
'
,
'
createElement
'
]
},
{
"
target
"
:
"
**/vs/**/{common,node,electron-main}/**
"
,
"
allowed
"
:
[
/* none */
]
'
target
'
:
'
**/vs/**/{common,node,electron-main}/**
'
,
'
allowed
'
:
[
/* none */
]
}
]
};
...
...
@@ -70,26 +70,26 @@ const TS_CONFIG_PATH = join(__dirname, '../../', 'src', 'tsconfig.json');
const
DOM_GLOBALS_DEFINITION
=
'
lib.dom.d.ts
'
;
const
DISALLOWED_DOM_GLOBALS
=
[
"
window
"
,
"
document
"
,
"
HTMLElement
"
,
"
createElement
"
'
window
'
,
'
document
'
,
'
HTMLElement
'
,
'
createElement
'
];
const
NODE_GLOBALS_DEFINITION
=
'
@types/node
'
;
const
DISALLOWED_NODE_GLOBALS
=
[
// https://nodejs.org/api/globals.html#globals_global_objects
"
NodeJS
"
,
"
Buffer
"
,
"
__dirname
"
,
"
__filename
"
,
"
clearImmediate
"
,
"
exports
"
,
"
global
"
,
"
module
"
,
"
process
"
,
"
setImmediate
"
'
NodeJS
'
,
'
Buffer
'
,
'
__dirname
'
,
'
__filename
'
,
'
clearImmediate
'
,
'
exports
'
,
'
global
'
,
'
module
'
,
'
process
'
,
'
setImmediate
'
];
interface
IRule
{
...
...
@@ -150,7 +150,7 @@ function checkFile(program: ts.Program, sourceFile: ts.SourceFile, rule: IRule)
function
createProgram
(
tsconfigPath
:
string
):
ts
.
Program
{
const
tsConfig
=
ts
.
readConfigFile
(
tsconfigPath
,
ts
.
sys
.
readFile
);
const
configHostParser
:
ts
.
ParseConfigHost
=
{
fileExists
:
existsSync
,
readDirectory
:
ts
.
sys
.
readDirectory
,
readFile
:
file
=>
readFileSync
(
file
,
"
utf8
"
),
useCaseSensitiveFileNames
:
process
.
platform
===
'
linux
'
};
const
configHostParser
:
ts
.
ParseConfigHost
=
{
fileExists
:
existsSync
,
readDirectory
:
ts
.
sys
.
readDirectory
,
readFile
:
file
=>
readFileSync
(
file
,
'
utf8
'
),
useCaseSensitiveFileNames
:
process
.
platform
===
'
linux
'
};
const
tsConfigParsed
=
ts
.
parseJsonConfigFileContent
(
tsConfig
.
config
,
configHostParser
,
resolve
(
dirname
(
tsconfigPath
)),
{
noEmit
:
true
});
const
compilerHost
=
ts
.
createCompilerHost
(
tsConfigParsed
.
options
,
true
);
...
...
@@ -167,14 +167,14 @@ for (const sourceFile of program.getSourceFiles()) {
let
noDomGlobalsLinter
:
{
allowed
:
string
[]
}
|
undefined
=
undefined
;
let
noNodeJSGlobalsLinter
:
{
allowed
:
string
[]
}
|
undefined
=
undefined
;
for
(
const
rules
of
RULES
[
"
no-dom-globals
"
])
{
for
(
const
rules
of
RULES
[
'
no-dom-globals
'
])
{
if
(
match
([
sourceFile
.
fileName
],
rules
.
target
).
length
>
0
)
{
noDomGlobalsLinter
=
{
allowed
:
rules
.
allowed
};
break
;
}
}
for
(
const
rules
of
RULES
[
"
no-nodejs-globals
"
])
{
for
(
const
rules
of
RULES
[
'
no-nodejs-globals
'
])
{
if
(
match
([
sourceFile
.
fileName
],
rules
.
target
).
length
>
0
)
{
noNodeJSGlobalsLinter
=
{
allowed
:
rules
.
allowed
};
break
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录