eranshabi / tslint-mobx Goto Github PK
View Code? Open in Web Editor NEWMobX specific linting rules for TSLint
License: MIT License
MobX specific linting rules for TSLint
License: MIT License
Since TSLint is deprecated, is there any plan to migrate this excellent plugin to ESLint?
Assuming you have
@inject('myStore')
class Foo extends React.Component {
public render() {
const {
myStore: { something },
} = this.props;
}
}
It throws mobx-react-no-unused-inject: Unused mobX store injected: myStore
Instead of passing a list of store names, it is also possible to create a custom mapper function and pass it to inject.
https://github.com/mobxjs/mobx-react#customizing-inject
It is possible to use a function as @inject
's first argument to map the available stores manually to the component props. Unfortunately mobx-react-no-unused-inject
can't handle this, and it even creates a false negative by creating the failuer: Unused mobX store injected: undefined
.
It probably should ignore those usages all together or - even better - use the function's return type for the check.
It would be useful to have a rule that will require using 'get' for computed methods. Example:
class UserStore {
@observable firstName = 'John';
@observable lastName = 'Snow';
// Should be an error: missing 'get' keyword
@computed fullName() {
return `${this.firstName} ${this.lastName}`;
}
}
Proposal:
The default tslint rule for no-unbound-method should have an exception when using @action.bound
decorator on a method.
For example:
class Foo {
@observable private enabled: boolean;
public someAction() {
fetch('x/y/z').then(this.toggle);
}
@action.bound private toggle() {
this.enabled = !this.enabled;
/* More code */
}
}
I know this can be solved by using it like this:
@action private toggle = () => (this.enabled = !this.enabled);
But the debugger sometimes doesn't recognize the this
because it is being transpiled to _this
.
And it becomes annoying on methods that have more than one line.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.