Skip to content

Commit 955d7a6

Browse files
author
Josh Goldberg
authored
chore: enabled restrict-template-expressions internally (typescript-eslint#3854)
1 parent 5ec9c33 commit 955d7a6

File tree

5 files changed

+15
-6
lines changed

5 files changed

+15
-6
lines changed

.eslintrc.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,21 @@ module.exports = {
5959
'@typescript-eslint/prefer-optional-chain': 'error',
6060
'@typescript-eslint/unbound-method': 'off',
6161
'@typescript-eslint/prefer-as-const': 'error',
62+
'@typescript-eslint/restrict-template-expressions': [
63+
'error',
64+
{
65+
allowNumber: true,
66+
allowBoolean: true,
67+
allowAny: true,
68+
allowNullish: true,
69+
allowRegExp: true,
70+
},
71+
],
6272
'@typescript-eslint/no-unused-vars': [
6373
'warn',
6474
{ varsIgnorePattern: '^_', argsIgnorePattern: '^_' },
6575
],
6676

67-
// TODO - enable these new recommended rules
68-
'@typescript-eslint/restrict-template-expressions': 'off',
6977
// TODO - enable this
7078
'@typescript-eslint/naming-convention': 'off',
7179

packages/eslint-plugin/src/rules/switch-exhaustiveness-check.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export default createRule({
144144
missingBranches: missingBranchTypes
145145
.map(missingType =>
146146
isTypeFlagSet(missingType, ts.TypeFlags.ESSymbolLike)
147-
? `typeof ${missingType.getSymbol()?.escapedName}`
147+
? `typeof ${missingType.getSymbol()?.escapedName as string}`
148148
: checker.typeToString(missingType),
149149
)
150150
.join(' | '),

packages/scope-manager/tests/fixtures.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ function nestDescribe(
124124
throw new Error(
125125
`Expected value for ${key} to be one of (${Array.from(type[1]).join(
126126
' | ',
127-
)}), but got ${value}`,
127+
)}), but got ${value as string}`,
128128
);
129129
}
130130

packages/scope-manager/tests/util/serializers/TSESTreeNode.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const EXCLUDED_KEYS = new Set([
1414

1515
const generator = createIdGenerator();
1616
type Node = Record<string, unknown> & { type: AST_NODE_TYPES };
17+
type Identifier = Node & { name: string; type: AST_NODE_TYPES.Identifier };
1718
const SEEN_NODES = new Map<Node, number>();
1819

1920
const serializer: NewPlugin = {
@@ -29,7 +30,7 @@ const serializer: NewPlugin = {
2930
},
3031
serialize(node: Node): string {
3132
if (node.type === AST_NODE_TYPES.Identifier) {
32-
return `Identifier<"${node.name}">`;
33+
return `Identifier<"${(node as Identifier).name}">`;
3334
}
3435

3536
const keys = Object.keys(node).filter(k => !EXCLUDED_KEYS.has(k));

packages/scope-manager/tests/util/serializers/baseSerializer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function createSerializer<TConstructor extends ConstructorSignature>(
6262
}
6363

6464
outputLines.push(
65-
`${childIndentation}${key}: ${printer(
65+
`${childIndentation}${key as string}: ${printer(
6666
value,
6767
config,
6868
childIndentation,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy