Repository: vuejs/eslint-plugin-vue (JavaScript)

Issue:
Simple prop declaration replaces "" with nothing when auto-fixing
**Tell us about your environment**	
* **ESLint version:**	v6.7.1
* **eslint-plugin-vue version:**	v6.0.1
* **Node version:** v12.13.0

**Please show your full configuration:**
<!-- Paste content of your .eslintrc file -->
```json
{
    "extends": [
        "eslint:recommended",
        "plugin:vue/recommended"
    ],
    "plugins": [
        "vue"
    ]
}
```

**What did you do?**	
<!-- Please include the actual source code causing the issue. -->

```vue
<template>
  <div>
    <h1>Hello</h1>
  </div>
</template>

<script>
export default {
  name: 'Test',
  props: {
    foo: "",
  },
};
</script>
```

Running `eslint test.vue` gives me the following:

![image](https://user-images.githubusercontent.com/65263/69540888-1b86a800-0f88-11ea-8083-5abfbe162eda.png)

And then after running `eslint --fix test.vue`

![image](https://user-images.githubusercontent.com/65263/69540904-26413d00-0f88-11ea-8a5c-6b62fbbf877b.png)

**What did you expect to happen?**

Not sure what I expected, but did not expect it to just replace `""` with nothing, leaving the JS invalid.

**What actually happened?**

```js
{
  props: {
    foo: "",
  }
}
```

was turned into

```js
{
  props: {
    foo: ,
  }
}
```



Discussion:
I'd say this rule isn't really be `--fix`-able , as we can at best take an educated guess that you meant it to be a string and should be `foo: String` instead of `foo: ""`.
> I'd say this rule isn't really be `--fix`-able , as we can at best take an educated guess that you meant it to be a string and should be `foo: String` instead of `foo: ""`.

Would that be possible? Or maybe rather assume that `foo: ""` could be rewritten to `foo: null` (allow any type) at least. Or just skip these declarations altogether.
Since the developer intent can't be properly inferred, silently assuming null when he developer may expect the prop validation to fail when something besides a string is passed would be dangerous.

The developer appearantly wanted to define the prop (likely to be a String), but failed to do so in the correct way/syntax, so it should simply fail and not be corrected, leaving that to the developer.
> Since the developer intent can't be properly inferred, silently assuming null when he developer may expect the prop validation to fail when something besides a string is passed would be dangerous.
> 
> The developer appearantly wanted to define the prop (likely to be a String), but failed to do so in the correct way/syntax, so it should simply fail and not be corrected, leaving that to the developer.

Yeah, I agree on that.

But why is `""` even removed in the first place and not just left as-is? It would at least still work afterwords.
Thank you for this issue.

I think it is a bug that the code is deleted.



Patch:
diff --git a/lib/rules/require-prop-type-constructor.js b/lib/rules/require-prop-type-constructor.js
index edde36f49..b0b312615 100644
--- a/lib/rules/require-prop-type-constructor.js
+++ b/lib/rules/require-prop-type-constructor.js
@@ -35,14 +35,23 @@ module.exports = {
 
   create (context) {
     const fix = node => fixer => {
+      let newText
       if (node.type === 'Literal') {
-        return fixer.replaceText(node, node.value)
+        if (typeof node.value !== 'string') {
+          return undefined
+        }
+        newText = node.value
       } else if (
         node.type === 'TemplateLiteral' &&
         node.expressions.length === 0 &&
         node.quasis.length === 1
       ) {
-        return fixer.replaceText(node, node.quasis[0].value.cooked)
+        newText = node.quasis[0].value.cooked
+      } else {
+        return undefined
+      }
+      if (newText) {
+        return fixer.replaceText(node, newText)
       }
     }
 


Test patch:
diff --git a/tests/lib/rules/require-prop-type-constructor.js b/tests/lib/rules/require-prop-type-constructor.js
index 70fc35e8e..103eb26a1 100644
--- a/tests/lib/rules/require-prop-type-constructor.js
+++ b/tests/lib/rules/require-prop-type-constructor.js
@@ -17,7 +17,7 @@ const RuleTester = require('eslint').RuleTester
 
 const ruleTester = new RuleTester({
   parserOptions: {
-    ecmaVersion: 2018,
+    ecmaVersion: 2020,
     sourceType: 'module'
   }
 })
@@ -237,6 +237,109 @@ ruleTester.run('require-prop-type-constructor', rule, {
         line: 4
       }],
       parser: require.resolve('@typescript-eslint/parser')
+    },
+    {
+      filename: 'LiteralsComponent.vue',
+      code: `
+      export default {
+        props: {
+          str: 'String',
+          str2: 'a',
+          emptyStr: '',
+          number: 1000,
+          binumber: 0b10000000000000000000000000000000,
+          hexnumber: 0x123456789ABCDEF,
+          exp1: 1E3,
+          exp2: 2e6,
+          exp3: 0.1e2,
+          bigInt: 9007199254740991n,
+          boolean: true,
+          'null': null,
+          regex: /a/,
+          template: \`String\`,
+          emptyTemplate: \`\`,
+        }
+      }
+      `,
+      output: `
+      export default {
+        props: {
+          str: String,
+          str2: a,
+          emptyStr: '',
+          number: 1000,
+          binumber: 0b10000000000000000000000000000000,
+          hexnumber: 0x123456789ABCDEF,
+          exp1: 1E3,
+          exp2: 2e6,
+          exp3: 0.1e2,
+          bigInt: 9007199254740991n,
+          boolean: true,
+          'null': null,
+          regex: /a/,
+          template: String,
+          emptyTemplate: \`\`,
+        }
+      }
+      `,
+      errors: [
+        {
+          message: 'The "str" property should be a constructor.',
+          line: 4
+        },
+        {
+          message: 'The "str2" property should be a constructor.',
+          line: 5
+        },
+        {
+          message: 'The "emptyStr" property should be a constructor.',
+          line: 6
+        },
+        {
+          message: 'The "number" property should be a constructor.',
+          line: 7
+        },
+        {
+          message: 'The "binumber" property should be a constructor.',
+          line: 8
+        },
+        {
+          message: 'The "hexnumber" property should be a constructor.',
+          line: 9
+        },
+        {
+          message: 'The "exp1" property should be a constructor.',
+          line: 10
+        },
+        {
+          message: 'The "exp2" property should be a constructor.',
+          line: 11
+        },
+        {
+          message: 'The "exp3" property should be a constructor.',
+          line: 12
+        },
+        {
+          message: 'The "bigInt" property should be a constructor.',
+          line: 13
+        },
+        {
+          message: 'The "boolean" property should be a constructor.',
+          line: 14
+        },
+        {
+          message: 'The "regex" property should be a constructor.',
+          line: 16
+        },
+        {
+          message: 'The "template" property should be a constructor.',
+          line: 17
+        },
+        {
+          message: 'The "emptyTemplate" property should be a constructor.',
+          line: 18
+        }
+      ]
     }
   ]
 })