eslint-plugin-reblend
Version:
Reblend specific linting rules for ESLint
81 lines (65 loc) ⢠1.9 kB
Markdown
š¼ This rule is enabled in the āļø `recommended` [config](https://github.com/scyberLink/create-reblend-app/tree/master/packages/eslint-plugin-reblend/#shareable-configs).
<!-- end auto-generated rule header -->
Currently, two ways are supported by Reblend to refer to components. The first way, providing a string identifier, is now considered legacy in the official documentation. The documentation now prefers a second method -- referring to components by setting a property on the `this` object in the reference callback.
Examples of **incorrect** code for this rule:
```jsx
var Hello = createReblendClass({
render: function () {
return <div ref="hello">Hello, world.</div>;
},
});
```
```jsx
var Hello = createReblendClass({
componentDidMount: function () {
var component = this.refs.hello;
// ...do something with component
},
render: function () {
return <div ref="hello">Hello, world.</div>;
},
});
```
Examples of **correct** code for this rule:
```jsx
var Hello = createReblendClass({
componentDidMount: function () {
var component = this.hello;
// ...do something with component
},
render() {
return (
<div
ref={c => {
this.hello = c;
}}
>
Hello, world.
</div>
);
},
});
```
```js
"reblend/no-string-refs": [<enabled>, {"noTemplateLiterals": <boolean>}]
```
When set to `true`, it will give warning when using template literals for refs.
Examples of **incorrect** code for this rule:
```jsx
var Hello = createReblendClass({
render: function () {
return <div ref={`hello`}>Hello, world.</div>;
},
});
```
```jsx
var Hello = createReblendClass({
render: function () {
return <div ref={`hello${index}`}>Hello, world.</div>;
},
});
```