chore(lint): enable lint check for duplicate vars

This commit is contained in:
Alex Eagle 2016-07-13 10:28:11 -07:00
parent 0426325ef7
commit 4c762a6be3
6 changed files with 36 additions and 28 deletions

View File

@ -317,7 +317,7 @@ function _parseAnimationKeyframes(
}
var firstKeyframeStyles = firstKeyframe[1];
var limit = rawKeyframes.length - 1;
limit = rawKeyframes.length - 1;
var lastKeyframe = rawKeyframes[limit];
if (lastKeyframe[0] != _TERMINAL_KEYFRAME) {
rawKeyframes.push(lastKeyframe = [_TERMINAL_KEYFRAME, {}]);

View File

@ -236,40 +236,46 @@ export class CssParser {
var block: CssBlockAst;
var type = this._resolveBlockType(token);
var span: ParseSourceSpan;
var tokens: CssToken[];
var endToken: CssToken;
var end: number;
var strValue: string;
var query: CssAtRulePredicateAst;
switch (type) {
case BlockType.Charset:
case BlockType.Namespace:
case BlockType.Import:
var value = this._parseValue(delimiters);
let value = this._parseValue(delimiters);
this._scanner.setMode(CssLexerMode.BLOCK);
this._scanner.consumeEmptyStatements();
var span = this._generateSourceSpan(startToken, value);
span = this._generateSourceSpan(startToken, value);
return new CssInlineRuleAst(span, type, value);
case BlockType.Viewport:
case BlockType.FontFace:
block = this._parseStyleBlock(delimiters);
var span = this._generateSourceSpan(startToken, block);
span = this._generateSourceSpan(startToken, block);
return new CssBlockRuleAst(span, type, block);
case BlockType.Keyframes:
var tokens = this._collectUntilDelim(delimiters | RBRACE_DELIM_FLAG | LBRACE_DELIM_FLAG);
tokens = this._collectUntilDelim(delimiters | RBRACE_DELIM_FLAG | LBRACE_DELIM_FLAG);
// keyframes only have one identifier name
var name = tokens[0];
var block = this._parseKeyframeBlock(delimiters);
var span = this._generateSourceSpan(startToken, block);
let name = tokens[0];
block = this._parseKeyframeBlock(delimiters);
span = this._generateSourceSpan(startToken, block);
return new CssKeyframeRuleAst(span, name, block);
case BlockType.MediaQuery:
this._scanner.setMode(CssLexerMode.MEDIA_QUERY);
var tokens = this._collectUntilDelim(delimiters | RBRACE_DELIM_FLAG | LBRACE_DELIM_FLAG);
var endToken = tokens[tokens.length - 1];
tokens = this._collectUntilDelim(delimiters | RBRACE_DELIM_FLAG | LBRACE_DELIM_FLAG);
endToken = tokens[tokens.length - 1];
// we do not track the whitespace after the mediaQuery predicate ends
// so we have to calculate the end string value on our own
var end = endToken.index + endToken.strValue.length - 1;
var strValue = this._extractSourceContent(start, end);
var span = this._generateSourceSpan(startToken, endToken);
var query = new CssAtRulePredicateAst(span, strValue, tokens);
end = endToken.index + endToken.strValue.length - 1;
strValue = this._extractSourceContent(start, end);
span = this._generateSourceSpan(startToken, endToken);
query = new CssAtRulePredicateAst(span, strValue, tokens);
block = this._parseBlock(delimiters);
strValue = this._extractSourceContent(start, this._getScannerIndex() - 1);
span = this._generateSourceSpan(startToken, block);
@ -279,14 +285,14 @@ export class CssParser {
case BlockType.Supports:
case BlockType.Page:
this._scanner.setMode(CssLexerMode.AT_RULE_QUERY);
var tokens = this._collectUntilDelim(delimiters | RBRACE_DELIM_FLAG | LBRACE_DELIM_FLAG);
var endToken = tokens[tokens.length - 1];
tokens = this._collectUntilDelim(delimiters | RBRACE_DELIM_FLAG | LBRACE_DELIM_FLAG);
endToken = tokens[tokens.length - 1];
// we do not track the whitespace after this block rule predicate ends
// so we have to calculate the end string value on our own
var end = endToken.index + endToken.strValue.length - 1;
var strValue = this._extractSourceContent(start, end);
var span = this._generateSourceSpan(startToken, tokens[tokens.length - 1]);
var query = new CssAtRulePredicateAst(span, strValue, tokens);
end = endToken.index + endToken.strValue.length - 1;
strValue = this._extractSourceContent(start, end);
span = this._generateSourceSpan(startToken, tokens[tokens.length - 1]);
query = new CssAtRulePredicateAst(span, strValue, tokens);
block = this._parseBlock(delimiters);
strValue = this._extractSourceContent(start, block.end.offset);
span = this._generateSourceSpan(startToken, block);
@ -294,8 +300,8 @@ export class CssParser {
// if a custom @rule { ... } is used it should still tokenize the insides
default:
var listOfTokens: CssToken[] = [];
var tokenName = token.strValue;
let listOfTokens: CssToken[] = [];
let tokenName = token.strValue;
this._scanner.setMode(CssLexerMode.ALL);
this._error(
generateErrorMessage(
@ -312,8 +318,8 @@ export class CssParser {
.forEach((token) => { listOfTokens.push(token); });
listOfTokens.push(this._consume(CssTokenType.Character, '}'));
}
var endToken = listOfTokens[listOfTokens.length - 1];
var span = this._generateSourceSpan(startToken, endToken);
endToken = listOfTokens[listOfTokens.length - 1];
span = this._generateSourceSpan(startToken, endToken);
return new CssUnknownRuleAst(span, tokenName, listOfTokens);
}
}

View File

@ -449,19 +449,20 @@ export class _ParseAST {
if (this.next.type == TokenType.Operator) {
const start = this.inputIndex;
const operator = this.next.strValue;
let result: AST;
switch (operator) {
case '+':
this.advance();
return this.parsePrefix();
case '-':
this.advance();
var result = this.parsePrefix();
result = this.parsePrefix();
return new Binary(
this.span(start), operator, new LiteralPrimitive(new ParseSpan(start, start), 0),
result);
case '!':
this.advance();
var result = this.parsePrefix();
result = this.parsePrefix();
return new PrefixNot(this.span(start), result);
}
}

View File

@ -29,7 +29,7 @@ expect(door.lock instanceof Lock).toBe(true);
// #enddocregion
// #docregion resolve_forward_ref
var ref = forwardRef(() => 'refValue');
ref = forwardRef(() => 'refValue');
expect(resolveForwardRef(ref)).toEqual('refValue');
expect(resolveForwardRef('regularValue')).toEqual('regularValue');
// #enddocregion

View File

@ -37,7 +37,7 @@ export function getComponentInfo(type: Type): ComponentInfo {
if (!selector.match(COMPONENT_SELECTOR)) {
throw new Error('Only selectors matching element names are supported, got: ' + selector);
}
var selector = selector.replace(
selector = selector.replace(
SKEWER_CASE, (all: any /** TODO #9100 */, letter: string) => letter.toUpperCase());
return {
type: type,

View File

@ -3,6 +3,7 @@
"requireInternalWithUnderscore": true,
"duplicateModuleImport": true,
"enforce-copyright-header": true,
"no-duplicate-variable": true,
"semicolon": true,
"variable-name": [true, "ban-keywords"]
}