Skip to content

Commit f927afd

Browse files
committed
fix(eslint-plugin): soft remove "ignoreTaggedTemplateExpressions"
1 parent cc70e4f commit f927afd

File tree

3 files changed

+8
-45
lines changed

3 files changed

+8
-45
lines changed

Diff for: packages/eslint-plugin/docs/rules/no-base-to-string.md

-26
Original file line numberDiff line numberDiff line change
@@ -52,32 +52,6 @@ const literalWithToString = {
5252
`Value: ${literalWithToString}`;
5353
```
5454

55-
## Options
56-
57-
The rule accepts an options object with the following properties:
58-
59-
```ts
60-
type Options = {
61-
// if true, interpolated expressions in tagged templates will not be checked
62-
ignoreTaggedTemplateExpressions?: boolean;
63-
};
64-
65-
const defaults = {
66-
ignoreTaggedTemplateExpressions: false,
67-
};
68-
```
69-
70-
### `ignoreTaggedTemplateExpressions`
71-
72-
This allows to skip checking tagged templates, for cases where the tags do not necessarily stringify interpolated values.
73-
74-
Examples of additional **correct** code for this rule with `{ ignoreTaggedTemplateExpressions: true }`:
75-
76-
```ts
77-
function tag() {}
78-
tag`${{}}`;
79-
```
80-
8155
## When Not To Use It
8256

8357
If you don't mind `"[object Object]"` in your strings, then you will not need this rule.

Diff for: packages/eslint-plugin/src/rules/no-base-to-string.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ enum Usefulness {
1414

1515
type Options = [
1616
{
17+
/** @deprecated This option is now ignored and treated as always true, it will be removed in 3.0 */
1718
ignoreTaggedTemplateExpressions?: boolean;
1819
},
1920
];
@@ -39,16 +40,16 @@ export default util.createRule<Options, MessageIds>({
3940
properties: {
4041
ignoreTaggedTemplateExpressions: {
4142
type: 'boolean',
42-
default: false,
43+
default: true,
4344
},
4445
},
4546
additionalProperties: false,
4647
},
4748
],
4849
type: 'suggestion',
4950
},
50-
defaultOptions: [{ ignoreTaggedTemplateExpressions: false }],
51-
create(context, [options]) {
51+
defaultOptions: [{ ignoreTaggedTemplateExpressions: true }],
52+
create(context) {
5253
const parserServices = util.getParserServices(context);
5354
const typeChecker = parserServices.program.getTypeChecker();
5455

@@ -130,7 +131,6 @@ export default util.createRule<Options, MessageIds>({
130131
},
131132
TemplateLiteral(node: TSESTree.TemplateLiteral): void {
132133
if (
133-
options.ignoreTaggedTemplateExpressions &&
134134
node.parent &&
135135
node.parent.type === AST_NODE_TYPES.TaggedTemplateExpression
136136
) {

Diff for: packages/eslint-plugin/tests/rules/no-base-to-string.test.ts

+4-15
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ const literalWithToString = {
7070
'let _ = {} ^ {};',
7171
'let _ = {} << {};',
7272
'let _ = {} >> {};',
73+
`
74+
function tag() {}
75+
tag\`\${{}}\`;
76+
`,
7377
{
7478
code: `
7579
function tag() {}
@@ -95,21 +99,6 @@ const literalWithToString = {
9599
},
96100
],
97101
},
98-
{
99-
code: `
100-
function tag() {}
101-
tag\`\${{}}\`;
102-
`,
103-
errors: [
104-
{
105-
data: {
106-
certainty: 'will',
107-
name: '{}',
108-
},
109-
messageId: 'baseToString',
110-
},
111-
],
112-
},
113102
{
114103
code: '({}.toString());',
115104
errors: [

0 commit comments

Comments
 (0)