chore(lint): enable lint check for duplicate vars
This commit is contained in:
parent
0426325ef7
commit
4c762a6be3
|
@ -317,7 +317,7 @@ function _parseAnimationKeyframes(
|
||||||
}
|
}
|
||||||
|
|
||||||
var firstKeyframeStyles = firstKeyframe[1];
|
var firstKeyframeStyles = firstKeyframe[1];
|
||||||
var limit = rawKeyframes.length - 1;
|
limit = rawKeyframes.length - 1;
|
||||||
var lastKeyframe = rawKeyframes[limit];
|
var lastKeyframe = rawKeyframes[limit];
|
||||||
if (lastKeyframe[0] != _TERMINAL_KEYFRAME) {
|
if (lastKeyframe[0] != _TERMINAL_KEYFRAME) {
|
||||||
rawKeyframes.push(lastKeyframe = [_TERMINAL_KEYFRAME, {}]);
|
rawKeyframes.push(lastKeyframe = [_TERMINAL_KEYFRAME, {}]);
|
||||||
|
|
|
@ -236,40 +236,46 @@ export class CssParser {
|
||||||
|
|
||||||
var block: CssBlockAst;
|
var block: CssBlockAst;
|
||||||
var type = this._resolveBlockType(token);
|
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) {
|
switch (type) {
|
||||||
case BlockType.Charset:
|
case BlockType.Charset:
|
||||||
case BlockType.Namespace:
|
case BlockType.Namespace:
|
||||||
case BlockType.Import:
|
case BlockType.Import:
|
||||||
var value = this._parseValue(delimiters);
|
let value = this._parseValue(delimiters);
|
||||||
this._scanner.setMode(CssLexerMode.BLOCK);
|
this._scanner.setMode(CssLexerMode.BLOCK);
|
||||||
this._scanner.consumeEmptyStatements();
|
this._scanner.consumeEmptyStatements();
|
||||||
var span = this._generateSourceSpan(startToken, value);
|
span = this._generateSourceSpan(startToken, value);
|
||||||
return new CssInlineRuleAst(span, type, value);
|
return new CssInlineRuleAst(span, type, value);
|
||||||
|
|
||||||
case BlockType.Viewport:
|
case BlockType.Viewport:
|
||||||
case BlockType.FontFace:
|
case BlockType.FontFace:
|
||||||
block = this._parseStyleBlock(delimiters);
|
block = this._parseStyleBlock(delimiters);
|
||||||
var span = this._generateSourceSpan(startToken, block);
|
span = this._generateSourceSpan(startToken, block);
|
||||||
return new CssBlockRuleAst(span, type, block);
|
return new CssBlockRuleAst(span, type, block);
|
||||||
|
|
||||||
case BlockType.Keyframes:
|
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
|
// keyframes only have one identifier name
|
||||||
var name = tokens[0];
|
let name = tokens[0];
|
||||||
var block = this._parseKeyframeBlock(delimiters);
|
block = this._parseKeyframeBlock(delimiters);
|
||||||
var span = this._generateSourceSpan(startToken, block);
|
span = this._generateSourceSpan(startToken, block);
|
||||||
return new CssKeyframeRuleAst(span, name, block);
|
return new CssKeyframeRuleAst(span, name, block);
|
||||||
|
|
||||||
case BlockType.MediaQuery:
|
case BlockType.MediaQuery:
|
||||||
this._scanner.setMode(CssLexerMode.MEDIA_QUERY);
|
this._scanner.setMode(CssLexerMode.MEDIA_QUERY);
|
||||||
var tokens = this._collectUntilDelim(delimiters | RBRACE_DELIM_FLAG | LBRACE_DELIM_FLAG);
|
tokens = this._collectUntilDelim(delimiters | RBRACE_DELIM_FLAG | LBRACE_DELIM_FLAG);
|
||||||
var endToken = tokens[tokens.length - 1];
|
endToken = tokens[tokens.length - 1];
|
||||||
// we do not track the whitespace after the mediaQuery predicate ends
|
// we do not track the whitespace after the mediaQuery predicate ends
|
||||||
// so we have to calculate the end string value on our own
|
// so we have to calculate the end string value on our own
|
||||||
var end = endToken.index + endToken.strValue.length - 1;
|
end = endToken.index + endToken.strValue.length - 1;
|
||||||
var strValue = this._extractSourceContent(start, end);
|
strValue = this._extractSourceContent(start, end);
|
||||||
var span = this._generateSourceSpan(startToken, endToken);
|
span = this._generateSourceSpan(startToken, endToken);
|
||||||
var query = new CssAtRulePredicateAst(span, strValue, tokens);
|
query = new CssAtRulePredicateAst(span, strValue, tokens);
|
||||||
block = this._parseBlock(delimiters);
|
block = this._parseBlock(delimiters);
|
||||||
strValue = this._extractSourceContent(start, this._getScannerIndex() - 1);
|
strValue = this._extractSourceContent(start, this._getScannerIndex() - 1);
|
||||||
span = this._generateSourceSpan(startToken, block);
|
span = this._generateSourceSpan(startToken, block);
|
||||||
|
@ -279,14 +285,14 @@ export class CssParser {
|
||||||
case BlockType.Supports:
|
case BlockType.Supports:
|
||||||
case BlockType.Page:
|
case BlockType.Page:
|
||||||
this._scanner.setMode(CssLexerMode.AT_RULE_QUERY);
|
this._scanner.setMode(CssLexerMode.AT_RULE_QUERY);
|
||||||
var tokens = this._collectUntilDelim(delimiters | RBRACE_DELIM_FLAG | LBRACE_DELIM_FLAG);
|
tokens = this._collectUntilDelim(delimiters | RBRACE_DELIM_FLAG | LBRACE_DELIM_FLAG);
|
||||||
var endToken = tokens[tokens.length - 1];
|
endToken = tokens[tokens.length - 1];
|
||||||
// we do not track the whitespace after this block rule predicate ends
|
// we do not track the whitespace after this block rule predicate ends
|
||||||
// so we have to calculate the end string value on our own
|
// so we have to calculate the end string value on our own
|
||||||
var end = endToken.index + endToken.strValue.length - 1;
|
end = endToken.index + endToken.strValue.length - 1;
|
||||||
var strValue = this._extractSourceContent(start, end);
|
strValue = this._extractSourceContent(start, end);
|
||||||
var span = this._generateSourceSpan(startToken, tokens[tokens.length - 1]);
|
span = this._generateSourceSpan(startToken, tokens[tokens.length - 1]);
|
||||||
var query = new CssAtRulePredicateAst(span, strValue, tokens);
|
query = new CssAtRulePredicateAst(span, strValue, tokens);
|
||||||
block = this._parseBlock(delimiters);
|
block = this._parseBlock(delimiters);
|
||||||
strValue = this._extractSourceContent(start, block.end.offset);
|
strValue = this._extractSourceContent(start, block.end.offset);
|
||||||
span = this._generateSourceSpan(startToken, block);
|
span = this._generateSourceSpan(startToken, block);
|
||||||
|
@ -294,8 +300,8 @@ export class CssParser {
|
||||||
|
|
||||||
// if a custom @rule { ... } is used it should still tokenize the insides
|
// if a custom @rule { ... } is used it should still tokenize the insides
|
||||||
default:
|
default:
|
||||||
var listOfTokens: CssToken[] = [];
|
let listOfTokens: CssToken[] = [];
|
||||||
var tokenName = token.strValue;
|
let tokenName = token.strValue;
|
||||||
this._scanner.setMode(CssLexerMode.ALL);
|
this._scanner.setMode(CssLexerMode.ALL);
|
||||||
this._error(
|
this._error(
|
||||||
generateErrorMessage(
|
generateErrorMessage(
|
||||||
|
@ -312,8 +318,8 @@ export class CssParser {
|
||||||
.forEach((token) => { listOfTokens.push(token); });
|
.forEach((token) => { listOfTokens.push(token); });
|
||||||
listOfTokens.push(this._consume(CssTokenType.Character, '}'));
|
listOfTokens.push(this._consume(CssTokenType.Character, '}'));
|
||||||
}
|
}
|
||||||
var endToken = listOfTokens[listOfTokens.length - 1];
|
endToken = listOfTokens[listOfTokens.length - 1];
|
||||||
var span = this._generateSourceSpan(startToken, endToken);
|
span = this._generateSourceSpan(startToken, endToken);
|
||||||
return new CssUnknownRuleAst(span, tokenName, listOfTokens);
|
return new CssUnknownRuleAst(span, tokenName, listOfTokens);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -449,19 +449,20 @@ export class _ParseAST {
|
||||||
if (this.next.type == TokenType.Operator) {
|
if (this.next.type == TokenType.Operator) {
|
||||||
const start = this.inputIndex;
|
const start = this.inputIndex;
|
||||||
const operator = this.next.strValue;
|
const operator = this.next.strValue;
|
||||||
|
let result: AST;
|
||||||
switch (operator) {
|
switch (operator) {
|
||||||
case '+':
|
case '+':
|
||||||
this.advance();
|
this.advance();
|
||||||
return this.parsePrefix();
|
return this.parsePrefix();
|
||||||
case '-':
|
case '-':
|
||||||
this.advance();
|
this.advance();
|
||||||
var result = this.parsePrefix();
|
result = this.parsePrefix();
|
||||||
return new Binary(
|
return new Binary(
|
||||||
this.span(start), operator, new LiteralPrimitive(new ParseSpan(start, start), 0),
|
this.span(start), operator, new LiteralPrimitive(new ParseSpan(start, start), 0),
|
||||||
result);
|
result);
|
||||||
case '!':
|
case '!':
|
||||||
this.advance();
|
this.advance();
|
||||||
var result = this.parsePrefix();
|
result = this.parsePrefix();
|
||||||
return new PrefixNot(this.span(start), result);
|
return new PrefixNot(this.span(start), result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ expect(door.lock instanceof Lock).toBe(true);
|
||||||
// #enddocregion
|
// #enddocregion
|
||||||
|
|
||||||
// #docregion resolve_forward_ref
|
// #docregion resolve_forward_ref
|
||||||
var ref = forwardRef(() => 'refValue');
|
ref = forwardRef(() => 'refValue');
|
||||||
expect(resolveForwardRef(ref)).toEqual('refValue');
|
expect(resolveForwardRef(ref)).toEqual('refValue');
|
||||||
expect(resolveForwardRef('regularValue')).toEqual('regularValue');
|
expect(resolveForwardRef('regularValue')).toEqual('regularValue');
|
||||||
// #enddocregion
|
// #enddocregion
|
||||||
|
|
|
@ -37,7 +37,7 @@ export function getComponentInfo(type: Type): ComponentInfo {
|
||||||
if (!selector.match(COMPONENT_SELECTOR)) {
|
if (!selector.match(COMPONENT_SELECTOR)) {
|
||||||
throw new Error('Only selectors matching element names are supported, got: ' + 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());
|
SKEWER_CASE, (all: any /** TODO #9100 */, letter: string) => letter.toUpperCase());
|
||||||
return {
|
return {
|
||||||
type: type,
|
type: type,
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
"requireInternalWithUnderscore": true,
|
"requireInternalWithUnderscore": true,
|
||||||
"duplicateModuleImport": true,
|
"duplicateModuleImport": true,
|
||||||
"enforce-copyright-header": true,
|
"enforce-copyright-header": true,
|
||||||
|
"no-duplicate-variable": true,
|
||||||
"semicolon": true,
|
"semicolon": true,
|
||||||
"variable-name": [true, "ban-keywords"]
|
"variable-name": [true, "ban-keywords"]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue