Harden lint rules
Summary: Taking another stab at adding some lint rules to make it harder to shoot yourself in the foot. Hopefully nothing too controversial. Preferring spread and rest should lead is more readable and there's no downside when using ES6. The "useless" rules are just things like renaming imports to the original name which should only happen during refactors. Reviewed By: jknoxville Differential Revision: D16180453 fbshipit-source-id: 1cf6851b7726c0aee953ec7cf7dd6fa0aca32253
This commit is contained in:
committed by
Facebook Github Bot
parent
8b2a886c19
commit
e831743132
@@ -23,10 +23,18 @@ module.exports = {
|
||||
'consistent-return': 0,
|
||||
'no-var': 2,
|
||||
'prefer-const': [2, {destructuring: 'all'}],
|
||||
'prefer-spread': 1,
|
||||
'prefer-rest-params': 1,
|
||||
'max-len': 0, // lets prettier take care of this
|
||||
indent: 0, // lets prettier take care of this
|
||||
'no-console': 0, // we're setting window.console in App.js
|
||||
'no-multi-spaces': 2,
|
||||
'prefer-promise-reject-errors': 1,
|
||||
'no-extra-boolean-cast': 2,
|
||||
'no-extra-semi': 2,
|
||||
'no-unsafe-negation': 2,
|
||||
'no-useless-computed-key': 2,
|
||||
'no-useless-rename': 2,
|
||||
|
||||
// additional rules for this project
|
||||
'header/header': [2, 'block', {pattern}],
|
||||
|
||||
@@ -155,7 +155,7 @@ export const requirePlugin = (
|
||||
if (plugin.default) {
|
||||
plugin = plugin.default;
|
||||
}
|
||||
if (!plugin.prototype instanceof FlipperBasePlugin) {
|
||||
if (!(plugin.prototype instanceof FlipperBasePlugin)) {
|
||||
throw new Error(`Plugin ${plugin.name} is not a FlipperBasePlugin`);
|
||||
}
|
||||
|
||||
|
||||
@@ -276,7 +276,7 @@ class PageInfo extends Component<
|
||||
|
||||
onSubmit(e: SyntheticKeyboardEvent<>) {
|
||||
if (e.key === 'Enter') {
|
||||
const rowNumber = parseInt(this.state.inputValue);
|
||||
const rowNumber = parseInt(this.state.inputValue, 10);
|
||||
console.log(rowNumber);
|
||||
this.props.onChange(rowNumber - 1, this.props.count);
|
||||
this.setState({isOpen: false});
|
||||
@@ -297,7 +297,7 @@ class PageInfo extends Component<
|
||||
<div style={{flex: 1}} />
|
||||
{this.state.isOpen ? (
|
||||
<Input
|
||||
tabIndex={1}
|
||||
tabIndex={-1}
|
||||
placeholder={this.props.currentRow + 1}
|
||||
onChange={this.onInputChanged.bind(this)}
|
||||
onKeyDown={this.onSubmit.bind(this)}
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
*/
|
||||
const defaultConsoleError = console.error;
|
||||
|
||||
console.error = function(message) {
|
||||
console.error = function(message, ...args) {
|
||||
defaultConsoleError(
|
||||
'console.error used in a test. This will be an error in the near future.',
|
||||
);
|
||||
defaultConsoleError.apply(console, arguments);
|
||||
defaultConsoleError(...args);
|
||||
};
|
||||
|
||||
global.fetch = require('jest-fetch-mock');
|
||||
|
||||
Reference in New Issue
Block a user