Skip to content

Commit

Permalink
fix(eslint-plugin): [no-base-to-string] soft remove "ignoreTaggedTemp…
Browse files Browse the repository at this point in the history
…lateExpressions" option
  • Loading branch information
LinusU committed Apr 18, 2020
1 parent cc70e4f commit 569a3f9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 30 deletions.
26 changes: 0 additions & 26 deletions packages/eslint-plugin/docs/rules/no-base-to-string.md
Expand Up @@ -52,32 +52,6 @@ const literalWithToString = {
`Value: ${literalWithToString}`;
```

## Options

The rule accepts an options object with the following properties:

```ts
type Options = {
// if true, interpolated expressions in tagged templates will not be checked
ignoreTaggedTemplateExpressions?: boolean;
};

const defaults = {
ignoreTaggedTemplateExpressions: false,
};
```

### `ignoreTaggedTemplateExpressions`

This allows to skip checking tagged templates, for cases where the tags do not necessarily stringify interpolated values.

Examples of additional **correct** code for this rule with `{ ignoreTaggedTemplateExpressions: true }`:

```ts
function tag() {}
tag`${{}}`;
```

## When Not To Use It

If you don't mind `"[object Object]"` in your strings, then you will not need this rule.
Expand Down
8 changes: 4 additions & 4 deletions packages/eslint-plugin/src/rules/no-base-to-string.ts
Expand Up @@ -14,6 +14,7 @@ enum Usefulness {

type Options = [
{
/** @deprecated This option is now ignored and treated as always true, it will be removed in 3.0 */
ignoreTaggedTemplateExpressions?: boolean;
},
];
Expand All @@ -39,16 +40,16 @@ export default util.createRule<Options, MessageIds>({
properties: {
ignoreTaggedTemplateExpressions: {
type: 'boolean',
default: false,
default: true,
},
},
additionalProperties: false,
},
],
type: 'suggestion',
},
defaultOptions: [{ ignoreTaggedTemplateExpressions: false }],
create(context, [options]) {
defaultOptions: [{ ignoreTaggedTemplateExpressions: true }],
create(context) {
const parserServices = util.getParserServices(context);
const typeChecker = parserServices.program.getTypeChecker();

Expand Down Expand Up @@ -130,7 +131,6 @@ export default util.createRule<Options, MessageIds>({
},
TemplateLiteral(node: TSESTree.TemplateLiteral): void {
if (
options.ignoreTaggedTemplateExpressions &&
node.parent &&
node.parent.type === AST_NODE_TYPES.TaggedTemplateExpression
) {
Expand Down

0 comments on commit 569a3f9

Please sign in to comment.