File: no-unused-placeholders.md

package info (click to toggle)
node-eslint-plugin-eslint-plugin 2.3.0%2B~0.3.0-6
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 652 kB
  • sloc: javascript: 5,372; makefile: 34; sh: 1
file content (58 lines) | stat: -rw-r--r-- 1,433 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Disallow unused placeholders in rule report messages (no-unused-placeholders)

This rule aims to disallow unused placeholders in rule report messages.

## Rule Details

Reports when a context.report call contains a data property that does not have a corresponding placeholder in the report message.

Examples of **incorrect** code for this rule:

```js
/*eslint eslint-plugin/no-unused-placeholders: error*/

module.exports = {
  create(context) {

    context.report({
      node,
      message: 'something is wrong.',
      data: { something: 'foo' }
    });

    context.report(node, 'something is wrong.', { something: 'foo' });
  }
};
```

Examples of **correct** code for this rule:

```js
/*eslint eslint-plugin/no-unused-placeholders: error*/

module.exports = {
  create(context) {
    context.report({
      node,
      message: 'something is wrong.'
    });

    context.report({
      node,
      message: '{{something}} is wrong.',
      data: { something: 'foo' }
    });

    context.report(node, '{{something}} is wrong.', { something: 'foo' });
  }
};
```

## When Not To Use It

If you want to allow unused placeholders, you should turn off this rule.

## Further Reading

* [context.report() API](http://eslint.org/docs/developer-guide/working-with-rules#contextreport)
* [no-missing-placeholders](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/no-missing-placeholders.md)