Uni*_*dan 9 javascript reactjs eslint
如何让这个ESLint规则(no-use-before-define
)在这些情况下不发出警告;
class App extends React.Component {
render() { return <div>{messages.helloWorld}</div> }
}
const messages = { helloWorld: 'Hello world!' }
Run Code Online (Sandbox Code Playgroud)
这是一个简化的例子,但我真的想messages
在每个组件的文件底部定义(按照惯例).
Rya*_*yan 21
variables
对于此规则,您可能对该选项感兴趣.您可以在此处阅读该选项.
你可以在你的配置中.eslintrc
,像这样 ......
{
"no-use-before-define": ["error", { "variables": false }]
}
Run Code Online (Sandbox Code Playgroud)
这将使该规则针对其他事物(例如类和函数)启用,但会为变量放宽它.
Aga*_*Aga 11
"rules": {
"no-use-before-define": ["error", {"functions": false, "classes": false}]
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7957 次 |
最近记录: |