Skip to content

Commit

Permalink
chore(deps): lock file maintenance (#490)
Browse files Browse the repository at this point in the history
Co-authored-by: WhiteSource Renovate <renovatebot@gmail.com>
Co-authored-by: Gareth Jones <Jones258@Gmail.com>
  • Loading branch information
3 people authored and SimenB committed Jan 19, 2020
1 parent 735f143 commit 95cce6b
Show file tree
Hide file tree
Showing 6 changed files with 1,024 additions and 926 deletions.
2 changes: 1 addition & 1 deletion src/rules/no-focused-tests.ts
Expand Up @@ -17,7 +17,7 @@ const testFunctions = new Set<string>([
...validTestCaseNames,
]);

interface ConcurrentExpression extends TSESTree.MemberExpression {
interface ConcurrentExpression extends TSESTree.MemberExpressionComputedName {
parent: TSESTree.MemberExpression;
}

Expand Down
8 changes: 2 additions & 6 deletions src/rules/prefer-to-be-null.ts
Expand Up @@ -13,11 +13,7 @@ import {
parseExpectCall,
} from './utils';

interface NullLiteral extends TSESTree.Literal {
value: null;
}

const isNullLiteral = (node: TSESTree.Node): node is NullLiteral =>
const isNullLiteral = (node: TSESTree.Node): node is TSESTree.NullLiteral =>
node.type === AST_NODE_TYPES.Literal && node.value === null;

/**
Expand All @@ -30,7 +26,7 @@ const isNullLiteral = (node: TSESTree.Node): node is NullLiteral =>
*/
const isNullEqualityMatcher = (
matcher: ParsedExpectMatcher,
): matcher is ParsedEqualityMatcherCall<MaybeTypeCast<NullLiteral>> =>
): matcher is ParsedEqualityMatcherCall<MaybeTypeCast<TSESTree.NullLiteral>> =>
isParsedEqualityMatcherCall(matcher) &&
isNullLiteral(followTypeAssertionChain(matcher.arguments[0]));

Expand Down
10 changes: 4 additions & 6 deletions src/rules/prefer-to-contain.ts
Expand Up @@ -20,15 +20,13 @@ import {
parseExpectCall,
} from './utils';

interface BooleanLiteral extends TSESTree.Literal {
value: boolean;
}

const isBooleanLiteral = (node: TSESTree.Node): node is BooleanLiteral =>
const isBooleanLiteral = (
node: TSESTree.Node,
): node is TSESTree.BooleanLiteral =>
node.type === AST_NODE_TYPES.Literal && typeof node.value === 'boolean';

type ParsedBooleanEqualityMatcherCall = ParsedEqualityMatcherCall<
MaybeTypeCast<BooleanLiteral>
MaybeTypeCast<TSESTree.BooleanLiteral>
>;

/**
Expand Down
4 changes: 2 additions & 2 deletions src/rules/utils.ts
Expand Up @@ -53,7 +53,7 @@ export const followTypeAssertionChain = <
* A `Literal` with a `value` of type `string`.
*/
interface StringLiteral<Value extends string = string>
extends TSESTree.Literal {
extends TSESTree.StringLiteral {
value: Value;
}

Expand Down Expand Up @@ -145,7 +145,7 @@ export const getStringValue = <S extends string>(node: StringNode<S>): S =>
* Represents a `MemberExpression` with a "known" `property`.
*/
interface KnownMemberExpression<Name extends string = string>
extends TSESTree.MemberExpression {
extends TSESTree.MemberExpressionComputedName {
property: AccessorNode<Name>;
}

Expand Down
48 changes: 20 additions & 28 deletions src/rules/valid-title.ts
Expand Up @@ -4,6 +4,7 @@ import {
} from '@typescript-eslint/experimental-utils';
import {
DescribeAlias,
StringNode,
TestCaseName,
createRule,
getJestFunctionArguments,
Expand Down Expand Up @@ -31,6 +32,11 @@ const doesBinaryExpressionContainStringNode = (
return isStringNode(binaryExp.left);
};

const quoteStringValue = (node: StringNode): string =>
node.type === AST_NODE_TYPES.TemplateLiteral
? `\`${node.quasis[0].value.raw}\``
: node.raw;

export default createRule({
name: __filename,
meta: {
Expand Down Expand Up @@ -111,21 +117,14 @@ export default createRule({
context.report({
messageId: 'accidentalSpace',
node: argument,
fix(fixer) {
const stringValue =
argument.type === AST_NODE_TYPES.TemplateLiteral
? `\`${argument.quasis[0].value.raw}\``
: argument.raw;

return [
fixer.replaceTextRange(
argument.range,
stringValue
.replace(/^([`'"]) +?/u, '$1')
.replace(/ +?([`'"])$/u, '$1'),
),
];
},
fix: fixer => [
fixer.replaceTextRange(
argument.range,
quoteStringValue(argument)
.replace(/^([`'"]) +?/u, '$1')
.replace(/ +?([`'"])$/u, '$1'),
),
],
});
}

Expand All @@ -136,19 +135,12 @@ export default createRule({
context.report({
messageId: 'duplicatePrefix',
node: argument,
fix(fixer) {
const stringValue =
argument.type === AST_NODE_TYPES.TemplateLiteral
? `\`${argument.quasis[0].value.raw}\``
: argument.raw;

return [
fixer.replaceTextRange(
argument.range,
stringValue.replace(/^([`'"]).+? /u, '$1'),
),
];
},
fix: fixer => [
fixer.replaceTextRange(
argument.range,
quoteStringValue(argument).replace(/^([`'"]).+? /u, '$1'),
),
],
});
}
},
Expand Down

0 comments on commit 95cce6b

Please sign in to comment.