Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/rules/no-unused-properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -586,8 +586,7 @@ module.exports = {
}
}),
{
/** @param {Program} node */
'Program:exit'(node) {
Program() {
const styleVars = getStyleVariablesContext(context)
if (styleVars) {
templatePropertiesContainer.propertyReferences.push(
Expand All @@ -596,6 +595,9 @@ module.exports = {
)
)
}
},
/** @param {Program} node */
'Program:exit'(node) {
if (!node.templateBody) {
reportUnusedProperties()
}
Expand Down
42 changes: 41 additions & 1 deletion tests/lib/rules/no-unused-properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
*/
'use strict'

const RuleTester = require('eslint').RuleTester
const { RuleTester, Linter } = require('eslint')
const assert = require('assert')
const rule = require('../../../lib/rules/no-unused-properties')

const tester = new RuleTester({
Expand Down Expand Up @@ -2805,3 +2806,42 @@ tester.run('no-unused-properties', rule, {
}
]
})

// https://github.com/vuejs/eslint-plugin-vue/issues/1789
describe('`vue/no-unused-properties` and `vue/no-unused-components` should not conflict.', () => {
const linter = new Linter()
linter.defineParser('vue-eslint-parser', require('vue-eslint-parser'))
linter.defineRule(
'vue/no-unused-components',
require('../../../lib/rules/no-unused-components')
)
linter.defineRule('vue/no-unused-properties', rule)

const config = {
parser: 'vue-eslint-parser',
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module'
},
rules: {
'vue/no-unused-components': 'error',
'vue/no-unused-properties': 'error'
}
}

it('should not be a false positive when using CSS v-bind().', () => {
const code = `
<template></template>
<script>
export default {
props: ['a']
};
</script>
<style>
a {
color: v-bind(a);
}
</style>`
assert.deepStrictEqual(linter.verify(code, config, 'test.vue'), [])
})
})