Appearance
vue/jsx-uses-vars
防止在 JSX 中使用的变量被标记为未使用
- ⚙️ 此规则包含在
"plugin:vue/base"
、*.configs["flat/base"]
、"plugin:vue/vue2-essential"
、*.configs["flat/vue2-essential"]
、"plugin:vue/essential"
、*.configs["flat/essential"]
、"plugin:vue/vue2-strongly-recommended"
、*.configs["flat/vue2-strongly-recommended"]
、"plugin:vue/strongly-recommended"
、*.configs["flat/strongly-recommended"]
、"plugin:vue/vue2-recommended"
、*.configs["flat/vue2-recommended"]
、"plugin:vue/recommended"
和*.configs["flat/recommended"]
中。
自 0.17.0 起,ESLint no-unused-vars
规则不检测 JSX(查看详细信息)中使用的变量。此规则将查找在 JSX 中使用的变量并将其标记为已使用。
¥Since 0.17.0 the ESLint no-unused-vars
rule does not detect variables used in JSX (see details). This rule will find variables used in JSX and mark them as used.
此规则仅在启用 no-unused-vars
规则时才有效。
¥This rule only has an effect when the no-unused-vars
rule is enabled.
📖 规则详情
如果没有此规则,此代码将触发警告:
¥Without this rule this code triggers warning:
jsx
import HelloWorld from './HelloWorld';
export default {
render () {
return (
<HelloWorld msg="world"/>
)
},
};
开启后,HelloWorld
被标记为已使用,no-unused-vars
规则未报告问题。
¥After turning on, HelloWorld
is being marked as used and no-unused-vars
rule doesn't report an issue.
🔇何时不使用
¥🔇 When Not To Use It
如果你没有使用 JSX 或不使用 no-unused-vars
规则,则可以禁用此规则。
¥If you are not using JSX or if you do not use the no-unused-vars
rule then you can disable this rule.
👫相关规则
¥👫 Related Rules
🚀版本
¥🚀 Version
此规则在 eslint-plugin-vue v2.0.0 中引入
¥This rule was introduced in eslint-plugin-vue v2.0.0
🔍代码实现
¥🔍 Implementation