Debian Codegraph @

eslint/plugin-fig-linter/rules/no-useless-insertvalue.js

raw symbols SCIP
1 module.exports = {
2 meta: {
3 type: "problem",
4 fixable: "code",
5 },
6 create(context) {
7 return {
8 'ObjectExpression > Property[key.name="insertValue"]': function (node) {
9 const nameProp = node.parent.properties.find(
10 (prop) => prop?.key?.name === "name"
11 );
12
13 if (!nameProp) return;
14
15 const insertValue = node.value.value;
16 const nameValue = nameProp.value.value;
17
18 if (!insertValue || !nameValue) return;
19 if (insertValue === nameValue) {
20 context.report({
21 node,
22 message:
23 "The insertValue prop can be omitted if the value is the same as name",
24 fix(fixer) {
25 const [start, end] = node.range;
26 // TODO: check if there is a comma after the prop before removing end + 1
27 return fixer.removeRange([start, end + 1]);
28 },
29 });
30 }
31 },
32 };
33 },
34 };