Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
fe219220
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,发现更多精彩内容 >>
提交
fe219220
编写于
11月 10, 2016
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add rule for bad node_module imports, #15293
上级
7f7c5703
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
115 addition
and
1 deletion
+115
-1
build/lib/tslint/importPatternsRule.js
build/lib/tslint/importPatternsRule.js
+50
-0
build/lib/tslint/importPatternsRule.ts
build/lib/tslint/importPatternsRule.ts
+53
-0
src/vs/workbench/parts/debug/electron-browser/repl.ts
src/vs/workbench/parts/debug/electron-browser/repl.ts
+1
-1
tslint.json
tslint.json
+11
-0
未找到文件。
build/lib/tslint/importPatternsRule.js
0 → 100644
浏览文件 @
fe219220
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
"
use strict
"
;
var
__extends
=
(
this
&&
this
.
__extends
)
||
function
(
d
,
b
)
{
for
(
var
p
in
b
)
if
(
b
.
hasOwnProperty
(
p
))
d
[
p
]
=
b
[
p
];
function
__
()
{
this
.
constructor
=
d
;
}
d
.
prototype
=
b
===
null
?
Object
.
create
(
b
)
:
(
__
.
prototype
=
b
.
prototype
,
new
__
());
};
var
Lint
=
require
(
'
tslint/lib/lint
'
);
var
minimatch
=
require
(
'
minimatch
'
);
var
Rule
=
(
function
(
_super
)
{
__extends
(
Rule
,
_super
);
function
Rule
()
{
_super
.
apply
(
this
,
arguments
);
}
Rule
.
prototype
.
apply
=
function
(
sourceFile
)
{
var
configs
=
this
.
getOptions
().
ruleArguments
;
for
(
var
_i
=
0
,
configs_1
=
configs
;
_i
<
configs_1
.
length
;
_i
++
)
{
var
config
=
configs_1
[
_i
];
if
(
minimatch
(
sourceFile
.
fileName
,
config
.
target
))
{
return
this
.
applyWithWalker
(
new
ImportPatterns
(
sourceFile
,
this
.
getOptions
(),
config
));
}
}
return
[];
};
return
Rule
;
}(
Lint
.
Rules
.
AbstractRule
));
exports
.
Rule
=
Rule
;
var
ImportPatterns
=
(
function
(
_super
)
{
__extends
(
ImportPatterns
,
_super
);
function
ImportPatterns
(
file
,
opts
,
_config
)
{
_super
.
call
(
this
,
file
,
opts
);
this
.
_config
=
_config
;
}
ImportPatterns
.
prototype
.
visitImportDeclaration
=
function
(
node
)
{
var
path
=
node
.
moduleSpecifier
.
getText
();
// remove quotes
path
=
path
.
slice
(
1
,
-
1
);
// ignore relative paths
if
(
path
[
0
]
===
'
.
'
)
{
return
;
}
if
(
!
minimatch
(
path
,
this
.
_config
.
restrictions
))
{
this
.
addFailure
(
this
.
createFailure
(
node
.
getStart
(),
node
.
getWidth
(),
"
Imports violates '
"
+
this
.
_config
.
restrictions
+
"
'-restriction.
"
));
}
};
return
ImportPatterns
;
}(
Lint
.
RuleWalker
));
build/lib/tslint/importPatternsRule.ts
0 → 100644
浏览文件 @
fe219220
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
*
as
ts
from
'
typescript
'
;
import
*
as
Lint
from
'
tslint/lib/lint
'
;
import
*
as
minimatch
from
'
minimatch
'
;
interface
ImportPatternsConfig
{
target
:
string
;
restrictions
:
string
;
}
export
class
Rule
extends
Lint
.
Rules
.
AbstractRule
{
public
apply
(
sourceFile
:
ts
.
SourceFile
):
Lint
.
RuleFailure
[]
{
const
configs
=
<
ImportPatternsConfig
[]
>
this
.
getOptions
().
ruleArguments
;
for
(
const
config
of
configs
)
{
if
(
minimatch
(
sourceFile
.
fileName
,
config
.
target
))
{
return
this
.
applyWithWalker
(
new
ImportPatterns
(
sourceFile
,
this
.
getOptions
(),
config
));
}
}
return
[];
}
}
class
ImportPatterns
extends
Lint
.
RuleWalker
{
constructor
(
file
:
ts
.
SourceFile
,
opts
:
Lint
.
IOptions
,
private
_config
:
ImportPatternsConfig
)
{
super
(
file
,
opts
);
}
protected
visitImportDeclaration
(
node
:
ts
.
ImportDeclaration
):
void
{
let
path
=
node
.
moduleSpecifier
.
getText
();
// remove quotes
path
=
path
.
slice
(
1
,
-
1
);
// ignore relative paths
if
(
path
[
0
]
===
'
.
'
)
{
return
;
}
if
(
!
minimatch
(
path
,
this
.
_config
.
restrictions
))
{
this
.
addFailure
(
this
.
createFailure
(
node
.
getStart
(),
node
.
getWidth
(),
`Imports violates '
${
this
.
_config
.
restrictions
}
'-restriction.`
));
}
}
}
src/vs/workbench/parts/debug/electron-browser/repl.ts
浏览文件 @
fe219220
...
...
@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
'
vs/css!
./..
/browser/media/repl
'
;
import
'
vs/css!
vs/workbench/parts/debug
/browser/media/repl
'
;
import
*
as
nls
from
'
vs/nls
'
;
import
uri
from
'
vs/base/common/uri
'
;
import
{
wireCancellationToken
}
from
'
vs/base/common/async
'
;
...
...
tslint.json
浏览文件 @
fe219220
...
...
@@ -46,6 +46,17 @@
"node"
]
}
],
"import-patterns"
:
[
false
,
{
"target"
:
"**/{node,electron-browser,electron-main}/**"
,
"restrictions"
:
"**/*"
},
{
"target"
:
"**/{common,browser,workbench}/**"
,
"restrictions"
:
"{**/vs/**,assert}"
}
]
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录