Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
6a07f2d9
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6a07f2d9
编写于
11月 11, 2016
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add tslint duplicateImportsRule
上级
89f24181
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
387 addition
and
299 deletion
+387
-299
build/lib/tslint/duplicateImportsRule.js
build/lib/tslint/duplicateImportsRule.js
+43
-0
build/lib/tslint/duplicateImportsRule.ts
build/lib/tslint/duplicateImportsRule.ts
+40
-0
build/lib/tslint/importPatternsRule.js
build/lib/tslint/importPatternsRule.js
+50
-50
build/lib/tslint/layeringRule.js
build/lib/tslint/layeringRule.js
+78
-76
build/lib/tslint/layeringRule.ts
build/lib/tslint/layeringRule.ts
+4
-1
build/lib/tslint/noUnexternalizedStringsRule.js
build/lib/tslint/noUnexternalizedStringsRule.js
+168
-168
build/lib/util.js
build/lib/util.js
+4
-4
未找到文件。
build/lib/tslint/duplicateImportsRule.js
0 → 100644
浏览文件 @
6a07f2d9
/*---------------------------------------------------------------------------------------------
* 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
path_1
=
require
(
'
path
'
);
var
Lint
=
require
(
'
tslint/lib/lint
'
);
var
Rule
=
(
function
(
_super
)
{
__extends
(
Rule
,
_super
);
function
Rule
()
{
_super
.
apply
(
this
,
arguments
);
}
Rule
.
prototype
.
apply
=
function
(
sourceFile
)
{
return
this
.
applyWithWalker
(
new
ImportPatterns
(
sourceFile
,
this
.
getOptions
()));
};
return
Rule
;
}(
Lint
.
Rules
.
AbstractRule
));
exports
.
Rule
=
Rule
;
var
ImportPatterns
=
(
function
(
_super
)
{
__extends
(
ImportPatterns
,
_super
);
function
ImportPatterns
(
file
,
opts
)
{
_super
.
call
(
this
,
file
,
opts
);
this
.
imports
=
Object
.
create
(
null
);
}
ImportPatterns
.
prototype
.
visitImportDeclaration
=
function
(
node
)
{
var
path
=
node
.
moduleSpecifier
.
getText
();
// remove quotes
path
=
path
.
slice
(
1
,
-
1
);
if
(
path
[
0
]
===
'
.
'
)
{
path
=
path_1
.
join
(
path_1
.
dirname
(
node
.
getSourceFile
().
fileName
),
path
);
}
if
(
this
.
imports
[
path
])
{
this
.
addFailure
(
this
.
createFailure
(
node
.
getStart
(),
node
.
getWidth
(),
"
Duplicate imports for '
"
+
path
+
"
'.
"
));
}
this
.
imports
[
path
]
=
true
;
};
return
ImportPatterns
;
}(
Lint
.
RuleWalker
));
build/lib/tslint/duplicateImportsRule.ts
0 → 100644
浏览文件 @
6a07f2d9
/*---------------------------------------------------------------------------------------------
* 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
{
join
,
dirname
}
from
'
path
'
;
import
*
as
Lint
from
'
tslint/lib/lint
'
;
export
class
Rule
extends
Lint
.
Rules
.
AbstractRule
{
public
apply
(
sourceFile
:
ts
.
SourceFile
):
Lint
.
RuleFailure
[]
{
return
this
.
applyWithWalker
(
new
ImportPatterns
(
sourceFile
,
this
.
getOptions
()));
}
}
class
ImportPatterns
extends
Lint
.
RuleWalker
{
private
imports
:
{
[
path
:
string
]:
boolean
;
}
=
Object
.
create
(
null
);
constructor
(
file
:
ts
.
SourceFile
,
opts
:
Lint
.
IOptions
)
{
super
(
file
,
opts
);
}
protected
visitImportDeclaration
(
node
:
ts
.
ImportDeclaration
):
void
{
let
path
=
node
.
moduleSpecifier
.
getText
();
// remove quotes
path
=
path
.
slice
(
1
,
-
1
);
if
(
path
[
0
]
===
'
.
'
)
{
path
=
join
(
dirname
(
node
.
getSourceFile
().
fileName
),
path
);
}
if
(
this
.
imports
[
path
])
{
this
.
addFailure
(
this
.
createFailure
(
node
.
getStart
(),
node
.
getWidth
(),
`Duplicate imports for '
${
path
}
'.`
));
}
this
.
imports
[
path
]
=
true
;
}
}
build/lib/tslint/importPatternsRule.js
浏览文件 @
6a07f2d9
build/lib/tslint/layeringRule.js
浏览文件 @
6a07f2d9
...
...
@@ -49,6 +49,8 @@ var LayeringRule = (function (_super) {
}
LayeringRule
.
prototype
.
visitImportDeclaration
=
function
(
node
)
{
var
path
=
node
.
moduleSpecifier
.
getText
();
// remove quotes
path
=
path
.
slice
(
1
,
-
1
);
if
(
path
[
0
]
===
'
.
'
)
{
path
=
path_1
.
join
(
path_1
.
dirname
(
node
.
getSourceFile
().
fileName
),
path
);
}
...
...
build/lib/tslint/layeringRule.ts
浏览文件 @
6a07f2d9
...
...
@@ -52,8 +52,11 @@ class LayeringRule extends Lint.RuleWalker {
}
protected
visitImportDeclaration
(
node
:
ts
.
ImportDeclaration
):
void
{
let
path
=
node
.
moduleSpecifier
.
getText
();
// remove quotes
path
=
path
.
slice
(
1
,
-
1
);
if
(
path
[
0
]
===
'
.
'
)
{
path
=
join
(
dirname
(
node
.
getSourceFile
().
fileName
),
path
);
}
...
...
build/lib/tslint/noUnexternalizedStringsRule.js
浏览文件 @
6a07f2d9
...
...
@@ -109,8 +109,8 @@ var NoUnexternalizedStringsRuleWalker = (function (_super) {
for
(
var
i
=
0
;
i
<
keyArg
.
properties
.
length
;
i
++
)
{
var
property
=
keyArg
.
properties
[
i
];
if
(
isPropertyAssignment
(
property
))
{
var
name
=
property
.
name
.
getText
();
if
(
name
===
'
key
'
)
{
var
name
_1
=
property
.
name
.
getText
();
if
(
name
_1
===
'
key
'
)
{
var
initializer
=
property
.
initializer
;
if
(
isStringLiteral
(
initializer
))
{
this
.
recordKey
(
initializer
,
this
.
messageIndex
?
callInfo
.
callExpression
.
arguments
[
this
.
messageIndex
]
:
undefined
);
...
...
build/lib/util.js
浏览文件 @
6a07f2d9
...
...
@@ -98,15 +98,15 @@ function skipDirectories() {
}
exports
.
skipDirectories
=
skipDirectories
;
function
cleanNodeModule
(
name
,
excludes
,
includes
)
{
var
g
lob
=
function
(
path
)
{
return
'
**/node_modules/
'
+
name
+
(
path
?
'
/
'
+
path
:
''
);
};
var
toG
lob
=
function
(
path
)
{
return
'
**/node_modules/
'
+
name
+
(
path
?
'
/
'
+
path
:
''
);
};
var
negate
=
function
(
str
)
{
return
'
!
'
+
str
;
};
var
allFilter
=
_filter
(
g
lob
(
'
**
'
),
{
restore
:
true
});
var
globs
=
[
glob
(
'
**
'
)].
concat
(
excludes
.
map
(
_
.
compose
(
negate
,
g
lob
)));
var
allFilter
=
_filter
(
toG
lob
(
'
**
'
),
{
restore
:
true
});
var
globs
=
[
toGlob
(
'
**
'
)].
concat
(
excludes
.
map
(
_
.
compose
(
negate
,
toG
lob
)));
var
input
=
es
.
through
();
var
nodeModuleInput
=
input
.
pipe
(
allFilter
);
var
output
=
nodeModuleInput
.
pipe
(
_filter
(
globs
));
if
(
includes
)
{
var
includeGlobs
=
includes
.
map
(
g
lob
);
var
includeGlobs
=
includes
.
map
(
toG
lob
);
output
=
es
.
merge
(
output
,
nodeModuleInput
.
pipe
(
_filter
(
includeGlobs
)));
}
output
=
output
.
pipe
(
allFilter
.
restore
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录